bool RunTest(const FString& Parameters) override { // find the matching test TestFunc TestFunction = nullptr; for (int32 i = 0; i < TestFunctionNames.Num(); ++i) { if (TestFunctionNames[i] == Parameters) { TestFunction = TestFunctions[i]; break; } } if (TestFunction == nullptr) { return false; } // get the current curve and data table (to restore later) UCurveTable *CurveTable = IGameplayAbilitiesModule::Get().GetAbilitySystemGlobals()->GetGlobalCurveTable(); UDataTable *DataTable = IGameplayAbilitiesModule::Get().GetAbilitySystemGlobals()->GetGlobalAttributeMetaDataTable(); // setup required GameplayTags UDataTable* TagTable = CreateGameplayDataTable(); IGameplayTagsModule::Get().GetGameplayTagsManager().PopulateTreeFromDataTable(TagTable); UWorld *World = UWorld::CreateWorld(EWorldType::Game, false); FWorldContext &WorldContext = GEngine->CreateNewWorldContext(EWorldType::Game); WorldContext.SetCurrentWorld(World); FURL URL; World->InitializeActorsForPlay(URL); World->BeginPlay(); // run the matching test uint64 InitialFrameCounter = GFrameCounter; { GameplayEffectsTestSuite Tester(World, this); (Tester.*TestFunction)(); } GFrameCounter = InitialFrameCounter; GEngine->DestroyWorldContext(World); World->DestroyWorld(false); IGameplayAbilitiesModule::Get().GetAbilitySystemGlobals()->AutomationTestOnly_SetGlobalCurveTable(CurveTable); IGameplayAbilitiesModule::Get().GetAbilitySystemGlobals()->AutomationTestOnly_SetGlobalAttributeDataTable(DataTable); return true; }
void RunWorld(const FURL& URL, FJavascriptFunction Function) { UWorld *World = UWorld::CreateWorld(EWorldType::Game, false); FWorldContext &WorldContext = GEngine->CreateNewWorldContext(EWorldType::Game); WorldContext.SetCurrentWorld(World); World->InitializeActorsForPlay(URL); World->BeginPlay(); // run the matching test uint64 InitialFrameCounter = GFrameCounter; { FJavascriptRunWorldParameters Params; Params.World = World; Function.Execute(FJavascriptRunWorldParameters::StaticStruct(), &Params); } GFrameCounter = InitialFrameCounter; GEngine->DestroyWorldContext(World); World->DestroyWorld(false); }