// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. #pragma once #include "FunctionalTest.generated.h" UENUM() namespace EFunctionalTestResult { enum Type { Invalid, Error, Running, Failed, Succeeded, }; } DECLARE_DYNAMIC_MULTICAST_DELEGATE(FFunctionalTestEventSignature); DECLARE_DELEGATE_OneParam(FFunctionalTestDoneSignature, class AFunctionalTest*); UCLASS(Blueprintable, MinimalAPI) class AFunctionalTest : public AActor { GENERATED_UCLASS_BODY() static const uint32 DefaultTimeLimit = 60; // seconds UPROPERTY() TSubobjectPtr SpriteComponent; UPROPERTY(BlueprintReadWrite, Category=FunctionalTesting) TEnumAsByte Result; /** If test is limited by time this is the result that will be returned when time runs out */ UPROPERTY(EditAnywhere, Category=FunctionalTesting) TEnumAsByte TimesUpResult; /** Test's time limit. '0' means no limit */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=FunctionalTesting) float TimeLimit; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=FunctionalTesting) FText TimesUpMessage; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=FunctionalTesting) AActor* ObservationPoint; /** Called when the test is started */ UPROPERTY(BlueprintAssignable) FFunctionalTestEventSignature OnTestStart; /** Called when the test is finished. Use it to clean up */ UPROPERTY(BlueprintAssignable) FFunctionalTestEventSignature OnTestFinished; UPROPERTY(Transient) TArray AutoDestroyActors; FString FailureMessage; #if WITH_EDITORONLY_DATA UPROPERTY() class UFuncTestRenderingComponent* RenderComp; #endif // WITH_EDITORONLY_DATA UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=FunctionalTesting) uint32 bIsEnabled:1; public: virtual bool StartTest(const TArray& Params = TArray()); UFUNCTION(BlueprintCallable, Category="Development") virtual void FinishTest(TEnumAsByte TestResult, const FString& Message); UFUNCTION(BlueprintCallable, Category="Development") virtual void LogMessage(const FString& Message); UFUNCTION(BlueprintCallable, Category="Development") virtual void SetTimeLimit(float NewTimeLimit, TEnumAsByte ResultWhenTimeRunsOut); /** retrieves information whether test wants to have another run just after finishing */ UFUNCTION(BlueprintImplementableEvent, Category="FunctionalTesting") virtual bool WantsToRunAgain() const; UFUNCTION(BlueprintImplementableEvent, Category = "FunctionalTesting") virtual FString GetAdditionalTestFinishedMessage(EFunctionalTestResult::Type TestResult) const; /** ACtors registered this way will be automatically destroyed (by limiting their lifespan) * on test finish */ UFUNCTION(BlueprintCallable, Category="Development", meta=(Keywords = "Delete")) virtual void RegisterAutoDestroyActor(AActor* ActorToAutoDestroy); /** Called to clean up when tests is removed from the list of active tests after finishing execution. * Note that FinishTest gets called after every "cycle" of a test (where further cycles are enabled by * WantsToRunAgain calls). CleanUp gets called when all cycles are done. */ virtual void CleanUp(); virtual FString GetReproString() const { return GetFName().ToString(); } #if WITH_EDITOR void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override; #endif // WITH_EDITOR // AActor interface begin virtual void Tick(float DeltaSeconds) override; // AActor interface end bool IsSuccessful() const { return Result == EFunctionalTestResult::Succeeded; } protected: void GoToObservationPoint(); public: FFunctionalTestDoneSignature TestFinishedObserver; protected: uint32 bIsRunning; float TotalTime; };