Files
UnrealEngineUWP/Engine/Source/Developer/FunctionalTesting/Private/ScreenshotFunctionalTest.cpp
Nick Darnell 22de597494 Copying //UE4/Dev-Automation to //UE4/Dev-Main (Source: //UE4/Dev-Automation @ 3502919)
#lockdown Nick.Penwarden
#rb none

=====================================
 MAJOR FEATURES + CHANGES
=====================================

Change 3487931 by Adric.Worley

	Add Negative test filter

	Filter out tests that test negative cases and are expected to fail

	#jira UE-45641
	#tests ran affected tests in editor, confirmed UI changes

Change 3491768 by Adric.Worley

	Add FieldOfView to Screenshot FTest options

	#tests used in WIP test map

Change 3492809 by Nick.Darnell

	Automation - Fixing some delay screenshot code in the Screenshot Functional Test Actor.

Change 3493557 by Adric.Worley

	Add automated postprocessing test map
	#jira QAENG-1153

Change 3494836 by Adric.Worley

	Fix CurvePlayTest timing out

	Time-out tolerances were set too tightly. Extended preparation time limit to 7 seconds.

	#tests PIE

Change 3494962 by Adric.Worley

	Fix CurveStopTest failure

	Added OnTestPrepare event for FTests using LevelBP for logic.
	Removed CurveStopTest dependency on CurveStartTest.
	Updated ground truth screenshot.

	#tests PIE

Change 3495166 by Adric.Worley

	Fix empty engine version content warnings

	#tests none

Change 3495412 by Adric.Worley

	Add Shield asset from ContentExamples project

Change 3495747 by Adric.Worley

	Automate static light tests
	#jira QAENG-1154

Change 3495914 by Adric.Worley

	Adding HDR environment asset

Change 3496341 by Adric.Worley

	Fix NotifyTest timing failures

	Rewrote tests to use blueprint events to verify notifications instead of fragile screenshots.

	#tests UFE

Change 3496613 by Adric.Worley

	Add TranslucencyLightingModes test map

	Automates test cases from QAGame's TM-TranslucencyLightingModes.
	Also resave shield assets to fix empty engine version warnings.

	#jira QAENG-1191
	#tests UFE

Change 3496703 by Adric.Worley

	Fix occasional ClothBallTest failures

	Extend screenshot delay to let cloth to fully settle.
	Consolidated screenshot delay values and removed redundant Delays.

	#jira UE-46066
	#tests UFE, 20+ iterations

Change 3498413 by Adric.Worley

	Fix occasional CurveTest failures

	Merged tests and set to use specific anim positions instead of relying on fragile test timing.

	#tests UFE

Change 3498976 by Adric.Worley

	Add automated ShaderModels test map

Change 3499079 by Adric.Worley

	Delete unused test and related assets

	#tests UFE

Change 3500869 by Adric.Worley

	Add horizontal scrollbar to automation results view

	#tests UFE

[CL 3511418 by Nick Darnell in Main branch]
2017-06-27 10:18:29 -04:00

103 lines
3.0 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "ScreenshotFunctionalTest.h"
#include "Engine/GameViewportClient.h"
#include "AutomationBlueprintFunctionLibrary.h"
#include "Camera/CameraComponent.h"
#include "Camera/PlayerCameraManager.h"
#include "Kismet/GameplayStatics.h"
#include "Engine/Engine.h"
#include "EngineGlobals.h"
#include "Misc/AutomationTest.h"
AScreenshotFunctionalTest::AScreenshotFunctionalTest( const FObjectInitializer& ObjectInitializer )
: AFunctionalTest(ObjectInitializer)
, ScreenshotOptions(EComparisonTolerance::Low)
{
ScreenshotCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
ScreenshotCamera->SetupAttachment(RootComponent);
FieldOfView = ScreenshotCamera->FieldOfView;
}
void AScreenshotFunctionalTest::PrepareTest()
{
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
PlayerController->SetViewTarget(this, FViewTargetTransitionParams());
// It's possible the defaults for certain tolerance levels have changed, so reset them on test start.
ScreenshotOptions.SetToleranceAmounts(ScreenshotOptions.Tolerance);
Super::PrepareTest();
}
bool AScreenshotFunctionalTest::IsReady_Implementation()
{
if ( (GetWorld()->GetTimeSeconds() - RunTime) > ScreenshotOptions.Delay )
{
return ( GFrameNumber - RunFrame ) > 5;
}
return false;
}
void AScreenshotFunctionalTest::StartTest()
{
Super::StartTest();
UAutomationBlueprintFunctionLibrary::TakeAutomationScreenshotInternal(this, GetName(), ScreenshotOptions);
FAutomationTestFramework::Get().OnScreenshotTakenAndCompared.AddUObject(this, &AScreenshotFunctionalTest::OnScreenshotTakenAndCompared);
}
void AScreenshotFunctionalTest::OnScreenshotTakenAndCompared()
{
FAutomationTestFramework::Get().OnScreenshotTakenAndCompared.RemoveAll(this);
FinishTest(EFunctionalTestResult::Succeeded, TEXT(""));
}
#if WITH_EDITOR
bool AScreenshotFunctionalTest::CanEditChange(const UProperty* InProperty) const
{
bool bIsEditable = Super::CanEditChange(InProperty);
if ( bIsEditable && InProperty )
{
const FName PropertyName = InProperty->GetFName();
if ( PropertyName == GET_MEMBER_NAME_CHECKED(FAutomationScreenshotOptions, ToleranceAmount) )
{
bIsEditable = ScreenshotOptions.Tolerance == EComparisonTolerance::Custom;
}
else if ( PropertyName == TEXT("ObservationPoint") )
{
// You can't ever observe from anywhere but the camera on the screenshot test.
bIsEditable = false;
}
}
return bIsEditable;
}
void AScreenshotFunctionalTest::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
if ( PropertyChangedEvent.Property )
{
const FName PropertyName = PropertyChangedEvent.Property->GetFName();
if ( PropertyName == GET_MEMBER_NAME_CHECKED(FAutomationScreenshotOptions, Tolerance) )
{
ScreenshotOptions.SetToleranceAmounts(ScreenshotOptions.Tolerance);
}
else if (PropertyName == GET_MEMBER_NAME_CHECKED(AScreenshotFunctionalTest, FieldOfView))
{
ScreenshotCamera->SetFieldOfView(FieldOfView);
}
}
}
#endif