Files
UnrealEngineUWP/Engine/Source/Developer/FunctionalTesting/Classes/ScreenshotFunctionalTestBase.h
andrew grant 7e92fd2998 More complete fix for UE-89839
Added a high level define (WITH_AUTOMATION_TESTS) that is set when thier WITH_DEV_AUTOMATION_TESTS or WITH_PERF_AUTOMATION_TESTS is set).

This allows support code to be wrapped in a single define and the WITH_DEV / WITH_PERF macros used for simply including/excluding test definitions.

#jira UE-89839
#rb na
#tests compiled UE4Game in dev/test/shipping

#ROBOMERGE-SOURCE: CL 11843115 in //UE4/Release-4.25/... via CL 11843116
#ROBOMERGE-BOT: RELEASE (Release-4.25Plus -> Main) (v656-11643781)

[CL 11843119 by andrew grant in Main branch]
2020-03-02 15:00:13 -05:00

84 lines
2.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "FunctionalTest.h"
#include "AutomationScreenshotOptions.h"
#include "Misc/AutomationTest.h"
#include "ScreenshotFunctionalTestBase.generated.h"
class FAutomationTestScreenshotEnvSetup;
/**
* Base class for screenshot functional test
*/
UCLASS(Blueprintable, abstract)
class FUNCTIONALTESTING_API AScreenshotFunctionalTestBase : public AFunctionalTest
{
GENERATED_BODY()
public:
AScreenshotFunctionalTestBase(const FObjectInitializer& ObjectInitializer);
#if WITH_EDITOR
virtual bool CanEditChange(const FProperty* InProperty) const override;
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif
virtual void Serialize(FArchive& Ar) override;
protected:
// Set player view target to screenshot camera and call PrepareForScreenshot
virtual void PrepareTest() override;
// Handle screenshot delay
virtual bool IsReady_Implementation() override;
// Register OnScreenshotTakenAndCompared and call RequestScreenshot
virtual void StartTest() override;
// Call RestoreViewport and finish this test
virtual void OnScreenshotTakenAndCompared();
// Resize viewport to screenshot size (if possible) and set up screenshot environment (disable AA, etc.)
void PrepareForScreenshot();
// Doesn't actually request in base class. It simply register OnScreenshotCaptured
virtual void RequestScreenshot();
// Pass screenshot pixels and meta data to FAutomationTestFramework. Register
// OnComparisonComplete which will be called the automation test system when
// screenshot comparison is complete
void OnScreenShotCaptured(int32 InSizeX, int32 InSizeY, const TArray<FColor>& InImageData);
// Do some logging and trigger OnScreenshotTakenAndCompared
void OnComparisonComplete(const FAutomationScreenshotCompareResults& CompareResults);
// Restore viewport size and original environment settings
void RestoreViewSettings();
protected:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Screenshot", meta = (MultiLine = "true"))
FString Notes;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Screenshot")
class UCameraComponent* ScreenshotCamera;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Screenshot", SimpleDisplay)
FAutomationScreenshotOptions ScreenshotOptions;
FIntPoint ViewportRestoreSize;
#if WITH_AUTOMATION_TESTS
TSharedPtr<FAutomationTestScreenshotEnvSetup> ScreenshotEnvSetup;
#endif
private:
bool bNeedsViewSettingsRestore;
bool bNeedsViewportRestore;
};