#pragma once #include "CoreMinimal.h" #include "Misc/AutomationTest.h" #include "Engine/World.h" /** * Shared by every Tests/Tests.cpp. Test names all start with "Descent." so `Automation RunTests Descent` * selects exactly these; a system uses "Descent..". Tests are headless (-nullrhi): pure logic only. * Anything that needs the renderer is a scenario (Debug/Scenarios_.cpp). * * EditorContext covers UnrealEditor-Cmd (what Tools/run_tests.ps1 uses); ClientContext covers a packaged game. */ #define DESCENT_TEST_FLAGS (EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext | EAutomationTestFlags::ProductFilter) /** * A throw-away game world, created and destroyed by the test. World subsystems of The Descent exist in it (they * support Game worlds), so a test gets the real UDescentSimSubsystem and friends and drives them by hand * (Step, FastForward, ...) without a map, a renderer or a tick. */ class FDescentTestWorld { public: FDescentTestWorld() : World(UWorld::CreateWorld(EWorldType::Game, /*bInformEngineOfWorld*/ false)) {} ~FDescentTestWorld() { if (World) { World->DestroyWorld(/*bInformEngineOfWorld*/ false); } } FDescentTestWorld(const FDescentTestWorld&) = delete; FDescentTestWorld& operator=(const FDescentTestWorld&) = delete; UWorld* Get() const { return World; } template TSubsystem* Sub() const { return World ? World->GetSubsystem() : nullptr; } private: UWorld* World = nullptr; };