2016-01-07 08:17:16 -05:00
|
|
|
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "AutomationWorkerPrivatePCH.h"
|
|
|
|
|
|
2015-08-19 16:16:04 -04:00
|
|
|
#if WITH_EDITOR
|
|
|
|
|
#include "AssetRegistryModule.h"
|
|
|
|
|
#endif
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "AutomationTest"
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_MODULE(FAutomationWorkerModule, AutomationWorker);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* IModuleInterface interface
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::StartupModule()
|
|
|
|
|
{
|
|
|
|
|
Initialize();
|
2015-04-28 02:55:47 -04:00
|
|
|
|
|
|
|
|
FAutomationTestFramework::GetInstance().PreTestingEvent.AddRaw(this, &FAutomationWorkerModule::HandlePreTestingEvent);
|
|
|
|
|
FAutomationTestFramework::GetInstance().PostTestingEvent.AddRaw(this, &FAutomationWorkerModule::HandlePostTestingEvent);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2015-04-28 02:55:47 -04:00
|
|
|
void FAutomationWorkerModule::ShutdownModule()
|
|
|
|
|
{
|
|
|
|
|
FAutomationTestFramework::GetInstance().PreTestingEvent.RemoveAll(this);
|
|
|
|
|
FAutomationTestFramework::GetInstance().PostTestingEvent.RemoveAll(this);
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
bool FAutomationWorkerModule::SupportsDynamicReloading()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* IAutomationWorkerModule interface
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::Tick()
|
|
|
|
|
{
|
|
|
|
|
//execute latent commands from the previous frame. Gives the rest of the engine a turn to tick before closing the test
|
|
|
|
|
bool bAllLatentCommandsComplete = ExecuteLatentCommands();
|
|
|
|
|
if (bAllLatentCommandsComplete)
|
|
|
|
|
{
|
|
|
|
|
//if we were running the latent commands as a result of executing a network command, report that we are now done
|
|
|
|
|
if (bExecutingNetworkCommandResults)
|
|
|
|
|
{
|
|
|
|
|
ReportNetworkCommandComplete();
|
|
|
|
|
bExecutingNetworkCommandResults = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if the controller has requested the next network command be executed
|
|
|
|
|
if (bExecuteNextNetworkCommand)
|
|
|
|
|
{
|
|
|
|
|
//execute network commands if there are any queued up and our role is appropriate
|
|
|
|
|
bool bAllNetworkCommandsComplete = ExecuteNetworkCommands();
|
|
|
|
|
if (bAllNetworkCommandsComplete)
|
|
|
|
|
{
|
|
|
|
|
ReportTestComplete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//we've now executed a network command which may have enqueued further latent actions
|
|
|
|
|
bExecutingNetworkCommandResults = true;
|
|
|
|
|
|
|
|
|
|
//do not execute anything else until expressly told to by the controller
|
|
|
|
|
bExecuteNextNetworkCommand = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (MessageEndpoint.IsValid())
|
|
|
|
|
{
|
|
|
|
|
MessageEndpoint->ProcessInbox();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ISessionManager implementation
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
bool FAutomationWorkerModule::ExecuteLatentCommands()
|
|
|
|
|
{
|
|
|
|
|
bool bAllLatentCommandsComplete = false;
|
|
|
|
|
|
|
|
|
|
if (GIsAutomationTesting)
|
|
|
|
|
{
|
|
|
|
|
// Ensure that latent automation commands have time to execute
|
|
|
|
|
bAllLatentCommandsComplete = FAutomationTestFramework::GetInstance().ExecuteLatentCommands();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bAllLatentCommandsComplete;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool FAutomationWorkerModule::ExecuteNetworkCommands()
|
|
|
|
|
{
|
|
|
|
|
bool bAllLatentCommandsComplete = false;
|
|
|
|
|
|
|
|
|
|
if (GIsAutomationTesting)
|
|
|
|
|
{
|
|
|
|
|
// Ensure that latent automation commands have time to execute
|
|
|
|
|
bAllLatentCommandsComplete = FAutomationTestFramework::GetInstance().ExecuteNetworkCommands();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bAllLatentCommandsComplete;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::Initialize()
|
|
|
|
|
{
|
|
|
|
|
if (FPlatformProcess::SupportsMultithreading())
|
|
|
|
|
{
|
|
|
|
|
// initialize messaging
|
|
|
|
|
MessageEndpoint = FMessageEndpoint::Builder("FAutomationWorkerModule")
|
|
|
|
|
.Handling<FAutomationWorkerFindWorkers>(this, &FAutomationWorkerModule::HandleFindWorkersMessage)
|
|
|
|
|
.Handling<FAutomationWorkerNextNetworkCommandReply>(this, &FAutomationWorkerModule::HandleNextNetworkCommandReplyMessage)
|
|
|
|
|
.Handling<FAutomationWorkerPing>(this, &FAutomationWorkerModule::HandlePingMessage)
|
|
|
|
|
.Handling<FAutomationWorkerResetTests>(this, &FAutomationWorkerModule::HandleResetTests)
|
|
|
|
|
.Handling<FAutomationWorkerRequestTests>(this, &FAutomationWorkerModule::HandleRequestTestsMessage)
|
|
|
|
|
.Handling<FAutomationWorkerRunTests>(this, &FAutomationWorkerModule::HandleRunTestsMessage)
|
|
|
|
|
.WithInbox();
|
|
|
|
|
|
|
|
|
|
if (MessageEndpoint.IsValid())
|
|
|
|
|
{
|
|
|
|
|
MessageEndpoint->Subscribe<FAutomationWorkerFindWorkers>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bExecuteNextNetworkCommand = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bExecuteNextNetworkCommand = false;
|
|
|
|
|
}
|
|
|
|
|
ExecutionCount = INDEX_NONE;
|
|
|
|
|
bExecutingNetworkCommandResults = false;
|
2015-10-06 15:59:09 -04:00
|
|
|
bSendAnalytics = false;
|
2015-03-18 10:26:17 -04:00
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::ReportNetworkCommandComplete()
|
|
|
|
|
{
|
|
|
|
|
if (GIsAutomationTesting)
|
|
|
|
|
{
|
2014-10-17 19:15:09 -04:00
|
|
|
MessageEndpoint->Send(new FAutomationWorkerRequestNextNetworkCommand(ExecutionCount), TestRequesterAddress);
|
2014-03-14 14:13:41 -04:00
|
|
|
if (StopTestEvent.IsBound())
|
|
|
|
|
{
|
|
|
|
|
// this is a local test; the message to continue will never arrive, so lets not wait for it
|
|
|
|
|
bExecuteNextNetworkCommand = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
/**
|
|
|
|
|
* Takes a large transport array and splits it into pieces of a desired size and returns the portion of this which is requested
|
|
|
|
|
*
|
2014-06-12 23:22:18 -04:00
|
|
|
* @param FullTransportArray The whole series of data
|
|
|
|
|
* @param CurrentChunkIndex The The chunk we are requesting
|
|
|
|
|
* @param NumToSend The maximum number of bytes we should be splitting into.
|
2014-03-14 14:13:41 -04:00
|
|
|
* @return The section of the transport array which matches our index requested
|
|
|
|
|
*/
|
|
|
|
|
TArray< uint8 > GetTransportSection( const TArray< uint8 >& FullTransportArray, const int32 NumToSend, const int32 RequestedChunkIndex )
|
|
|
|
|
{
|
|
|
|
|
TArray< uint8 > TransportArray = FullTransportArray;
|
|
|
|
|
|
|
|
|
|
if( NumToSend > 0 )
|
|
|
|
|
{
|
|
|
|
|
int32 NumToRemoveFromStart = RequestedChunkIndex * NumToSend;
|
|
|
|
|
if( NumToRemoveFromStart > 0 )
|
|
|
|
|
{
|
|
|
|
|
TransportArray.RemoveAt( 0, NumToRemoveFromStart );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32 NumToRemoveFromEnd = FullTransportArray.Num() - NumToRemoveFromStart - NumToSend;
|
|
|
|
|
if( NumToRemoveFromEnd > 0 )
|
|
|
|
|
{
|
|
|
|
|
TransportArray.RemoveAt( TransportArray.Num()-NumToRemoveFromEnd, NumToRemoveFromEnd );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TransportArray.Empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TransportArray;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::ReportTestComplete()
|
|
|
|
|
{
|
|
|
|
|
if (GIsAutomationTesting)
|
|
|
|
|
{
|
|
|
|
|
//see if there are any more network commands left to execute
|
|
|
|
|
bool bAllLatentCommandsComplete = FAutomationTestFramework::GetInstance().ExecuteLatentCommands();
|
|
|
|
|
|
|
|
|
|
//structure to track error/warning/log messages
|
|
|
|
|
FAutomationTestExecutionInfo ExecutionInfo;
|
|
|
|
|
|
|
|
|
|
bool bSuccess = FAutomationTestFramework::GetInstance().StopTest(ExecutionInfo);
|
|
|
|
|
|
|
|
|
|
if (StopTestEvent.IsBound())
|
|
|
|
|
{
|
|
|
|
|
StopTestEvent.Execute(bSuccess, TestName, ExecutionInfo);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// send the results to the controller
|
|
|
|
|
FAutomationWorkerRunTestsReply* Message = new FAutomationWorkerRunTestsReply();
|
|
|
|
|
|
|
|
|
|
Message->TestName = TestName;
|
|
|
|
|
Message->ExecutionCount = ExecutionCount;
|
|
|
|
|
Message->Success = bSuccess;
|
|
|
|
|
Message->Duration = ExecutionInfo.Duration;
|
|
|
|
|
Message->Errors = ExecutionInfo.Errors;
|
|
|
|
|
Message->Warnings = ExecutionInfo.Warnings;
|
|
|
|
|
Message->Logs = ExecutionInfo.LogItems;
|
2014-10-17 19:15:09 -04:00
|
|
|
MessageEndpoint->Send(Message, TestRequesterAddress);
|
2015-10-06 15:59:09 -04:00
|
|
|
|
|
|
|
|
if (bSendAnalytics)
|
|
|
|
|
{
|
|
|
|
|
if (!FAutomationAnalytics::IsInitialized())
|
|
|
|
|
{
|
|
|
|
|
FAutomationAnalytics::Initialize();
|
|
|
|
|
}
|
|
|
|
|
FAutomationAnalytics::FireEvent_AutomationTestResults(Message, BeautifiedTestName);
|
|
|
|
|
SendAnalyticsEvents(ExecutionInfo.AnalyticsItems);
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// reset local state
|
2014-10-17 19:15:09 -04:00
|
|
|
TestRequesterAddress.Invalidate();
|
2014-03-14 14:13:41 -04:00
|
|
|
ExecutionCount = INDEX_NONE;
|
|
|
|
|
TestName.Empty();
|
|
|
|
|
StopTestEvent.Unbind();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::SendTests( const FMessageAddress& ControllerAddress )
|
|
|
|
|
{
|
|
|
|
|
for( int32 TestIndex = 0; TestIndex < TestInfo.Num(); TestIndex++ )
|
|
|
|
|
{
|
|
|
|
|
MessageEndpoint->Send(new FAutomationWorkerRequestTestsReply(TestInfo[TestIndex].GetTestAsString(), TestInfo.Num()), ControllerAddress);
|
|
|
|
|
}
|
2015-08-28 13:23:02 -04:00
|
|
|
MessageEndpoint->Send(new FAutomationWorkerRequestTestsReplyComplete(), ControllerAddress);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* FAutomationWorkerModule callbacks
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2015-05-08 08:36:05 -04:00
|
|
|
void FAutomationWorkerModule::HandleFindWorkersMessage(const FAutomationWorkerFindWorkers& Message, const IMessageContextRef& Context)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
// Set the Instance name to be the same as the session browser. This information should be shared at some point
|
|
|
|
|
if ((Message.SessionId == FApp::GetSessionId()) && (Message.Changelist == 10000))
|
|
|
|
|
{
|
2015-05-08 08:36:05 -04:00
|
|
|
TestRequesterAddress = Context->GetSender();
|
2015-08-19 16:16:04 -04:00
|
|
|
|
|
|
|
|
#if WITH_EDITOR
|
2015-05-08 08:36:05 -04:00
|
|
|
//If the asset registry is loading assets then we'll wait for it to stop before running our automation tests.
|
|
|
|
|
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
|
|
|
|
|
if (AssetRegistryModule.Get().IsLoadingAssets())
|
|
|
|
|
{
|
|
|
|
|
if (!AssetRegistryModule.Get().OnFilesLoaded().IsBoundToObject(this))
|
|
|
|
|
{
|
|
|
|
|
AssetRegistryModule.Get().OnFilesLoaded().AddRaw(this, &FAutomationWorkerModule::SendWorkerFound);
|
|
|
|
|
GLog->Logf(ELogVerbosity::Log, TEXT("...Forcing Asset Registry Load For Automation"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2015-08-19 16:16:04 -04:00
|
|
|
#endif
|
2015-05-08 08:36:05 -04:00
|
|
|
{
|
|
|
|
|
//If the registry is not loading then we'll just go ahead and run our tests.
|
|
|
|
|
SendWorkerFound();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-16 17:44:18 -04:00
|
|
|
|
|
|
|
|
|
2015-05-08 08:36:05 -04:00
|
|
|
void FAutomationWorkerModule::SendWorkerFound()
|
|
|
|
|
{
|
|
|
|
|
FAutomationWorkerFindWorkersResponse* Response = new FAutomationWorkerFindWorkersResponse();
|
2014-05-16 17:44:18 -04:00
|
|
|
|
2015-05-08 08:36:05 -04:00
|
|
|
FString OSMajorVersionString, OSSubVersionString;
|
|
|
|
|
FPlatformMisc::GetOSVersions(OSMajorVersionString, OSSubVersionString);
|
|
|
|
|
|
|
|
|
|
FString OSVersionString = OSMajorVersionString + TEXT(" ") + OSSubVersionString;
|
|
|
|
|
FString CPUModelString = FPlatformMisc::GetCPUBrand().Trim();
|
|
|
|
|
|
|
|
|
|
Response->DeviceName = FPlatformProcess::ComputerName();
|
|
|
|
|
Response->InstanceName = FString::Printf(TEXT("%s-%i"), FPlatformProcess::ComputerName(), FPlatformProcess::GetCurrentProcessId());
|
|
|
|
|
Response->Platform = FPlatformProperties::PlatformName();
|
|
|
|
|
Response->SessionId = FApp::GetSessionId();
|
|
|
|
|
Response->OSVersionName = OSVersionString;
|
|
|
|
|
Response->ModelName = FPlatformMisc::GetDefaultDeviceProfileName();
|
|
|
|
|
Response->GPUName = FPlatformMisc::GetPrimaryGPUBrand();
|
|
|
|
|
Response->CPUModelName = CPUModelString;
|
|
|
|
|
Response->RAMInGB = FPlatformMemory::GetPhysicalGBRam();
|
2014-05-16 17:44:18 -04:00
|
|
|
#if WITH_ENGINE
|
2015-05-08 08:36:05 -04:00
|
|
|
Response->RenderModeName = AutomationCommon::GetRenderDetailsString();
|
2014-05-16 17:44:18 -04:00
|
|
|
#else
|
2015-05-08 08:36:05 -04:00
|
|
|
Response->RenderModeName = TEXT("Unknown");
|
2014-05-16 17:44:18 -04:00
|
|
|
#endif
|
|
|
|
|
|
2015-05-08 08:36:05 -04:00
|
|
|
MessageEndpoint->Send(Response, TestRequesterAddress);
|
|
|
|
|
TestRequesterAddress.Invalidate();
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::HandleNextNetworkCommandReplyMessage( const FAutomationWorkerNextNetworkCommandReply& Message, const IMessageContextRef& Context )
|
|
|
|
|
{
|
|
|
|
|
// Allow the next command to execute
|
|
|
|
|
bExecuteNextNetworkCommand = true;
|
|
|
|
|
|
|
|
|
|
// We should never be executing sub-commands of a network command when we're waiting for a cue for the next network command
|
|
|
|
|
check(bExecutingNetworkCommandResults == false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::HandlePingMessage( const FAutomationWorkerPing& Message, const IMessageContextRef& Context )
|
|
|
|
|
{
|
|
|
|
|
MessageEndpoint->Send(new FAutomationWorkerPong(), Context->GetSender());
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
void FAutomationWorkerModule::HandleResetTests( const FAutomationWorkerResetTests& Message, const IMessageContextRef& Context )
|
|
|
|
|
{
|
|
|
|
|
FAutomationTestFramework::GetInstance().ResetTests();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::HandleRequestTestsMessage( const FAutomationWorkerRequestTests& Message, const IMessageContextRef& Context )
|
|
|
|
|
{
|
2014-04-24 12:38:41 -04:00
|
|
|
FAutomationTestFramework::GetInstance().LoadTestModules();
|
2014-03-14 14:13:41 -04:00
|
|
|
FAutomationTestFramework::GetInstance().SetDeveloperDirectoryIncluded(Message.DeveloperDirectoryIncluded);
|
2015-08-28 13:23:02 -04:00
|
|
|
FAutomationTestFramework::GetInstance().SetRequestedTestFilter(Message.RequestedTestFlags);
|
2014-03-14 14:13:41 -04:00
|
|
|
FAutomationTestFramework::GetInstance().GetValidTestNames( TestInfo );
|
|
|
|
|
|
|
|
|
|
SendTests(Context->GetSender());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-04-28 02:55:47 -04:00
|
|
|
void FAutomationWorkerModule::HandlePreTestingEvent()
|
|
|
|
|
{
|
2014-03-14 14:13:41 -04:00
|
|
|
#if WITH_ENGINE
|
2015-04-28 02:55:47 -04:00
|
|
|
if (!GIsEditor && GEngine->GameViewport)
|
|
|
|
|
{
|
|
|
|
|
GEngine->GameViewport->OnScreenshotCaptured().AddRaw(this, &FAutomationWorkerModule::HandleScreenShotCaptured);
|
|
|
|
|
}
|
|
|
|
|
//Register the editor screen shot callback
|
|
|
|
|
FAutomationTestFramework::GetInstance().OnScreenshotCaptured().BindRaw(this, &FAutomationWorkerModule::HandleScreenShotCapturedWithName);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::HandlePostTestingEvent()
|
|
|
|
|
{
|
|
|
|
|
#if WITH_ENGINE
|
|
|
|
|
if (!GIsEditor && GEngine->GameViewport)
|
|
|
|
|
{
|
|
|
|
|
GEngine->GameViewport->OnScreenshotCaptured().RemoveAll(this);
|
|
|
|
|
}
|
|
|
|
|
//Register the editor screen shot callback
|
|
|
|
|
FAutomationTestFramework::GetInstance().OnScreenshotCaptured().BindRaw(this, &FAutomationWorkerModule::HandleScreenShotCapturedWithName);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if WITH_ENGINE
|
|
|
|
|
void FAutomationWorkerModule::HandleScreenShotCaptured(int32 Width, int32 Height, const TArray<FColor>& Bitmap)
|
|
|
|
|
{
|
|
|
|
|
FString Filename = FScreenshotRequest::GetFilename();
|
|
|
|
|
|
|
|
|
|
HandleScreenShotCapturedWithName(Width, Height, Bitmap, Filename);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::HandleScreenShotCapturedWithName(int32 Width, int32 Height, const TArray<FColor>& Bitmap, const FString& ScreenShotName)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-05-16 17:44:18 -04:00
|
|
|
if( FAutomationTestFramework::GetInstance().IsScreenshotAllowed() )
|
2014-05-13 12:08:56 -04:00
|
|
|
{
|
|
|
|
|
int32 NewHeight = Height;
|
|
|
|
|
int32 NewWidth = Width;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-05-13 12:08:56 -04:00
|
|
|
TArray<FColor> ScaledBitmap;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-05-13 12:08:56 -04:00
|
|
|
if( FAutomationTestFramework::GetInstance().ShouldUseFullSizeScreenshots() )
|
|
|
|
|
{
|
|
|
|
|
ScaledBitmap = Bitmap;
|
|
|
|
|
//Clear the alpha channel before saving
|
|
|
|
|
for ( int32 Index = 0; Index < Width*Height; Index++ )
|
|
|
|
|
{
|
|
|
|
|
ScaledBitmap[Index].A = 255;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//Set the thumbnail size
|
|
|
|
|
NewHeight = 128;
|
|
|
|
|
NewWidth = 256;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-05-13 12:08:56 -04:00
|
|
|
// Create and save the thumbnail
|
|
|
|
|
FImageUtils::CropAndScaleImage(Width, Height, NewWidth, NewHeight, Bitmap, ScaledBitmap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TArray<uint8> CompressedBitmap;
|
|
|
|
|
FImageUtils::CompressImageArray(NewWidth, NewHeight, ScaledBitmap, CompressedBitmap);
|
|
|
|
|
|
|
|
|
|
// Send the screen shot if we have a target
|
2014-10-17 19:15:09 -04:00
|
|
|
if( TestRequesterAddress.IsValid() )
|
2014-05-13 12:08:56 -04:00
|
|
|
{
|
|
|
|
|
FAutomationWorkerScreenImage* Message = new FAutomationWorkerScreenImage();
|
|
|
|
|
|
|
|
|
|
FString SFilename = ScreenShotName;
|
|
|
|
|
Message->ScreenShotName = SFilename;
|
|
|
|
|
Message->ScreenImage = CompressedBitmap;
|
2014-10-17 19:15:09 -04:00
|
|
|
MessageEndpoint->Send(Message, TestRequesterAddress);
|
2014-05-13 12:08:56 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//Save locally
|
|
|
|
|
const bool bTree = true;
|
|
|
|
|
const FString FileName = FPaths::RootDir() + ScreenShotName;
|
|
|
|
|
IFileManager::Get().MakeDirectory( *FPaths::GetPath(FileName), bTree );
|
|
|
|
|
FFileHelper::SaveArrayToFile( CompressedBitmap, *FileName );
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
void FAutomationWorkerModule::HandleRunTestsMessage( const FAutomationWorkerRunTests& Message, const IMessageContextRef& Context )
|
|
|
|
|
{
|
|
|
|
|
ExecutionCount = Message.ExecutionCount;
|
|
|
|
|
TestName = Message.TestName;
|
2015-10-06 15:59:09 -04:00
|
|
|
BeautifiedTestName = Message.BeautifiedTestName;
|
|
|
|
|
bSendAnalytics = Message.bSendAnalytics;
|
2014-10-17 19:15:09 -04:00
|
|
|
TestRequesterAddress = Context->GetSender();
|
2014-05-13 12:08:56 -04:00
|
|
|
FAutomationTestFramework::GetInstance().SetScreenshotOptions(Message.bScreenshotsEnabled, Message.bUseFullSizeScreenShots);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
// Always allow the first network command to execute
|
|
|
|
|
bExecuteNextNetworkCommand = true;
|
|
|
|
|
|
|
|
|
|
// We are not executing network command sub-commands right now
|
|
|
|
|
bExecutingNetworkCommandResults = false;
|
|
|
|
|
|
|
|
|
|
FAutomationTestFramework::GetInstance().StartTestByName(Message.TestName, Message.RoleIndex);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 23:22:18 -04:00
|
|
|
|
2015-10-06 15:59:09 -04:00
|
|
|
//dispatches analytics events to the data collector
|
|
|
|
|
void FAutomationWorkerModule::SendAnalyticsEvents(TArray<FString>& InAnalyticsItems)
|
|
|
|
|
{
|
|
|
|
|
for (int32 i = 0; i < InAnalyticsItems.Num(); ++i)
|
|
|
|
|
{
|
|
|
|
|
FString EventString = InAnalyticsItems[i];
|
|
|
|
|
if( EventString.EndsWith( TEXT( ",PERF" ) ) )
|
|
|
|
|
{
|
|
|
|
|
// Chop the ",PERF" off the end
|
|
|
|
|
EventString = EventString.Left( EventString.Len() - 5 );
|
|
|
|
|
|
|
|
|
|
FAutomationPerformanceSnapshot PerfSnapshot;
|
|
|
|
|
PerfSnapshot.FromCommaDelimitedString( EventString );
|
|
|
|
|
|
|
|
|
|
RecordPerformanceAnalytics( PerfSnapshot );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FAutomationWorkerModule::RecordPerformanceAnalytics( const FAutomationPerformanceSnapshot& PerfSnapshot )
|
|
|
|
|
{
|
|
|
|
|
// @todo: Pass in additional performance capture data from incoming FAutomationPerformanceSnapshot!
|
|
|
|
|
|
|
|
|
|
FAutomationAnalytics::FireEvent_FPSCapture(PerfSnapshot);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE
|