Files
UnrealEngineUWP/Engine/Source/Developer/AutomationDriver/Private/AutomationDriverModule.cpp
ryan durand 471d972e62 Updating copyright for Engine Developer.
#rnx
#rb none


#ROBOMERGE-SOURCE: CL 10869240 via CL 10869516 via CL 10869902
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870584 by ryan durand in Main branch]
2019-12-26 15:32:37 -05:00

89 lines
2.4 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());
FSlateApplication::Get().SetPlatformApplication(AutomatedApplication.ToSharedRef());
}
virtual void Disable() override
{
if (!AutomatedApplication.IsValid())
{
return;
}
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);