Files
sebastian lewicki 695acb1980 Upgrading the CQTest plugin to an Engine module
Introducing the CQTestEnhancedInput plugin as this requires use of the EnhancedInput Engine Plugin (Engine modules cannot make use of the Engine Plugin)
#jira UE-217806
#rb Devin.Doucette, Jerome.Delattre, rob.huyett, sean.sweeney

[CL 36039088 by sebastian lewicki in ue5-main branch]
2024-09-05 10:24:20 -04:00

60 lines
1.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Components/CQTestSlateComponent.h"
#include "Framework/Application/SlateApplication.h"
#include "Tests/AutomationCommon.h"
DEFINE_LOG_CATEGORY_STATIC(LogCQTestSlateComponent, Log, All);
FCQTestSlateComponent::FCQTestSlateComponent()
{
checkf(FSlateApplication::IsInitialized(), TEXT("No Slate application initialized."));
// Disable Slate from going into a sleep state forcing it to always tick
TestEnvironment = FScopedTestEnvironment::Get();
TestEnvironment->SetConsoleVariableValue(TEXT("Slate.AllowSlateToSleep"), TEXT("0"));
TickDelegateHandle = FSlateApplication::Get().OnPostTick().AddRaw(this, &FCQTestSlateComponent::OnPostTick);
}
FCQTestSlateComponent::~FCQTestSlateComponent()
{
if (FSlateApplication::IsInitialized() && TickDelegateHandle.IsValid())
{
FSlateApplication::Get().OnPostTick().Remove(TickDelegateHandle);
}
}
bool FCQTestSlateComponent::HaveTicksElapsed(uint32 Ticks)
{
// Early out checking that 0 ticks have elapsed as there is nothing to wait for
if (Ticks == 0)
{
UE_LOG(LogCQTestSlateComponent, Verbose, TEXT("Nothing to wait for as the expected elapsed ticks requested is 0."));
return true;
}
if (!ExpectedTick.IsSet())
{
ExpectedTick = TickCounter + Ticks;
UE_LOG(LogCQTestSlateComponent, Verbose, TEXT("HaveTicksElapsed called for %d ticks."), Ticks);
UE_LOG(LogCQTestSlateComponent, Verbose, TEXT("Slate has ticked %d times."), TickCounter.load());
UE_LOG(LogCQTestSlateComponent, Verbose, TEXT("ExpectedTick set with a value of %d."), ExpectedTick.GetValue());
}
else if (ExpectedTick.GetValue() <= TickCounter)
{
UE_LOG(LogCQTestSlateComponent, Verbose, TEXT("Slate ticked %d times and has met the expected tick goal of %d ticks."), TickCounter.load(), ExpectedTick.GetValue());
ExpectedTick.Reset();
return true;
}
return false;
}
void FCQTestSlateComponent::OnPostTick(const float InDeltaTime)
{
TickCounter++;
}