Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
LowLevelTestAdapter.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if !WITH_LOW_LEVEL_TESTS
6
7#include "CoreTypes.h"
8#include "Misc/AssertionMacros.h"
9
10#define IMPLEMENT_SIMPLE_AUTOMATION_TEST_PRIVATE_LLT( TClass, PrettyName, TFlags, FileName, LineNumber )
11 class TClass : public FAutomationTestBase
12 {
13 public:
14 TClass( const FString& InName)
15 : FAutomationTestBase( InName, false )
16 {
17 TestFlags = ExtractAutomationTestFlags(TFlags);
18 PrettyNameDotNotation = FString(PrettyName).Replace(TEXT("::"), TEXT("."));
19 if (!(TestFlags & EAutomationTestFlags::ApplicationContextMask))
20 {
21 TestFlags |= EAutomationTestFlags::ApplicationContextMask;
22 }
23 if (!(TestFlags & EAutomationTestFlags::FilterMask))
24 {
25 TestFlags |= EAutomationTestFlags::EngineFilter;
26 }
27 }
28 virtual uint32 GetTestFlags() const override { return TestFlags; }
29 virtual bool IsStressTest() const { return false; }
30 virtual uint32 GetRequiredDeviceNum() const override { return 1; }
31 virtual FString GetTestSourceFileName() const override { return FileName; }
32 virtual int32 GetTestSourceFileLine() const override { return LineNumber; }
33 protected:
34 virtual void GetTests(TArray<FString>& OutBeautifiedNames, TArray <FString>& OutTestCommands) const override
35 {
36 OutBeautifiedNames.Add(PrettyNameDotNotation);
37 OutTestCommands.Add(FString());
38 }
39 void TestBody(const FString& Parameters);
40 virtual bool RunTest(const FString& Parameters) {
41 TestBody(Parameters);
42 return true;
43 }
44 virtual FString GetBeautifiedTestName() const override { return PrettyNameDotNotation; }
45 private:
46 uint32 TestFlags;
47 FString PrettyNameDotNotation;
48 };
49
50#define LLT_JOIN(Prefix, Counter) LLT_JOIN_INNER(Prefix, Counter)
51#define LLT_JOIN_INNER(Prefix, Counter) Prefix##Counter
52
53#define TEST_CASE_NAMED(TClass, StrName, PrettyName, TFlags)
54 IMPLEMENT_SIMPLE_AUTOMATION_TEST_PRIVATE_LLT(TClass, PrettyName, TFlags, __FILE__, __LINE__)
55 namespace
56 {
57 TClass LLT_JOIN(TClass, Instance)(TEXT(StrName));
58 }
59 void TClass::TestBody(const FString& Parameters)
60
61
62#define TEST_CASE_GENERATED_NAME_UNIQUE LLT_JOIN(FLLTAdaptedTest, __COUNTER__)
63#define LLT_STR(Macro) #Macro
64#define LLT_STR_EXPAND(Macro) LLT_STR(Macro)
65#define TEST_CASE_GENERATED_NAME_UNIQUE_STR LLT_STR_EXPAND(TEST_CASE_GENERATED_NAME_UNIQUE)
66#define TEST_CASE(PrettyName, TFlags) TEST_CASE_NAMED(TEST_CASE_GENERATED_NAME_UNIQUE, TEST_CASE_GENERATED_NAME_UNIQUE_STR, PrettyName, TFlags)
67
68#define CHECK(Expr) if (!(Expr)) { FAutomationTestFramework::Get().GetCurrentTest()->AddError(TEXT("Condition failed")); }
69#define CHECK_FALSE(Expr) if (Expr) { FAutomationTestFramework::Get().GetCurrentTest()->AddError(TEXT("Condition expected to return false but returned true")); }
70#define REQUIRE(Expr) if (!(Expr)) { FAutomationTestFramework::Get().GetCurrentTest()->AddError(TEXT("Required condition failed, interrupting test")); return; }
71
72#define SECTION(Text) AddInfo(TEXT(Text));
73
74#endif // !WITH_LOW_LEVEL_TESTS
#define TEST_CASE_NAMED(TClass, StrName, PrettyName, TFlags)
#define LLT_STR(Macro)
#define LLT_STR_EXPAND(Macro)
#define LLT_JOIN(Prefix, Counter)
#define TEST_CASE_GENERATED_NAME_UNIQUE_STR
#define IMPLEMENT_SIMPLE_AUTOMATION_TEST_PRIVATE_LLT(TClass, PrettyName, TFlags, FileName, LineNumber)
#define TEST_CASE_GENERATED_NAME_UNIQUE
#define LLT_JOIN_INNER(Prefix, Counter)
#define TEXT(x)
Definition Platform.h:1108