2019-12-26 15:32:37 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-05-01 21:54:46 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "Misc/AutomationTest.h"
|
|
|
|
|
|
|
|
|
|
/**
|
2024-06-25 18:34:35 -04:00
|
|
|
* Base class for Functional test cases.
|
2019-05-01 21:54:46 -04:00
|
|
|
*/
|
2023-09-23 14:10:24 -04:00
|
|
|
class FFunctionalTestBase : public FAutomationTestBase
|
2019-05-01 21:54:46 -04:00
|
|
|
{
|
|
|
|
|
public:
|
2023-09-23 14:10:24 -04:00
|
|
|
FUNCTIONALTESTING_API FFunctionalTestBase(const FString& InName, const bool bInComplexTask);
|
2019-05-01 21:54:46 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If true logs will not be included in test events
|
|
|
|
|
*
|
|
|
|
|
* @return true to suppress logs
|
|
|
|
|
*/
|
2024-06-25 18:34:35 -04:00
|
|
|
FUNCTIONALTESTING_API virtual bool SuppressLogs();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should the log category be captured and surfaced as part of the test.
|
|
|
|
|
*
|
|
|
|
|
* @return true to allow a log category through.
|
|
|
|
|
*/
|
|
|
|
|
FUNCTIONALTESTING_API virtual bool ShouldCaptureLogCategory(const class FName& Category) const;
|
|
|
|
|
|
2019-05-01 21:54:46 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Specify how log errors & warnings should be handled during tests. If values are not set then the project
|
|
|
|
|
* defaults will be used.
|
|
|
|
|
*/
|
2020-06-23 18:40:00 -04:00
|
|
|
void SetLogErrorAndWarningHandling(TOptional<bool> InSuppressErrors, TOptional<bool> InSuppressWarnings, TOptional<bool> InWarningsAreErrors)
|
2019-05-01 21:54:46 -04:00
|
|
|
{
|
|
|
|
|
SetLogErrorAndWarningHandlingToDefault();
|
2020-03-03 09:51:07 -05:00
|
|
|
|
2020-06-23 18:40:00 -04:00
|
|
|
if (InSuppressErrors.IsSet())
|
2020-03-03 09:51:07 -05:00
|
|
|
{
|
2020-06-23 18:40:00 -04:00
|
|
|
bSuppressLogErrors = InSuppressErrors.GetValue();
|
2020-03-03 09:51:07 -05:00
|
|
|
}
|
|
|
|
|
|
2020-06-23 18:40:00 -04:00
|
|
|
if (InSuppressWarnings.IsSet())
|
2020-03-03 09:51:07 -05:00
|
|
|
{
|
2020-06-23 18:40:00 -04:00
|
|
|
bSuppressLogWarnings = InSuppressWarnings.GetValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (InWarningsAreErrors.IsSet())
|
|
|
|
|
{
|
|
|
|
|
bElevateLogWarningsToErrors = InWarningsAreErrors.GetValue();
|
2020-03-03 09:51:07 -05:00
|
|
|
}
|
2023-12-04 17:33:28 -05:00
|
|
|
}
|
2019-05-01 21:54:46 -04:00
|
|
|
|
|
|
|
|
/**
|
2020-06-23 18:40:00 -04:00
|
|
|
* Determines if Error logs should be suppressed from test results
|
2019-05-01 21:54:46 -04:00
|
|
|
*/
|
2020-06-23 18:40:00 -04:00
|
|
|
virtual bool SuppressLogErrors() override
|
2019-05-01 21:54:46 -04:00
|
|
|
{
|
2020-06-23 18:40:00 -04:00
|
|
|
return bSuppressLogErrors;
|
2019-05-01 21:54:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-06-23 18:40:00 -04:00
|
|
|
* Determines if Warning logs should be suppressed from test results
|
2019-05-01 21:54:46 -04:00
|
|
|
*/
|
2020-06-23 18:40:00 -04:00
|
|
|
virtual bool SuppressLogWarnings() override
|
2019-05-01 21:54:46 -04:00
|
|
|
{
|
2020-06-23 18:40:00 -04:00
|
|
|
return bSuppressLogWarnings;
|
2019-05-01 21:54:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-06-23 18:40:00 -04:00
|
|
|
* Determines if Warning logs should be treated as errors
|
2019-05-01 21:54:46 -04:00
|
|
|
*/
|
2020-06-23 18:40:00 -04:00
|
|
|
virtual bool ElevateLogWarningsToErrors() override
|
2019-05-01 21:54:46 -04:00
|
|
|
{
|
2020-06-23 18:40:00 -04:00
|
|
|
return bElevateLogWarningsToErrors;
|
2019-05-01 21:54:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Marks us as actively running a functional test
|
|
|
|
|
*/
|
2023-09-23 14:10:24 -04:00
|
|
|
FUNCTIONALTESTING_API void SetFunctionalTestRunning(const FString& InName);
|
2020-06-23 18:40:00 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Marks us as no longer running a test
|
|
|
|
|
*/
|
2023-09-23 14:10:24 -04:00
|
|
|
FUNCTIONALTESTING_API void SetFunctionalTestComplete(const FString& InName);
|
2020-06-23 18:40:00 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the name of the running functional test. Empty if no test is running
|
|
|
|
|
*/
|
2023-12-04 17:33:28 -05:00
|
|
|
FUNCTIONALTESTING_API static FString GetRunningTestName() { return ActiveTestName; }
|
2020-06-23 18:40:00 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if a functional test is running (does not include map setup)
|
|
|
|
|
*/
|
2024-06-25 18:34:35 -04:00
|
|
|
FUNCTIONALTESTING_API static bool IsFunctionalTestRunning() { return bIsFunctionalTestRunning; }
|
2019-05-01 21:54:46 -04:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
2023-12-04 17:33:28 -05:00
|
|
|
FUNCTIONALTESTING_API void SetLogErrorAndWarningHandlingToDefault();
|
2019-05-01 21:54:46 -04:00
|
|
|
|
2020-06-23 18:40:00 -04:00
|
|
|
bool bSuppressLogErrors;
|
|
|
|
|
bool bSuppressLogWarnings;
|
|
|
|
|
bool bElevateLogWarningsToErrors;
|
2019-05-01 21:54:46 -04:00
|
|
|
bool bSuppressLogs;
|
2020-06-23 18:40:00 -04:00
|
|
|
|
2023-12-04 17:33:28 -05:00
|
|
|
private:
|
|
|
|
|
|
2024-03-12 16:04:01 -04:00
|
|
|
FUNCTIONALTESTING_API static bool bIsFunctionalTestRunning;
|
2020-06-23 18:40:00 -04:00
|
|
|
static FString ActiveTestName;
|
2019-05-01 21:54:46 -04:00
|
|
|
};
|