Files
UnrealEngineUWP/Engine/Source/Developer/AutomationDriver/Private/DriverElement.cpp
Justin Sargent ed5e7c2b7e Copying //UE4/Portal-Staging to //UE4/Dev-Main (Source: //Portal/Main @ 3216504)
#lockdown Nick.Penwarden
#rb no one

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

Change 3216141 on 2016/11/30 by Justin.Sargent

	Completed first ready to use pass of the new AutomationDriver module and new Spec test type.

Change 3213288 on 2016/11/29 by Leigh.Swift

	#jira OPP-6353: CEF FName Javascript PROBLEM
	Removing deprecation of IWebBrowserSingleton::SetJSBindingToLoweringEnabled for now.

Change 3212796 on 2016/11/29 by Leigh.Swift

	#jira OPP-6353: CEF FName Javascript PROBLEM
	Added SetJSBindingToLoweringEnabled to IWebBrowserSingleton so that the to-lowering of binding names can be disabled.
	Deprecated SetJSBindingToLoweringEnabled since 4.15. In future the to-lowering will always occurr.
	Adding GetBindingName helper to FWebJSScripting, which returns a to-lowered name for a UField, unless disabled.
	Updated all current binding code to use GetBindingName when building from UObjects/UStructs. This affects Windows, Mac, Linux, and Android.
	Portal currently disables to-lowering unless a commandline -LowercaseJS is provided.

Change 3200370 on 2016/11/16 by Richard.Fawcett

	Ensure we always get the latest version of the user content catalog when promoting marketplace items.

Change 3192974 on 2016/11/10 by Leigh.Swift

	#jira OPP-6365: Crash during shutdown if a manifest is still being downloaded
	This is because of the OnPreExit core delegate being used to null out the Data uobject member on a manifest, also being the only sensible way to ensure threads complete in a safe and clean manner.
	Refactoring BuildPatchServices manifest class to not permanently hold any UObject and simply just use one while serialising.
	This removes the reliance on the OnPreExit delegate from manifest class, making it generally safer behaviour for shutdown.

Change 3187028 on 2016/11/04 by Leigh.Swift

	PortalPublishingTool: Adding UE_Main app to UnrealEngine project

Change 3186788 on 2016/11/04 by Richard.Fawcett

	Change C# wrapper for BuildPatchTool patch generation to prevent clobbering manifest files by default, unless we specifically pass in an optional flag to allow this.
	#jira OPP-6355

Change 3186779 on 2016/11/04 by Richard.Fawcett

	Add support to automation tool testing framework for the following assertions:
	    Assert.AreNotEqual(a, b, optionalFailureMessage)
	    Assert.ThrowsError(actionToCarryOut, expectedExceptionType, optionalExceptionMessageContainsString)

	Moved attribute-based expected exception declarations to their own attribute, TestThrowsExceptionAttribute, which can now accept an optional parameter for a string which should be contained within the exception message.

	Fixed a bug where a test method with an attribute-based expected exception would not count towards the success total if the exception was encountered as expected.

	Fixed a bug where NOT throwing an exception when we were expecting one would count as a success.

	Added an internal property bDoNotLogTestFailsAsError which we can set to true to suppress logging of UAT errors when a test fails (but still count them in our failure results), to allow us to deliberately cause test failures to test the test framework!

	Added a suite of unit tests for the test framework itself, in TestRunner.Automation.Tests.cs.

Change 3185411 on 2016/11/03 by Richard.Fawcett

	Allow Rocket_PromoteBuild changelist to be overridden by a changelist read from a file.

Change 3184843 on 2016/11/03 by Richard.Fawcett

	Ensure catalog file synced during user content generation is always the latest one.

Change 3184752 on 2016/11/03 by Richard.Fawcett

	Ensure we log reading changelist from specified file.

Change 3184744 on 2016/11/03 by Richard.Fawcett

	Ensure directory is created for Changelist file if it doesn't already exist.

Change 3184738 on 2016/11/03 by Richard.Fawcett

	Ensure we use latest CL from all of Perforce when generating build versions for user content

	Because of the nature of the build farm, where separate parts of the job are executed on different build agents at different times, this changelist is serialized to the filesystem during execution of a node dedicated to this task, and then made available to all future nodes, so that they're working with a consistent build version.  In the case of an execution where we're updating Perforce with new content, this calculation of the changelist occurs AFTER we've updated Perforce with the new content.

	Have also optimized the build graph scripts to enable Mac and Windows user generated content to execute simultaneously.

	#jira OPP-6274

Change 3181456 on 2016/11/01 by Andrew.Brown

	SExpandable area has been modified as the Portal settings mocks weren't able to be achieved with default functionality.
	Added BodyBorderImage arguement and BodyBorderBackgroundColor attribute so we can specify a different brush/color to use for the expanded area compared with the title area. Additional care was made to ensure that rounded corners still appear correctly if the developer doesn't want to specify a different look to the body.
	Added AreaTitlePadding attribute, to be able to specify padding between the expand/collapse icon and the header content.
	Added MinWidth arguement, to ensure that the areas meet a minimum width requirement.

Change 3181285 on 2016/11/01 by Richard.Fawcett

	Ensure user content generated using latest changelist submitted to Perforce, rather than using portal's latest changelist

	#jira OPP-6274

Change 3177758 on 2016/10/28 by Leigh.Swift

	#jira OPP-6247: Portal needs Social Plugin integration v1.2
	Copying //Portal/Dev-Social to Dev-Main (//Portal/Dev-Main)

Change 3175889 on 2016/10/26 by Wes.Fudala

	Web browser tooltips will no longer continue to appear when the mouse leaves the browser window.
	#jira: OPP-5895 The Mouseover info in Recent Additions (Marketplace) anchors itself to the mouse pointer over other Browser windows
	rb: Justin.Sargent

Change 3171388 on 2016/10/22 by Leigh.Swift

	#jira OPP-6343: Launcher crashes patching from 2.12.13 Main to 2.12.13 Release-Live
	BPS: FBuildPatchAppManifest needs to listen for FCoreDelegates::OnPreExit in order to clean up references to it's UObject which is about to be destroyed.

Change 3170373 on 2016/10/21 by Leigh.Swift

	#jira: OPP-6340: Portal builds fail on audit nodes.
	Reducing platform regex to only match pre-defined possibilities.

[CL 3219291 by Justin Sargent in Main branch]
2016-12-02 13:27:02 -05:00

1516 lines
45 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "DriverElement.h"
#include "IDriverElement.h"
#include "IDriverSequence.h"
#include "IElementLocator.h"
#include "IApplicationElement.h"
#include "AutomationDriver.h"
#include "Async.h"
#include "AsyncResult.h"
#include "InputCoreTypes.h"
#include "GenericApplicationMessageHandler.h"
class FDriverElementExtensions
{
private:
static TSharedPtr<IApplicationElement> LocateSingleElement(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
check(IsInGameThread());
TArray<TSharedRef<IApplicationElement>> Elements;
ElementLocator->Locate(Elements);
if (Elements.Num() > 1)
{
return nullptr;
}
else if (Elements.Num() == 0)
{
return nullptr;
}
return Elements[0];
}
public:
static bool CanFocus(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return false;
}
return Element->CanFocus();
}
static bool IsFocused(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return false;
}
return Element->IsFocused();
}
static bool IsFocused(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator, uint32 UserIndex)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return false;
}
return Element->IsFocused(UserIndex);
}
static bool HasFocusedDescendants(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return false;
}
return Element->HasFocusedDescendants();
}
static bool HasFocusedDescendants(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator, uint32 UserIndex)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return false;
}
return Element->HasFocusedDescendants(UserIndex);
}
static bool Exists(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
return LocateSingleElement(ElementLocator).IsValid();
}
static bool IsInteractable(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return false;
}
return Element->IsInteractable();
}
static bool IsHovered(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return false;
}
return Element->IsHovered();
}
static bool IsVisible(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return false;
}
return Element->IsVisible();
}
static bool IsScrollable(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return false;
}
return Element->IsScrollable();
}
static bool IsScrolledToBeginning(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return false;
}
return Element->IsScrolledToBeginning();
}
static bool IsScrolledToEnd(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return false;
}
return Element->IsScrolledToEnd();
}
static FVector2D GetAbsolutePosition(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return FVector2D::ZeroVector;
}
return Element->GetAbsolutePosition();
}
static FVector2D GetSize(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return FVector2D::ZeroVector;
}
return Element->GetSize();
}
static FText GetText(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
const TSharedPtr<IApplicationElement> Element = LocateSingleElement(ElementLocator);
if (!Element.IsValid())
{
return FText::GetEmpty();
}
return Element->GetText();
}
};
class FAsyncDriverElementCollection
: public IAsyncDriverElementCollection
, public TSharedFromThis<FAsyncDriverElementCollection, ESPMode::ThreadSafe>
{
public:
virtual ~FAsyncDriverElementCollection()
{ }
virtual TAsyncResult<TArray<TSharedRef<IAsyncDriverElement, ESPMode::ThreadSafe>>> GetElements() override
{
const TSharedRef<TPromise<TArray<TSharedRef<IAsyncDriverElement, ESPMode::ThreadSafe>>>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<TArray<TSharedRef<IAsyncDriverElement, ESPMode::ThreadSafe>>>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
const TSharedRef<FAsyncAutomationDriver, ESPMode::ThreadSafe> Driver = AsyncDriver;
AsyncTask(
ENamedThreads::GameThread,
[Driver, Locator, Promise]()
{
TArray<TSharedRef<IApplicationElement>> AppElements;
Locator->Locate(AppElements);
TArray<TSharedRef<IAsyncDriverElement, ESPMode::ThreadSafe>> DriverElements;
for (int32 Index = 0; Index < AppElements.Num(); ++Index)
{
DriverElements.Add(FAsyncDriverElementFactory::Create(
Driver,
AppElements[Index]->CreateLocator()));
}
Promise->SetValue(DriverElements);
}
);
return TAsyncResult<TArray<TSharedRef<IAsyncDriverElement, ESPMode::ThreadSafe>>>(Promise->GetFuture(), nullptr, nullptr);
}
private:
FAsyncDriverElementCollection(
const TSharedRef<FAsyncAutomationDriver, ESPMode::ThreadSafe>& InAsyncDriver,
const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& InElementLocator)
: AsyncDriver(InAsyncDriver)
, ElementLocator(InElementLocator)
{ }
private:
const TSharedRef<FAsyncAutomationDriver, ESPMode::ThreadSafe> AsyncDriver;
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> ElementLocator;
friend FAsyncDriverElementCollectionFactory;
};
TSharedRef<IAsyncDriverElementCollection, ESPMode::ThreadSafe> FAsyncDriverElementCollectionFactory::Create(
const TSharedRef<FAsyncAutomationDriver, ESPMode::ThreadSafe>& AsyncDriver,
const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
return MakeShareable(new FAsyncDriverElementCollection(
AsyncDriver,
ElementLocator));
}
class FAsyncDriverElement
: public IAsyncDriverElement
, public TSharedFromThis<FAsyncDriverElement, ESPMode::ThreadSafe>
{
public:
virtual ~FAsyncDriverElement()
{ }
virtual TAsyncResult<bool> Hover() override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().MoveToElement(SharedThis(this));
return Sequence->Perform();
}
virtual TAsyncResult<bool> Click(EMouseButtons::Type MouseButton) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Click(SharedThis(this), MouseButton);
return Sequence->Perform();
}
virtual TAsyncResult<bool> Click() override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Click(SharedThis(this), EMouseButtons::Left);
return Sequence->Perform();
}
virtual TAsyncResult<bool> DoubleClick(EMouseButtons::Type MouseButton) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().DoubleClick(SharedThis(this), MouseButton);
return Sequence->Perform();
}
virtual TAsyncResult<bool> DoubleClick() override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().DoubleClick(SharedThis(this), EMouseButtons::Left);
return Sequence->Perform();
}
virtual TAsyncResult<bool> ScrollBy(float Delta) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().ScrollBy(SharedThis(this), Delta);
return Sequence->Perform();
}
virtual TAsyncResult<bool> ScrollToBeginning() override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().ScrollToBeginning(SharedThis(this));
return Sequence->Perform();
}
virtual TAsyncResult<bool> ScrollToBeginning(float Amount) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().ScrollToBeginning(SharedThis(this), Amount);
return Sequence->Perform();
}
virtual TAsyncResult<bool> ScrollToBeginningUntil(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& DesiredElementLocator) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().ScrollToBeginningUntil(SharedThis(this), DesiredElementLocator);
return Sequence->Perform();
}
virtual TAsyncResult<bool> ScrollToEnd() override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().ScrollToEnd(SharedThis(this));
return Sequence->Perform();
}
virtual TAsyncResult<bool> ScrollToEnd(float Amount) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().ScrollToEnd(SharedThis(this), Amount);
return Sequence->Perform();
}
virtual TAsyncResult<bool> ScrollToEndUntil(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& DesiredElementLocator) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().ScrollToEndUntil(SharedThis(this), DesiredElementLocator);
return Sequence->Perform();
}
virtual TAsyncResult<bool> Type(const TCHAR* Text) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Type(SharedThis(this), FString(Text));
return Sequence->Perform();
}
virtual TAsyncResult<bool> Type(FString Text) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Type(SharedThis(this), MoveTemp(Text));
return Sequence->Perform();
}
virtual TAsyncResult<bool> Type(FKey Key) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Type(SharedThis(this), Key);
return Sequence->Perform();
}
virtual TAsyncResult<bool> Type(TCHAR Character) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Type(SharedThis(this), Character);
return Sequence->Perform();
}
virtual TAsyncResult<bool> Type(const TArray<FKey>& Keys) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Type(SharedThis(this), Keys);
return Sequence->Perform();
}
virtual TAsyncResult<bool> TypeChord(FKey Key1, FKey Key2) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().TypeChord(SharedThis(this), Key1, Key2);
return Sequence->Perform();
}
virtual TAsyncResult<bool> TypeChord(FKey Key1, TCHAR Character) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().TypeChord(SharedThis(this), Key1, Character);
return Sequence->Perform();
}
virtual TAsyncResult<bool> TypeChord(FKey Key1, FKey Key2, FKey Key3) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().TypeChord(SharedThis(this), Key1, Key2, Key3);
return Sequence->Perform();
}
virtual TAsyncResult<bool> TypeChord(FKey Key1, FKey Key2, TCHAR Character) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().TypeChord(SharedThis(this), Key1, Key2, Character);
return Sequence->Perform();
}
virtual TAsyncResult<bool> Press(TCHAR Character) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Press(SharedThis(this), Character);
return Sequence->Perform();
}
virtual TAsyncResult<bool> Press(FKey Key) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Press(SharedThis(this), Key);
return Sequence->Perform();
}
virtual TAsyncResult<bool> Press(EMouseButtons::Type MouseButton) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Press(SharedThis(this), MouseButton);
return Sequence->Perform();
}
virtual TAsyncResult<bool> PressChord(FKey Key1, FKey Key2) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().PressChord(SharedThis(this), Key1, Key2);
return Sequence->Perform();
}
virtual TAsyncResult<bool> PressChord(FKey Key1, TCHAR Character) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().PressChord(SharedThis(this), Key1, Character);
return Sequence->Perform();
}
virtual TAsyncResult<bool> PressChord(FKey Key1, FKey Key2, FKey Key3) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().PressChord(SharedThis(this), Key1, Key2, Key3);
return Sequence->Perform();
}
virtual TAsyncResult<bool> PressChord(FKey Key1, FKey Key2, TCHAR Character) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().PressChord(SharedThis(this), Key1, Key2, Character);
return Sequence->Perform();
}
virtual TAsyncResult<bool> Release(TCHAR Character) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Release(SharedThis(this), Character);
return Sequence->Perform();
}
virtual TAsyncResult<bool> Release(FKey Key) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Release(SharedThis(this), Key);
return Sequence->Perform();
}
virtual TAsyncResult<bool> Release(EMouseButtons::Type MouseButton) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Release(SharedThis(this), MouseButton);
return Sequence->Perform();
}
virtual TAsyncResult<bool> ReleaseChord(FKey Key1, FKey Key2) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().ReleaseChord(SharedThis(this), Key1, Key2);
return Sequence->Perform();
}
virtual TAsyncResult<bool> ReleaseChord(FKey Key1, TCHAR Character) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().ReleaseChord(SharedThis(this), Key1, Character);
return Sequence->Perform();
}
virtual TAsyncResult<bool> ReleaseChord(FKey Key1, FKey Key2, FKey Key3) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().ReleaseChord(SharedThis(this), Key1, Key2, Key3);
return Sequence->Perform();
}
virtual TAsyncResult<bool> ReleaseChord(FKey Key1, FKey Key2, TCHAR Character) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().ReleaseChord(SharedThis(this), Key1, Key2, Character);
return Sequence->Perform();
}
virtual TAsyncResult<bool> Focus() override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Focus(SharedThis(this));
return Sequence->Perform();
}
virtual TAsyncResult<bool> Focus(uint32 UserFocus) override
{
TSharedRef<IAsyncDriverSequence, ESPMode::ThreadSafe> Sequence = AsyncDriver->CreateSequence();
Sequence->Actions().Focus(SharedThis(this), UserFocus);
return Sequence->Perform();
}
virtual TAsyncResult<bool> CanFocus() const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::CanFocus(Locator));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<bool> IsFocused() const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsFocused(Locator));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<bool> IsFocused(uint32 UserIndex) const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, UserIndex, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsFocused(Locator, UserIndex));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<bool> HasFocusedDescendants() const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::HasFocusedDescendants(Locator));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<bool> HasFocusedDescendants(uint32 UserIndex) const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, UserIndex, Promise]()
{
Promise->SetValue(FDriverElementExtensions::HasFocusedDescendants(Locator, UserIndex));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<bool> Exists() const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::Exists(Locator));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<bool> IsVisible() const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsVisible(Locator));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<bool> IsInteractable() const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsInteractable(Locator));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<bool> IsScrollable() const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsScrollable(Locator));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<bool> IsScrolledToBeginning() const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsScrolledToBeginning(Locator));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<bool> IsScrolledToEnd() const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsScrolledToEnd(Locator));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<bool> IsHovered() const override
{
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsHovered(Locator));
}
);
return TAsyncResult<bool>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<FVector2D> GetAbsolutePosition() const override
{
const TSharedRef<TPromise<FVector2D>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<FVector2D>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::GetAbsolutePosition(Locator));
}
);
return TAsyncResult<FVector2D>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<FVector2D> GetSize() const override
{
const TSharedRef<TPromise<FVector2D>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<FVector2D>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::GetSize(Locator));
}
);
return TAsyncResult<FVector2D>(Promise->GetFuture(), nullptr, nullptr);
}
virtual TAsyncResult<FText> GetText() const override
{
const TSharedRef<TPromise<FText>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<FText>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::GetText(Locator));
}
);
return TAsyncResult<FText>(Promise->GetFuture(), nullptr, nullptr);
}
virtual void Locate(TArray<TSharedRef<IApplicationElement>>& OutElements) const override
{
return ElementLocator->Locate(OutElements);
}
virtual FString ToDebugString() const override
{
return ElementLocator->ToDebugString();
}
private:
FAsyncDriverElement(
const TSharedRef<FAsyncAutomationDriver, ESPMode::ThreadSafe>& InAsyncDriver,
const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& InElementLocator)
: AsyncDriver(InAsyncDriver)
, ElementLocator(InElementLocator)
{ }
private:
const TSharedRef<FAsyncAutomationDriver, ESPMode::ThreadSafe> AsyncDriver;
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> ElementLocator;
friend FAsyncDriverElementFactory;
};
TSharedRef<IAsyncDriverElement, ESPMode::ThreadSafe> FAsyncDriverElementFactory::Create(
const TSharedRef<FAsyncAutomationDriver, ESPMode::ThreadSafe>& AsyncDriver,
const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
return MakeShareable(new FAsyncDriverElement(
AsyncDriver,
ElementLocator));
}
class FDriverElementCollection
: public IDriverElementCollection
, public TSharedFromThis<FDriverElementCollection, ESPMode::ThreadSafe>
{
public:
virtual TArray<TSharedRef<IDriverElement, ESPMode::ThreadSafe>> GetElements() override
{
if (IsInGameThread())
{
return InternalGetElement();
}
const TSharedRef<FDriverElementCollection, ESPMode::ThreadSafe> LocalThis = SharedThis(this);
const TSharedRef<TPromise<TArray<TSharedRef<IDriverElement, ESPMode::ThreadSafe>>>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<TArray<TSharedRef<IDriverElement, ESPMode::ThreadSafe>>>());
AsyncTask(
ENamedThreads::GameThread,
[LocalThis, Promise]()
{
Promise->SetValue(LocalThis->InternalGetElement());
}
);
return Promise->GetFuture().Get();
}
private:
TArray<TSharedRef<IDriverElement, ESPMode::ThreadSafe>> InternalGetElement()
{
check(IsInGameThread());
TArray<TSharedRef<IApplicationElement>> AppElements;
ElementLocator->Locate(AppElements);
TArray<TSharedRef<IDriverElement, ESPMode::ThreadSafe>> DriverElements;
for (int32 Index = 0; Index < AppElements.Num(); ++Index)
{
DriverElements.Add(FDriverElementFactory::Create(
Driver,
AppElements[Index]->CreateLocator()));
}
return DriverElements;
}
private:
FDriverElementCollection(
const TSharedRef<FAutomationDriver, ESPMode::ThreadSafe>& InDriver,
const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& InElementLocator)
: Driver(InDriver)
, ElementLocator(InElementLocator)
{ }
private:
const TSharedRef<FAutomationDriver, ESPMode::ThreadSafe> Driver;
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> ElementLocator;
friend FDriverElementCollectionFactory;
};
TSharedRef<IDriverElementCollection, ESPMode::ThreadSafe> FDriverElementCollectionFactory::Create(
const TSharedRef<FAutomationDriver, ESPMode::ThreadSafe>& Driver,
const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
return MakeShareable(new FDriverElementCollection(
Driver,
ElementLocator));
}
class FDriverElement
: public IDriverElement
, public TSharedFromThis<FDriverElement, ESPMode::ThreadSafe>
{
public:
virtual bool Hover() override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().MoveToElement(SharedThis(this));
return Sequence->Perform();
}
virtual bool Click(EMouseButtons::Type MouseButton) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Click(SharedThis(this), MouseButton);
return Sequence->Perform();
}
virtual bool Click() override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Click(SharedThis(this), EMouseButtons::Left);
return Sequence->Perform();
}
virtual bool DoubleClick() override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().DoubleClick(SharedThis(this), EMouseButtons::Left);
return Sequence->Perform();
}
virtual bool DoubleClick(EMouseButtons::Type MouseButton) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().DoubleClick(SharedThis(this), MouseButton);
return Sequence->Perform();
}
virtual bool ScrollBy(float Delta) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().ScrollBy(SharedThis(this), Delta);
return Sequence->Perform();
}
virtual bool ScrollToBeginning() override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().ScrollToBeginning(SharedThis(this));
return Sequence->Perform();
}
virtual bool ScrollToBeginning(float Amount) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().ScrollToBeginning(SharedThis(this), Amount);
return Sequence->Perform();
}
virtual bool ScrollToBeginningUntil(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& DesiredElementLocator) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().ScrollToBeginningUntil(SharedThis(this), DesiredElementLocator);
return Sequence->Perform();
}
virtual bool ScrollToEnd() override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().ScrollToEnd(SharedThis(this));
return Sequence->Perform();
}
virtual bool ScrollToEnd(float Amount) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().ScrollToEnd(SharedThis(this), Amount);
return Sequence->Perform();
}
virtual bool ScrollToEndUntil(const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& DesiredElementLocator) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().ScrollToEndUntil(SharedThis(this), DesiredElementLocator);
return Sequence->Perform();
}
virtual bool Type(const TCHAR* Text) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Type(SharedThis(this), FString(Text));
return Sequence->Perform();
}
virtual bool Type(FString Text) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Type(SharedThis(this), MoveTemp(Text));
return Sequence->Perform();
}
virtual bool Type(FKey Key) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Type(SharedThis(this), Key);
return Sequence->Perform();
}
virtual bool Type(TCHAR Character) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Type(SharedThis(this), Character);
return Sequence->Perform();
}
virtual bool Type(const TArray<FKey>& Keys) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Type(SharedThis(this), Keys);
return Sequence->Perform();
}
virtual bool TypeChord(FKey Key1, FKey Key2) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().TypeChord(SharedThis(this), Key1, Key2);
return Sequence->Perform();
}
virtual bool TypeChord(FKey Key1, TCHAR Character) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().TypeChord(SharedThis(this), Key1, Character);
return Sequence->Perform();
}
virtual bool TypeChord(FKey Key1, FKey Key2, FKey Key3) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().TypeChord(SharedThis(this), Key1, Key2, Key3);
return Sequence->Perform();
}
virtual bool TypeChord(FKey Key1, FKey Key2, TCHAR Character) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().TypeChord(SharedThis(this), Key1, Key2, Character);
return Sequence->Perform();
}
virtual bool Press(TCHAR Character) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Press(SharedThis(this), Character);
return Sequence->Perform();
}
virtual bool Press(FKey Key) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Press(SharedThis(this), Key);
return Sequence->Perform();
}
virtual bool Press(EMouseButtons::Type MouseButton) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Press(SharedThis(this), MouseButton);
return Sequence->Perform();
}
virtual bool PressChord(FKey Key1, FKey Key2) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().PressChord(SharedThis(this), Key1, Key2);
return Sequence->Perform();
}
virtual bool PressChord(FKey Key1, TCHAR Character) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().PressChord(SharedThis(this), Key1, Character);
return Sequence->Perform();
}
virtual bool PressChord(FKey Key1, FKey Key2, FKey Key3) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().PressChord(SharedThis(this), Key1, Key2, Key3);
return Sequence->Perform();
}
virtual bool PressChord(FKey Key1, FKey Key2, TCHAR Character) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().PressChord(SharedThis(this), Key1, Key2, Character);
return Sequence->Perform();
}
virtual bool Release(TCHAR Character) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Release(SharedThis(this), Character);
return Sequence->Perform();
}
virtual bool Release(FKey Key) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Release(SharedThis(this), Key);
return Sequence->Perform();
}
virtual bool Release(EMouseButtons::Type MouseButton) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Release(SharedThis(this), MouseButton);
return Sequence->Perform();
}
virtual bool ReleaseChord(FKey Key1, FKey Key2) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().ReleaseChord(SharedThis(this), Key1, Key2);
return Sequence->Perform();
}
virtual bool ReleaseChord(FKey Key1, TCHAR Character) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().ReleaseChord(SharedThis(this), Key1, Character);
return Sequence->Perform();
}
virtual bool ReleaseChord(FKey Key1, FKey Key2, FKey Key3) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().ReleaseChord(SharedThis(this), Key1, Key2, Key3);
return Sequence->Perform();
}
virtual bool ReleaseChord(FKey Key1, FKey Key2, TCHAR Character) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().ReleaseChord(SharedThis(this), Key1, Key2, Character);
return Sequence->Perform();
}
virtual bool Focus() override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Focus(SharedThis(this));
return Sequence->Perform();
}
virtual bool Focus(uint32 UserIndex) override
{
TSharedRef<IDriverSequence, ESPMode::ThreadSafe> Sequence = Driver->CreateSequence();
Sequence->Actions().Focus(SharedThis(this), UserIndex);
return Sequence->Perform();
}
virtual bool CanFocus() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::CanFocus(ElementLocator);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::CanFocus(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual bool IsFocused() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::IsFocused(ElementLocator);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsFocused(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual bool IsFocused(uint32 UserIndex) const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::IsFocused(ElementLocator, UserIndex);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, UserIndex, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsFocused(Locator, UserIndex));
}
);
return Promise->GetFuture().Get();
}
virtual bool HasFocusedDescendants() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::HasFocusedDescendants(ElementLocator);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::HasFocusedDescendants(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual bool HasFocusedDescendants(uint32 UserIndex) const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::HasFocusedDescendants(ElementLocator, UserIndex);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, UserIndex, Promise]()
{
Promise->SetValue(FDriverElementExtensions::HasFocusedDescendants(Locator, UserIndex));
}
);
return Promise->GetFuture().Get();
}
virtual bool Exists() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::Exists(ElementLocator);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::Exists(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual bool IsVisible() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::IsVisible(ElementLocator);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsVisible(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual bool IsInteractable() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::IsInteractable(ElementLocator);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsInteractable(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual bool IsScrollable() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::IsScrollable(ElementLocator);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsScrollable(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual bool IsScrolledToBeginning() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::IsScrolledToBeginning(ElementLocator);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsScrolledToBeginning(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual bool IsScrolledToEnd() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::IsScrolledToEnd(ElementLocator);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsScrolledToEnd(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual bool IsHovered() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::IsHovered(ElementLocator);
}
const TSharedRef<TPromise<bool>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<bool>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::IsHovered(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual FVector2D GetAbsolutePosition() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::GetAbsolutePosition(ElementLocator);
}
const TSharedRef<TPromise<FVector2D>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<FVector2D>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::GetAbsolutePosition(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual FVector2D GetSize() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::GetSize(ElementLocator);
}
const TSharedRef<TPromise<FVector2D>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<FVector2D>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::GetSize(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual FText GetText() const override
{
if (IsInGameThread())
{
return FDriverElementExtensions::GetText(ElementLocator);
}
const TSharedRef<TPromise<FText>, ESPMode::ThreadSafe> Promise = MakeShareable(new TPromise<FText>());
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> Locator = ElementLocator;
AsyncTask(
ENamedThreads::GameThread,
[Locator, Promise]()
{
Promise->SetValue(FDriverElementExtensions::GetText(Locator));
}
);
return Promise->GetFuture().Get();
}
virtual void Locate(TArray<TSharedRef<IApplicationElement>>& OutElements) const override
{
ElementLocator->Locate(OutElements);
}
virtual FString ToDebugString() const override
{
return ElementLocator->ToDebugString();
}
private:
FDriverElement(
const TSharedRef<FAutomationDriver, ESPMode::ThreadSafe>& InDriver,
const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& InElementLocator)
: Driver(InDriver)
, ElementLocator(InElementLocator)
{ }
private:
const TSharedRef<FAutomationDriver, ESPMode::ThreadSafe> Driver;
const TSharedRef<IElementLocator, ESPMode::ThreadSafe> ElementLocator;
friend FDriverElementFactory;
};
TSharedRef<IDriverElement, ESPMode::ThreadSafe> FDriverElementFactory::Create(
const TSharedRef<FAutomationDriver, ESPMode::ThreadSafe>& Driver,
const TSharedRef<IElementLocator, ESPMode::ThreadSafe>& ElementLocator)
{
return MakeShareable(new FDriverElement(
Driver,
ElementLocator));
}