Files
UnrealEngineUWP/Engine/Source/Developer/AutomationDriver/Private/AutomationDriverModule.cpp
josh engebretson bd7a9ca444 Fix automation driver module message handling
#jira UE-90136
#rb justin.sargent

#ROBOMERGE-SOURCE: CL 11937646 in //UE4/Release-4.25/... via CL 11937648
#ROBOMERGE-BOT: RELEASE (Release-4.25Plus -> Main) (v656-11643781)

[CL 11937669 by josh engebretson in Main branch]
2020-03-05 09:53:10 -05:00

96 lines
2.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "IAutomationDriverModule.h"
#include "PassThroughMessageHandler.h"
#include "AutomatedApplication.h"
#include "AutomationDriver.h"
#include "Framework/Application/SlateApplication.h"
class FAutomationDriverModule
: public IAutomationDriverModule
{
public:
virtual void StartupModule() override
{
}
virtual void ShutdownModule() override
{
}
virtual TSharedRef<IAutomationDriver, ESPMode::ThreadSafe> CreateDriver() const override
{
return FAutomationDriverFactory::Create(AutomatedApplication.Get());
}
virtual TSharedRef<IAutomationDriver, ESPMode::ThreadSafe> CreateDriver(const TSharedRef<FDriverConfiguration, ESPMode::ThreadSafe>& Configuration) const override
{
return FAutomationDriverFactory::Create(AutomatedApplication.Get(), Configuration);
}
virtual TSharedRef<IAsyncAutomationDriver, ESPMode::ThreadSafe> CreateAsyncDriver() const override
{
return FAsyncAutomationDriverFactory::Create(AutomatedApplication.Get());
}
virtual TSharedRef<IAsyncAutomationDriver, ESPMode::ThreadSafe> CreateAsyncDriver(const TSharedRef<FDriverConfiguration, ESPMode::ThreadSafe>& Configuration) const override
{
return FAsyncAutomationDriverFactory::Create(AutomatedApplication.Get(), Configuration);
}
virtual bool IsEnabled() const override
{
return AutomatedApplication.IsValid();
}
virtual void Enable() override
{
if (AutomatedApplication.IsValid())
{
return;
}
RealApplication = FSlateApplication::Get().GetPlatformApplication();
RealMessageHandler = RealApplication->GetMessageHandler();
AutomatedApplication = FAutomatedApplicationFactory::Create(
RealApplication.ToSharedRef(),
FPassThroughMessageHandlerFactoryFactory::Create());
if (AutomatedApplication.IsValid())
{
AutomatedApplication->AllowPlatformMessageHandling();
}
FSlateApplication::Get().SetPlatformApplication(AutomatedApplication.ToSharedRef());
}
virtual void Disable() override
{
if (!AutomatedApplication.IsValid())
{
return;
}
AutomatedApplication->DisablePlatformMessageHandling();
FSlateApplication::Get().SetPlatformApplication(RealApplication.ToSharedRef());
RealApplication->SetMessageHandler(RealMessageHandler.ToSharedRef());
AutomatedApplication.Reset();
RealApplication.Reset();
RealMessageHandler.Reset();
}
private:
TSharedPtr<FAutomatedApplication> AutomatedApplication;
TSharedPtr<GenericApplication> RealApplication;
TSharedPtr<FGenericApplicationMessageHandler> RealMessageHandler;
};
IMPLEMENT_MODULE(FAutomationDriverModule, AutomationDriver);