UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AutomationCommon.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
8#include "Engine/World.h"
9
10class AActor;
11class SWindow;
12class SWidget;
13
14#if WITH_AUTOMATION_TESTS
15
17// Common Latent commands which are used across test type. I.e. Engine, Network, etc...
18
21
23
24#endif
25
31{
34
36 inline UWorld* GetTestWorld() const {return TestWorld;}
37
39 ENGINE_API virtual bool CreateTestWorld(EWorldType::Type WorldType);
40
43
45 ENGINE_API virtual bool BeginPlayInTestWorld();
46
48 ENGINE_API virtual bool TickTestWorld(float DeltaTime = 0.01f);
49
51 ENGINE_API virtual bool EndPlayInTestWorld();
52
54 ENGINE_API virtual void ReportFailure(const TCHAR* ErrorMessage);
55
57 ENGINE_API virtual void ClearFailureState();
58
60 ENGINE_API virtual bool HasFailed() const;
61
64
67
68protected:
69 UWorld* TestWorld = nullptr;
72};
73
81{
84
86
91 ENGINE_API void Set(const FString& Value);
92
94 ENGINE_API FString Get();
95
97 ENGINE_API void Restore();
98
99private:
100 bool bModified;
101 FString ConsoleVariableName;
102 FString OriginalValue;
103};
104
110{
113
119
125 ENGINE_API void SetConsoleVariableValue(const FString& ConsoleVariableName, const FString& Value);
126
133 ENGINE_API bool TryGetConsoleVariableValue(const FString& ConsoleVariableName, FString* OutValue);
134
136 ENGINE_API void Restore();
137
138private:
139 FScopedTestEnvironment() = default;
140
143 FScopedTestEnvironment& operator=(FScopedTestEnvironment&&) = delete;
144 FScopedTestEnvironment& operator=(const FScopedTestEnvironment&) = delete;
145
147
148 static TWeakPtr<struct FScopedTestEnvironment> EnvironmentInstance;
149};
150
152namespace AutomationCommon
153{
154#if WITH_AUTOMATION_TESTS
155
158
159
164 ENGINE_API FString GetScreenshotPath(const FString& TestName);
165
172
173 ENGINE_API FAutomationScreenshotData BuildScreenshotData(const FString& MapOrContext, const FString& TestName, const FString& ScreenShotName, int32 Width, int32 Height);
174
177 {
179 }
180
181 ENGINE_API TArray<uint8> CaptureFrameTrace(const FString& MapOrContext, const FString& TestName);
182
189
191
192#endif
194
195 /* Get the adjusted World name to use for screenshot paths */
197}
198
199#if WITH_AUTOMATION_TESTS
200
205{
206 FString ScreenshotName;
208};
209
213ENGINE_API bool AutomationOpenMap(const FString& MapName, bool bForceReload = false);
214
219
224
225
230
235
240
245
250
255
260
261
266
267
272
277
278
283
284
289
290
298{
299public:
300
302
303 ENGINE_API bool Update() override;
304
305public:
306
307 // Framerate we want to see
308 float DesiredFrameRate;
309
310 // How long must we maintain this framerate
311 float Duration;
312
313 // Max time so spend waiting
314 float MaxWaitTime;
315
316private:
317
318 // Add a sample to the rolling buffer where we hold tick rate
319 void AddTickRateSample(const double Value);
320
321 // return the average tick rate
322 double CurrentAverageTickRate() const;
323
324 // Time we began executing
325 double StartTimeOfWait;
326
327 // how many seconds we've been at the desired framerate
329
330 // time we last logged we are waiting
331 double LastReportTime;
332
333 // time of last tick
334 double LastTickTime;
335
336 // buffer of recent tick rate
338
339 // index into the buffer
340 int32 BufferIndex;
341
342 // We tick at 60Hz
343 const double kTickRate = 60.0;
344
345 // How many samples we hold
346 const int kSampleCount = (int32)kTickRate * 5;
347};
348
353{
354public:
355
356 ENGINE_API bool Update() override;
357
358private:
359
360 // Frame to be passed to consider the waiting over
361 uint64 LastFrame = 0;
362};
363
368{
369public:
371
372 ENGINE_API bool Update() override;
373
374private:
375 int32 FrameCounter = 0;
377};
378
379
386
387
388#endif
EAutomationComparisonToleranceLevel
Definition AutomationTest.h:864
#define DEFINE_ENGINE_LATENT_AUTOMATION_COMMAND(CommandName)
Definition AutomationTest.h:3977
#define DEFINE_ENGINE_LATENT_AUTOMATION_COMMAND_ONE_PARAMETER(CommandName, ParamType, ParamName)
Definition AutomationTest.h:3980
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_MULTICAST_DELEGATE_ThreeParams(DelegateName, Param1Type, Param2Type, Param3Type)
Definition DelegateCombinations.h:67
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
Definition Actor.h:257
Definition AutomationTest.h:1594
Definition NameTypes.h:617
Definition AutomationTest.h:525
virtual bool Update()=0
Definition SWidget.h:165
Definition SWindow.h:243
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
Definition SharedPointer.h:1295
Definition GameViewportClient.h:71
Definition World.h:918
Definition AutomationCommon.cpp:413
UGameViewportClient * GetAnyGameViewportClient()
Definition AutomationCommon.cpp:726
FString GetWorldContext(UWorld *InWorld)
Definition AutomationCommon.cpp:745
Definition AutomationTest.cpp:34
Type
Definition EngineTypes.h:1264
Definition AutomationTest.h:721
Definition AutomationCommon.h:110
static ENGINE_API TSharedPtr< FScopedTestEnvironment > Get()
Definition AutomationCommon.cpp:352
ENGINE_API void SetConsoleVariableValue(const FString &ConsoleVariableName, const FString &Value)
Definition AutomationCommon.cpp:367
ENGINE_API void Restore()
Definition AutomationCommon.cpp:399
ENGINE_API ~FScopedTestEnvironment()
Definition AutomationCommon.cpp:347
ENGINE_API bool TryGetConsoleVariableValue(const FString &ConsoleVariableName, FString *OutValue)
Definition AutomationCommon.cpp:383
Definition AutomationCommon.h:81
ENGINE_API void Restore()
Definition AutomationCommon.cpp:324
ENGINE_API ~FTestConsoleVariable()
Definition AutomationCommon.cpp:289
ENGINE_API FString Get()
Definition AutomationCommon.cpp:313
Definition AutomationCommon.h:31
UWorld * TestWorld
Definition AutomationCommon.h:69
TArray< FString > FailureErrors
Definition AutomationCommon.h:71
virtual ENGINE_API ~FTestWorldWrapper()
Definition AutomationCommon.cpp:50
virtual ENGINE_API void ReportFailure(const TCHAR *ErrorMessage)
Definition AutomationCommon.cpp:238
virtual ENGINE_API void ClearFailureState()
Definition AutomationCommon.cpp:243
virtual ENGINE_API bool DestroyTestWorld(bool bForceGarbageCollect)
Definition AutomationCommon.cpp:117
virtual ENGINE_API void ForwardErrorMessages(FAutomationTestBase *AutomationTest) const
Definition AutomationCommon.cpp:258
UWorld * GetTestWorld() const
Definition AutomationCommon.h:36
virtual ENGINE_API bool EndPlayInTestWorld()
Definition AutomationCommon.cpp:199
virtual ENGINE_API void AppendErrorMessages(TArray< FString > &OutErrorMessages) const
Definition AutomationCommon.cpp:253
uint64 CachedFrameCounter
Definition AutomationCommon.h:70
virtual ENGINE_API bool BeginPlayInTestWorld()
Definition AutomationCommon.cpp:149
virtual ENGINE_API bool HasFailed() const
Definition AutomationCommon.cpp:248
virtual ENGINE_API bool CreateTestWorld(EWorldType::Type WorldType)
Definition AutomationCommon.cpp:59
virtual ENGINE_API bool TickTestWorld(float DeltaTime=0.01f)
Definition AutomationCommon.cpp:220