UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AutomationTest.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Async/Async.h"
6#include "Async/Future.h"
7#include "Containers/Array.h"
8#include "Containers/Map.h"
9#include "Containers/Queue.h"
10#include "Containers/Set.h"
13#include "CoreTypes.h"
14#include "Delegates/Delegate.h"
19#include "HAL/CriticalSection.h"
21#include "HAL/PlatformProcess.h"
23#include "HAL/PlatformTime.h"
25#include "HAL/ThreadSafeBool.h"
28#include "Math/Color.h"
29#include "Math/MathFwd.h"
30#include "Math/Rotator.h"
32#include "Math/Vector.h"
35#include "Misc/Build.h"
36#include "Misc/Char.h"
37#include "Misc/CString.h"
38#include "Misc/DateTime.h"
40#include "Misc/Guid.h"
41#include "Misc/Optional.h"
42#include "Misc/OutputDevice.h"
43#include "Misc/SourceLocation.h"
45#include "Misc/Timespan.h"
48#include "Templates/Function.h"
51#include "UObject/NameTypes.h"
52
53#include <atomic>
54
57
61
62#ifndef WITH_AUTOMATION_TESTS
63 #define WITH_AUTOMATION_TESTS (WITH_DEV_AUTOMATION_TESTS || WITH_PERF_AUTOMATION_TESTS)
64#endif
65
67#define SAFE_GETSTACK(VariableName, IgnoreCount, MaxDepth) \
68 TArray<FProgramCounterSymbolInfo> VariableName = FPlatformStackWalk::GetStack(IgnoreCount, MaxDepth); \
69 if (VariableName.Num() == 0) \
70 { \
71 /* This is a rare failure that can occur in some circumstances */ \
72 FProgramCounterSymbolInfo& Info = VariableName.Emplace_GetRef(); \
73 TCString<ANSICHAR>::Strncpy(Info.Filename, "Unknown", FProgramCounterSymbolInfo::MAX_NAME_LENGTH); \
74 Info.LineNumber = 1; \
75 }
76
77// This macro allows for early exit of the executing unit test function when the condition is false
78// It explicitly uses the condition to ensure static analysis is happy with nullptr checks
79#ifndef UE_RETURN_ON_ERROR
80#define UE_RETURN_ON_ERROR(Condition, Message) const bool PREPROCESSOR_JOIN(UE____bCondition_Line_, __LINE__) = (Condition); AddErrorIfFalse(PREPROCESSOR_JOIN(UE____bCondition_Line_, __LINE__), (Message)); if(!PREPROCESSOR_JOIN(UE____bCondition_Line_, __LINE__)) return false
81#endif
82
88{
89 None = 0x00000000,
90 //~ Application context required for the test
91 // Test is suitable for running within the editor
92 EditorContext = 0x00000001,
93 // Test is suitable for running within the client
94 ClientContext = 0x00000002,
95 // Test is suitable for running within the server
96 ServerContext = 0x00000004,
97 // Test is suitable for running within a commandlet
98 CommandletContext = 0x00000008,
99 // Test is suitable for running within program application (not editor, nor game)
100 ProgramContext = 0x00000010,
101
102 //~ Features required for the test - not specifying means it is valid for any feature combination
103 // Test requires a non-null RHI to run correctly
104 NonNullRHI = 0x00000100,
105 // Test requires a user instigated session
106 RequiresUser = 0x00000200,
107
108 //~ One-off flags
109 // Fast disable: turns off a test without commenting code out. Never returns for a filter.
110 Disabled = 0x00010000,
111
112 // When AutoRTFM is enabled, the test will be executed within a transaction that commits,
113 // and within another transaction that aborts. (The test will also execute non-transactionally.)
114 SupportsAutoRTFM = 0x00020000,
115
116 //~ Priority of the test
117 // The highest priority possible. Showstopper/blocker.
118 CriticalPriority = 0x00100000,
119 // High priority. Major feature functionality etc.
120 HighPriority = 0x00200000,
121 // Medium Priority. Minor feature functionality, major generic content issues.
122 MediumPriority = 0x00400000,
123 // Low Priority. Minor content bugs. String errors. Etc.
124 LowPriority = 0x00800000,
125
126 //~ Speed of the test
127 //Super Fast Filter
128 SmokeFilter = 0x01000000,
129 //Engine Level Test
130 EngineFilter = 0x02000000,
131 //Product Level Test
132 ProductFilter = 0x04000000,
133 //Performance Test
134 PerfFilter = 0x08000000,
135 //Stress Test
136 StressFilter = 0x10000000,
137 //Negative Test. For tests whose correct expected outcome is failure.
138 NegativeFilter = 0x20000000,
139};
140
142
149
151
154{
156 {
157 // When matching expected messages, do so exactly.
159 // When matching expected messages, just see if the message string is contained in the string to be evaluated.
161 };
162
163 inline const TCHAR* ToString(EAutomationExpectedMessageFlags::MatchType ThisType)
164 {
165 switch (ThisType)
166 {
167 case Contains:
168 return TEXT("Contains");
169 case Exact:
170 return TEXT("Exact");
171 }
172 return TEXT("Unknown");
173 }
174}
175
178
180{
181 FString DataPoint;
183 FString Context;
184
185 FAutomationTelemetryData(const FString& InDataPoint, double InMeasurement, const FString& InContext)
189 {
190 }
191};
192
195{
196public:
199 : bSuccessful( false )
200 , Duration(0.0)
201 , Errors(0)
202 , Warnings(0)
203 {}
204
210
212 CORE_API void Clear();
213
215
217
219 const TArray<FAutomationExecutionEntry>& GetEntries() const { return Entries; }
220
221 CORE_API void AddEvent(const FAutomationEvent& Event, int StackOffset = 0, bool bCaptureStack = true);
222
223 CORE_API void AddWarning(const FString& WarningMessage);
224 CORE_API void AddError(const FString& ErrorMessage);
225
226 int32 GetWarningTotal() const { return Warnings; }
227 int32 GetErrorTotal() const { return Errors; }
228
229 const FString& GetContext() const
230 {
231 static FString EmptyContext;
232 return ContextStack.Num() ? ContextStack.Top() : EmptyContext;
233 }
234
235 void PushContext(const FString& Context)
236 {
237 ContextStack.Push(Context);
238 }
239
241 {
242 if ( ContextStack.Num() > 0 )
243 {
244 ContextStack.Pop();
245 }
246 }
247
248public:
249
252
255
258
261
263 double Duration;
264
265private:
268
269 int32 Errors;
270 int32 Warnings;
271
272 TArray<FString> ContextStack;
273};
274
277{
278public:
279
280 // Default constructor
282
298 FAutomationTestInfo(const FString& InDisplayName, const FString& InFullTestPath, const FString& InTestName, const EAutomationTestFlags InTestFlags, const int32 InNumParticipantsRequired, const FString& InParameterName = FString(), const FString& InSourceFile = FString(), int32 InSourceFileLine = 0, const FString& InAssetPath = FString(), const FString& InOpenCommand = FString(), const FString& InTestTags = FString())
299 : DisplayName( InDisplayName )
300 , FullTestPath( InFullTestPath )
301 , TestName( InTestName )
302 , TestTags( InTestTags )
303 , TestParameter( InParameterName )
304 , SourceFile( InSourceFile )
305 , SourceFileLine( InSourceFileLine )
306 , AssetPath( InAssetPath )
307 , OpenCommand( InOpenCommand )
308 , TestFlags( InTestFlags )
309 , NumParticipantsRequired( InNumParticipantsRequired )
310 , NumDevicesCurrentlyRunningTest( 0 )
311 {
312 }
313
314public:
315
322 {
323 TestFlags |= InTestFlags;
324 }
325
331 const FString& GetDisplayName() const
332 {
333 return DisplayName;
334 }
335
341 const FString& GetFullTestPath() const
342 {
343 return FullTestPath;
344 }
345
351 FString GetTestName() const
352 {
353 return TestName;
354 }
355
361 FString GetTestTags() const
362 {
363 return TestTags;
364 }
365
371 const FString GetTestParameter() const
372 {
373 return TestParameter;
374 }
375
381 const FString GetSourceFile() const
382 {
383 return SourceFile;
384 }
385
392 {
393 return SourceFileLine;
394 }
395
401 const FString GetAssetPath() const
402 {
403 return AssetPath;
404 }
405
411 const FString GetOpenCommand() const
412 {
413 return OpenCommand;
414 }
415
422 {
423 return TestFlags;
424 }
425
430 {
431 NumDevicesCurrentlyRunningTest = 0;
432 }
433
438 {
439 NumDevicesCurrentlyRunningTest++;
440 }
441
447 const int GetNumDevicesRunningTest() const
448 {
449 return NumDevicesCurrentlyRunningTest;
450 }
451
458 {
459 return NumParticipantsRequired;
460 }
461
462
468 void SetDisplayName( const FString& InDisplayName )
469 {
470 DisplayName = InDisplayName;
471 }
472
479 {
480 NumParticipantsRequired = NumRequired;
481 }
482
483private:
485 FString DisplayName;
486
487 FString FullTestPath;
488
490 FString TestName;
491
493 FString TestTags;
494
496 FString TestParameter;
497
499 FString SourceFile;
500
502 int32 SourceFileLine;
503
505 FString AssetPath;
506
508 FString OpenCommand;
509
512
514 uint32 NumParticipantsRequired = 0;
515
517 uint32 NumDevicesCurrentlyRunningTest = 0;
518};
519
520
524class IAutomationLatentCommand : public TSharedFromThis<IAutomationLatentCommand>
525{
526public:
527 /* virtual destructor */
529
533 virtual bool Update() = 0;
534
535private:
539 bool InternalUpdate()
540 {
541 if (StartTime == 0.0)
542 {
544 }
545
546 return Update();
547 }
548
549protected:
552 : StartTime(0.0f)
553 {
554 }
555
556 // Gets current run time for the command for reporting purposes.
557 double GetCurrentRunTime() const
558 {
559 if (StartTime == 0.0)
560 {
561 return 0.0;
562 }
563
565 }
566
568 double StartTime;
569
571};
572
577{
578public:
579
581
582 virtual bool Update() override
583 {
584 if (!Future.IsValid())
585 {
587 }
588
589 return Future.IsReady();
590 }
591
595
596protected:
597
599
601
603};
604
605
609class IAutomationNetworkCommand : public TSharedFromThis<IAutomationNetworkCommand>
610{
611public:
612 /* virtual destructor */
614
620 virtual uint32 GetRoleIndex() const = 0;
621
623 virtual void Run() = 0;
624};
625
627{
628 // Original string pattern matching expected log message.
629 // If IsRegex is false, it is this string that is used to match.
630 // Otherwise MessagePatternRegex is set to a valid pointer of FRegexPattern.
631 // The base pattern string is preserved none the less to allow checks for duplicate entries.
633 // Regular expression pattern from MessagePatternString if regex option was true(default), otherwise it is not set.
635 // Type of comparison to perform on error log using MessagePattern.
644 // Log message Verbosity
646
662
671
672 inline bool IsRegex() const
673 {
674 return MessagePatternRegex.IsSet();
675 }
676
677 inline bool IsExactCompareType() const
678 {
680 }
681
687 bool Matches(const FString& Message)
688 {
689 bool HasMatch = false;
690 if (IsRegex())
691 {
693 HasMatch = MessageMatcher.FindNext();
694 }
695 else
696 {
697 HasMatch = Message.Contains(MessagePatternString) && (!IsExactCompareType() || Message.Len() == MessagePatternString.Len());
698 }
700 return HasMatch;
701 }
702
704 {
705 return MessagePatternString == Other.MessagePatternString;
706 }
707
709 {
710 return MessagePatternString < Other.MessagePatternString;
711 }
712
713};
714
719
721{
723 FString VariantName;
724 FString Context;
725 FString TestName;
726 FString Notes;
727
729 FString Commit;
730
733
734 // RHI Details
735 FString Platform;
736 FString Rhi;
739
740 // Track if ScreenShotData was created with Substrate enabled or not
742
743 // Hardware Details
744 FString Vendor;
745 FString AdapterName;
749
750 // Quality Levels
762
763 // Comparison Requests
775
776 // Path of the screenshot generated from AutomationCommon::GetScreenShotPath()
778
810};
811
862
864{
865 Zero,
866 Low,
867 Medium,
868 High
869};
870
917
925
927
929
931
932DECLARE_MULTICAST_DELEGATE_TwoParams(FOnTestDataRetrieved, bool /*bWasNew*/, const FString& /*JsonData*/);
933
934DECLARE_MULTICAST_DELEGATE_TwoParams(FOnPerformanceDataRetrieved, bool /*bSuccess*/, const FString& /*ErrorMessage*/);
935
937
939
941
943
944
947{
948public:
951
954
957
960
963
966
969
972
975
978
981
984 CORE_API void TriggerOnEnteringTestSection(const FString& Section) const;
986
989 CORE_API void TriggerOnLeavingTestSection(const FString& Section) const;
991
999
1005 CORE_API FString GetUserAutomationDirectory() const;
1006
1019
1026
1036 CORE_API bool RegisterAutomationTestTags(const FString& InTestNameToRegister, const FString& InTestTagsToRegister, bool InImmutable = true);
1037
1046
1057
1059
1060 CORE_API bool IsTagImmutable(const FString& InTestName, const FString& InTag) const;
1061
1069 CORE_API FString GetTagsForAutomationTest(const FString& InTestName);
1070
1079
1086
1093
1101 CORE_API bool ContainsTest( const FString& InTestName ) const;
1102
1108 CORE_API bool RunSmokeTests();
1109
1113 CORE_API void ResetTests();
1114
1122 CORE_API void StartTestByName( const FString& InTestToRun, const int32 InRoleIndex, const FString& InFullTestPath = FString() );
1123
1130
1137
1144
1149
1154 {
1155 return LatentCommands.IsEmpty();
1156 }
1157
1162
1170
1181
1182 CORE_API void GetPossibleRestrictedPaths(const FString& BasePath, const TArray<FString>& RestrictedFolderNames, TArray<FString>& OutRestrictedFolders) const;
1183
1188
1192 CORE_API void LoadTestTagMappings(const FString& BasePath, const bool RestrictedPathsOnly);
1193
1194
1199
1205 CORE_API bool ShouldTestContent(const FString& Path) const;
1206
1211
1216
1217
1222
1227
1232 {
1233 bForceSmokeTests = bInForceSmokeTests;
1234 }
1235
1236 bool GetCaptureStack() const
1237 {
1238 return bCaptureStack && !NeedSkipStackWalk();
1239 }
1240
1245 void SetCaptureStack(bool bCapture)
1246 {
1247 bCaptureStack = bCapture;
1248 }
1249
1256
1261 {
1262 return CurrentTest;
1263 }
1264
1269 {
1270 return CurrentTestFullPath;
1271 }
1272
1276 static CORE_API bool NeedSkipStackWalk();
1277
1281 static CORE_API bool NeedLogBPTestMetadata();
1282
1287
1292
1297
1302
1303 CORE_API void NotifyTestDataRetrieved(bool bWasNew, const FString& JsonData);
1304 CORE_API void NotifyPerformanceDataRetrieved(bool bSuccess, const FString& ErrorMessage);
1305
1307
1317 CORE_API bool CanRunTestInEnvironment(const FString& InTestToRun, FString* OutReason, bool* OutWarn) const;
1318
1319private:
1320
1322 class FAutomationTestOutputDevice : public FOutputDevice
1323 {
1324 public:
1325 FAutomationTestOutputDevice()
1326 : CurTest( nullptr ) {}
1327
1328 ~FAutomationTestOutputDevice()
1329 {
1330 CurTest = nullptr;
1331 }
1332
1339 virtual void Serialize( const TCHAR* V, ELogVerbosity::Type Verbosity, const class FName& Category ) override;
1340
1346 virtual bool CanBeUsedOnMultipleThreads() const override
1347 {
1348 return true;
1349 }
1350
1357 void SetCurrentAutomationTest( FAutomationTestBase* InAutomationTest )
1358 {
1359 CurTest = InAutomationTest;
1360 }
1361
1362 private:
1364 std::atomic<FAutomationTestBase*>CurTest;
1365 };
1366
1368 class FAutomationTestMessageFilter: public FFeedbackContext
1369 {
1370 public:
1371 FAutomationTestMessageFilter()
1372 : CurTest(nullptr)
1373 , DestinationContext(nullptr) {}
1374
1375 ~FAutomationTestMessageFilter()
1376 {
1377 DestinationContext = nullptr;
1378 CurTest = nullptr;
1379 }
1380
1387 virtual void Serialize(const TCHAR* V, ELogVerbosity::Type Verbosity, const FName& Category) override;
1388 virtual void Serialize(const TCHAR* V, ELogVerbosity::Type Verbosity, const FName& Category, double Time) override;
1389
1390 virtual void SerializeRecord(const UE::FLogRecord& Record) override;
1391
1397 virtual bool CanBeUsedOnMultipleThreads() const override
1398 {
1399 return true;
1400 }
1401
1409 void SetCurrentAutomationTest(FAutomationTestBase* InAutomationTest)
1410 {
1411 CurTest = InAutomationTest;
1412 }
1413
1420 void SetDestinationContext(FFeedbackContext* InDestinationContext)
1421 {
1422 DestinationContext = InDestinationContext;
1423 }
1424
1425 private:
1426 std::atomic<FAutomationTestBase*> CurTest;
1427 std::atomic<FFeedbackContext*> DestinationContext;
1429 };
1430
1433 CORE_API void PrepForAutomationTests();
1434
1436 CORE_API void ConcludeAutomationTests();
1437
1444 CORE_API void DumpAutomationTestExecutionInfo( const TMap<FString, FAutomationTestExecutionInfo>& InInfoToDump );
1445
1452 CORE_API void InternalStartTest( const FString& InTestToRun, const FString& InFullTestPath );
1453
1461
1464
1467
1468 // Copy constructor and assignment operator intentionally left unimplemented
1471
1473 FAutomationTestOutputDevice AutomationTestOutputDevice;
1474
1476 FAutomationTestMessageFilter AutomationTestMessageFilter;
1477
1478 FFeedbackContext* OriginalGWarn = nullptr;
1479
1481 TMap<FString, FAutomationTestBase*> AutomationTestClassNameToInstanceMap;
1482
1483 /* Set of all tags whether they are code declared or through config file */
1484 TSet<FString> AllExistingTags;
1485
1489 TMap<FString, FString> TestFullNameToTagDataMap;
1490
1494 TMap<FString, TSet<FString>> ImmutableTags;
1495
1498
1501
1503 EAutomationTestFlags RequestedTestFilter;
1504
1506 double StartTime;
1507
1509 bool bTestSuccessful;
1510
1512 FAutomationTestBase* CurrentTest;
1513
1515 FString Parameters;
1516
1518 FString CurrentTestFullPath;
1519
1521 bool bDeveloperDirectoryIncluded;
1522
1524 uint32 NetworkRoleIndex;
1525
1527 FOnTestScreenshotCaptured TestScreenshotCapturedDelegate;
1528
1530 FOnTestScreenshotAndTraceCaptured TestScreenshotAndTraceCapturedDelegate;
1531
1533 bool bForceSmokeTests;
1534
1535 bool bCaptureStack;
1536
1537 TMap<FString, FOnTestSectionEvent> OnEnteringTestSectionEvent;
1538 TMap<FString, FOnTestSectionEvent> OnLeavingTestSectionEvent;
1539
1547 bool TagsMatchPattern(const FString& Tags, const FString& TagPattern) const;
1548
1551};
1552
1555{
1556public:
1564 FAutomationTestTags(const FString& InTestFullName, const FString& InTags)
1565 {
1566 LLM_SCOPE_BYNAME(TEXT("AutomationTest/Framework"));
1567 TestFullName = InTestFullName;
1569 if (!Registered)
1570 {
1571 UE_LOG(LogAutomationTestFramework, Warning, TEXT("Tag registration already exists for test '%s', existing value was not overridden"), *TestFullName);
1572 }
1573 }
1574
1579
1581 {
1582 if (!TestFullName.IsEmpty())
1583 {
1584 //ignore failure to unregister due to already being unregistered
1586 }
1587 }
1588private:
1589 FString TestFullName;
1590};
1591
1594{
1595public:
1601 CORE_API FAutomationTestBase( const FString& InName, const bool bInComplexTask );
1602
1604 CORE_API virtual ~FAutomationTestBase() ;
1605
1611
1618
1620 FString GetTestName() const { return TestName; }
1621
1623 FString GetTestContext() const { return TestParameterContext; }
1624
1628 virtual FString GetBeautifiedTestName() const = 0;
1629
1633 virtual FString GetTestFullName() const {
1634 if (FAutomationTestFramework::Get().GetCurrentTest() == this)
1635 {
1637 }
1638 if (GetTestContext().IsEmpty()) { return GetBeautifiedTestName(); }
1639 return FString::Printf(TEXT("%s.%s"), *GetBeautifiedTestName(), *GetTestContext());
1640 }
1641
1647 virtual uint32 GetRequiredDeviceNum() const = 0;
1648
1651
1657 CORE_API virtual void AddError( const FString& InError, int32 StackOffset = 0 );
1658
1666 CORE_API virtual bool AddErrorIfFalse( bool bCondition, const FString& InError, int32 StackOffset = 0 );
1667
1675 UE_DEPRECATED(5.4, "Please use AddError instead.")
1676 CORE_API virtual void AddErrorS(const FString& InError, const FString& InFilename, int32 InLineNumber);
1677
1685 UE_DEPRECATED(5.4, "Please use AddWarning instead.")
1686 CORE_API virtual void AddWarningS(const FString& InWarning, const FString& InFilename, int32 InLineNumber);
1687
1693 CORE_API virtual void AddWarning( const FString& InWarning, int32 StackOffset = 0);
1694
1700 CORE_API virtual void AddInfo( const FString& InLogItem, int32 StackOffset = 0, bool bCaptureStack = false);
1701
1707 CORE_API virtual void AddEvent(const FAutomationEvent& InEvent, int32 StackOffset = 0, bool bCaptureStack = false);
1708
1714 CORE_API virtual void AddAnalyticsItem(const FString& InAnalyticsItem);
1715
1723 CORE_API virtual void AddTelemetryData(const FString& DataPoint, double Measurement, const FString& Context = TEXT(""));
1724
1731 CORE_API virtual void AddTelemetryData(const TMap<FString, double>& ValuePairs, const FString& Context = TEXT(""));
1732
1738 CORE_API virtual void SetTelemetryStorage(const FString& StorageName);
1739
1745 CORE_API bool HasAnyErrors() const;
1746
1753
1760
1765
1773
1777 CORE_API void GenerateTestNames( TArray<FAutomationTestInfo>& TestInfo ) const;
1778
1783
1802
1816
1829
1841
1842
1852
1861
1873 CORE_API void AddExpectedError(FString ExpectedPatternString, EAutomationExpectedErrorFlags::MatchType CompareType = EAutomationExpectedErrorFlags::Contains, int32 Occurrences = 1, bool IsRegex = true);
1874
1886
1892 const bool IsComplexTask() const
1893 {
1894 return bComplexTask;
1895 }
1896
1897 const bool IsRanOnSeparateThread() const
1898 {
1899 return bRunOnSeparateThread;
1900 }
1901
1907 virtual bool SuppressLogs()
1908 {
1909 return bSuppressLogs;
1910 }
1911
1919 virtual bool ShouldCaptureLogCategory(const class FName& Category) const { return true; }
1920
1926 virtual bool SuppressLogErrors() { return bSuppressLogErrors; }
1927
1934
1941
1946
1947
1951 inline void AddCommand(IAutomationLatentCommand* NewCommand)
1952 {
1953 TSharedRef<IAutomationLatentCommand> CommandPtr = MakeShareable(NewCommand);
1955 }
1956
1960 inline void AddCommand(IAutomationNetworkCommand* NewCommand)
1961 {
1964 }
1965
1967 virtual FString GetTestSourceFileName() const { return TEXT(""); }
1968
1970 virtual int32 GetTestSourceFileLine() const { return 0; }
1971
1973 virtual FString GetTestSourceFileName(const FString& InTestName) const { return GetTestSourceFileName(); }
1974
1976 virtual int32 GetTestSourceFileLine(const FString& InTestName) const { return GetTestSourceFileLine(); }
1977
1979 virtual FString GetTestAssetPath(const FString& Parameter) const { return TEXT(""); }
1980
1982 virtual FString GetTestOpenCommand(const FString& Parameter) const { return TEXT(""); }
1983
1984 void PushContext(const FString& Context)
1985 {
1987 }
1988
1990 {
1992 }
1993
1995 virtual bool CanRunInEnvironment(const FString& TestParams, FString* OutReason, bool* OutWarn) const
1996 {
1997 // By default the test is able to run in the current environment
1998 // It is responsibility of a child class to decide if the flow should skip the corresponding test.
1999 return true;
2000 }
2001
2002public:
2003
2004 CORE_API bool TestEqual(const TCHAR* What, const int32 Actual, const int32 Expected);
2005 CORE_API bool TestEqual(const TCHAR* What, const int64 Actual, const int64 Expected);
2006#if PLATFORM_64BITS
2007 CORE_API bool TestEqual(const TCHAR* What, const SIZE_T Actual, const SIZE_T Expected);
2008#endif
2009 CORE_API bool TestEqual(const TCHAR* What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2010 CORE_API bool TestEqual(const TCHAR* What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER);
2011 CORE_API bool TestEqual(const TCHAR* What, const FVector Actual, const FVector Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2012 CORE_API bool TestEqual(const TCHAR* What, const FTransform Actual, const FTransform Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2013 CORE_API bool TestEqual(const TCHAR* What, const FRotator Actual, const FRotator Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2014 CORE_API bool TestEqual(const TCHAR* What, const FColor Actual, const FColor Expected);
2015 CORE_API bool TestEqual(const TCHAR* What, const FLinearColor Actual, const FLinearColor Expected);
2016 CORE_API bool TestEqual(const TCHAR* What, const TCHAR* Actual, const TCHAR* Expected);
2017 CORE_API bool TestEqual(const TCHAR* What, FStringView Actual, FStringView Expected);
2018 bool TestEqual(const TCHAR* What, const FString& Actual, const FString& Expected)
2019 {
2020 return TestEqual(What, *Actual, *Expected);
2021 }
2022 CORE_API bool TestEqual(const TCHAR* What, FUtf8StringView Actual, FUtf8StringView Expected);
2023 CORE_API bool TestEqual(const TCHAR* What, const FText Actual, const FText Expected);
2024 CORE_API bool TestEqual(const TCHAR* What, const FName Actual, const FName Expected);
2025 CORE_API bool TestNotEqual(const TCHAR* What, const TCHAR* Actual, const TCHAR* Expected);
2026 CORE_API bool TestNotEqual(const TCHAR* What, FStringView Actual, FStringView Expected);
2027 bool TestNotEqual(const TCHAR* What, const FString& Actual, const FString& Expected)
2028 {
2029 return TestNotEqual(What, *Actual, *Expected);
2030 }
2031 CORE_API bool TestNotEqual(const TCHAR* What, FUtf8StringView Actual, FUtf8StringView Expected);
2032 CORE_API bool TestNotEqual(const TCHAR* What, const FText Actual, const FText Expected);
2033 CORE_API bool TestNotEqual(const TCHAR* What, const FName Actual, const FName Expected);
2034
2035 UE_DEPRECATED(5.5, "Use TestEqual instead (string tests are case insensitive by default)")
2036 CORE_API bool TestEqualInsensitive(const TCHAR* What, const TCHAR* Actual, const TCHAR* Expected);
2037 UE_DEPRECATED(5.5, "Use TestEqual instead (string tests are case insensitive by default)")
2038 CORE_API bool TestEqualInsensitive(const TCHAR* What, FStringView Actual, FStringView Expected);
2039 UE_DEPRECATED(5.5, "Use TestEqual instead (string tests are case insensitive by default)")
2041 UE_DEPRECATED(5.5, "Use TestNotEqual instead (string tests are case insensitive by default)")
2042 CORE_API bool TestNotEqualInsensitive(const TCHAR* What, const TCHAR* Actual, const TCHAR* Expected);
2043 UE_DEPRECATED(5.5, "Use TestNotEqual instead (string tests are case insensitive by default)")
2045 UE_DEPRECATED(5.5, "Use TestNotEqual instead (string tests are case insensitive by default)")
2047
2048 CORE_API bool TestEqualSensitive(const TCHAR* What, const TCHAR* Actual, const TCHAR* Expected);
2049 CORE_API bool TestEqualSensitive(const TCHAR* What, FStringView Actual, FStringView Expected);
2050 bool TestEqualSensitive(const TCHAR* What, const FString& Actual, const FString& Expected)
2051 {
2052 return TestEqualSensitive(What, *Actual, *Expected);
2053 }
2055 CORE_API bool TestNotEqualSensitive(const TCHAR* What, const TCHAR* Actual, const TCHAR* Expected);
2057 bool TestNotEqualSensitive(const TCHAR* What, const FString& Actual, const FString& Expected)
2058 {
2059 return TestNotEqualSensitive(What, *Actual, *Expected);
2060 }
2062
2063 bool TestEqual(const FString& What, const int32 Actual, const int32 Expected)
2064 {
2065 return TestEqual(*What, Actual, Expected);
2066 }
2067
2068 bool TestEqual(const FString& What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2069 {
2070 return TestEqual(*What, Actual, Expected, Tolerance);
2071 }
2072
2073 bool TestEqual(const FString& What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER)
2074 {
2075 return TestEqual(*What, Actual, Expected, Tolerance);
2076 }
2077
2078 bool TestEqual(const FString& What, const FVector Actual, const FVector Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2079 {
2080 return TestEqual(*What, Actual, Expected, Tolerance);
2081 }
2082
2083 bool TestEqual(const FString& What, const FTransform Actual, const FTransform Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2084 {
2085 return TestEqual(*What, Actual, Expected, Tolerance);
2086 }
2087
2088 bool TestEqual(const FString& What, const FRotator Actual, const FRotator Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2089 {
2090 return TestEqual(*What, Actual, Expected, Tolerance);
2091 }
2092
2093 bool TestEqual(const FString& What, const FColor Actual, const FColor Expected)
2094 {
2095 return TestEqual(*What, Actual, Expected);
2096 }
2097
2098 bool TestEqual(const FString& What, const TCHAR* Actual, const TCHAR* Expected)
2099 {
2100 return TestEqual(*What, Actual, Expected);
2101 }
2102
2103 bool TestEqual(const FString& What, FUtf8StringView Actual, FUtf8StringView Expected)
2104 {
2105 return TestEqual(*What, Actual, Expected);
2106 }
2107
2108 bool TestEqual(const FString& What, FStringView Actual, FStringView Expected)
2109 {
2110 return TestEqual(*What, Actual, Expected);
2111 }
2112
2113 bool TestEqual(const FString& What, FStringView Actual, FUtf8StringView Expected)
2114 {
2115 // This overload is here because there are some tests that have raw string literals as the expected value.
2116 FString Tmp(Expected);
2117 return TestEqual(*What, Actual, Tmp);
2118 }
2119
2120 bool TestEqual(const FString& What, FUtf8StringView Actual, FStringView Expected)
2121 {
2122 // This overload is here because there are some tests that have raw string literals as the Actual value.
2123 FString Tmp(Actual);
2124 return TestEqual(*What, Tmp, Expected);
2125 }
2126
2127 bool TestEqualSensitive(const FString& What, const TCHAR* Actual, const TCHAR* Expected)
2128 {
2129 return TestEqualSensitive(*What, Actual, Expected);
2130 }
2131
2132 bool TestEqualSensitive(const FString& What, FUtf8StringView Actual, FUtf8StringView Expected)
2133 {
2134 return TestEqualSensitive(*What, Actual, Expected);
2135 }
2136
2137 bool TestEqualSensitive(const FString& What, FStringView Actual, FStringView Expected)
2138 {
2139 return TestEqualSensitive(*What, Actual, Expected);
2140 }
2141
2142 bool TestEqualSensitive(const FString& What, FStringView Actual, FUtf8StringView Expected)
2143 {
2144 // This overload is here because there are some tests that have raw string literals as the expected value.
2145 FString Tmp(Expected);
2146 return TestEqualSensitive(*What, Actual, Tmp);
2147 }
2148
2149 bool TestEqualSensitive(const FString& What, FUtf8StringView Actual, FStringView Expected)
2150 {
2151 // This overload is here because there are some tests that have raw string literals as the Actual value.
2152 FString Tmp(Actual);
2153 return TestEqualSensitive(*What, Tmp, Expected);
2154 }
2155
2156 bool TestNotEqualSensitive(const FString& What, const TCHAR* Actual, const TCHAR* Expected)
2157 {
2158 return TestNotEqualSensitive(*What, Actual, Expected);
2159 }
2160
2162 {
2163 return TestNotEqualSensitive(*What, Actual, Expected);
2164 }
2165
2166 bool TestNotEqualSensitive(const FString& What, FStringView Actual, FStringView Expected)
2167 {
2168 return TestNotEqualSensitive(*What, Actual, Expected);
2169 }
2170
2171 bool TestNotEqualSensitive(const FString& What, FStringView Actual, FUtf8StringView Expected)
2172 {
2173 // This overload is here because there are some tests that have raw string literals as the expected value.
2174 FString Tmp(Expected);
2175 return TestNotEqualSensitive(*What, Actual, Tmp);
2176 }
2177
2178 bool TestNotEqualSensitive(const FString& What, FUtf8StringView Actual, FStringView Expected)
2179 {
2180 // This overload is here because there are some tests that have raw string literals as the Actual value.
2181 FString Tmp(Actual);
2182 return TestNotEqualSensitive(*What, Tmp, Expected);
2183 }
2184
2194 template<typename ValueType>
2195 inline bool TestEqual(const TCHAR* What, const ValueType& Actual, const ValueType& Expected)
2196 {
2197 if (Actual != Expected)
2198 {
2199 AddError(FString::Printf(TEXT("%s: The two values are not equal."), What));
2200 return false;
2201 }
2202 return true;
2203 }
2204
2205 template<typename ValueType>
2206 bool TestEqual(const FString& What, const ValueType& Actual, const ValueType& Expected)
2207 {
2208 return TestEqual(*What, Actual, Expected);
2209 }
2210
2211 CORE_API bool TestNearlyEqual(const TCHAR* What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2212 CORE_API bool TestNearlyEqual(const TCHAR* What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER);
2213 CORE_API bool TestNearlyEqual(const TCHAR* What, const FVector Actual, const FVector Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2214 CORE_API bool TestNearlyEqual(const TCHAR* What, const FTransform Actual, const FTransform Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2215 CORE_API bool TestNearlyEqual(const TCHAR* What, const FRotator Actual, const FRotator Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2216
2217 bool TestNearlyEqual(const FString& What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2218 {
2219 return TestNearlyEqual(*What, Actual, Expected, Tolerance);
2220 }
2221
2222 bool TestNearlyEqual(const FString& What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER)
2223 {
2224 return TestNearlyEqual(*What, Actual, Expected, Tolerance);
2225 }
2226
2227 bool TestNearlyEqual(const FString& What, const FVector Actual, const FVector Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2228 {
2229 return TestNearlyEqual(*What, Actual, Expected, Tolerance);
2230 }
2231
2232 bool TestNearlyEqual(const FString& What, const FTransform Actual, const FTransform Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2233 {
2234 return TestNearlyEqual(*What, Actual, Expected, Tolerance);
2235 }
2236
2237 bool TestNearlyEqual(const FString& What, const FRotator Actual, const FRotator Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2238 {
2239 return TestNearlyEqual(*What, Actual, Expected, Tolerance);
2240 }
2241
2242 CORE_API bool TestLessThan(const TCHAR* What, const int32 Actual, const int32 Expected);
2243 CORE_API bool TestLessThan(const TCHAR* What, const int64 Actual, const int64 Expected);
2244 CORE_API bool TestGreaterThan(const TCHAR* What, const int32 Actual, const int32 Expected);
2245 CORE_API bool TestGreaterThan(const TCHAR* What, const int64 Actual, const int64 Expected);
2246 CORE_API bool TestLessEqual(const TCHAR* What, const int32 Actual, const int32 Expected);
2247 CORE_API bool TestLessEqual(const TCHAR* What, const int64 Actual, const int64 Expected);
2248 CORE_API bool TestGreaterEqual(const TCHAR* What, const int32 Actual, const int32 Expected);
2249 CORE_API bool TestGreaterEqual(const TCHAR* What, const int64 Actual, const int64 Expected);
2250#if PLATFORM_64BITS
2251 CORE_API bool TestLessThan(const TCHAR* What, const SIZE_T Actual, const SIZE_T Expected);
2252 CORE_API bool TestGreaterThan(const TCHAR* What, const SIZE_T Actual, const SIZE_T Expected);
2253 CORE_API bool TestLessEqual(const TCHAR* What, const SIZE_T Actual, const SIZE_T Expected);
2254 CORE_API bool TestGreaterEqual(const TCHAR* What, const SIZE_T Actual, const SIZE_T Expected);
2255#endif
2256 CORE_API bool TestLessThan(const TCHAR* What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2257 CORE_API bool TestLessThan(const TCHAR* What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER);
2258 CORE_API bool TestGreaterThan(const TCHAR* What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2259 CORE_API bool TestGreaterThan(const TCHAR* What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER);
2260 CORE_API bool TestLessEqual(const TCHAR* What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2261 CORE_API bool TestLessEqual(const TCHAR* What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER);
2262 CORE_API bool TestGreaterEqual(const TCHAR* What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2263 CORE_API bool TestGreaterEqual(const TCHAR* What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER);
2264
2265 bool TestLessThan(const FString& What, const int32 Actual, const int32 Expected)
2266 {
2267 return TestLessThan(*What, Actual, Expected);
2268 }
2269
2270 bool TestLessThan(const FString& What, const int64 Actual, const int64 Expected)
2271 {
2272 return TestLessThan(*What, Actual, Expected);
2273 }
2274
2275 bool TestGreaterThan(const FString& What, const int32 Actual, const int32 Expected)
2276 {
2277 return TestGreaterThan(*What, Actual, Expected);
2278 }
2279
2280 bool TestGreaterThan(const FString& What, const int64 Actual, const int64 Expected)
2281 {
2282 return TestGreaterThan(*What, Actual, Expected);
2283 }
2284
2285 bool TestLessEqual(const FString& What, const int32 Actual, const int32 Expected)
2286 {
2287 return TestLessEqual(*What, Actual, Expected);
2288 }
2289
2290 bool TestLessEqual(const FString& What, const int64 Actual, const int64 Expected)
2291 {
2292 return TestLessEqual(*What, Actual, Expected);
2293 }
2294
2295 bool TestGreaterEqual(const FString& What, const int32 Actual, const int32 Expected)
2296 {
2297 return TestGreaterEqual(*What, Actual, Expected);
2298 }
2299
2300 bool TestGreaterEqual(const FString& What, const int64 Actual, const int64 Expected)
2301 {
2302 return TestGreaterEqual(*What, Actual, Expected);
2303 }
2304
2305 bool TestLessThan(const FString& What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2306 {
2307 return TestLessThan(*What, Actual, Expected, Tolerance);
2308 }
2309
2310 bool TestLessThan(const FString& What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER)
2311 {
2312 return TestLessThan(*What, Actual, Expected, Tolerance);
2313 }
2314
2315 bool TestGreaterThan(const FString& What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2316 {
2317 return TestGreaterThan(*What, Actual, Expected, Tolerance);
2318 }
2319
2320 bool TestGreaterThan(const FString& What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER)
2321 {
2322 return TestGreaterThan(*What, Actual, Expected, Tolerance);
2323 }
2324
2325 bool TestLessEqual(const FString& What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2326 {
2327 return TestLessEqual(*What, Actual, Expected, Tolerance);
2328 }
2329
2330 bool TestLessEqual(const FString& What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER)
2331 {
2332 return TestLessEqual(*What, Actual, Expected, Tolerance);
2333 }
2334
2335 bool TestGreaterEqual(const FString& What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2336 {
2337 return TestGreaterEqual(*What, Actual, Expected, Tolerance);
2338 }
2339
2340 bool TestGreaterEqual(const FString& What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER)
2341 {
2342 return TestGreaterEqual(*What, Actual, Expected, Tolerance);
2343 }
2344
2353 CORE_API bool TestFalse(const TCHAR* What, bool Value);
2354
2355 bool TestFalse(const FString& What, bool Value)
2356 {
2357 return TestFalse(*What, Value);
2358 }
2359
2361 #define TestFalseExpr(Expression) TestFalse(TEXT(#Expression), Expression)
2362
2371 template<typename ValueType>
2372 inline bool TestInvalid(const TCHAR* Description, const ValueType& Value)
2373 {
2374 if (Value.IsValid())
2375 {
2376 AddError(FString::Printf(TEXT("%s: The value is valid (.IsValid() returned true)."), Description));
2377 return false;
2378 }
2379 return true;
2380 }
2381
2382 template<typename ValueType>
2383 bool TestInvalid(const FString& Description, const ValueType& Value)
2384 {
2385 return TestInvalid(*Description, Value);
2386 }
2387
2397 template<typename ValueType>
2398 inline bool TestNotEqual(const TCHAR* Description, const ValueType& Actual, const ValueType& Expected)
2399 {
2400 if (Actual == Expected)
2401 {
2402 AddError(FString::Printf(TEXT("%s: The two values are equal."), Description));
2403 return false;
2404 }
2405 return true;
2406 }
2407
2408 template<typename ValueType> bool TestNotEqual(const FString& Description, const ValueType& Actual, const ValueType& Expected)
2409 {
2410 return TestNotEqual(*Description, Actual, Expected);
2411 }
2412
2413 CORE_API bool TestNotEqual(const TCHAR* What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER);
2414 CORE_API bool TestNotEqual(const TCHAR* What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER);
2415
2416 bool TestNotEqual(const FString& What, const float Actual, const float Expected, float Tolerance = UE_KINDA_SMALL_NUMBER)
2417 {
2418 return TestNotEqual(*What, Actual, Expected, Tolerance);
2419 }
2420
2421 bool TestNotEqual(const FString& What, const double Actual, const double Expected, double Tolerance = UE_KINDA_SMALL_NUMBER)
2422 {
2423 return TestNotEqual(*What, Actual, Expected, Tolerance);
2424 }
2425
2434 template<typename ValueType>
2435 inline bool TestNotNull(const TCHAR* What, const ValueType* Pointer)
2436 {
2437 if (Pointer == nullptr)
2438 {
2439 AddError(FString::Printf(TEXT("Expected '%s' to be not null."), What));
2440 return false;
2441 }
2442 return true;
2443 }
2444
2445 template<typename ValueType> bool TestNotNull(const FString& What, const ValueType* Pointer)
2446 {
2447 return TestNotNull(*What, Pointer);
2448 }
2449
2459 template<typename ValueType>
2460 inline bool TestNotSame(const TCHAR* Description, const ValueType& Actual, const ValueType& Expected)
2461 {
2462 if (&Actual == &Expected)
2463 {
2464 AddError(FString::Printf(TEXT("%s: The two values are the same."), Description));
2465 return false;
2466 }
2467 return true;
2468 }
2469
2470 template<typename ValueType> bool TestNotSame(const FString& Description, const ValueType& Actual, const ValueType& Expected)
2471 {
2472 return TestNotSame(*Description, Actual, Expected);
2473 }
2474
2484 template<typename ValueType>
2485 inline bool TestNotSamePtr(const TCHAR* Description, const ValueType* Actual, const ValueType* Expected)
2486 {
2487 if (nullptr == Actual)
2488 {
2489 AddWarning(FString::Printf(TEXT("%s: Actual value is nullptr."), Description));
2490 }
2491 if (nullptr == Expected)
2492 {
2493 AddWarning(FString::Printf(TEXT("%s: Expected value is nullptr, which may be unintended. If intentional consider instead using TestNotNull()."), Description));
2494 }
2495 if (Actual == Expected)
2496 {
2497 AddError(FString::Printf(TEXT("%s: The two pointers are the same."), Description));
2498 return false;
2499 }
2500 return true;
2501 }
2502
2503 template<typename ValueType> bool TestNotSamePtr(const FString& Description, const ValueType* Actual, const ValueType* Expected)
2504 {
2505 return TestNotSamePtr(*Description, Actual, Expected);
2506 }
2507
2516 CORE_API bool TestNull(const TCHAR* What, const void* Pointer);
2517
2518 bool TestNull(const FString& What, const void* Pointer)
2519 {
2520 return TestNull(*What, Pointer);
2521 }
2522
2532 template<typename ValueType>
2533 inline bool TestSame(const TCHAR* Description, const ValueType& Actual, const ValueType& Expected)
2534 {
2535 if (&Actual != &Expected)
2536 {
2537 AddError(FString::Printf(TEXT("%s: The two values are not the same."), Description));
2538 return false;
2539 }
2540 return true;
2541 }
2542
2543 template<typename ValueType> bool TestSame(const FString& Description, const ValueType& Actual, const ValueType& Expected)
2544 {
2545 return TestSame(*Description, Actual, Expected);
2546 }
2547
2557 template<typename ValueType>
2558 inline bool TestSamePtr(const TCHAR* Description, const ValueType* Actual, const ValueType* Expected)
2559 {
2560 if (nullptr == Actual)
2561 {
2562 AddWarning(FString::Printf(TEXT("%s: Actual value is nullptr."), Description));
2563 }
2564 if (nullptr == Expected)
2565 {
2566 AddWarning(FString::Printf(TEXT("%s: Expected value is nullptr, which may be unintended. If intentional consider instead using TestNull()."), Description));
2567 }
2568 if (Actual != Expected)
2569 {
2570 AddError(FString::Printf(TEXT("%s: The two pointers are not the same."), Description));
2571 return false;
2572 }
2573 return true;
2574 }
2575
2576 template<typename ValueType> bool TestSamePtr(const FString& Description, const ValueType* Actual, const ValueType* Expected)
2577 {
2578 return TestSamePtr(*Description, Actual, Expected);
2579 }
2580
2589 CORE_API bool TestTrue(const TCHAR* What, bool Value);
2590
2591 bool TestTrue(const FString& What, bool Value)
2592 {
2593 return TestTrue(*What, Value);
2594 }
2595
2597 #define TestTrueExpr(...) TestTrue(TEXT(#__VA_ARGS__), __VA_ARGS__)
2598
2607 template<typename ValueType>
2608 inline bool TestValid(const TCHAR* Description, const ValueType& Value)
2609 {
2610 if (!Value.IsValid())
2611 {
2612 AddError(FString::Printf(TEXT("%s: The value is not valid (.IsValid() returned false)."), Description));
2613 return false;
2614 }
2615 return true;
2616 }
2617
2618 template<typename ValueType>
2619 bool TestValid(const FString& Description, const ValueType& Value)
2620 {
2621 return TestValid(*Description, Value);
2622 }
2623
2624protected:
2631 virtual void GetTests(TArray<FString>& OutBeautifiedNames, TArray <FString>& OutTestCommands) const = 0;
2632
2639 virtual bool RunTest(const FString& Parameters)=0;
2640
2643
2646
2647protected:
2648
2649 //Flag to indicate if this is a complex task
2651
2652 //Flag to indicate if this test should be ran on it's own thread
2654
2656 bool bSuppressLogs = false;
2657
2659 FString TestName;
2660
2663
2666
2667 //allow framework to call protected function
2669
2670private:
2677 CORE_API bool IsExpectedMessage(const FString& Message, const ELogVerbosity::Type& Verbosity = ELogVerbosity::All);
2678
2684 CORE_API void InternalSetSuccessState(bool bSuccessful);
2685
2691 FString GetStringValueToDisplay(FStringView Value) const;
2692 FString GetStringValueToDisplay(FUtf8StringView Value) const;
2693
2694 /* Log messages to be expected while processing this test.*/
2695 TSet<FAutomationExpectedMessage> ExpectedMessages;
2696
2699};
2700
2702{
2703public:
2704 FBDDAutomationTestBase(const FString& InName, const bool bInComplexTask)
2706 , bIsDiscoveryMode(false)
2707 , bBaseRunTestRan(false)
2708 {}
2709
2710 virtual bool RunTest(const FString& Parameters) override
2711 {
2712 bBaseRunTestRan = true;
2713 TestIdToExecute = Parameters;
2714
2715 return true;
2716 }
2717
2718 virtual void GetTests(TArray<FString>& OutBeautifiedNames, TArray <FString>& OutTestCommands) const override
2719 {
2720 const_cast<FBDDAutomationTestBase*>(this)->BeautifiedNames.Empty();
2721 const_cast<FBDDAutomationTestBase*>(this)->TestCommands.Empty();
2722
2723 bIsDiscoveryMode = true;
2724 const_cast<FBDDAutomationTestBase*>(this)->RunTest(FString());
2725 bIsDiscoveryMode = false;
2726
2727 OutBeautifiedNames.Append(BeautifiedNames);
2728 OutTestCommands.Append(TestCommands);
2729 bBaseRunTestRan = false;
2730 }
2731
2732 bool IsDiscoveryMode() const
2733 {
2734 return bIsDiscoveryMode;
2735 }
2736
2737 void xDescribe(const FString& InDescription, TFunction<void()> DoWork)
2738 {
2739 check(bBaseRunTestRan);
2740 //disabled this suite
2741 }
2742
2743 void Describe(const FString& InDescription, TFunction<void()> DoWork)
2744 {
2745 check(bBaseRunTestRan);
2746
2747 PushDescription(InDescription);
2748
2749 int32 OriginalBeforeEachCount = BeforeEachStack.Num();
2750 int32 OriginalAfterEachCount = AfterEachStack.Num();
2751
2752 DoWork();
2753
2754 check(OriginalBeforeEachCount <= BeforeEachStack.Num());
2755 if (OriginalBeforeEachCount != BeforeEachStack.Num())
2756 {
2757 BeforeEachStack.Pop();
2758 }
2759
2760 check(OriginalAfterEachCount <= AfterEachStack.Num());
2761 if (OriginalAfterEachCount != AfterEachStack.Num())
2762 {
2763 AfterEachStack.Pop();
2764 }
2765
2766 PopDescription(InDescription);
2767 }
2768
2769 void xIt(const FString& InDescription, TFunction<void()> DoWork)
2770 {
2771 check(bBaseRunTestRan);
2772 //disabled this spec
2773 }
2774
2775 void It(const FString& InDescription, TFunction<void()> DoWork)
2776 {
2777 check(bBaseRunTestRan);
2778
2779 PushDescription(InDescription);
2780
2781 if (bIsDiscoveryMode)
2782 {
2783 BeautifiedNames.Add(GetDescription());
2784
2785 bIsDiscoveryMode = false;
2786 TestCommands.Add(GetDescription());
2787 bIsDiscoveryMode = true;
2788 }
2789 else if (TestIdToExecute.IsEmpty() || GetDescription() == TestIdToExecute)
2790 {
2791 for (int32 Index = 0; Index < BeforeEachStack.Num(); Index++)
2792 {
2793 BeforeEachStack[Index]();
2794 }
2795
2796 DoWork();
2797
2798 for (int32 Index = AfterEachStack.Num() - 1; Index >= 0; Index--)
2799 {
2800 AfterEachStack[Index]();
2801 }
2802 }
2803
2804 PopDescription(InDescription);
2805 }
2806
2807 void BeforeEach(TFunction<void()> DoWork)
2808 {
2809 BeforeEachStack.Push(DoWork);
2810 }
2811
2812 void AfterEach(TFunction<void()> DoWork)
2813 {
2814 AfterEachStack.Push(DoWork);
2815 }
2816
2817private:
2818
2819 void PushDescription(const FString& InDescription)
2820 {
2821 Description.Add(InDescription);
2822 }
2823
2824 void PopDescription(const FString& InDescription)
2825 {
2826 Description.RemoveAt(Description.Num() - 1);
2827 }
2828
2829 FString GetDescription() const
2830 {
2831 FString CompleteDescription;
2832 for (int32 Index = 0; Index < Description.Num(); ++Index)
2833 {
2834 if (Description[Index].IsEmpty())
2835 {
2836 continue;
2837 }
2838
2839 if (CompleteDescription.IsEmpty())
2840 {
2841 CompleteDescription = Description[Index];
2842 }
2844 {
2845 if (bIsDiscoveryMode)
2846 {
2847 CompleteDescription = CompleteDescription + TEXT(".") + Description[Index];
2848 }
2849 else
2850 {
2852 }
2853 }
2854 else
2855 {
2856 if (bIsDiscoveryMode)
2857 {
2858 CompleteDescription = FString::Printf(TEXT("%s.%s"), *CompleteDescription, *Description[Index]);
2859 }
2860 else
2861 {
2862 CompleteDescription = FString::Printf(TEXT("%s %s"), *CompleteDescription, *Description[Index]);
2863 }
2864 }
2865 }
2866
2867 return CompleteDescription;
2868 }
2869
2870private:
2871
2872 FString TestIdToExecute;
2873 TArray<FString> Description;
2874 TArray<TFunction<void()>> BeforeEachStack;
2875 TArray<TFunction<void()>> AfterEachStack;
2876
2877 TArray<FString> BeautifiedNames;
2878 TArray<FString> TestCommands;
2879 mutable bool bIsDiscoveryMode;
2880 mutable bool bBaseRunTestRan;
2881};
2882
2884
2886 : public FAutomationTestBase
2887 , public TSharedFromThis<FAutomationSpecBase>
2888{
2889private:
2890
2891 class FSingleExecuteLatentCommand : public IAutomationLatentCommand
2892 {
2893 public:
2894 FSingleExecuteLatentCommand(const FAutomationSpecBase* const InSpec, TFunction<void()> InPredicate, bool bInSkipIfErrored = false)
2895 : Spec(InSpec)
2896 , Predicate(MoveTemp(InPredicate))
2897 , bSkipIfErrored(bInSkipIfErrored)
2898 { }
2899
2900 virtual ~FSingleExecuteLatentCommand()
2901 { }
2902
2903 virtual bool Update() override
2904 {
2905 if (bSkipIfErrored && Spec->HasAnyErrors())
2906 {
2907 return true;
2908 }
2909
2910 Predicate();
2911 return true;
2912 }
2913
2914 private:
2915
2916 const FAutomationSpecBase* const Spec;
2917 const TFunction<void()> Predicate;
2918 const bool bSkipIfErrored;
2919 };
2920
2921 class FUntilDoneLatentCommand : public IAutomationLatentCommand
2922 {
2923 public:
2924
2925 FUntilDoneLatentCommand(FAutomationSpecBase* const InSpec, TFunction<void(const FDoneDelegate&)> InPredicate, const FTimespan& InTimeout, bool bInSkipIfErrored = false)
2926 : Spec(InSpec)
2927 , Predicate(MoveTemp(InPredicate))
2929 , bSkipIfErrored(bInSkipIfErrored)
2930 , bIsRunning(false)
2931 , bDone(false)
2932 { }
2933
2934 virtual ~FUntilDoneLatentCommand()
2935 { }
2936
2937 virtual bool Update() override
2938 {
2939 if (!bIsRunning)
2940 {
2941 if (bSkipIfErrored && Spec->HasAnyErrors())
2942 {
2943 return true;
2944 }
2945
2946 bDone = false;
2947 bIsRunning = true;
2948 StartedRunning = FDateTime::UtcNow();
2949 Predicate(FDoneDelegate::CreateSP(this, &FUntilDoneLatentCommand::Done));
2950 }
2951
2952 if (bDone)
2953 {
2954 Reset();
2955 return true;
2956 }
2957 else if (FDateTime::UtcNow() >= StartedRunning + Timeout)
2958 {
2959 Reset();
2960 Spec->AddError(TEXT("Latent command timed out."), 0);
2961 return true;
2962 }
2963
2964 return false;
2965 }
2966
2967 private:
2968
2969 void Done()
2970 {
2971 if (bIsRunning)
2972 {
2973 bDone = true;
2974 }
2975 }
2976
2977 void Reset()
2978 {
2979 // Reset the done for the next potential run of this command
2980 bDone = false;
2981 bIsRunning = false;
2982 }
2983
2984 private:
2985
2986 FAutomationSpecBase* const Spec;
2987 const TFunction<void(const FDoneDelegate&)> Predicate;
2988 const FTimespan Timeout;
2989 const bool bSkipIfErrored;
2990
2991 bool bIsRunning;
2992 FDateTime StartedRunning;
2993 FThreadSafeBool bDone;
2994 };
2995
2996 class FAsyncUntilDoneLatentCommand : public IAutomationLatentCommand
2997 {
2998 public:
2999
3000 FAsyncUntilDoneLatentCommand(FAutomationSpecBase* const InSpec, EAsyncExecution InExecution, TFunction<void(const FDoneDelegate&)> InPredicate, const FTimespan& InTimeout, bool bInSkipIfErrored = false)
3001 : Spec(InSpec)
3003 , Predicate(MoveTemp(InPredicate))
3005 , bSkipIfErrored(bInSkipIfErrored)
3006 , bDone(false)
3007 { }
3008
3009 virtual ~FAsyncUntilDoneLatentCommand()
3010 { }
3011
3012 virtual bool Update() override
3013 {
3014 if (!Future.IsValid())
3015 {
3016 if (bSkipIfErrored && Spec->HasAnyErrors())
3017 {
3018 return true;
3019 }
3020
3021 UE::TScopeLock CriticalSection(ActionCS);
3022 bDone = false;
3023 StartedRunning = FDateTime::UtcNow();
3024 Future = Async(Execution, [this]() {
3025 Predicate(FDoneDelegate::CreateRaw(this, &FAsyncUntilDoneLatentCommand::Done));
3026 });
3027 }
3028
3029 if (bDone)
3030 {
3031 Reset();
3032 return true;
3033 }
3034 else if (FDateTime::UtcNow() >= StartedRunning + Timeout)
3035 {
3036 Reset();
3037 Spec->AddError(TEXT("Latent command timed out."), 0);
3038 return true;
3039 }
3040
3041 return false;
3042 }
3043
3044 private:
3045
3046 void Done()
3047 {
3048 UE::TScopeLock CriticalSection(ActionCS);
3049 if (Future.IsValid())
3050 {
3051 bDone = true;
3052 }
3053 }
3054
3055 void Reset()
3056 {
3057 UE::TScopeLock CriticalSection(ActionCS);
3058 // Reset the done for the next potential run of this command
3059 bDone = false;
3060 Future.Reset();
3061 }
3062
3063 private:
3064
3065 FAutomationSpecBase* const Spec;
3067 const TFunction<void(const FDoneDelegate&)> Predicate;
3068 const FTimespan Timeout;
3069 const bool bSkipIfErrored;
3070
3071 FThreadSafeBool bDone;
3072 FDateTime StartedRunning;
3073 TFuture<void> Future;
3075 };
3076
3077 class FAsyncLatentCommand : public IAutomationLatentCommand
3078 {
3079 public:
3080
3081 FAsyncLatentCommand(FAutomationSpecBase* const InSpec, EAsyncExecution InExecution, TFunction<void()> InPredicate, const FTimespan& InTimeout, bool bInSkipIfErrored = false)
3082 : Spec(InSpec)
3084 , Predicate(MoveTemp(InPredicate))
3086 , bSkipIfErrored(bInSkipIfErrored)
3087 , bDone(false)
3088 { }
3089
3090 virtual ~FAsyncLatentCommand()
3091 { }
3092
3093 virtual bool Update() override
3094 {
3095 if (!Future.IsValid())
3096 {
3097 if (bSkipIfErrored && Spec->HasAnyErrors())
3098 {
3099 return true;
3100 }
3101
3102 UE::TScopeLock CriticalSection(ActionCS);
3103 bDone = false;
3104 StartedRunning = FDateTime::UtcNow();
3105 Future = Async(Execution, [this]() {
3106 Predicate();
3107 Done();
3108 });
3109 }
3110
3111 if (bDone)
3112 {
3113 Reset();
3114 return true;
3115 }
3116 else if (FDateTime::UtcNow() >= StartedRunning + Timeout)
3117 {
3118 Reset();
3119 Spec->AddError(TEXT("Latent command timed out."), 0);
3120 return true;
3121 }
3122
3123 return false;
3124 }
3125
3126 private:
3127
3128 void Done()
3129 {
3130 UE::TScopeLock CriticalSection(ActionCS);
3131 if (Future.IsValid())
3132 {
3133 bDone = true;
3134 }
3135 }
3136
3137 void Reset()
3138 {
3139 UE::TScopeLock CriticalSection(ActionCS);
3140 // Reset the done for the next potential run of this command
3141 bDone = false;
3142 Future.Reset();
3143 }
3144
3145 private:
3146
3147 FAutomationSpecBase* const Spec;
3149 const TFunction<void()> Predicate;
3150 const FTimespan Timeout;
3151 const bool bSkipIfErrored;
3152
3153 FThreadSafeBool bDone;
3154 FDateTime StartedRunning;
3155 TFuture<void> Future;
3157 };
3158
3159 struct FSpecIt
3160 {
3161 public:
3162
3163 FString Description;
3164 FString Id;
3165 FString Filename;
3166 int32 LineNumber;
3168
3170 : Description(MoveTemp(InDescription))
3171 , Id(MoveTemp(InId))
3172 , Filename(InFilename)
3173 , LineNumber(MoveTemp(InLineNumber))
3174 , Command(MoveTemp(InCommand))
3175 { }
3176 };
3177
3178 struct FSpecDefinitionScope
3179 {
3180 public:
3181
3182 FString Description;
3183
3187
3189 };
3190
3191 struct FSpec
3192 {
3193 public:
3194
3195 FString Id;
3196 FString Description;
3197 FString Filename;
3198 int32 LineNumber;
3200 };
3201
3202public:
3203
3204 FAutomationSpecBase(const FString& InName, const bool bInComplexTask)
3206 , DefaultTimeout(FTimespan::FromSeconds(30))
3208 , RootDefinitionScope(MakeShareable(new FSpecDefinitionScope()))
3209 , bHasBeenDefined(false)
3210 {
3211 DefinitionScopeStack.Push(RootDefinitionScope.ToSharedRef());
3212 }
3213
3214 virtual bool RunTest(const FString& InParameters) override
3215 {
3217
3218 if (!InParameters.IsEmpty())
3219 {
3220 const TSharedRef<FSpec>* SpecToRun = IdToSpecMap.Find(InParameters);
3221 if (SpecToRun != nullptr)
3222 {
3223 for (int32 Index = 0; Index < (*SpecToRun)->Commands.Num(); ++Index)
3224 {
3226 }
3227 }
3228 }
3229 else
3230 {
3232 IdToSpecMap.GenerateValueArray(Specs);
3233
3234 for (int32 SpecIndex = 0; SpecIndex < Specs.Num(); SpecIndex++)
3235 {
3236 for (int32 CommandIndex = 0; CommandIndex < Specs[SpecIndex]->Commands.Num(); ++CommandIndex)
3237 {
3239 }
3240 }
3241 }
3242
3243 return true;
3244 }
3245
3246 virtual bool IsStressTest() const
3247 {
3248 return false;
3249 }
3250
3251 virtual uint32 GetRequiredDeviceNum() const override
3252 {
3253 return 1;
3254 }
3255
3256 virtual FString GetTestSourceFileName(const FString& InTestName) const override
3257 {
3258 FString TestId = InTestName;
3259 if (TestId.StartsWith(TestName + TEXT(" ")))
3260 {
3261 TestId = InTestName.RightChop(TestName.Len() + 1);
3262 }
3263
3264 const TSharedRef<FSpec>* Spec = IdToSpecMap.Find(TestId);
3265 if (Spec != nullptr)
3266 {
3267 return (*Spec)->Filename;
3268 }
3269
3271 }
3272
3273 virtual int32 GetTestSourceFileLine(const FString& InTestName) const override
3274 {
3275 FString TestId = InTestName;
3276 if (TestId.StartsWith(TestName + TEXT(" ")))
3277 {
3278 TestId = InTestName.RightChop(TestName.Len() + 1);
3279 }
3280
3281 const TSharedRef<FSpec>* Spec = IdToSpecMap.Find(TestId);
3282 if (Spec != nullptr)
3283 {
3284 return (*Spec)->LineNumber;
3285 }
3286
3288 }
3289
3291 {
3293
3295 IdToSpecMap.GenerateValueArray(Specs);
3296
3297 for (int32 Index = 0; Index < Specs.Num(); Index++)
3298 {
3299 OutTestCommands.Push(Specs[Index]->Id);
3300 OutBeautifiedNames.Push(Specs[Index]->Description);
3301 }
3302 }
3303
3304 void xDescribe(const FString& InDescription, TFunction<void()> DoWork)
3305 {
3306 //disabled
3307 }
3308
3309 void Describe(const TArray<FString> InDescriptions, TFunction<void(int32 /*Iteration*/)> DoWork)
3310 {
3311 LLM_SCOPE_BYNAME(TEXT("AutomationTest/Framework"));
3312
3313 for (int32 It = 0; It < InDescriptions.Num(); ++It)
3314 {
3315 const TSharedRef<FSpecDefinitionScope> ParentScope = DefinitionScopeStack.Last();
3316 const TSharedRef<FSpecDefinitionScope> NewScope = MakeShareable(new FSpecDefinitionScope());
3317 NewScope->Description = InDescriptions[It];
3318 ParentScope->Children.Push(NewScope);
3319
3320 DefinitionScopeStack.Push(NewScope);
3321 PushDescription(InDescriptions[It]);
3322 DoWork(It);
3323 PopDescription(InDescriptions[It]);
3324 DefinitionScopeStack.Pop();
3325
3326 if (NewScope->It.Num() == 0 && NewScope->Children.Num() == 0)
3327 {
3328 ParentScope->Children.Remove(NewScope);
3329 }
3330 }
3331 }
3332
3333 void Describe(const FString& InDescription, TFunction<void()> DoWork)
3334 {
3335 Describe({InDescription}, [DoWork](int32){DoWork();});
3336 }
3337
3338 void xIt(const FString& InDescription, TFunction<void()> DoWork)
3339 {
3340 //disabled
3341 }
3342
3343 void xIt(const FString& InDescription, EAsyncExecution Execution, TFunction<void()> DoWork)
3344 {
3345 //disabled
3346 }
3347
3348 void xIt(const FString& InDescription, EAsyncExecution Execution, const FTimespan& Timeout, TFunction<void()> DoWork)
3349 {
3350 //disabled
3351 }
3352
3353 void xLatentIt(const FString& InDescription, TFunction<void(const FDoneDelegate&)> DoWork)
3354 {
3355 //disabled
3356 }
3357
3358 void xLatentIt(const FString& InDescription, const FTimespan& Timeout, TFunction<void(const FDoneDelegate&)> DoWork)
3359 {
3360 //disabled
3361 }
3362
3363 void xLatentIt(const FString& InDescription, EAsyncExecution Execution, TFunction<void(const FDoneDelegate&)> DoWork)
3364 {
3365 //disabled
3366 }
3367
3368 void xLatentIt(const FString& InDescription, EAsyncExecution Execution, const FTimespan& Timeout, TFunction<void(const FDoneDelegate&)> DoWork)
3369 {
3370 //disabled
3371 }
3372
3373 void It(const FString& InDescription, TFunction<void()> DoWork, UE::FSourceLocation Location = UE::FSourceLocation::Current())
3374 {
3375 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3376
3377 PushDescription(InDescription);
3378 CurrentScope->It.Push(MakeShareable(new FSpecIt(GetDescription(), GetId(), Location.GetFileName(), Location.GetLine(), MakeShareable(new FSingleExecuteLatentCommand(this, DoWork, bEnableSkipIfError)))));
3379 PopDescription(InDescription);
3380 }
3381
3383 {
3384 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3385
3386 PushDescription(InDescription);
3387 CurrentScope->It.Push(MakeShareable(new FSpecIt(GetDescription(), GetId(), Location.GetFileName(), Location.GetLine(), MakeShareable(new FAsyncLatentCommand(this, Execution, DoWork, DefaultTimeout, bEnableSkipIfError)))));
3388 PopDescription(InDescription);
3389 }
3390
3392 {
3393 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3394
3395 PushDescription(InDescription);
3396 CurrentScope->It.Push(MakeShareable(new FSpecIt(GetDescription(), GetId(), Location.GetFileName(), Location.GetLine(), MakeShareable(new FAsyncLatentCommand(this, Execution, DoWork, Timeout, bEnableSkipIfError)))));
3397 PopDescription(InDescription);
3398 }
3399
3401 {
3402 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3403
3404 PushDescription(InDescription);
3405 CurrentScope->It.Push(MakeShareable(new FSpecIt(GetDescription(), GetId(), Location.GetFileName(), Location.GetLine(), MakeShareable(new FUntilDoneLatentCommand(this, DoWork, DefaultTimeout, bEnableSkipIfError)))));
3406 PopDescription(InDescription);
3407 }
3408
3410 {
3411 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3412
3413 PushDescription(InDescription);
3414 CurrentScope->It.Push(MakeShareable(new FSpecIt(GetDescription(), GetId(), Location.GetFileName(), Location.GetLine(), MakeShareable(new FUntilDoneLatentCommand(this, DoWork, Timeout, bEnableSkipIfError)))));
3415 PopDescription(InDescription);
3416 }
3417
3419 {
3420 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3421
3422 PushDescription(InDescription);
3423 CurrentScope->It.Push(MakeShareable(new FSpecIt(GetDescription(), GetId(), Location.GetFileName(), Location.GetLine(), MakeShareable(new FAsyncUntilDoneLatentCommand(this, Execution, DoWork, DefaultTimeout, bEnableSkipIfError)))));
3424 PopDescription(InDescription);
3425 }
3426
3428 {
3429 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3430
3431 PushDescription(InDescription);
3432 CurrentScope->It.Push(MakeShareable(new FSpecIt(GetDescription(), GetId(), Location.GetFileName(), Location.GetLine(), MakeShareable(new FAsyncUntilDoneLatentCommand(this, Execution, DoWork, Timeout, bEnableSkipIfError)))));
3433 PopDescription(InDescription);
3434 }
3435
3436 void xBeforeEach(TFunction<void()> DoWork)
3437 {
3438 // disabled
3439 }
3440
3442 {
3443 // disabled
3444 }
3445
3447 {
3448 // disabled
3449 }
3450
3451 void xLatentBeforeEach(TFunction<void(const FDoneDelegate&)> DoWork)
3452 {
3453 // disabled
3454 }
3455
3456 void xLatentBeforeEach(const FTimespan& Timeout, TFunction<void(const FDoneDelegate&)> DoWork)
3457 {
3458 // disabled
3459 }
3460
3462 {
3463 // disabled
3464 }
3465
3467 {
3468 // disabled
3469 }
3470
3471 void BeforeEach(TFunction<void()> DoWork)
3472 {
3473 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3474 CurrentScope->BeforeEach.Push(MakeShareable(new FSingleExecuteLatentCommand(this, DoWork, bEnableSkipIfError)));
3475 }
3476
3478 {
3479 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3480 CurrentScope->BeforeEach.Push(MakeShareable(new FAsyncLatentCommand(this, Execution, DoWork, DefaultTimeout, bEnableSkipIfError)));
3481 }
3482
3484 {
3485 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3486 CurrentScope->BeforeEach.Push(MakeShareable(new FAsyncLatentCommand(this, Execution, DoWork, Timeout, bEnableSkipIfError)));
3487 }
3488
3489 void LatentBeforeEach(TFunction<void(const FDoneDelegate&)> DoWork)
3490 {
3491 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3492 CurrentScope->BeforeEach.Push(MakeShareable(new FUntilDoneLatentCommand(this, DoWork, DefaultTimeout, bEnableSkipIfError)));
3493 }
3494
3495 void LatentBeforeEach(const FTimespan& Timeout, TFunction<void(const FDoneDelegate&)> DoWork)
3496 {
3497 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3498 CurrentScope->BeforeEach.Push(MakeShareable(new FUntilDoneLatentCommand(this, DoWork, Timeout, bEnableSkipIfError)));
3499 }
3500
3502 {
3503 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3504 CurrentScope->BeforeEach.Push(MakeShareable(new FAsyncUntilDoneLatentCommand(this, Execution, DoWork, DefaultTimeout, bEnableSkipIfError)));
3505 }
3506
3508 {
3509 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3510 CurrentScope->BeforeEach.Push(MakeShareable(new FAsyncUntilDoneLatentCommand(this, Execution, DoWork, Timeout, bEnableSkipIfError)));
3511 }
3512
3513 void xAfterEach(TFunction<void()> DoWork)
3514 {
3515 // disabled
3516 }
3517
3519 {
3520 // disabled
3521 }
3522
3524 {
3525 // disabled
3526 }
3527
3528 void xLatentAfterEach(TFunction<void(const FDoneDelegate&)> DoWork)
3529 {
3530 // disabled
3531 }
3532
3533 void xLatentAfterEach(const FTimespan& Timeout, TFunction<void(const FDoneDelegate&)> DoWork)
3534 {
3535 // disabled
3536 }
3537
3539 {
3540 // disabled
3541 }
3542
3544 {
3545 // disabled
3546 }
3547
3548 void AfterEach(TFunction<void()> DoWork)
3549 {
3550 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3551 CurrentScope->AfterEach.Push(MakeShareable(new FSingleExecuteLatentCommand(this, DoWork)));
3552 }
3553
3555 {
3556 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3557 CurrentScope->AfterEach.Push(MakeShareable(new FAsyncLatentCommand(this, Execution, DoWork, DefaultTimeout)));
3558 }
3559
3561 {
3562 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3563 CurrentScope->AfterEach.Push(MakeShareable(new FAsyncLatentCommand(this, Execution, DoWork, Timeout)));
3564 }
3565
3566 void LatentAfterEach(TFunction<void(const FDoneDelegate&)> DoWork)
3567 {
3568 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3569 CurrentScope->AfterEach.Push(MakeShareable(new FUntilDoneLatentCommand(this, DoWork, DefaultTimeout)));
3570 }
3571
3572 void LatentAfterEach(const FTimespan& Timeout, TFunction<void(const FDoneDelegate&)> DoWork)
3573 {
3574 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3575 CurrentScope->AfterEach.Push(MakeShareable(new FUntilDoneLatentCommand(this, DoWork, Timeout)));
3576 }
3577
3579 {
3580 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3581 CurrentScope->AfterEach.Push(MakeShareable(new FAsyncUntilDoneLatentCommand(this, Execution, DoWork, DefaultTimeout)));
3582 }
3583
3585 {
3586 const TSharedRef<FSpecDefinitionScope> CurrentScope = DefinitionScopeStack.Last();
3587 CurrentScope->AfterEach.Push(MakeShareable(new FAsyncUntilDoneLatentCommand(this, Execution, DoWork, Timeout)));
3588 }
3589
3590protected:
3591
3592 /* The timespan for how long a block should be allowed to execute before giving up and failing the test */
3594
3595 /* Whether or not BeforeEach and It blocks should skip execution if the test has already failed */
3597
3599 {
3600 if (!bHasBeenDefined)
3601 {
3602 const_cast<FAutomationSpecBase*>(this)->Define();
3603 const_cast<FAutomationSpecBase*>(this)->PostDefine();
3604 }
3605 }
3606
3607 virtual void Define() = 0;
3608
3610 {
3612 Stack.Push(RootDefinitionScope.ToSharedRef());
3613
3616
3617 while (Stack.Num() > 0)
3618 {
3619 const TSharedRef<FSpecDefinitionScope> Scope = Stack.Last();
3620
3621 BeforeEach.Append(Scope->BeforeEach);
3622 AfterEach.Append(Scope->AfterEach); // iterate in reverse
3623
3624 for (int32 ItIndex = 0; ItIndex < Scope->It.Num(); ItIndex++)
3625 {
3626 TSharedRef<FSpecIt> It = Scope->It[ItIndex];
3627
3628 TSharedRef<FSpec> Spec = MakeShareable(new FSpec());
3629 Spec->Id = It->Id;
3630 Spec->Description = It->Description;
3631 Spec->Filename = It->Filename;
3632 Spec->LineNumber = It->LineNumber;
3633 Spec->Commands.Append(BeforeEach);
3634 Spec->Commands.Add(It->Command);
3635
3637 {
3638 Spec->Commands.Add(AfterEach[AfterEachIndex]);
3639 }
3640
3641 check(!IdToSpecMap.Contains(Spec->Id));
3642 IdToSpecMap.Add(Spec->Id, Spec);
3643 }
3644 Scope->It.Empty();
3645
3646 if (Scope->Children.Num() > 0)
3647 {
3648 Stack.Append(Scope->Children);
3649 Scope->Children.Empty();
3650 }
3651 else
3652 {
3653 while (Stack.Num() > 0 && Stack.Last()->Children.Num() == 0 && Stack.Last()->It.Num() == 0)
3654 {
3656
3657 if (PoppedScope->BeforeEach.Num() > 0)
3658 {
3659 BeforeEach.RemoveAt(BeforeEach.Num() - PoppedScope->BeforeEach.Num(), PoppedScope->BeforeEach.Num());
3660 }
3661
3662 if (PoppedScope->AfterEach.Num() > 0)
3663 {
3664 AfterEach.RemoveAt(AfterEach.Num() - PoppedScope->AfterEach.Num(), PoppedScope->AfterEach.Num());
3665 }
3666 }
3667 }
3668 }
3669
3670 RootDefinitionScope.Reset();
3671 DefinitionScopeStack.Reset();
3672 bHasBeenDefined = true;
3673 }
3674
3676 {
3677 Description.Empty();
3678 IdToSpecMap.Empty();
3679 RootDefinitionScope.Reset();
3680 DefinitionScopeStack.Empty();
3681 bHasBeenDefined = false;
3682
3683 RootDefinitionScope = MakeShareable(new FSpecDefinitionScope());
3684 DefinitionScopeStack.Push(RootDefinitionScope.ToSharedRef());
3685 }
3686
3687private:
3688
3689 void PushDescription(const FString& InDescription)
3690 {
3691 LLM_SCOPE_BYNAME(TEXT("AutomationTest/Framework"));
3692 Description.Add(InDescription);
3693 }
3694
3695 void PopDescription(const FString& InDescription)
3696 {
3697 Description.RemoveAt(Description.Num() - 1);
3698 }
3699
3700 FString GetDescription() const
3701 {
3702 FString CompleteDescription;
3703 for (int32 Index = 0; Index < Description.Num(); ++Index)
3704 {
3705 if (Description[Index].IsEmpty())
3706 {
3707 continue;
3708 }
3709
3710 if (CompleteDescription.IsEmpty())
3711 {
3712 CompleteDescription = Description[Index];
3713 }
3715 {
3716 CompleteDescription = CompleteDescription + TEXT(".") + Description[Index];
3717 }
3718 else
3719 {
3720 CompleteDescription = FString::Printf(TEXT("%s.%s"), *CompleteDescription, *Description[Index]);
3721 }
3722 }
3723
3724 return CompleteDescription;
3725 }
3726
3727 FString GetId() const
3728 {
3729 if (Description.Last().EndsWith(TEXT("]")))
3730 {
3731 FString ItDescription = Description.Last();
3732 ItDescription.RemoveAt(ItDescription.Len() - 1);
3733
3735 if (ItDescription.FindLastChar(TEXT('['), StartingBraceIndex) && StartingBraceIndex != ItDescription.Len() - 1)
3736 {
3737 FString CommandId = ItDescription.RightChop(StartingBraceIndex + 1);
3738 return CommandId;
3739 }
3740 }
3741
3742 FString CompleteId;
3743 for (int32 Index = 0; Index < Description.Num(); ++Index)
3744 {
3745 if (Description[Index].IsEmpty())
3746 {
3747 continue;
3748 }
3749
3750 if (CompleteId.IsEmpty())
3751 {
3752 CompleteId = Description[Index];
3753 }
3754 else if (FChar::IsWhitespace(CompleteId[CompleteId.Len() - 1]) || FChar::IsWhitespace(Description[Index][0]))
3755 {
3756 CompleteId = CompleteId + Description[Index];
3757 }
3758 else
3759 {
3760 CompleteId = FString::Printf(TEXT("%s %s"), *CompleteId, *Description[Index]);
3761 }
3762 }
3763
3764 return CompleteId;
3765 }
3766
3767private:
3768 TArray<FString> Description;
3770 TSharedPtr<FSpecDefinitionScope> RootDefinitionScope;
3771 TArray<TSharedRef<FSpecDefinitionScope>> DefinitionScopeStack;
3772 bool bHasBeenDefined;
3773};
3774
3775
3777// Latent command definition macros
3778
3779#define DEFINE_LATENT_AUTOMATION_COMMAND(CommandName) \
3780class CommandName : public IAutomationLatentCommand \
3781 { \
3782 public: \
3783 virtual ~CommandName() \
3784 {} \
3785 virtual bool Update() override; \
3786}
3787
3788#define DEFINE_LATENT_AUTOMATION_COMMAND_ONE_PARAMETER(CommandName,ParamType,ParamName) \
3789class CommandName : public IAutomationLatentCommand \
3790 { \
3791 public: \
3792 CommandName(ParamType InputParam) \
3793 : ParamName(InputParam) \
3794 {} \
3795 virtual ~CommandName() \
3796 {} \
3797 virtual bool Update() override; \
3798 private: \
3799 ParamType ParamName; \
3800}
3801
3802#define DEFINE_LATENT_AUTOMATION_COMMAND_TWO_PARAMETER(CommandName,ParamType0,ParamName0,ParamType1,ParamName1) \
3803class CommandName : public IAutomationLatentCommand \
3804 { \
3805 public: \
3806 CommandName(ParamType0 InputParam0, ParamType1 InputParam1) \
3807 : ParamName0(InputParam0) \
3808 , ParamName1(InputParam1) \
3809 {} \
3810 virtual ~CommandName() \
3811 {} \
3812 virtual bool Update() override; \
3813 private: \
3814 ParamType0 ParamName0; \
3815 ParamType1 ParamName1; \
3816}
3817
3818#define DEFINE_LATENT_AUTOMATION_COMMAND_THREE_PARAMETER(CommandName,ParamType0,ParamName0,ParamType1,ParamName1,ParamType2,ParamName2) \
3819class CommandName : public IAutomationLatentCommand \
3820 { \
3821 public: \
3822 CommandName(ParamType0 InputParam0, ParamType1 InputParam1, ParamType2 InputParam2) \
3823 : ParamName0(InputParam0) \
3824 , ParamName1(InputParam1) \
3825 , ParamName2(InputParam2) \
3826 {} \
3827 virtual ~CommandName() \
3828 {} \
3829 virtual bool Update() override; \
3830 private: \
3831 ParamType0 ParamName0; \
3832 ParamType1 ParamName1; \
3833 ParamType2 ParamName2; \
3834}
3835
3836#define DEFINE_LATENT_AUTOMATION_COMMAND_FOUR_PARAMETER(CommandName,ParamType0,ParamName0,ParamType1,ParamName1,ParamType2,ParamName2,ParamType3,ParamName3) \
3837class CommandName : public IAutomationLatentCommand \
3838 { \
3839 public: \
3840 CommandName(ParamType0 InputParam0, ParamType1 InputParam1, ParamType2 InputParam2, ParamType3 InputParam3) \
3841 : ParamName0(InputParam0) \
3842 , ParamName1(InputParam1) \
3843 , ParamName2(InputParam2) \
3844 , ParamName3(InputParam3) \
3845 {} \
3846 virtual ~CommandName() \
3847 {} \
3848 virtual bool Update() override; \
3849 private: \
3850 ParamType0 ParamName0; \
3851 ParamType1 ParamName1; \
3852 ParamType2 ParamName2; \
3853 ParamType3 ParamName3; \
3854}
3855
3856#define DEFINE_LATENT_AUTOMATION_COMMAND_FIVE_PARAMETER(CommandName,ParamType0,ParamName0,ParamType1,ParamName1,ParamType2,ParamName2,ParamType3,ParamName3,ParamType4,ParamName4) \
3857class CommandName : public IAutomationLatentCommand \
3858 { \
3859 public: \
3860 CommandName(ParamType0 InputParam0, ParamType1 InputParam1, ParamType2 InputParam2, ParamType3 InputParam3, ParamType4 InputParam4) \
3861 : ParamName0(InputParam0) \
3862 , ParamName1(InputParam1) \
3863 , ParamName2(InputParam2) \
3864 , ParamName3(InputParam3) \
3865 , ParamName4(InputParam4) \
3866 {} \
3867 virtual ~CommandName() \
3868 {} \
3869 virtual bool Update() override; \
3870 private: \
3871 ParamType0 ParamName0; \
3872 ParamType1 ParamName1; \
3873 ParamType2 ParamName2; \
3874 ParamType3 ParamName3; \
3875 ParamType4 ParamName4; \
3876}
3877
3878#define DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND(EXPORT_API, CommandName) \
3879class CommandName : public IAutomationLatentCommand \
3880 { \
3881 public: \
3882 virtual ~CommandName() \
3883 {} \
3884 EXPORT_API virtual bool Update() override; \
3885}
3886
3887#define DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND_ONE_PARAMETER(EXPORT_API, CommandName,ParamType,ParamName) \
3888class CommandName : public IAutomationLatentCommand \
3889 { \
3890 public: \
3891 CommandName(ParamType InputParam) \
3892 : ParamName(InputParam) \
3893 {} \
3894 virtual ~CommandName() \
3895 {} \
3896 EXPORT_API virtual bool Update() override; \
3897 private: \
3898 ParamType ParamName; \
3899}
3900
3901#define DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND_TWO_PARAMETER(EXPORT_API, CommandName,ParamType0,ParamName0,ParamType1,ParamName1) \
3902class CommandName : public IAutomationLatentCommand \
3903 { \
3904 public: \
3905 CommandName(ParamType0 InputParam0, ParamType1 InputParam1) \
3906 : ParamName0(InputParam0) \
3907 , ParamName1(InputParam1) \
3908 {} \
3909 virtual ~CommandName() \
3910 {} \
3911 EXPORT_API virtual bool Update() override; \
3912 private: \
3913 ParamType0 ParamName0; \
3914 ParamType1 ParamName1; \
3915}
3916
3917#define DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND_THREE_PARAMETER(EXPORT_API, CommandName,ParamType0,ParamName0,ParamType1,ParamName1,ParamType2,ParamName2) \
3918class CommandName : public IAutomationLatentCommand \
3919 { \
3920 public: \
3921 CommandName(ParamType0 InputParam0, ParamType1 InputParam1, ParamType2 InputParam2) \
3922 : ParamName0(InputParam0) \
3923 , ParamName1(InputParam1) \
3924 , ParamName2(InputParam2) \
3925 {} \
3926 virtual ~CommandName() \
3927 {} \
3928 EXPORT_API virtual bool Update() override; \
3929 private: \
3930 ParamType0 ParamName0; \
3931 ParamType1 ParamName1; \
3932 ParamType2 ParamName2; \
3933}
3934
3935#define DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND_FOUR_PARAMETER(EXPORT_API, CommandName,ParamType0,ParamName0,ParamType1,ParamName1,ParamType2,ParamName2,ParamType3,ParamName3) \
3936class CommandName : public IAutomationLatentCommand \
3937 { \
3938 public: \
3939 CommandName(ParamType0 InputParam0, ParamType1 InputParam1, ParamType2 InputParam2, ParamType3 InputParam3) \
3940 : ParamName0(InputParam0) \
3941 , ParamName1(InputParam1) \
3942 , ParamName2(InputParam2) \
3943 , ParamName3(InputParam3) \
3944 {} \
3945 virtual ~CommandName() \
3946 {} \
3947 EXPORT_API virtual bool Update() override; \
3948 private: \
3949 ParamType0 ParamName0; \
3950 ParamType1 ParamName1; \
3951 ParamType2 ParamName2; \
3952 ParamType3 ParamName3; \
3953}
3954
3955#define DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND_FIVE_PARAMETER(EXPORT_API, CommandName,ParamType0,ParamName0,ParamType1,ParamName1,ParamType2,ParamName2,ParamType3,ParamName3,ParamType4,ParamName4) \
3956class CommandName : public IAutomationLatentCommand \
3957 { \
3958 public: \
3959 CommandName(ParamType0 InputParam0, ParamType1 InputParam1, ParamType2 InputParam2, ParamType3 InputParam3, ParamType4 InputParam4) \
3960 : ParamName0(InputParam0) \
3961 , ParamName1(InputParam1) \
3962 , ParamName2(InputParam2) \
3963 , ParamName3(InputParam3) \
3964 , ParamName4(InputParam4) \
3965 {} \
3966 virtual ~CommandName() \
3967 {} \
3968 EXPORT_API virtual bool Update() override; \
3969 private: \
3970 ParamType0 ParamName0; \
3971 ParamType1 ParamName1; \
3972 ParamType2 ParamName2; \
3973 ParamType3 ParamName3; \
3974 ParamType4 ParamName4; \
3975}
3976
3977#define DEFINE_ENGINE_LATENT_AUTOMATION_COMMAND(CommandName) \
3978 DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND(ENGINE_API, CommandName)
3979
3980#define DEFINE_ENGINE_LATENT_AUTOMATION_COMMAND_ONE_PARAMETER(CommandName,ParamType,ParamName) \
3981 DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND_ONE_PARAMETER(ENGINE_API, CommandName, ParamType, ParamName)
3982
3983#define DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND_WITH_RETRIES(EXPORT_API,CommandName,RetryCount,WaitTimeBetweenRuns) \
3984class CommandName : public IAutomationLatentCommandWithRetriesAndDelays \
3985 { \
3986 public: \
3987 CommandName(int32 InRetryCount, double InWaitTimeBetweenRuns) \
3988 : IAutomationLatentCommandWithRetriesAndDelays(#CommandName, InRetryCount, InWaitTimeBetweenRuns) \
3989 {} \
3990 virtual ~CommandName() \
3991 {} \
3992 EXPORT_API virtual bool Execute() override; \
3993 private: \
3994}
3995
3996#define DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND_WITH_RETRIES_ONE_PARAMETER(EXPORT_API,CommandName,RetryCount,WaitTimeBetweenRuns,ParamType,ParamName) \
3997class CommandName : public IAutomationLatentCommandWithRetriesAndDelays \
3998 { \
3999 public: \
4000 CommandName(int32 InRetryCount, double InWaitTimeBetweenRuns, ParamType ParamName) \
4001 : IAutomationLatentCommandWithRetriesAndDelays(#CommandName, InRetryCount, InWaitTimeBetweenRuns) \
4002 , ParamName(ParamName) \
4003 {} \
4004 virtual ~CommandName() \
4005 {} \
4006 EXPORT_API virtual bool Execute() override; \
4007 private: \
4008 ParamType ParamName; \
4009}
4010
4011#define DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND_WITH_RETRIES_TWO_PARAMETERS(EXPORT_API,CommandName,RetryCount,WaitTimeBetweenRuns,ParamType0,ParamName0,ParamType1,ParamName1) \
4012class CommandName : public IAutomationLatentCommandWithRetriesAndDelays \
4013 { \
4014 public: \
4015 CommandName(int32 InRetryCount, double InWaitTimeBetweenRuns, ParamType0 ParamName0, ParamType1 ParamName1) \
4016 : IAutomationLatentCommandWithRetriesAndDelays(#CommandName, InRetryCount, InWaitTimeBetweenRuns) \
4017 , ParamName0(ParamName0) \
4018 , ParamName1(ParamName1) \
4019 {} \
4020 virtual ~CommandName() \
4021 {} \
4022 EXPORT_API virtual bool Execute() override; \
4023 private: \
4024 ParamType0 ParamName0; \
4025 ParamType1 ParamName1; \
4026}
4027
4028#define DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND_WITH_RETRIES_THREE_PARAMETERS(EXPORT_API,CommandName,RetryCount,WaitTimeBetweenRuns,ParamType0,ParamName0,ParamType1,ParamName1,ParamType2,ParamName2) \
4029class CommandName : public IAutomationLatentCommandWithRetriesAndDelays \
4030 { \
4031 public: \
4032 CommandName(int32 InRetryCount, double InWaitTimeBetweenRuns, ParamType0 ParamName0, ParamType1 ParamName1, ParamType2 ParamName2) \
4033 : IAutomationLatentCommandWithRetriesAndDelays(#CommandName, InRetryCount, InWaitTimeBetweenRuns) \
4034 , ParamName0(ParamName0) \
4035 , ParamName1(ParamName1) \
4036 , ParamName2(ParamName2) \
4037 {} \
4038 virtual ~CommandName() \
4039 {} \
4040 EXPORT_API virtual bool Execute() override; \
4041 private: \
4042 ParamType0 ParamName0; \
4043 ParamType1 ParamName1; \
4044 ParamType2 ParamName2; \
4045}
4046
4047#define DEFINE_EXPORTED_LATENT_AUTOMATION_COMMAND_WITH_RETRIES_FOUR_PARAMETERS(EXPORT_API,CommandName,RetryCount,WaitTimeBetweenRuns,ParamType0,ParamName0,ParamType1,ParamName1,ParamType2,ParamName2,ParamType3,ParamName3) \
4048class CommandName : public IAutomationLatentCommandWithRetriesAndDelays \
4049 { \
4050 public: \
4051 CommandName(int32 InRetryCount, double InWaitTimeBetweenRuns, ParamType0 ParamName0, ParamType1 ParamName1, ParamType2 ParamName2, ParamType3 ParamName3) \
4052 : IAutomationLatentCommandWithRetriesAndDelays(#CommandName, InRetryCount, InWaitTimeBetweenRuns) \
4053 , ParamName0(ParamName0) \
4054 , ParamName1(ParamName1) \
4055 , ParamName2(ParamName2) \
4056 , ParamName3(ParamName3) \
4057 {} \
4058 virtual ~CommandName() \
4059 {} \
4060 EXPORT_API virtual bool Execute() override; \
4061 private: \
4062 ParamType0 ParamName0; \
4063 ParamType1 ParamName1; \
4064 ParamType2 ParamName2; \
4065 ParamType3 ParamName3; \
4066}
4067
4068//macro to simply the syntax for enqueueing a latent command
4069#if WITH_AUTOMATION_TESTS
4070#define ADD_LATENT_AUTOMATION_COMMAND(ClassDeclaration) FAutomationTestFramework::Get().EnqueueLatentCommand(MakeShareable(new ClassDeclaration));
4071#else
4072#define ADD_LATENT_AUTOMATION_COMMAND(ClassDeclaration)
4073#endif
4074
4075//declare the class
4076#define START_NETWORK_AUTOMATION_COMMAND(ClassDeclaration) \
4077class F##ClassDeclaration : public IAutomationNetworkCommand \
4078{ \
4079private:\
4080 int32 RoleIndex; \
4081public: \
4082 F##ClassDeclaration(int32 InRoleIndex) : RoleIndex(InRoleIndex) {} \
4083 virtual ~F##ClassDeclaration() {} \
4084 virtual uint32 GetRoleIndex() const override { return RoleIndex; } \
4085 virtual void Run() override
4086
4087//close the class and add to the framework
4088#define END_NETWORK_AUTOMATION_COMMAND(ClassDeclaration,InRoleIndex) }; \
4089 FAutomationTestFramework::Get().EnqueueNetworkCommand(MakeShareable(new F##ClassDeclaration(InRoleIndex))); \
4090
4104#define IMPLEMENT_SIMPLE_AUTOMATION_TEST_PRIVATE( TClass, TBaseClass, PrettyName, TFlags, FileName, LineNumber ) \
4105 class TClass : public TBaseClass \
4106 { \
4107 public: \
4108 TClass( const FString& InName ) \
4109 :TBaseClass( InName, false ) {\
4110 static_assert(!!((TFlags) & EAutomationTestFlags_ApplicationContextMask), "AutomationTest has no application flag. It shouldn't run. See AutomationTest.h."); \
4111 static_assert( !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::SmokeFilter) || \
4112 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::EngineFilter) || \
4113 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::ProductFilter) || \
4114 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::PerfFilter) || \
4115 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::StressFilter) || \
4116 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::NegativeFilter), \
4117 "All AutomationTests must have exactly 1 filter type specified. See AutomationTest.h."); \
4118 } \
4119 virtual EAutomationTestFlags GetTestFlags() const override { return TFlags; } \
4120 virtual bool IsStressTest() const { return false; } \
4121 virtual uint32 GetRequiredDeviceNum() const override { return 1; } \
4122 virtual FString GetTestSourceFileName() const override { return FileName; } \
4123 virtual int32 GetTestSourceFileLine() const override { return LineNumber; } \
4124 protected: \
4125 virtual void GetTests(TArray<FString>& OutBeautifiedNames, TArray <FString>& OutTestCommands) const override \
4126 { \
4127 OutBeautifiedNames.Add(PrettyName); \
4128 OutTestCommands.Add(FString()); \
4129 } \
4130 virtual bool RunTest(const FString& Parameters) override; \
4131 virtual FString GetBeautifiedTestName() const override { return PrettyName; } \
4132 };
4133
4134
4135
4136#define IMPLEMENT_COMPLEX_AUTOMATION_TEST_PRIVATE( TClass, TBaseClass, PrettyName, TFlags, FileName, LineNumber ) \
4137 class TClass : public TBaseClass \
4138 { \
4139 public: \
4140 TClass( const FString& InName ) \
4141 :TBaseClass( InName, true ) { \
4142 static_assert(!!((TFlags) & EAutomationTestFlags_ApplicationContextMask), "AutomationTest has no application flag. It shouldn't run. See AutomationTest.h."); \
4143 static_assert( !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::SmokeFilter) || \
4144 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::EngineFilter) || \
4145 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::ProductFilter) || \
4146 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::PerfFilter) || \
4147 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::StressFilter) || \
4148 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::NegativeFilter), \
4149 "All AutomationTests must have exactly 1 filter type specified. See AutomationTest.h."); \
4150 } \
4151 virtual EAutomationTestFlags GetTestFlags() const override { return ((TFlags) & ~(EAutomationTestFlags::SmokeFilter)); } \
4152 virtual bool IsStressTest() const { return true; } \
4153 virtual uint32 GetRequiredDeviceNum() const override { return 1; } \
4154 virtual FString GetTestSourceFileName() const override { return FileName; } \
4155 virtual int32 GetTestSourceFileLine() const override { return LineNumber; } \
4156 protected: \
4157 virtual void GetTests(TArray<FString>& OutBeautifiedNames, TArray <FString>& OutTestCommands) const override; \
4158 virtual bool RunTest(const FString& Parameters) override; \
4159 virtual FString GetBeautifiedTestName() const override { return PrettyName; } \
4160 };
4161
4162#define IMPLEMENT_NETWORKED_AUTOMATION_TEST_PRIVATE(TClass, TBaseClass, PrettyName, TFlags, NumParticipants, FileName, LineNumber) \
4163 class TClass : public TBaseClass \
4164 { \
4165 public: \
4166 TClass( const FString& InName ) \
4167 :TBaseClass( InName, false ) { \
4168 static_assert(!!((TFlags) & EAutomationTestFlags_ApplicationContextMask), "AutomationTest has no application flag. It shouldn't run. See AutomationTest.h."); \
4169 static_assert( !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::SmokeFilter) || \
4170 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::EngineFilter) || \
4171 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::ProductFilter) || \
4172 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::PerfFilter) || \
4173 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::StressFilter) || \
4174 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::NegativeFilter), \
4175 "All AutomationTests must have exactly 1 filter type specified. See AutomationTest.h."); \
4176 } \
4177 virtual EAutomationTestFlags GetTestFlags() const override { return ((TFlags) & ~(EAutomationTestFlags::EditorContext | EAutomationTestFlags::CommandletContext | EAutomationTestFlags::SmokeFilter)); } \
4178 virtual uint32 GetRequiredDeviceNum() const override { return NumParticipants; } \
4179 virtual FString GetTestSourceFileName() const override { return FileName; } \
4180 virtual int32 GetTestSourceFileLine() const override { return LineNumber; } \
4181 protected: \
4182 virtual void GetTests(TArray<FString>& OutBeautifiedNames, TArray <FString>& OutTestCommands) const override \
4183 { \
4184 OutBeautifiedNames.Add(PrettyName); \
4185 OutTestCommands.Add(FString()); \
4186 } \
4187 virtual bool RunTest(const FString& Parameters) override; \
4188 virtual FString GetBeautifiedTestName() const override { return PrettyName; } \
4189 };
4190
4191#define IMPLEMENT_BDD_AUTOMATION_TEST_PRIVATE( TClass, PrettyName, TFlags, FileName, LineNumber ) \
4192 class TClass : public FBDDAutomationTestBase \
4193 { \
4194 public: \
4195 TClass( const FString& InName ) \
4196 :FBDDAutomationTestBase( InName, false ) {\
4197 static_assert(!!((TFlags) & EAutomationTestFlags_ApplicationContextMask), "AutomationTest has no application flag. It shouldn't run. See AutomationTest.h."); \
4198 static_assert( !!((((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::SmokeFilter) || \
4199 !!((((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::EngineFilter) || \
4200 !!((((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::ProductFilter) || \
4201 !!((((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::PerfFilter) || \
4202 !!((((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::StressFilter) || \
4203 !!((((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::NegativeFilter), \
4204 "All AutomationTests must have exactly 1 filter type specified. See AutomationTest.h."); \
4205 } \
4206 virtual EAutomationTestFlags GetTestFlags() const override { return TFlags; } \
4207 virtual bool IsStressTest() const { return false; } \
4208 virtual uint32 GetRequiredDeviceNum() const override { return 1; } \
4209 virtual FString GetTestSourceFileName() const override { return FileName; } \
4210 virtual int32 GetTestSourceFileLine() const override { return LineNumber; } \
4211 protected: \
4212 virtual bool RunTest(const FString& Parameters) override; \
4213 virtual FString GetBeautifiedTestName() const override { return PrettyName; } \
4214 private: \
4215 void Define(); \
4216 };
4217
4218#define DEFINE_SPEC_PRIVATE( TClass, PrettyName, TFlags, FileName, LineNumber ) \
4219 class TClass : public FAutomationSpecBase \
4220 { \
4221 public: \
4222 TClass( const FString& InName ) \
4223 : FAutomationSpecBase( InName, false ) {\
4224 static_assert(!!((TFlags) & EAutomationTestFlags_ApplicationContextMask), "AutomationTest has no application flag. It shouldn't run. See AutomationTest.h."); \
4225 static_assert( !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::SmokeFilter) || \
4226 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::EngineFilter) || \
4227 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::ProductFilter) || \
4228 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::PerfFilter) || \
4229 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::StressFilter) || \
4230 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::NegativeFilter), \
4231 "All AutomationTests must have exactly 1 filter type specified. See AutomationTest.h."); \
4232 } \
4233 virtual EAutomationTestFlags GetTestFlags() const override { return TFlags; } \
4234 using FAutomationSpecBase::GetTestSourceFileName; \
4235 virtual FString GetTestSourceFileName() const override { return FileName; } \
4236 using FAutomationSpecBase::GetTestSourceFileLine; \
4237 virtual int32 GetTestSourceFileLine() const override { return LineNumber; } \
4238 virtual FString GetTestSourceFileName(const FString&) const override { return GetTestSourceFileName(); } \
4239 virtual int32 GetTestSourceFileLine(const FString&) const override { return GetTestSourceFileLine(); } \
4240 protected: \
4241 virtual FString GetBeautifiedTestName() const override { return PrettyName; } \
4242 virtual void Define() override; \
4243 };
4244
4245#define BEGIN_DEFINE_SPEC_PRIVATE( TClass, PrettyName, TFlags, FileName, LineNumber ) \
4246 class TClass : public FAutomationSpecBase \
4247 { \
4248 public: \
4249 TClass( const FString& InName ) \
4250 : FAutomationSpecBase( InName, false ) {\
4251 static_assert(!!((TFlags) & EAutomationTestFlags_ApplicationContextMask), "AutomationTest has no application flag. It shouldn't run. See AutomationTest.h."); \
4252 static_assert( !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::SmokeFilter) || \
4253 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::EngineFilter) || \
4254 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::ProductFilter) || \
4255 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::PerfFilter) || \
4256 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::StressFilter) || \
4257 !!(((TFlags) & EAutomationTestFlags_FilterMask) == EAutomationTestFlags::NegativeFilter), \
4258 "All AutomationTests must have exactly 1 filter type specified. See AutomationTest.h."); \
4259 } \
4260 virtual EAutomationTestFlags GetTestFlags() const override { return TFlags; } \
4261 using FAutomationSpecBase::GetTestSourceFileName; \
4262 virtual FString GetTestSourceFileName() const override { return FileName; } \
4263 using FAutomationSpecBase::GetTestSourceFileLine; \
4264 virtual int32 GetTestSourceFileLine() const override { return LineNumber; } \
4265 protected: \
4266 virtual FString GetBeautifiedTestName() const override { return PrettyName; } \
4267 virtual void Define() override;
4268
4269#define REGISTER_SIMPLE_AUTOMATION_TEST_TAGS( TClass, PrettyName, TagsString ) \
4270 namespace\
4271 {\
4272 FAutomationTestTags TClass##AutomationTagsInstance(PrettyName, TagsString);\
4273 }
4274
4275#if WITH_AUTOMATION_WORKER
4276 #define IMPLEMENT_SIMPLE_AUTOMATION_TEST( TClass, PrettyName, TFlags ) \
4277 IMPLEMENT_SIMPLE_AUTOMATION_TEST_PRIVATE(TClass, FAutomationTestBase, PrettyName, TFlags, __FILE__, __LINE__) \
4278 namespace\
4279 {\
4280 TClass TClass##AutomationTestInstance( TEXT(#TClass) );\
4281 }
4282 #define IMPLEMENT_COMPLEX_AUTOMATION_TEST( TClass, PrettyName, TFlags ) \
4283 IMPLEMENT_COMPLEX_AUTOMATION_TEST_PRIVATE(TClass, FAutomationTestBase, PrettyName, TFlags, __FILE__, __LINE__) \
4284 namespace\
4285 {\
4286 TClass TClass##AutomationTestInstance( TEXT(#TClass) );\
4287 }
4288 #define IMPLEMENT_COMPLEX_AUTOMATION_CLASS( TClass, PrettyName, TFlags ) \
4289 IMPLEMENT_COMPLEX_AUTOMATION_TEST_PRIVATE(TClass, FAutomationTestBase, PrettyName, TFlags, __FILE__, __LINE__)
4290 #define IMPLEMENT_NETWORKED_AUTOMATION_TEST(TClass, PrettyName, TFlags, NumParticipants) \
4291 IMPLEMENT_NETWORKED_AUTOMATION_TEST_PRIVATE(TClass, FAutomationTestBase, PrettyName, TFlags, NumParticipants, __FILE__, __LINE__) \
4292 namespace\
4293 {\
4294 TClass TClass##AutomationTestInstance( TEXT(#TClass) );\
4295 }
4296
4297 #define IMPLEMENT_CUSTOM_SIMPLE_AUTOMATION_TEST( TClass, TBaseClass, PrettyName, TFlags ) \
4298 IMPLEMENT_SIMPLE_AUTOMATION_TEST_PRIVATE(TClass, TBaseClass, PrettyName, TFlags, __FILE__, __LINE__) \
4299 namespace\
4300 {\
4301 TClass TClass##AutomationTestInstance( TEXT(#TClass) );\
4302 }
4303
4304 #define IMPLEMENT_CUSTOM_COMPLEX_AUTOMATION_TEST( TClass, TBaseClass, PrettyName, TFlags ) \
4305 IMPLEMENT_COMPLEX_AUTOMATION_TEST_PRIVATE(TClass, TBaseClass, PrettyName, TFlags, __FILE__, __LINE__) \
4306 namespace\
4307 {\
4308 TClass TClass##AutomationTestInstance( TEXT(#TClass) );\
4309 }
4310
4311 #define IMPLEMENT_BDD_AUTOMATION_TEST( TClass, PrettyName, TFlags ) \
4312 IMPLEMENT_BDD_AUTOMATION_TEST_PRIVATE(TClass, PrettyName, TFlags, __FILE__, __LINE__) \
4313 namespace\
4314 {\
4315 TClass TClass##AutomationTestInstance( TEXT(#TClass) );\
4316 }
4317
4318 #define DEFINE_SPEC( TClass, PrettyName, TFlags ) \
4319 DEFINE_SPEC_PRIVATE(TClass, PrettyName, TFlags, __FILE__, __LINE__) \
4320 namespace\
4321 {\
4322 TClass TClass##AutomationSpecInstance( TEXT(#TClass) );\
4323 }
4324
4325 #define BEGIN_DEFINE_SPEC( TClass, PrettyName, TFlags ) \
4326 BEGIN_DEFINE_SPEC_PRIVATE(TClass, PrettyName, TFlags, __FILE__, __LINE__)
4327
4328 #define END_DEFINE_SPEC( TClass ) \
4329 };\
4330 namespace\
4331 {\
4332 TClass TClass##AutomationSpecInstance( TEXT(#TClass) );\
4333 }
4334
4335 //#define BEGIN_CUSTOM_COMPLEX_AUTOMATION_TEST( TClass, TBaseClass, PrettyName, TFlags ) \
4336 // BEGIN_COMPLEX_AUTOMATION_TEST_PRIVATE(TClass, TBaseClass, PrettyName, TFlags, __FILE__, __LINE__)
4337 //
4338 //#define END_CUSTOM_COMPLEX_AUTOMATION_TEST( TClass ) \
4339 // BEGIN_COMPLEX_AUTOMATION_TEST_PRIVATE(TClass, TBaseClass, PrettyName, TFlags, __FILE__, __LINE__)
4340 // namespace\
4341 // {\
4342 // TClass TClass##AutomationTestInstance( TEXT(#TClass) );\
4343 // }
4344
4345#else
4346 #define IMPLEMENT_SIMPLE_AUTOMATION_TEST( TClass, PrettyName, TFlags ) \
4347 IMPLEMENT_SIMPLE_AUTOMATION_TEST_PRIVATE(TClass, FAutomationTestBase, PrettyName, TFlags, __FILE__, __LINE__)
4348 #define IMPLEMENT_COMPLEX_AUTOMATION_TEST( TClass, PrettyName, TFlags ) \
4349 IMPLEMENT_COMPLEX_AUTOMATION_TEST_PRIVATE(TClass, FAutomationTestBase, PrettyName, TFlags, __FILE__, __LINE__)
4350 #define IMPLEMENT_NETWORKED_AUTOMATION_TEST(TClass, PrettyName, TFlags, NumParticipants) \
4351 IMPLEMENT_NETWORKED_AUTOMATION_TEST_PRIVATE(TClass, FAutomationTestBase, PrettyName, TFlags, NumParticipants, __FILE__, __LINE__)
4352
4353 #define IMPLEMENT_CUSTOM_SIMPLE_AUTOMATION_TEST( TClass, TBaseClass, PrettyName, TFlags ) \
4354 IMPLEMENT_SIMPLE_AUTOMATION_TEST_PRIVATE(TClass, TBaseClass, PrettyName, TFlags, __FILE__, __LINE__)
4355 #define IMPLEMENT_CUSTOM_COMPLEX_AUTOMATION_TEST( TClass, TBaseClass, PrettyName, TFlags ) \
4356 IMPLEMENT_COMPLEX_AUTOMATION_TEST_PRIVATE(TClass, TBaseClass, PrettyName, TFlags, __FILE__, __LINE__)
4357 #define IMPLEMENT_BDD_AUTOMATION_TEST(TClass, PrettyName, TFlags) \
4358 IMPLEMENT_BDD_AUTOMATION_TEST_PRIVATE(TClass, PrettyName, TFlags, __FILE__, __LINE__)
4359 #define DEFINE_SPEC(TClass, PrettyName, TFlags) \
4360 DEFINE_SPEC_PRIVATE(TClass, PrettyName, TFlags, __FILE__, __LINE__)
4361 #define BEGIN_DEFINE_SPEC(TClass, PrettyName, TFlags) \
4362 BEGIN_DEFINE_SPEC_PRIVATE(TClass, PrettyName, TFlags, __FILE__, __LINE__)
4363 #define END_DEFINE_SPEC(TClass) \
4364 }; \
4365
4366 //#define BEGIN_CUSTOM_COMPLEX_AUTOMATION_TEST( TClass, TBaseClass, PrettyName, TFlags ) \
4367 // BEGIN_CUSTOM_COMPLEX_AUTOMATION_TEST_PRIVATE(TClass, TBaseClass, PrettyName, TFlags, __FILE__, __LINE__)
4368
4369 //#define END_CUSTOM_COMPLEX_AUTOMATION_TEST( TClass )
4370 // END_COMPLEX_AUTOMATION_TEST_PRIVATE(TClass, TBaseClass, PrettyName, TFlags, __FILE__, __LINE__)
4371#endif // #if WITH_AUTOMATION_WORKER
4372
4373
4396#define UTEST_EQUAL(What, Actual, Expected)\
4397 if (!TestEqual(What, Actual, Expected))\
4398 {\
4399 return false;\
4400 }
4401
4402#define UTEST_EQUAL_EXPR(Actual, Expected)\
4403 if (!TestEqual(TEXT(#Actual), Actual, Expected))\
4404 {\
4405 return false;\
4406 }
4407
4408#define UTEST_EQUAL_TOLERANCE(What, Actual, Expected, Tolerance)\
4409 if (!TestEqual(What, Actual, Expected, Tolerance))\
4410 {\
4411 return false;\
4412 }
4413
4414#define UTEST_EQUAL_TOLERANCE_EXPR(Actual, Expected, Tolerance)\
4415 if (!TestEqual(TEXT(#Actual), Actual, Expected, Tolerance))\
4416 {\
4417 return false;\
4418 }
4419
4420#define UTEST_NEARLY_EQUAL(What, Actual, Expected, Tolerance)\
4421 if (!TestNearlyEqual(What, Actual, Expected, Tolerance))\
4422 {\
4423 return false;\
4424 }
4425
4426#define UTEST_NEARLY_EQUAL_EXPR(Actual, Expected, Tolerance)\
4427 if (!TestNearlyEqual(TEXT(#Actual), Actual, Expected, Tolerance))\
4428 {\
4429 return false;\
4430 }
4431
4432#define UTEST_EQUAL_INSENSITIVE(What, Actual, Expected)\
4433 if (!TestEqual(What, Actual, Expected))\
4434 {\
4435 return false;\
4436 }
4437
4438#define UTEST_EQUAL_INSENSITIVE_EXPR(Actual, Expected)\
4439 if (!TestEqual(TEXT(#Actual), Actual, Expected))\
4440 {\
4441 return false;\
4442 }
4443
4444#define UTEST_NOT_EQUAL_INSENSITIVE(What, Actual, Expected)\
4445 if (!TestNotEqual(What, Actual, Expected))\
4446 {\
4447 return false;\
4448 }
4449
4450#define UTEST_NOT_EQUAL_INSENSITIVE_EXPR(Actual, Expected)\
4451 if (!TestNotEqual(TEXT(#Actual), Actual, Expected))\
4452 {\
4453 return false;\
4454 }
4455
4456#define UTEST_EQUAL_SENSITIVE(What, Actual, Expected)\
4457 if (!TestEqualSensitive(What, Actual, Expected))\
4458 {\
4459 return false;\
4460 }
4461
4462#define UTEST_EQUAL_SENSITIVE_EXPR(Actual, Expected)\
4463 if (!TestEqualSensitive(TEXT(#Actual), Actual, Expected))\
4464 {\
4465 return false;\
4466 }
4467
4468#define UTEST_NOT_EQUAL_SENSITIVE(What, Actual, Expected)\
4469 if (!TestNotEqualSensitive(What, Actual, Expected))\
4470 {\
4471 return false;\
4472 }
4473
4474#define UTEST_NOT_EQUAL_SENSITIVE_EXPR(Actual, Expected)\
4475 if (!TestNotEqualSensitive(TEXT(#Actual), Actual, Expected))\
4476 {\
4477 return false;\
4478 }
4479
4480#define UTEST_NOT_EQUAL(What, Actual, Expected)\
4481 if (!TestNotEqual(What, Actual, Expected))\
4482 {\
4483 return false;\
4484 }
4485
4486#define UTEST_NOT_EQUAL_EXPR(Actual, Expected)\
4487 if (!TestNotEqual(FString::Printf(TEXT("%s != %s"), TEXT(#Actual), TEXT(#Expected)), Actual, Expected))\
4488 {\
4489 return false;\
4490 }
4491
4492#define UTEST_LESS(What, Actual, Expected)\
4493 if (!TestLessThan(What, Actual, Expected))\
4494 {\
4495 return false;\
4496 }
4497
4498#define UTEST_LESS_EXPR(Actual, Expected)\
4499 if (!TestLessThan(TEXT(#Actual), Actual, Expected))\
4500 {\
4501 return false;\
4502 }
4503
4504#define UTEST_LESS_TOLERANCE(What, Actual, Expected, Tolerance)\
4505 if (!TestLessThan(What, Actual, Expected, Tolerance))\
4506 {\
4507 return false;\
4508 }
4509
4510#define UTEST_LESS_TOLERANCE_EXPR(Actual, Expected, Tolerance)\
4511 if (!TestLessThan(TEXT(#Actual), Actual, Expected, Tolerance))\
4512 {\
4513 return false;\
4514 }
4515
4516#define UTEST_GREATER(What, Actual, Expected)\
4517 if (!TestGreaterThan(What, Actual, Expected))\
4518 {\
4519 return false;\
4520 }
4521
4522#define UTEST_GREATER_EXPR(Actual, Expected)\
4523 if (!TestGreaterThan(TEXT(#Actual), Actual, Expected))\
4524 {\
4525 return false;\
4526 }
4527
4528#define UTEST_GREATER_TOLERANCE(What, Actual, Expected, Tolerance)\
4529 if (!TestGreaterThan(What, Actual, Expected, Tolerance))\
4530 {\
4531 return false;\
4532 }
4533
4534#define UTEST_GREATER_TOLERANCE_EXPR(Actual, Expected, Tolerance)\
4535 if (!TestGreaterThan(TEXT(#Actual), Actual, Expected, Tolerance))\
4536 {\
4537 return false;\
4538 }
4539
4540#define UTEST_LESS_EQUAL(What, Actual, Expected)\
4541 if (!TestLessEqual(What, Actual, Expected))\
4542 {\
4543 return false;\
4544 }
4545
4546#define UTEST_LESS_EQUAL_EXPR(Actual, Expected)\
4547 if (!TestLessEqual(TEXT(#Actual), Actual, Expected))\
4548 {\
4549 return false;\
4550 }
4551
4552#define UTEST_LESS_EQUAL_TOLERANCE(What, Actual, Expected, Tolerance)\
4553 if (!TestLessEqual(What, Actual, Expected, Tolerance))\
4554 {\
4555 return false;\
4556 }
4557
4558#define UTEST_LESS_EQUAL_TOLERANCE_EXPR(Actual, Expected, Tolerance)\
4559 if (!TestLessEqual(TEXT(#Actual), Actual, Expected, Tolerance))\
4560 {\
4561 return false;\
4562 }
4563
4564#define UTEST_GREATER_EQUAL(What, Actual, Expected)\
4565 if (!TestGreaterEqual(What, Actual, Expected))\
4566 {\
4567 return false;\
4568 }
4569
4570#define UTEST_GREATER_EQUAL_EXPR(Actual, Expected)\
4571 if (!TestGreaterEqual(TEXT(#Actual), Actual, Expected))\
4572 {\
4573 return false;\
4574 }
4575
4576#define UTEST_GREATER_EQUAL_TOLERANCE(What, Actual, Expected, Tolerance)\
4577 if (!TestGreaterEqual(What, Actual, Expected, Tolerance))\
4578 {\
4579 return false;\
4580 }
4581
4582#define UTEST_GREATER_EQUAL_TOLERANCE_EXPR(Actual, Expected, Tolerance)\
4583 if (!TestGreaterEqual(TEXT(#Actual), Actual, Expected, Tolerance))\
4584 {\
4585 return false;\
4586 }
4587
4588#define UTEST_SAME(What, Actual, Expected)\
4589 if (!TestSame(What, Actual, Expected))\
4590 {\
4591 return false;\
4592 }
4593
4594#define UTEST_SAME_EXPR(Actual, Expected)\
4595 if (!TestSame(FString::Printf(TEXT("%s == %s"), TEXT(#Actual), TEXT(#Expected)), Actual, Expected))\
4596 {\
4597 return false;\
4598 }
4599
4600#define UTEST_NOT_SAME(What, Actual, Expected)\
4601 if (!TestNotSame(What, Actual, Expected))\
4602 {\
4603 return false;\
4604 }
4605
4606#define UTEST_NOT_SAME_EXPR(Actual, Expected)\
4607 if (!TestNotSame(FString::Printf(TEXT("%s != %s"), TEXT(#Actual), TEXT(#Expected)), Actual, Expected))\
4608 {\
4609 return false;\
4610 }
4611
4612#define UTEST_SAME_PTR(What, Actual, Expected)\
4613 if (!TestSamePtr(What, Actual, Expected))\
4614 {\
4615 return false;\
4616 }
4617
4618#define UTEST_SAME_PTR_EXPR(Actual, Expected)\
4619 if (!TestSamePtr(FString::Printf(TEXT("%s == %s"), TEXT(#Actual), TEXT(#Expected)), Actual, Expected))\
4620 {\
4621 return false;\
4622 }
4623
4624#define UTEST_NOT_SAME_PTR(What, Actual, Expected)\
4625 if (!TestNotSamePtr(What, Actual, Expected))\
4626 {\
4627 return false;\
4628 }
4629
4630#define UTEST_NOT_SAME_PTR_EXPR(Actual, Expected)\
4631 if (!TestNotSamePtr(FString::Printf(TEXT("%s != %s"), TEXT(#Actual), TEXT(#Expected)), Actual, Expected))\
4632 {\
4633 return false;\
4634 }
4635
4636#define UTEST_TRUE(What, Value)\
4637 if (!TestTrue(What, Value))\
4638 {\
4639 return false;\
4640 }
4641
4642#define UTEST_TRUE_EXPR(Expression)\
4643 if (!TestTrue(TEXT(#Expression), Expression))\
4644 {\
4645 return false;\
4646 }
4647
4648#define UTEST_FALSE(What, Value)\
4649 if (!TestFalse(What, Value))\
4650 {\
4651 return false;\
4652 }
4653
4654#define UTEST_FALSE_EXPR(Expression)\
4655 if (!TestFalse(TEXT(#Expression), Expression))\
4656 {\
4657 return false;\
4658 }
4659
4660#define UTEST_VALID(What, Value)\
4661 if (!TestValid(What, Value))\
4662 {\
4663 return false;\
4664 }
4665
4666#define UTEST_VALID_EXPR(Value)\
4667 if (!TestValid(TEXT(#Value), Value))\
4668 {\
4669 return false;\
4670 }
4671
4672#define UTEST_INVALID(What, Value)\
4673 if (!TestInvalid(What, Value))\
4674 {\
4675 return false;\
4676 }
4677
4678#define UTEST_INVALID_EXPR(Value)\
4679 if (!TestInvalid(TEXT(#Value), Value))\
4680 {\
4681 return false;\
4682 }
4683
4684#define UTEST_NULL(What, Pointer)\
4685 if (!TestNull(What, Pointer))\
4686 {\
4687 return false;\
4688 }
4689
4690#define UTEST_NULL_EXPR(Pointer)\
4691 if (!TestNull(TEXT(#Pointer), Pointer))\
4692 {\
4693 return false;\
4694 }
4695
4696#define UTEST_NOT_NULL(What, Pointer)\
4697 if (!TestNotNull(What, Pointer))\
4698 {\
4699 return false;\
4700 }\
4701 CA_ASSUME(Pointer);
4702
4703#define UTEST_NOT_NULL_EXPR(Pointer)\
4704 if (!TestNotNull(TEXT(#Pointer), Pointer))\
4705 {\
4706 return false;\
4707 }\
4708 CA_ASSUME(Pointer);
4709
4711// Basic Latent Commands
4712
4718{
4719public:
4721 : LatentPredicate(MoveTemp(InLatentPredicate))
4722 {
4723 }
4724
4726 {
4727 }
4728
4729 virtual bool Update() override
4730 {
4731 return LatentPredicate();
4732 }
4733
4734private:
4735 TFunction<bool()> LatentPredicate;
4736};
4737
4738
4740{
4741public:
4743 : Callback(MoveTemp(InCallback))
4744 , Delay(InDelay)
4745 {}
4746
4747 virtual bool Update() override
4748 {
4749 double NewTime = FPlatformTime::Seconds();
4750 if ( NewTime - StartTime >= Delay )
4751 {
4752 Callback();
4753 return true;
4754 }
4755 return false;
4756 }
4757
4758private:
4759 TFunction<void()> Callback;
4760 float Delay;
4761};
4762
4763
4765{
4766public:
4768 : Callback(MoveTemp(InCallback))
4769 , TimeoutCallback(MoveTemp(InTimeoutCallback))
4771 {}
4772
4773 virtual bool Update() override
4774 {
4775 if ( !Callback() )
4776 {
4777 const double NewTime = FPlatformTime::Seconds();
4778 if ( NewTime - StartTime >= Timeout )
4779 {
4780 TimeoutCallback();
4781 return true;
4782 }
4783
4784 return false;
4785 }
4786
4787 return true;
4788 }
4789
4790private:
4791 TFunction<bool()> Callback;
4792 TFunction<bool()> TimeoutCallback;
4793 float Timeout;
4794};
4795
4796// Extension of IAutomationLatentCommand with delays between attempts
4797// if initial command does not succeed. Has a max retry count that can be
4798// overridden. Default is 10 retries with a 1 second delay in between.
4799// To protect against misuse of unlimited retries, has a Max execution
4800// time of 5 minutes. This can be overridden, but not recommended. Only
4801// do this if you're absolutely certain it will not cause an infinite loop
4803{
4804public:
4806
4807 virtual void CommandFailedDueToError(const FString& ErrorMessage)
4808 {
4809 // Stop further commands and log error so the test fails.
4811 // Must log here so that Gauntlet can also pick up the error for its report. Otherwise, it will only show up in the Automation log.
4812 UE_LOG(LogLatentCommands, Error, TEXT("%s"), *ErrorMessage);
4813 GetCurrentTest()->AddError(ErrorMessage);
4814 }
4815
4816 // Base Update override with delay logic built in. Can be further overridden in child
4817 // classes
4818 virtual bool Update() override
4819 {
4821 {
4822 // command has unlimited retries, so need to check if max run time has been exceeded
4824 {
4825 // Command run time has exceeded max total run time.
4826 FString ErrorMessageText = FString::Printf(
4827 TEXT("%s has failed due to exceeding the max allowed run time of %f seconds. ")
4828 TEXT("This may be due to an error, or having a single command attempt to do ")
4829 TEXT("too many things. If this is not due to an error, consider breaking ")
4830 TEXT("up this command into multiple, smaller commands."), *GetTestAndCommandName(), MaxTotalRunTimeInSeconds);
4832 return true;
4833 }
4834 }
4835
4836 if (IsDelayTimerRunning())
4837 {
4838 return false;
4839 }
4840
4841 // pre-increment iteration so that its 1 based instead of 0 based for readability
4842 CurrentIteration++;
4843
4844 if (!CanRetry())
4845 {
4846 // Must log here so that Gauntlet can also pick up the error for its report. Otherwise, it will only show up in the Automation log.
4847 FString ErrorMessageText = FString::Printf(TEXT("%s Latent command with retries and delays has failed after %d retries"), *GetTestAndCommandName(), MaxRetries);
4849 return true;
4850 }
4851
4853
4854 // auto-logging for limited retries and unlimited retries
4856 {
4857 UE_LOG(LogLatentCommands, Log, TEXT("%s Executing Attempt %d."), *GetTestAndCommandName(), CurrentIteration);
4858 }
4859 else
4860 {
4861 UE_LOG(LogLatentCommands, Log, TEXT("%s Executing Attempt %d of %d."), *GetTestAndCommandName(), CurrentIteration, MaxRetries);
4862 }
4863
4864 if (Execute())
4865 {
4866 // completion log message, logs total time taken.
4867 UE_LOG(LogLatentCommands, Log, TEXT("%s Completed Successfully, total run time: %f seconds."), *GetTestAndCommandName(), GetCurrentRunTime());
4868
4869 return true;
4870 }
4871
4872 return false;
4873 }
4874
4875 // Pure virtual method that must be overridden.
4876 // This is the actual command logic.
4877 virtual bool Execute() = 0;
4878
4879private:
4880 // To keep track of which iteration we are on. 1 based
4881 // To allow for more readable logs. Attempt 1 of N instead
4882 // of 0 of N.
4883 int32 CurrentIteration = 0;
4884
4885protected:
4886 // default constructor
4888
4889 // parameterized constructor
4895 {
4896 // set first run start time so that we don't start off in a delay. Its fine if its negative.
4898
4899 // warn if command has unlimited retries MaxTotalRunTime
4901 {
4902 // Must log here so that Gauntlet can also pick up the error for its report. Otherwise, it will only show up in the Automation log.
4904 TEXT("%s has been set to Unlimited retries. Will be using MaxTotalRunTime to prevent ")
4905 TEXT("running forever. Default time is set at 300 seconds. If this is not enough time, ")
4906 TEXT("make sure to override this in your Execute() loop."), *GetTestAndCommandName());
4907 }
4908 }
4909
4910 // Resets the Delay Timer by setting start time to now (In game time).
4915
4916 // Determines if timer is running, pausing execution in a non-blocking way.
4918 {
4919 // time elapsed < Delay time
4921 }
4922
4923 // Returns if we have exceeded max allowed total run time for this latent command
4925 {
4926 return MaxTotalRunTimeInSeconds - GetCurrentRunTime() < 0;
4927 }
4928
4929 // Determines if we should execute the command. If MaxRetries is set to 0,
4930 // indicates unlimited retries.
4931 bool CanRetry() const
4932 {
4933 return (CurrentIteration <= MaxRetries) || MaxRetries == 0;
4934 }
4935
4936 // Returns the command name
4938 {
4939 // Otherwise use the provided string
4940 return FString::Printf(TEXT("Test: %s - Command: %s - "), *GetCurrentTest()->GetTestFullName(), *CommandClassName);
4941 }
4942
4947
4948 void OverrideMaxTotalRunTimeInSeconds(double OverrideValue)
4949 {
4950 MaxTotalRunTimeInSeconds = OverrideValue;
4951 }
4952
4953 // Command Name stored for easy logging
4954 const FString CommandClassName = "UnknownCommand";
4955
4956 // Times to retry command before reporting command failure.
4957 // Defaults to 10, but can be overridden.
4958 const int32 MaxRetries = 10;
4959
4960 // Indicates that this latent command has unlimited retries
4961 // Used to implement the MaxTotalRunTimeInSeconds logic
4962 const bool bHasUnlimitedRetries = false;
4963
4964 // Time in between UpdateDelayed calls.
4965 // Default is 1 second but can be overridden.
4966 const double DelayTimeInSeconds = 1.0;
4967
4968 // Time that the Delay Timer started.
4969 double DelayStartTime = 0.0;
4970
4971private:
4972 // Max total run time for command
4973 // Default is 5 minutes, but can be overridden
4974 double MaxTotalRunTimeInSeconds = 300.0;
4975
4976};
4977
4978#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_6
4980#endif
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
EAsyncExecution
Definition Async.h:28
EAutomationEventType
Definition AutomationEvent.h:10
constexpr EAutomationTestFlags EAutomationTestFlags_MediumPriorityAndAbove
Definition AutomationTest.h:146
constexpr EAutomationTestFlags EAutomationTestFlags_HighPriorityAndAbove
Definition AutomationTest.h:145
EAutomationComparisonToleranceLevel
Definition AutomationTest.h:864
UE_FORCEINLINE_HINT uint32 GetTypeHash(const FAutomationExpectedMessage &Object)
Definition AutomationTest.h:715
EAutomationTestFlags
Definition AutomationTest.h:88
CORE_API const TMap< FString, EAutomationTestFlags > & EAutomationTestFlags_GetTestFlagsMap()
Definition AutomationTest.cpp:179
constexpr EAutomationTestFlags EAutomationTestFlags_PriorityMask
Definition AutomationTest.h:147
constexpr EAutomationTestFlags EAutomationTestFlags_ApplicationContextMask
Definition AutomationTest.h:143
constexpr EAutomationTestFlags EAutomationTestFlags_FeatureMask
Definition AutomationTest.h:144
constexpr EAutomationTestFlags EAutomationTestFlags_FilterMask
Definition AutomationTest.h:148
bool bSuccess
Definition ConvexDecomposition3.cpp:819
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
SharedPointerInternals::TRawPtrProxy< ObjectType > MakeShareable(ObjectType *InObject)
Definition SharedPointer.h:1947
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_MULTICAST_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:58
#define DECLARE_DELEGATE(DelegateName)
Definition DelegateCombinations.h:20
#define DECLARE_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:57
#define DECLARE_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:48
#define DECLARE_DELEGATE_ThreeParams(DelegateName, Param1Type, Param2Type, Param3Type)
Definition DelegateCombinations.h:66
#define DECLARE_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:49
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
return true
Definition ExternalRpcRegistry.cpp:601
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
#define UE_LOG(CategoryName, Verbosity, Format,...)
Definition LogMacros.h:270
#define LLM_SCOPE_BYNAME(...)
Definition LowLevelMemTracker.h:1098
const bool
Definition NetworkReplayStreaming.h:178
ERegexPatternFlags
Definition Regex.h:12
::FCriticalSection FTransactionallySafeCriticalSection
Definition TransactionallySafeCriticalSection.h:16
#define UE_KINDA_SMALL_NUMBER
Definition UnrealMathUtility.h:131
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition AutomationTest.h:2888
void xLatentIt(const FString &InDescription, const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3358
FTimespan DefaultTimeout
Definition AutomationTest.h:3593
void xLatentBeforeEach(EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3466
void xIt(const FString &InDescription, EAsyncExecution Execution, TFunction< void()> DoWork)
Definition AutomationTest.h:3343
void xLatentIt(const FString &InDescription, EAsyncExecution Execution, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3363
virtual FString GetTestSourceFileName(const FString &InTestName) const override
Definition AutomationTest.h:3256
void xLatentIt(const FString &InDescription, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3353
void LatentAfterEach(TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3566
void xLatentIt(const FString &InDescription, EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3368
void LatentAfterEach(const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3572
void LatentIt(const FString &InDescription, EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork, UE::FSourceLocation Location=UE::FSourceLocation::Current())
Definition AutomationTest.h:3427
void xBeforeEach(EAsyncExecution Execution, TFunction< void()> DoWork)
Definition AutomationTest.h:3441
void xLatentAfterEach(const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3533
void xIt(const FString &InDescription, TFunction< void()> DoWork)
Definition AutomationTest.h:3338
void xLatentAfterEach(TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3528
void xLatentAfterEach(EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3543
void xLatentAfterEach(EAsyncExecution Execution, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3538
void LatentBeforeEach(const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3495
void LatentAfterEach(EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3584
void xBeforeEach(TFunction< void()> DoWork)
Definition AutomationTest.h:3436
void It(const FString &InDescription, EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void()> DoWork, UE::FSourceLocation Location=UE::FSourceLocation::Current())
Definition AutomationTest.h:3391
void LatentIt(const FString &InDescription, TFunction< void(const FDoneDelegate &)> DoWork, UE::FSourceLocation Location=UE::FSourceLocation::Current())
Definition AutomationTest.h:3400
void PostDefine()
Definition AutomationTest.h:3609
FAutomationSpecBase(const FString &InName, const bool bInComplexTask)
Definition AutomationTest.h:3204
void AfterEach(TFunction< void()> DoWork)
Definition AutomationTest.h:3548
void It(const FString &InDescription, EAsyncExecution Execution, TFunction< void()> DoWork, UE::FSourceLocation Location=UE::FSourceLocation::Current())
Definition AutomationTest.h:3382
void BeforeEach(EAsyncExecution Execution, TFunction< void()> DoWork)
Definition AutomationTest.h:3477
virtual int32 GetTestSourceFileLine(const FString &InTestName) const override
Definition AutomationTest.h:3273
void EnsureDefinitions() const
Definition AutomationTest.h:3598
void xAfterEach(EAsyncExecution Execution, TFunction< void()> DoWork)
Definition AutomationTest.h:3518
void xAfterEach(EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void()> DoWork)
Definition AutomationTest.h:3523
virtual void Define()=0
void It(const FString &InDescription, TFunction< void()> DoWork, UE::FSourceLocation Location=UE::FSourceLocation::Current())
Definition AutomationTest.h:3373
void AfterEach(EAsyncExecution Execution, TFunction< void()> DoWork)
Definition AutomationTest.h:3554
void LatentIt(const FString &InDescription, EAsyncExecution Execution, TFunction< void(const FDoneDelegate &)> DoWork, UE::FSourceLocation Location=UE::FSourceLocation::Current())
Definition AutomationTest.h:3418
void xLatentBeforeEach(const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3456
void xLatentBeforeEach(EAsyncExecution Execution, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3461
void xIt(const FString &InDescription, EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void()> DoWork)
Definition AutomationTest.h:3348
void LatentAfterEach(EAsyncExecution Execution, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3578
void Describe(const TArray< FString > InDescriptions, TFunction< void(int32)> DoWork)
Definition AutomationTest.h:3309
void Redefine()
Definition AutomationTest.h:3675
void xBeforeEach(EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void()> DoWork)
Definition AutomationTest.h:3446
virtual bool RunTest(const FString &InParameters) override
Definition AutomationTest.h:3214
void xAfterEach(TFunction< void()> DoWork)
Definition AutomationTest.h:3513
virtual uint32 GetRequiredDeviceNum() const override
Definition AutomationTest.h:3251
void LatentBeforeEach(TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3489
void LatentBeforeEach(EAsyncExecution Execution, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3501
void xLatentBeforeEach(TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3451
bool bEnableSkipIfError
Definition AutomationTest.h:3596
void LatentIt(const FString &InDescription, const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork, UE::FSourceLocation Location=UE::FSourceLocation::Current())
Definition AutomationTest.h:3409
void BeforeEach(EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void()> DoWork)
Definition AutomationTest.h:3483
void LatentBeforeEach(EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void(const FDoneDelegate &)> DoWork)
Definition AutomationTest.h:3507
virtual void GetTests(TArray< FString > &OutBeautifiedNames, TArray< FString > &OutTestCommands) const override
Definition AutomationTest.h:3290
void AfterEach(EAsyncExecution Execution, const FTimespan &Timeout, TFunction< void()> DoWork)
Definition AutomationTest.h:3560
virtual bool IsStressTest() const
Definition AutomationTest.h:3246
void BeforeEach(TFunction< void()> DoWork)
Definition AutomationTest.h:3471
void Describe(const FString &InDescription, TFunction< void()> DoWork)
Definition AutomationTest.h:3333
void xDescribe(const FString &InDescription, TFunction< void()> DoWork)
Definition AutomationTest.h:3304
Definition AutomationTest.h:1594
bool TestEqual(const TCHAR *What, const FString &Actual, const FString &Expected)
Definition AutomationTest.h:2018
bool TestGreaterEqual(const FString &What, const int64 Actual, const int64 Expected)
Definition AutomationTest.h:2300
bool TestNotEqualSensitive(const FString &What, FStringView Actual, FStringView Expected)
Definition AutomationTest.h:2166
CORE_API bool TestNull(const TCHAR *What, const void *Pointer)
Definition AutomationTest.cpp:2681
CORE_API bool TestEqual(const TCHAR *What, const int32 Actual, const int32 Expected)
Definition AutomationTest.cpp:2066
virtual uint32 GetRequiredDeviceNum() const =0
CORE_API void AddExpectedMessage(FString ExpectedPatternString, ELogVerbosity::Type ExpectedVerbosity, EAutomationExpectedMessageFlags::MatchType CompareType=EAutomationExpectedMessageFlags::Contains, int32 Occurrences=1, bool IsRegex=true)
Definition AutomationTest.cpp:1917
CORE_API bool TestNotEqualSensitive(const TCHAR *What, const TCHAR *Actual, const TCHAR *Expected)
Definition AutomationTest.cpp:2364
bool TestValid(const FString &Description, const ValueType &Value)
Definition AutomationTest.h:2619
bool TestNotEqual(const TCHAR *Description, const ValueType &Actual, const ValueType &Expected)
Definition AutomationTest.h:2398
bool TestEqual(const FString &What, FUtf8StringView Actual, FUtf8StringView Expected)
Definition AutomationTest.h:2103
bool TestNotEqualSensitive(const FString &What, FStringView Actual, FUtf8StringView Expected)
Definition AutomationTest.h:2171
bool TestNotSamePtr(const TCHAR *Description, const ValueType *Actual, const ValueType *Expected)
Definition AutomationTest.h:2485
bool TestNotSamePtr(const FString &Description, const ValueType *Actual, const ValueType *Expected)
Definition AutomationTest.h:2503
bool TestLessThan(const FString &What, const double Actual, const double Expected, double Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2310
CORE_API bool TestLessThan(const TCHAR *What, const int32 Actual, const int32 Expected)
Definition AutomationTest.cpp:2423
FAutomationTestExecutionInfo ExecutionInfo
Definition AutomationTest.h:2665
bool TestEqualSensitive(const FString &What, FUtf8StringView Actual, FStringView Expected)
Definition AutomationTest.h:2149
bool TestInvalid(const TCHAR *Description, const ValueType &Value)
Definition AutomationTest.h:2372
static CORE_API TArray< FString > SuppressedLogCategories
Definition AutomationTest.h:1610
bool TestNotSame(const TCHAR *Description, const ValueType &Actual, const ValueType &Expected)
Definition AutomationTest.h:2460
bool TestSame(const FString &Description, const ValueType &Actual, const ValueType &Expected)
Definition AutomationTest.h:2543
bool TestNotEqualSensitive(const TCHAR *What, const FString &Actual, const FString &Expected)
Definition AutomationTest.h:2057
virtual bool SuppressLogWarnings()
Definition AutomationTest.h:1933
CORE_API bool HasMetExpectedMessages(ELogVerbosity::Type VerbosityType=ELogVerbosity::All)
Definition AutomationTest.cpp:1813
virtual bool SuppressLogErrors()
Definition AutomationTest.h:1926
CORE_API bool TestGreaterThan(const TCHAR *What, const int32 Actual, const int32 Expected)
Definition AutomationTest.cpp:2443
bool TestEqual(const FString &What, FStringView Actual, FStringView Expected)
Definition AutomationTest.h:2108
FString GetTestContext() const
Definition AutomationTest.h:1623
virtual FString GetBeautifiedTestName() const =0
bool TestEqual(const FString &What, const int32 Actual, const int32 Expected)
Definition AutomationTest.h:2063
bool TestGreaterThan(const FString &What, const double Actual, const double Expected, double Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2320
bool TestLessThan(const FString &What, const int64 Actual, const int64 Expected)
Definition AutomationTest.h:2270
bool TestNotEqualSensitive(const FString &What, FUtf8StringView Actual, FUtf8StringView Expected)
Definition AutomationTest.h:2161
virtual void SetTestContext(FString Context)
Definition AutomationTest.h:2642
bool bSuppressLogs
Definition AutomationTest.h:2656
virtual FString GetTestSourceFileName() const
Definition AutomationTest.h:1967
virtual bool CanRunInEnvironment(const FString &TestParams, FString *OutReason, bool *OutWarn) const
Definition AutomationTest.h:1995
bool bRunOnSeparateThread
Definition AutomationTest.h:2653
bool bComplexTask
Definition AutomationTest.h:2650
bool TestValid(const TCHAR *Description, const ValueType &Value)
Definition AutomationTest.h:2608
virtual CORE_API void AddErrorS(const FString &InError, const FString &InFilename, int32 InLineNumber)
Definition AutomationTest.cpp:1720
static CORE_API void LoadDefaultLogSettings()
Definition AutomationTest.cpp:2056
bool TestNotEqual(const FString &What, const float Actual, const float Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2416
bool TestGreaterThan(const FString &What, const int32 Actual, const int32 Expected)
Definition AutomationTest.h:2275
bool TestLessEqual(const FString &What, const int64 Actual, const int64 Expected)
Definition AutomationTest.h:2290
bool TestSamePtr(const FString &Description, const ValueType *Actual, const ValueType *Expected)
Definition AutomationTest.h:2576
bool TestNotEqual(const TCHAR *What, const FString &Actual, const FString &Expected)
Definition AutomationTest.h:2027
bool TestNotSame(const FString &Description, const ValueType &Actual, const ValueType &Expected)
Definition AutomationTest.h:2470
virtual CORE_API void AddError(const FString &InError, int32 StackOffset=0)
Definition AutomationTest.cpp:1700
bool TestNotNull(const FString &What, const ValueType *Pointer)
Definition AutomationTest.h:2445
bool TestNotEqualSensitive(const FString &What, FUtf8StringView Actual, FStringView Expected)
Definition AutomationTest.h:2178
const bool IsComplexTask() const
Definition AutomationTest.h:1892
bool TestNull(const FString &What, const void *Pointer)
Definition AutomationTest.h:2518
bool TestSame(const TCHAR *Description, const ValueType &Actual, const ValueType &Expected)
Definition AutomationTest.h:2533
virtual void GetTests(TArray< FString > &OutBeautifiedNames, TArray< FString > &OutTestCommands) const =0
bool TestEqual(const FString &What, FUtf8StringView Actual, FStringView Expected)
Definition AutomationTest.h:2120
CORE_API bool GetLastExecutionSuccessState()
Definition AutomationTest.cpp:1907
static CORE_API bool bElevateLogWarningsToErrors
Definition AutomationTest.h:1609
bool TestSamePtr(const TCHAR *Description, const ValueType *Actual, const ValueType *Expected)
Definition AutomationTest.h:2558
bool TestNearlyEqual(const FString &What, const FTransform Actual, const FTransform Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2232
bool TestEqual(const FString &What, const double Actual, const double Expected, double Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2073
bool TestTrue(const FString &What, bool Value)
Definition AutomationTest.h:2591
virtual bool RunTest(const FString &Parameters)=0
FString GetTestName() const
Definition AutomationTest.h:1620
bool TestLessEqual(const FString &What, const float Actual, const float Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2325
bool TestGreaterEqual(const FString &What, const float Actual, const float Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2335
CORE_API bool HasMetExpectedErrors()
Definition AutomationTest.cpp:1873
virtual CORE_API void AddEvent(const FAutomationEvent &InEvent, int32 StackOffset=0, bool bCaptureStack=false)
Definition AutomationTest.cpp:1789
bool TestEqual(const FString &What, const FTransform Actual, const FTransform Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2083
virtual FString GetTestOpenCommand(const FString &Parameter) const
Definition AutomationTest.h:1982
virtual CORE_API ~FAutomationTestBase()
Definition AutomationTest.cpp:168
CORE_API void GenerateTestNames(TArray< FAutomationTestInfo > &TestInfo) const
Definition AutomationTest.cpp:2005
virtual int32 GetTestSourceFileLine(const FString &InTestName) const
Definition AutomationTest.h:1976
bool TestInvalid(const FString &Description, const ValueType &Value)
Definition AutomationTest.h:2383
virtual EAutomationTestFlags GetTestFlags() const =0
CORE_API void AddExpectedMessagePlain(FString ExpectedString, ELogVerbosity::Type ExpectedVerbosity, EAutomationExpectedMessageFlags::MatchType CompareType=EAutomationExpectedMessageFlags::Contains, int32 Occurrences=1)
Definition AutomationTest.cpp:1937
const bool IsRanOnSeparateThread() const
Definition AutomationTest.h:1897
bool TestGreaterThan(const FString &What, const int64 Actual, const int64 Expected)
Definition AutomationTest.h:2280
bool TestEqual(const FString &What, const FColor Actual, const FColor Expected)
Definition AutomationTest.h:2093
virtual FString GetTestSourceFileName(const FString &InTestName) const
Definition AutomationTest.h:1973
CORE_API bool TestTrue(const TCHAR *What, bool Value)
Definition AutomationTest.cpp:2671
virtual CORE_API void AddWarning(const FString &InWarning, int32 StackOffset=0)
Definition AutomationTest.cpp:1740
CORE_API void GetExecutionInfo(FAutomationTestExecutionInfo &OutInfo) const
Definition AutomationTest.cpp:1912
CORE_API bool TestNearlyEqual(const TCHAR *What, const float Actual, const float Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.cpp:2398
virtual bool SuppressLogs()
Definition AutomationTest.h:1907
virtual FString GetTestAssetPath(const FString &Parameter) const
Definition AutomationTest.h:1979
virtual bool ShouldCaptureLogCategory(const class FName &Category) const
Definition AutomationTest.h:1919
CORE_API void ClearExecutionInfo()
Definition AutomationTest.cpp:1694
bool TestLessThan(const FString &What, const int32 Actual, const int32 Expected)
Definition AutomationTest.h:2265
bool TestFalse(const FString &What, bool Value)
Definition AutomationTest.h:2355
bool TestEqual(const FString &What, FStringView Actual, FUtf8StringView Expected)
Definition AutomationTest.h:2113
CORE_API bool TestFalse(const TCHAR *What, bool Value)
Definition AutomationTest.cpp:2661
bool TestEqual(const FString &What, const FVector Actual, const FVector Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2078
CORE_API void AddExpectedErrorPlain(FString ExpectedString, EAutomationExpectedErrorFlags::MatchType CompareType=EAutomationExpectedErrorFlags::Contains, int32 Occurrences=1)
Definition AutomationTest.cpp:1982
virtual TArray< FString > GetSuppressedLogCategories()
Definition AutomationTest.h:1945
virtual int32 GetTestSourceFileLine() const
Definition AutomationTest.h:1970
CORE_API bool TestEqualInsensitive(const TCHAR *What, const TCHAR *Actual, const TCHAR *Expected)
Definition AutomationTest.cpp:2300
static CORE_API bool bSuppressLogWarnings
Definition AutomationTest.h:1607
CORE_API EAutomationTestFlags ExtractAutomationTestFlags(FString InTagNotation)
Definition AutomationTest.cpp:1990
virtual CORE_API bool AddErrorIfFalse(bool bCondition, const FString &InError, int32 StackOffset=0)
Definition AutomationTest.cpp:1710
void PushContext(const FString &Context)
Definition AutomationTest.h:1984
bool TestEqual(const TCHAR *What, const ValueType &Actual, const ValueType &Expected)
Definition AutomationTest.h:2195
bool TestNearlyEqual(const FString &What, const double Actual, const double Expected, double Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2222
bool TestNearlyEqual(const FString &What, const float Actual, const float Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2217
static CORE_API bool LogCategoryMatchesSeverityInclusive(ELogVerbosity::Type Actual, ELogVerbosity::Type MaximumVerbosity)
Definition AutomationTest.cpp:2048
bool TestEqual(const FString &What, const FRotator Actual, const FRotator Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2088
CORE_API bool TestEqualSensitive(const TCHAR *What, const TCHAR *Actual, const TCHAR *Expected)
Definition AutomationTest.cpp:2330
FString TestParameterContext
Definition AutomationTest.h:2662
virtual CORE_API void SetTelemetryStorage(const FString &StorageName)
Definition AutomationTest.cpp:1783
CORE_API bool HasAnyErrors() const
Definition AutomationTest.cpp:1808
virtual FString GetTestFullName() const
Definition AutomationTest.h:1633
static CORE_API bool bSuppressLogErrors
Definition AutomationTest.h:1608
CORE_API bool TestNotEqualInsensitive(const TCHAR *What, const TCHAR *Actual, const TCHAR *Expected)
Definition AutomationTest.cpp:2315
bool TestEqualSensitive(const FString &What, FUtf8StringView Actual, FUtf8StringView Expected)
Definition AutomationTest.h:2132
bool TestNearlyEqual(const FString &What, const FRotator Actual, const FRotator Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2237
bool TestEqual(const FString &What, const ValueType &Actual, const ValueType &Expected)
Definition AutomationTest.h:2206
CORE_API bool TestGreaterEqual(const TCHAR *What, const int32 Actual, const int32 Expected)
Definition AutomationTest.cpp:2483
virtual CORE_API void AddAnalyticsItem(const FString &InAnalyticsItem)
Definition AutomationTest.cpp:1760
bool TestNotEqual(const FString &Description, const ValueType &Actual, const ValueType &Expected)
Definition AutomationTest.h:2408
bool TestLessEqual(const FString &What, const double Actual, const double Expected, double Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2330
bool TestGreaterThan(const FString &What, const float Actual, const float Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2315
bool TestEqualSensitive(const FString &What, const TCHAR *Actual, const TCHAR *Expected)
Definition AutomationTest.h:2127
CORE_API void GetExpectedMessages(TArray< FAutomationExpectedMessage > &OutInfo, ELogVerbosity::Type Verbosity=ELogVerbosity::All) const
Definition AutomationTest.cpp:1954
bool TestEqualSensitive(const FString &What, FStringView Actual, FUtf8StringView Expected)
Definition AutomationTest.h:2142
CORE_API void AddExpectedError(FString ExpectedPatternString, EAutomationExpectedErrorFlags::MatchType CompareType=EAutomationExpectedErrorFlags::Contains, int32 Occurrences=1, bool IsRegex=true)
Definition AutomationTest.cpp:1976
bool TestEqualSensitive(const FString &What, FStringView Actual, FStringView Expected)
Definition AutomationTest.h:2137
CORE_API bool TestNotEqual(const TCHAR *What, const TCHAR *Actual, const TCHAR *Expected)
Definition AutomationTest.cpp:2224
void PopContext()
Definition AutomationTest.h:1989
void AddCommand(IAutomationNetworkCommand *NewCommand)
Definition AutomationTest.h:1960
FString TestName
Definition AutomationTest.h:2659
bool TestLessThan(const FString &What, const float Actual, const float Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2305
virtual bool ElevateLogWarningsToErrors()
Definition AutomationTest.h:1940
bool TestNotEqualSensitive(const FString &What, const TCHAR *Actual, const TCHAR *Expected)
Definition AutomationTest.h:2156
bool TestGreaterEqual(const FString &What, const int32 Actual, const int32 Expected)
Definition AutomationTest.h:2295
bool TestNotEqual(const FString &What, const double Actual, const double Expected, double Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2421
virtual CORE_API void AddWarningS(const FString &InWarning, const FString &InFilename, int32 InLineNumber)
Definition AutomationTest.cpp:1730
bool TestGreaterEqual(const FString &What, const double Actual, const double Expected, double Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2340
void AddCommand(IAutomationLatentCommand *NewCommand)
Definition AutomationTest.h:1951
bool TestNearlyEqual(const FString &What, const FVector Actual, const FVector Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2227
virtual CORE_API void AddTelemetryData(const FString &DataPoint, double Measurement, const FString &Context=TEXT(""))
Definition AutomationTest.cpp:1767
bool TestLessEqual(const FString &What, const int32 Actual, const int32 Expected)
Definition AutomationTest.h:2285
CORE_API bool TestLessEqual(const TCHAR *What, const int32 Actual, const int32 Expected)
Definition AutomationTest.cpp:2463
bool TestNotNull(const TCHAR *What, const ValueType *Pointer)
Definition AutomationTest.h:2435
bool TestEqual(const FString &What, const float Actual, const float Expected, float Tolerance=UE_KINDA_SMALL_NUMBER)
Definition AutomationTest.h:2068
bool TestEqual(const FString &What, const TCHAR *Actual, const TCHAR *Expected)
Definition AutomationTest.h:2098
virtual CORE_API void AddInfo(const FString &InLogItem, int32 StackOffset=0, bool bCaptureStack=false)
Definition AutomationTest.cpp:1750
Definition AutomationTest.h:195
void PushContext(const FString &Context)
Definition AutomationTest.h:235
~FAutomationTestExecutionInfo()
Definition AutomationTest.h:206
int32 GetErrorTotal() const
Definition AutomationTest.h:227
const FString & GetContext() const
Definition AutomationTest.h:229
TArray< FAutomationTelemetryData > TelemetryItems
Definition AutomationTest.h:257
CORE_API void AddEvent(const FAutomationEvent &Event, int StackOffset=0, bool bCaptureStack=true)
Definition AutomationTest.cpp:1607
double Duration
Definition AutomationTest.h:263
CORE_API void AddError(const FString &ErrorMessage)
Definition AutomationTest.cpp:1648
void PopContext()
Definition AutomationTest.h:240
TArray< FString > AnalyticsItems
Definition AutomationTest.h:254
CORE_API int32 RemoveAllEvents(EAutomationEventType EventType)
Definition AutomationTest.cpp:1577
FString TelemetryStorage
Definition AutomationTest.h:260
CORE_API void AddWarning(const FString &WarningMessage)
Definition AutomationTest.cpp:1643
const TArray< FAutomationExecutionEntry > & GetEntries() const
Definition AutomationTest.h:219
bool bSuccessful
Definition AutomationTest.h:251
CORE_API void Clear()
Definition AutomationTest.cpp:1564
int32 GetWarningTotal() const
Definition AutomationTest.h:226
FAutomationTestExecutionInfo()
Definition AutomationTest.h:198
Definition AutomationTest.h:947
CORE_API void LoadTestTagMappings()
Definition AutomationTest.cpp:924
CORE_API bool RunSmokeTests()
Definition AutomationTest.cpp:526
static CORE_API bool NeedLogBPTestMetadata()
Definition AutomationTest.cpp:343
FOnTestEvent OnTestStartEvent
Definition AutomationTest.h:956
bool IsLatentCommandQueueEmpty() const
Definition AutomationTest.h:1153
CORE_API void EnqueueNetworkCommand(TSharedPtr< IAutomationNetworkCommand > NewCommand)
Definition AutomationTest.cpp:482
FSimpleMulticastDelegate OnAfterAllTestsEvent
Definition AutomationTest.h:980
static FAutomationTestFramework & GetInstance()
Definition AutomationTest.h:998
FString GetCurrentTestFullPath() const
Definition AutomationTest.h:1268
FOnTestEvent OnTestEndEvent
Definition AutomationTest.h:959
CORE_API bool RegisterAutomationTest(const FString &InTestNameToRegister, FAutomationTestBase *InTestToRegister)
Definition AutomationTest.cpp:358
FOnTestDataRetrieved OnTestDataRetrieved
Definition AutomationTest.h:968
CORE_API void GetValidTestNames(TArray< FAutomationTestInfo > &TestInfo) const
Definition AutomationTest.cpp:795
CORE_API bool CanRunTestInEnvironment(const FString &InTestToRun, FString *OutReason, bool *OutWarn) const
Definition AutomationTest.cpp:1411
FOnTestScreenshotComparisonReport OnScreenshotComparisonReport
Definition AutomationTest.h:965
CORE_API void SetRequestedTestFilter(const EAutomationTestFlags InRequestedTestFlags)
Definition AutomationTest.cpp:1115
CORE_API void GetTestFullNamesMatchingTagPattern(TArray< FString > &OutTestNames, const FString &TagPattern) const
Definition AutomationTest.cpp:895
FSimpleMulticastDelegate PostTestingEvent
Definition AutomationTest.h:953
CORE_API bool ExecuteLatentCommands()
Definition AutomationTest.cpp:674
CORE_API FString GetUserAutomationDirectory() const
Definition AutomationTest.cpp:331
CORE_API void SaveTestTagMappings(const TArray< FString > &TestFullNames, const TArray< FString > &TestFilePaths, const FBeforeTagMappingConfigSaved &BeforeConfigSaved, const FAfterTagMappingConfigSaved &AfterConfigSaved) const
Definition AutomationTest.cpp:990
CORE_API TSet< FString > GetAllExistingTags()
Definition AutomationTest.cpp:440
CORE_API bool IsAnyOnLeavingTestSectionBound() const
Definition AutomationTest.cpp:1182
CORE_API FOnTestSectionEvent & GetOnEnteringTestSection(const FString &Section)
Definition AutomationTest.cpp:1130
CORE_API FOnTestScreenshotCaptured & OnScreenshotCaptured()
Definition AutomationTest.cpp:1120
CORE_API void NotifyPerformanceDataRetrieved(bool bSuccess, const FString &ErrorMessage)
Definition AutomationTest.cpp:1486
CORE_API void GetPossibleRestrictedPaths(const FString &BasePath, const TArray< FString > &RestrictedFolderNames, TArray< FString > &OutRestrictedFolders) const
Definition AutomationTest.cpp:910
CORE_API TArray< FString > GetTagsForAutomationTestAsArray(const FString &InTestName)
Definition AutomationTest.cpp:460
friend class FAutomationTestOutputDevice
Definition AutomationTest.h:1431
void SetForceSmokeTests(const bool bInForceSmokeTests)
Definition AutomationTest.h:1231
CORE_API void NotifyTestDataRetrieved(bool bWasNew, const FString &JsonData)
Definition AutomationTest.cpp:1481
CORE_API void TriggerOnEnteringTestSection(const FString &Section) const
Definition AutomationTest.cpp:1140
FSimpleMulticastDelegate PreTestingEvent
Definition AutomationTest.h:950
CORE_API FOnTestSectionEvent & GetOnLeavingTestSection(const FString &Section)
Definition AutomationTest.cpp:1164
CORE_API void NotifyScreenshotComparisonComplete(const FAutomationScreenshotCompareResults &CompareResults)
Definition AutomationTest.cpp:1471
CORE_API void EnqueueLatentCommand(TSharedPtr< IAutomationLatentCommand > NewCommand)
Definition AutomationTest.cpp:471
CORE_API bool RegisterAutomationTestTags(const FString &InTestNameToRegister, const FString &InTestTagsToRegister, bool InImmutable=true)
Definition AutomationTest.cpp:379
CORE_API void DequeueAllCommands()
Definition AutomationTest.cpp:732
CORE_API bool StopTest(FAutomationTestExecutionInfo &OutExecutionInfo)
Definition AutomationTest.cpp:661
FOnTestScreenshotComparisonComplete OnScreenshotCompared
Definition AutomationTest.h:962
static CORE_API bool NeedPerformStereoTestVariants()
Definition AutomationTest.cpp:348
FOnPerformanceDataRetrieved OnPerformanceDataRetrieved
Definition AutomationTest.h:971
static CORE_API bool NeedUseLightweightStereoTestVariants()
Definition AutomationTest.cpp:353
CORE_API FOnTestScreenshotAndTraceCaptured & OnScreenshotAndTraceCaptured()
Definition AutomationTest.cpp:1125
CORE_API bool ContainsTest(const FString &InTestName) const
Definition AutomationTest.cpp:493
CORE_API void SetDeveloperDirectoryIncluded(const bool bInDeveloperDirectoryIncluded)
Definition AutomationTest.cpp:1110
CORE_API bool ExecuteNetworkCommands()
Definition AutomationTest.cpp:713
FSimpleMulticastDelegate OnBeforeAllTestsEvent
Definition AutomationTest.h:977
void SetCaptureStack(bool bCapture)
Definition AutomationTest.h:1245
CORE_API void NotifyScreenshotComparisonReport(const FAutomationScreenshotCompareResults &CompareResults)
Definition AutomationTest.cpp:1476
CORE_API void NotifyScreenshotTakenAndCompared()
Definition AutomationTest.cpp:1491
CORE_API void TriggerOnLeavingTestSection(const FString &Section) const
Definition AutomationTest.cpp:1174
CORE_API FString GetTagsForAutomationTest(const FString &InTestName)
Definition AutomationTest.cpp:450
CORE_API void StartTestByName(const FString &InTestToRun, const int32 InRoleIndex, const FString &InFullTestPath=FString())
Definition AutomationTest.cpp:611
CORE_API bool IsTagImmutable(const FString &InTestName, const FString &InTag) const
Definition AutomationTest.cpp:445
CORE_API void ResetTests()
Definition AutomationTest.cpp:603
FSimpleMulticastDelegate OnScreenshotTakenAndCompared
Definition AutomationTest.h:974
CORE_API bool ShouldTestContent(const FString &Path) const
Definition AutomationTest.cpp:1083
bool GetCaptureStack() const
Definition AutomationTest.h:1236
CORE_API bool UnregisterAutomationTestTags(const FString &InTestNameToUnregister)
Definition AutomationTest.cpp:424
CORE_API bool RegisterComplexAutomationTestTags(const FAutomationTestBase *InTest, const FString &InBeautifiedTestName, const FString &InTestTagsToRegister)
Definition AutomationTest.cpp:434
static CORE_API FAutomationTestFramework & Get()
Definition AutomationTest.cpp:325
CORE_API void AddAnalyticsItemToCurrentTest(const FString &AnalyticsItem)
Definition AutomationTest.cpp:1459
FAutomationTestBase * GetCurrentTest() const
Definition AutomationTest.h:1260
static CORE_API bool NeedSkipStackWalk()
Definition AutomationTest.cpp:337
CORE_API void LoadTestModules()
Definition AutomationTest.cpp:746
CORE_API bool UnregisterAutomationTest(const FString &InTestNameToUnregister)
Definition AutomationTest.cpp:369
CORE_API bool IsAnyOnEnteringTestSectionBound() const
Definition AutomationTest.cpp:1148
Definition AutomationTest.h:277
FString GetTestTags() const
Definition AutomationTest.h:361
const int32 GetNumParticipantsRequired() const
Definition AutomationTest.h:457
const FString & GetDisplayName() const
Definition AutomationTest.h:331
const FString GetOpenCommand() const
Definition AutomationTest.h:411
void InformOfNewDeviceRunningTest()
Definition AutomationTest.h:437
const FString GetTestParameter() const
Definition AutomationTest.h:371
void ResetNumDevicesRunningTest()
Definition AutomationTest.h:429
FAutomationTestInfo()=default
void SetNumParticipantsRequired(int32 NumRequired)
Definition AutomationTest.h:478
const FString GetAssetPath() const
Definition AutomationTest.h:401
FAutomationTestInfo(const FString &InDisplayName, const FString &InFullTestPath, const FString &InTestName, const EAutomationTestFlags InTestFlags, const int32 InNumParticipantsRequired, const FString &InParameterName=FString(), const FString &InSourceFile=FString(), int32 InSourceFileLine=0, const FString &InAssetPath=FString(), const FString &InOpenCommand=FString(), const FString &InTestTags=FString())
Definition AutomationTest.h:298
const FString GetSourceFile() const
Definition AutomationTest.h:381
const EAutomationTestFlags GetTestFlags() const
Definition AutomationTest.h:421
void AddTestFlags(const EAutomationTestFlags InTestFlags)
Definition AutomationTest.h:321
void SetDisplayName(const FString &InDisplayName)
Definition AutomationTest.h:468
const int32 GetSourceFileLine() const
Definition AutomationTest.h:391
const FString & GetFullTestPath() const
Definition AutomationTest.h:341
const int GetNumDevicesRunningTest() const
Definition AutomationTest.h:447
FString GetTestName() const
Definition AutomationTest.h:351
Definition AutomationTest.h:1555
FAutomationTestTags(const FString &InTestFullName, const FString &InTags)
Definition AutomationTest.h:1564
~FAutomationTestTags()
Definition AutomationTest.h:1580
FAutomationTestTags()
Definition AutomationTest.h:1578
Definition AutomationTest.h:2702
bool IsDiscoveryMode() const
Definition AutomationTest.h:2732
void It(const FString &InDescription, TFunction< void()> DoWork)
Definition AutomationTest.h:2775
FBDDAutomationTestBase(const FString &InName, const bool bInComplexTask)
Definition AutomationTest.h:2704
virtual void GetTests(TArray< FString > &OutBeautifiedNames, TArray< FString > &OutTestCommands) const override
Definition AutomationTest.h:2718
void xIt(const FString &InDescription, TFunction< void()> DoWork)
Definition AutomationTest.h:2769
virtual bool RunTest(const FString &Parameters) override
Definition AutomationTest.h:2710
void Describe(const FString &InDescription, TFunction< void()> DoWork)
Definition AutomationTest.h:2743
void xDescribe(const FString &InDescription, TFunction< void()> DoWork)
Definition AutomationTest.h:2737
void BeforeEach(TFunction< void()> DoWork)
Definition AutomationTest.h:2807
void AfterEach(TFunction< void()> DoWork)
Definition AutomationTest.h:2812
Definition AutomationTest.h:4740
virtual bool Update() override
Definition AutomationTest.h:4747
FDelayedFunctionLatentCommand(TFunction< void()> InCallback, float InDelay=0.1f)
Definition AutomationTest.h:4742
Definition FeedbackContext.h:30
Definition AutomationTest.h:4718
virtual bool Update() override
Definition AutomationTest.h:4729
virtual ~FFunctionLatentCommand()
Definition AutomationTest.h:4725
FFunctionLatentCommand(TFunction< bool()> InLatentPredicate)
Definition AutomationTest.h:4720
Definition NameTypes.h:617
Definition UnrealType.h:3087
Definition OutputDevice.h:133
Definition Regex.h:44
Definition Regex.h:23
Definition TextFilterExpressionEvaluator.h:198
Definition Text.h:385
Definition ThreadSafeBool.h:17
Definition AutomationTest.h:577
FThreadedAutomationLatentCommand(TUniqueFunction< void()> InFunction)
Definition AutomationTest.h:592
TFuture< void > Future
Definition AutomationTest.h:600
virtual bool Update() override
Definition AutomationTest.h:582
virtual ~FThreadedAutomationLatentCommand()
Definition AutomationTest.h:580
TUniqueFunction< void()> Function
Definition AutomationTest.h:598
Definition AutomationTest.h:4765
FUntilCommand(TFunction< bool()> InCallback, TFunction< bool()> InTimeoutCallback, float InTimeout=5.0f)
Definition AutomationTest.h:4767
virtual bool Update() override
Definition AutomationTest.h:4773
Definition AutomationTest.h:4803
bool IsDelayTimerRunning() const
Definition AutomationTest.h:4917
IAutomationLatentCommandWithRetriesAndDelays(const FString InCommandClassName, const int32 InMaxRetries, const double InWaitTimeBetweenRuns)
Definition AutomationTest.h:4890
const int32 MaxRetries
Definition AutomationTest.h:4958
virtual ~IAutomationLatentCommandWithRetriesAndDelays()
Definition AutomationTest.h:4805
bool HasExceededMaxTotalRunTime()
Definition AutomationTest.h:4924
bool CanRetry() const
Definition AutomationTest.h:4931
const double DelayTimeInSeconds
Definition AutomationTest.h:4966
void OverrideMaxTotalRunTimeInSeconds(double OverrideValue)
Definition AutomationTest.h:4948
const FString CommandClassName
Definition AutomationTest.h:4954
void ResetDelayTimer()
Definition AutomationTest.h:4911
IAutomationLatentCommandWithRetriesAndDelays()
Definition AutomationTest.h:4887
const bool bHasUnlimitedRetries
Definition AutomationTest.h:4962
double DelayStartTime
Definition AutomationTest.h:4969
virtual void CommandFailedDueToError(const FString &ErrorMessage)
Definition AutomationTest.h:4807
FAutomationTestBase * GetCurrentTest() const
Definition AutomationTest.h:4943
virtual bool Update() override
Definition AutomationTest.h:4818
FString GetTestAndCommandName() const
Definition AutomationTest.h:4937
Definition AutomationTest.h:525
virtual bool Update()=0
double StartTime
Definition AutomationTest.h:568
virtual ~IAutomationLatentCommand()
Definition AutomationTest.h:528
IAutomationLatentCommand()
Definition AutomationTest.h:551
double GetCurrentRunTime() const
Definition AutomationTest.h:557
Definition AutomationTest.h:610
virtual void Run()=0
virtual uint32 GetRoleIndex() const =0
virtual ~IAutomationNetworkCommand()
Definition AutomationTest.h:613
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT ElementType & Last(SizeType IndexFromTheEnd=0) UE_LIFETIMEBOUND
Definition Array.h:1263
void RemoveAt(SizeType Index, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2083
UE_NODEBUG UE_FORCEINLINE_HINT void Push(ElementType &&Item)
Definition Array.h:1224
void Reset(SizeType NewSize=0)
Definition Array.h:2246
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
void Append(const TArray< OtherElementType, OtherAllocatorType > &Source)
Definition Array.h:2412
ElementType Pop(EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:1196
UE_NODEBUG UE_FORCEINLINE_HINT ElementType & Top() UE_LIFETIMEBOUND
Definition Array.h:1248
void Empty(SizeType Slack=0)
Definition Array.h:2273
Definition AssetRegistryState.h:50
Definition AndroidPlatformMisc.h:14
bool IsValid() const
Definition Future.h:267
bool IsReady() const
Definition Future.h:256
Definition Future.h:393
Definition UnrealString.h.inl:34
Definition Queue.h:48
bool IsEmpty() const
Definition Queue.h:206
Definition SharedPointer.h:1640
Definition SharedPointer.h:692
TSharedRef< ObjectType, Mode > ToSharedRef() const &
Definition SharedPointer.h:1028
UE_FORCEINLINE_HINT void Reset()
Definition SharedPointer.h:1120
Definition SharedPointer.h:153
Definition FunctionFwd.h:19
Definition StructuredLog.h:182
Definition CriticalSection.h:14
Definition SourceLocation.h:21
static UE_CONSTEVAL FSourceLocation Current(FSourceLocationImpl Impl=FSourceLocationImpl::current()) noexcept
Definition SourceLocation.h:107
Definition ScopeLock.h:21
Definition AutomationTest.h:154
MatchType
Definition AutomationTest.h:156
@ Contains
Definition AutomationTest.h:160
@ Exact
Definition AutomationTest.h:158
Definition GenericPlatformFile.h:25
Type
Definition LogVerbosity.h:17
@ All
Definition LogVerbosity.h:56
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
static double Seconds()
Definition AndroidPlatformTime.h:20
Definition AutomationTest.h:872
FAutomationComparisonToleranceAmount()
Definition AutomationTest.h:875
uint8 MinBrightness
Definition AutomationTest.h:914
uint8 Green
Definition AutomationTest.h:911
uint8 MaxBrightness
Definition AutomationTest.h:915
static FAutomationComparisonToleranceAmount FromToleranceLevel(EAutomationComparisonToleranceLevel InTolerance)
Definition AutomationTest.h:895
FAutomationComparisonToleranceAmount(uint8 R, uint8 G, uint8 B, uint8 A, uint8 InMinBrightness, uint8 InMaxBrightness)
Definition AutomationTest.h:885
uint8 Red
Definition AutomationTest.h:910
uint8 Blue
Definition AutomationTest.h:912
uint8 Alpha
Definition AutomationTest.h:913
Definition AutomationEvent.h:17
Definition AutomationTest.h:627
bool operator<(const FAutomationExpectedMessage &Other) const
Definition AutomationTest.h:708
bool operator==(const FAutomationExpectedMessage &Other) const
Definition AutomationTest.h:703
bool Matches(const FString &Message)
Look if Message matches the expected message and increment internal counter if true.
Definition AutomationTest.h:687
FAutomationExpectedMessage(FString &InMessagePattern, ELogVerbosity::Type InVerbosity, int32 InExpectedNumberOfOccurrences)
Definition AutomationTest.h:663
FString MessagePatternString
Definition AutomationTest.h:632
int32 ActualNumberOfOccurrences
Definition AutomationTest.h:643
FAutomationExpectedMessage(FString &InMessagePattern, ELogVerbosity::Type InVerbosity, EAutomationExpectedMessageFlags::MatchType InCompareType, int32 InExpectedNumberOfOccurrences=1, bool IsRegex=true)
Definition AutomationTest.h:650
TOptional< FRegexPattern > MessagePatternRegex
Definition AutomationTest.h:634
bool IsRegex() const
Definition AutomationTest.h:672
int32 ExpectedNumberOfOccurrences
Definition AutomationTest.h:642
ELogVerbosity::Type Verbosity
Definition AutomationTest.h:645
bool IsExactCompareType() const
Definition AutomationTest.h:677
EAutomationExpectedMessageFlags::MatchType CompareType
Definition AutomationTest.h:636
Definition AutomationTest.h:813
FAutomationScreenshotCompareResults()
Definition AutomationTest.h:826
bool bWasNew
Definition AutomationTest.h:818
FString ReportIncomingFilePath
Definition AutomationTest.h:823
FString ReportApprovedFilePath
Definition AutomationTest.h:822
double GlobalDifference
Definition AutomationTest.h:817
FString ScreenshotPath
Definition AutomationTest.h:824
double MaxLocalDifference
Definition AutomationTest.h:816
FString ReportComparisonFilePath
Definition AutomationTest.h:821
FGuid UniqueId
Definition AutomationTest.h:814
CORE_API FAutomationEvent ToAutomationEvent() const
Definition AutomationTest.cpp:1655
FString ErrorMessage
Definition AutomationTest.h:815
bool bWasSimilar
Definition AutomationTest.h:819
FString IncomingFilePath
Definition AutomationTest.h:820
FAutomationScreenshotCompareResults(FGuid InUniqueId, FString InErrorMessage, double InMaxLocalDifference, double InGlobalDifference, bool InWasNew, bool InWasSimilar, FString InIncomingFilePath, FString InReportComparisonFilePath, FString InReportApprovedFilePath, FString InReportIncomingFilePath, FString InScreenshotPath)
Definition AutomationTest.h:834
Definition AutomationTest.h:721
FString Rhi
Definition AutomationTest.h:736
float MaximumLocalError
Definition AutomationTest.h:771
int32 TextureQuality
Definition AutomationTest.h:758
int32 ShadingQuality
Definition AutomationTest.h:761
bool bIgnoreColors
Definition AutomationTest.h:774
uint8 ToleranceRed
Definition AutomationTest.h:765
uint8 ToleranceMaxBrightness
Definition AutomationTest.h:770
int32 PostProcessQuality
Definition AutomationTest.h:757
int32 ReflectionQuality
Definition AutomationTest.h:756
FString UniqueDeviceId
Definition AutomationTest.h:748
FString AdapterInternalDriverVersion
Definition AutomationTest.h:746
FString ScreenshotPath
Definition AutomationTest.h:777
int32 AntiAliasingQuality
Definition AutomationTest.h:753
int32 Width
Definition AutomationTest.h:731
bool bIgnoreAntiAliasing
Definition AutomationTest.h:773
FString FeatureLevel
Definition AutomationTest.h:737
FString TestName
Definition AutomationTest.h:725
uint8 ToleranceMinBrightness
Definition AutomationTest.h:769
bool bHasComparisonRules
Definition AutomationTest.h:764
FString Platform
Definition AutomationTest.h:735
float MaximumGlobalError
Definition AutomationTest.h:772
int32 FoliageQuality
Definition AutomationTest.h:760
FString Vendor
Definition AutomationTest.h:744
FString VariantName
Definition AutomationTest.h:723
FString AdapterUserDriverVersion
Definition AutomationTest.h:747
FAutomationScreenshotData()
Definition AutomationTest.h:779
uint8 ToleranceAlpha
Definition AutomationTest.h:768
FString Commit
Definition AutomationTest.h:729
bool bIsStereo
Definition AutomationTest.h:738
uint8 ToleranceGreen
Definition AutomationTest.h:766
FString Notes
Definition AutomationTest.h:726
bool bIsSubstrate
Definition AutomationTest.h:741
FString AdapterName
Definition AutomationTest.h:745
float ResolutionQuality
Definition AutomationTest.h:751
FString ScreenShotName
Definition AutomationTest.h:722
uint8 ToleranceBlue
Definition AutomationTest.h:767
int32 ShadowQuality
Definition AutomationTest.h:754
int32 Height
Definition AutomationTest.h:732
FGuid Id
Definition AutomationTest.h:728
FString Context
Definition AutomationTest.h:724
int32 GlobalIlluminationQuality
Definition AutomationTest.h:755
int32 EffectsQuality
Definition AutomationTest.h:759
int32 ViewDistanceQuality
Definition AutomationTest.h:752
Definition AutomationTest.h:180
FString Context
Definition AutomationTest.h:183
FAutomationTelemetryData(const FString &InDataPoint, double InMeasurement, const FString &InContext)
Definition AutomationTest.h:185
FString DataPoint
Definition AutomationTest.h:181
double Measurement
Definition AutomationTest.h:182
Definition Color.h:486
Definition DateTime.h:76
static CORE_API FDateTime UtcNow()
Definition DateTime.cpp:980
Definition Guid.h:109
Definition Color.h:48
Definition Timespan.h:76
static bool IsWhitespace(CharType Char)
Definition Char.h:282
Definition Optional.h:131
constexpr OptionalType & GetValue()
Definition Optional.h:443
constexpr bool IsSet() const
Definition Optional.h:69