|
| 1 | +// Copyright 2015-2019 Piperift. All Rights Reserved. |
| 2 | + |
| 3 | +#pragma once |
| 4 | + |
| 5 | +#include <CoreMinimal.h> |
| 6 | +#include <Misc/AutomationTest.h> |
| 7 | +#include <Engine/World.h> |
| 8 | + |
| 9 | + |
| 10 | +class FAESpec : public FAutomationSpecBase |
| 11 | +{ |
| 12 | +public: |
| 13 | + |
| 14 | + FAESpec(const FString& InName, const bool bInComplexTask) |
| 15 | + : FAutomationSpecBase(InName, bInComplexTask) |
| 16 | + {} |
| 17 | + |
| 18 | +protected: |
| 19 | + |
| 20 | + void TestNotImplemented() |
| 21 | + { |
| 22 | + AddWarning("Test not implemented."); |
| 23 | + } |
| 24 | + |
| 25 | + UWorld* GetTestWorld() const; |
| 26 | +}; |
| 27 | + |
| 28 | + |
| 29 | +#define BASE_SPEC FAESpec |
| 30 | + |
| 31 | +#define BEGIN_TESTSPEC_PRIVATE( TClass, PrettyName, TFlags, FileName, LineNumber ) \ |
| 32 | + class TClass : public BASE_SPEC \ |
| 33 | + { \ |
| 34 | + using Super = BASE_SPEC; \ |
| 35 | + public: \ |
| 36 | + TClass( const FString& InName ) \ |
| 37 | + : Super( InName, false ) { \ |
| 38 | + static_assert((TFlags)&EAutomationTestFlags::ApplicationContextMask, "AutomationTest has no application flag. It shouldn't run. See AutomationTest.h."); \ |
| 39 | + static_assert( (((TFlags)&EAutomationTestFlags::FilterMask) == EAutomationTestFlags::SmokeFilter) || \ |
| 40 | + (((TFlags)&EAutomationTestFlags::FilterMask) == EAutomationTestFlags::EngineFilter) || \ |
| 41 | + (((TFlags)&EAutomationTestFlags::FilterMask) == EAutomationTestFlags::ProductFilter) || \ |
| 42 | + (((TFlags)&EAutomationTestFlags::FilterMask) == EAutomationTestFlags::PerfFilter) || \ |
| 43 | + (((TFlags)&EAutomationTestFlags::FilterMask) == EAutomationTestFlags::StressFilter) || \ |
| 44 | + (((TFlags)&EAutomationTestFlags::FilterMask) == EAutomationTestFlags::NegativeFilter), \ |
| 45 | + "All AutomationTests must have exactly 1 filter type specified. See AutomationTest.h."); \ |
| 46 | + } \ |
| 47 | + virtual uint32 GetTestFlags() const override { return TFlags; } \ |
| 48 | + using Super::GetTestSourceFileName; \ |
| 49 | + virtual FString GetTestSourceFileName() const override { return FileName; } \ |
| 50 | + using Super::GetTestSourceFileLine; \ |
| 51 | + virtual int32 GetTestSourceFileLine() const override { return LineNumber; } \ |
| 52 | + protected: \ |
| 53 | + virtual FString GetBeautifiedTestName() const override { return PrettyName; } \ |
| 54 | + virtual void Define() override; |
| 55 | + |
| 56 | + |
| 57 | +#if WITH_AUTOMATION_WORKER |
| 58 | + #define TESTSPEC( TClass, PrettyName, TFlags ) \ |
| 59 | + BEGIN_TESTSPEC_PRIVATE(TClass, PrettyName, TFlags, __FILE__, __LINE__) \ |
| 60 | + };\ |
| 61 | + namespace\ |
| 62 | + {\ |
| 63 | + TClass TClass##AutomationSpecInstance( TEXT(#TClass) );\ |
| 64 | + } |
| 65 | + |
| 66 | + #define BEGIN_TESTSPEC( TClass, PrettyName, TFlags ) \ |
| 67 | + BEGIN_TESTSPEC_PRIVATE(TClass, PrettyName, TFlags, __FILE__, __LINE__) |
| 68 | + |
| 69 | + #define END_TESTSPEC( TClass ) \ |
| 70 | + };\ |
| 71 | + namespace\ |
| 72 | + {\ |
| 73 | + TClass TClass##AutomationSpecInstance( TEXT(#TClass) );\ |
| 74 | + } |
| 75 | +#endif |
| 76 | + |
0 commit comments