2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# pragma once
2014-06-25 05:47:19 -04:00
# include "GameFramework/Actor.h"
2014-11-11 10:35:51 -05:00
# include "Math/RandomStream.h"
2014-03-14 14:13:41 -04:00
# include "FunctionalTest.generated.h"
2014-06-25 05:47:19 -04:00
class UBillboardComponent ;
2014-03-14 14:13:41 -04:00
UENUM ( )
namespace EFunctionalTestResult
{
enum Type
{
Invalid ,
Error ,
Running ,
Failed ,
Succeeded ,
} ;
}
DECLARE_DYNAMIC_MULTICAST_DELEGATE ( FFunctionalTestEventSignature ) ;
DECLARE_DELEGATE_OneParam ( FFunctionalTestDoneSignature , class AFunctionalTest * ) ;
2014-09-03 09:56:49 -04:00
UCLASS ( Blueprintable , MinimalAPI )
2014-03-14 14:13:41 -04:00
class AFunctionalTest : public AActor
{
2015-03-17 05:38:32 -04:00
GENERATED_UCLASS_BODY ( )
2014-03-14 14:13:41 -04:00
static const uint32 DefaultTimeLimit = 60 ; // seconds
2014-10-30 17:10:56 -04:00
private_subobject :
DEPRECATED_FORGAME ( 4.6 , " SpriteComponent should not be accessed directly, please use GetSpriteComponent() function instead. SpriteComponent will soon be private and your code will not compile. " )
2014-03-14 14:13:41 -04:00
UPROPERTY ( )
2014-10-16 09:02:30 -04:00
UBillboardComponent * SpriteComponent ;
public :
2014-03-14 14:13:41 -04:00
UPROPERTY ( BlueprintReadWrite , Category = FunctionalTesting )
TEnumAsByte < EFunctionalTestResult : : Type > Result ;
/** If test is limited by time this is the result that will be returned when time runs out */
UPROPERTY ( EditAnywhere , Category = FunctionalTesting )
TEnumAsByte < EFunctionalTestResult : : Type > TimesUpResult ;
/** Test's time limit. '0' means no limit */
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = FunctionalTesting )
float TimeLimit ;
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = FunctionalTesting )
FText TimesUpMessage ;
2014-06-09 11:13:04 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = FunctionalTesting )
AActor * ObservationPoint ;
2014-03-14 14:13:41 -04:00
/** 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 < AActor * > AutoDestroyActors ;
2014-06-09 11:13:04 -04:00
2014-04-23 19:29:53 -04:00
FString FailureMessage ;
2014-11-11 10:35:51 -05:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = FunctionalTesting )
FRandomStream RandomNumbersStream ;
2015-03-11 11:02:39 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = FunctionalTesting )
FString Description ;
2014-03-14 14:13:41 -04:00
# if WITH_EDITORONLY_DATA
UPROPERTY ( )
class UFuncTestRenderingComponent * RenderComp ;
# endif // WITH_EDITORONLY_DATA
UPROPERTY ( EditAnywhere , BlueprintReadOnly , Category = FunctionalTesting )
2014-04-23 19:29:53 -04:00
uint32 bIsEnabled : 1 ;
public :
2014-03-14 14:13:41 -04:00
2014-06-17 08:31:02 -04:00
virtual bool StartTest ( const TArray < FString > & Params = TArray < FString > ( ) ) ;
2014-03-14 14:13:41 -04:00
UFUNCTION ( BlueprintCallable , Category = " Development " )
virtual void FinishTest ( TEnumAsByte < EFunctionalTestResult : : Type > TestResult , const FString & Message ) ;
UFUNCTION ( BlueprintCallable , Category = " Development " )
virtual void LogMessage ( const FString & Message ) ;
UFUNCTION ( BlueprintCallable , Category = " Development " )
virtual void SetTimeLimit ( float NewTimeLimit , TEnumAsByte < EFunctionalTestResult : : Type > ResultWhenTimeRunsOut ) ;
2015-03-11 11:02:39 -04:00
/** Used by debug drawing to gather actors this test is using and point at them on the level to better understand test's setup */
UFUNCTION ( BlueprintImplementableEvent , Category = " FunctionalTesting " )
2015-03-18 17:50:49 -04:00
TArray < AActor * > DebugGatherRelevantActors ( ) const ;
2015-03-11 11:02:39 -04:00
virtual void GatherRelevantActors ( TArray < AActor * > & OutActors ) const ;
2014-04-23 19:29:53 -04:00
/** retrieves information whether test wants to have another run just after finishing */
UFUNCTION ( BlueprintImplementableEvent , Category = " FunctionalTesting " )
2015-03-18 12:16:37 -04:00
bool OnWantsReRunCheck ( ) const ;
virtual bool WantsToRunAgain ( ) const { return false ; }
2014-04-23 19:29:53 -04:00
UFUNCTION ( BlueprintImplementableEvent , Category = " FunctionalTesting " )
2015-03-18 12:16:37 -04:00
FString OnAdditionalTestFinishedMessageRequest ( EFunctionalTestResult : : Type TestResult ) const ;
virtual FString GetAdditionalTestFinishedMessage ( EFunctionalTestResult : : Type TestResult ) const { return FString ( ) ; }
2014-04-23 19:29:53 -04:00
2014-03-14 14:13:41 -04:00
/** 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 ) ;
2014-04-23 19:29:53 -04:00
/** 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 ( ) ;
2014-06-17 08:31:02 -04:00
virtual FString GetReproString ( ) const { return GetFName ( ) . ToString ( ) ; }
2014-03-14 14:13:41 -04:00
# if WITH_EDITOR
2014-06-13 06:14:46 -04:00
void PostEditChangeProperty ( struct FPropertyChangedEvent & PropertyChangedEvent ) override ;
2015-03-11 11:02:39 -04:00
static void OnSelectObject ( UObject * NewSelection ) ;
2014-03-14 14:13:41 -04:00
# endif // WITH_EDITOR
// AActor interface begin
2014-06-13 06:14:46 -04:00
virtual void Tick ( float DeltaSeconds ) override ;
2014-06-25 05:47:19 -04:00
virtual void EndPlay ( const EEndPlayReason : : Type EndPlayReason ) override ;
2014-03-14 14:13:41 -04:00
// AActor interface end
2014-06-16 15:57:17 -04:00
bool IsSuccessful ( ) const { return Result = = EFunctionalTestResult : : Succeeded ; }
2014-06-16 09:55:19 -04:00
2014-06-09 11:13:04 -04:00
protected :
void GoToObservationPoint ( ) ;
public :
2014-03-14 14:13:41 -04:00
FFunctionalTestDoneSignature TestFinishedObserver ;
protected :
uint32 bIsRunning ;
2014-06-06 06:27:44 -04:00
float TotalTime ;
2014-10-16 09:02:30 -04:00
public :
/** Returns SpriteComponent subobject **/
2014-10-30 17:10:56 -04:00
UBillboardComponent * GetSpriteComponent ( ) ;
2014-10-16 09:02:30 -04:00
} ;