diff --git a/Assets/AltTester/Runtime/AltDriver/AltDriver.cs b/Assets/AltTester/Runtime/AltDriver/AltDriver.cs
index f159a9213..628cc5c6a 100644
--- a/Assets/AltTester/Runtime/AltDriver/AltDriver.cs
+++ b/Assets/AltTester/Runtime/AltDriver/AltDriver.cs
@@ -25,605 +25,57 @@ You should have received a copy of the GNU General Public License
namespace AltTester.AltTesterUnitySDK.Driver
{
- public enum By
+ public class AltDriver: AltDriverUnity
{
- TAG, LAYER, NAME, COMPONENT, PATH, ID, TEXT
- }
-
- public class AltDriver
- {
- private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger();
- private readonly IDriverCommunication communicationHandler;
- private static object driverLock = new object();
- public static readonly string VERSION = "2.2.2";
-
- public IDriverCommunication CommunicationHandler { get { return communicationHandler; } }
-
- ///
- /// Initiates AltDriver and begins connection with the instrumented Unity application through to AltServer.
- ///
- /// The IP or hostname AltTester® Server is listening on.
- /// The port AltTester® Server is listening on.
- /// If true it enables driver commands logging to log file and Unity.
- /// The connect timeout in seconds.
- /// The name of the Unity application.
+
public AltDriver(string host = "127.0.0.1", int port = 13000, string appName = "__default__", bool enableLogging = false, int connectTimeout = 60, string platform = "unknown", string platformVersion = "unknown", string deviceInstanceId = "unknown", string appId = "unknown", string driverType = "SDK")
- {
- lock (driverLock)
- {
-#if UNITY_EDITOR || ALTTESTER
- var defaultLevels = new Dictionary { { AltLogger.File, AltLogLevel.Debug }, { AltLogger.Unity, AltLogLevel.Debug } };
-#else
- var defaultLevels = new Dictionary { { AltLogger.File, AltLogLevel.Debug }, { AltLogger.Console, AltLogLevel.Debug } };
-#endif
-
-
- if (enableLogging)
- {
- DriverLogManager.SetupAltDriverLogging(defaultLevels);
- }
- else
- {
- DriverLogManager.StopLogging();
- }
-
- logger.Debug(
- "Connecting to AltTester(R) on host: '{0}', port: '{1}', appName: '{2}', platform: '{3}', platformVersion: '{4}', deviceInstanceId: '{5}' and driverType: '{6}'.",
- host,
- port,
- appName,
- platform,
- platformVersion,
- deviceInstanceId,
- driverType
- );
- while (true)
- {
- communicationHandler = new DriverCommunicationHandler(host, port, connectTimeout, appName, platform, platformVersion, deviceInstanceId, appId, driverType);
- communicationHandler.Connect();
- try
- {
- checkServerVersion();
- break;
- }
- catch (NullReferenceException)//There is a strange situation when sometimes checkServerVersion throws that command params is null. I investigated but didn't find the cause.
- {
- communicationHandler.Close();
- }
- }
- }
- }
-
- private void splitVersion(string version, out string major, out string minor)
- {
- var parts = version.Split(new[] { "." }, StringSplitOptions.None);
- major = parts[0];
- minor = parts.Length > 1 ? parts[1] : string.Empty;
- }
-
- private void checkServerVersion()
- {
- string serverVersion = GetServerVersion();
-
- string majorServer;
- string majorDriver;
- string minorDriver;
- string minorServer;
-
- splitVersion(serverVersion, out majorServer, out minorServer);
- splitVersion(VERSION, out majorDriver, out minorDriver);
-
- int serverMajor, serverMinor;
-
- serverMajor = int.Parse(majorServer);
- serverMinor = int.Parse(minorServer);
-
- bool isSupported =
- (serverMajor == 2 && serverMinor == 2) || // Server version 2.2.x
- (serverMajor == 1 && serverMinor == 0); // Server version 1.0.0
-
- if (!isSupported)
- {
- string message = $"Version mismatch. AltDriver version is {VERSION}. AltTester(R) version is {serverVersion}.";
- logger.Warn(message);
- }
- }
-
- public void Stop()
- {
- communicationHandler.Close();
- }
-
- public void ResetInput()
- {
- new AltResetInput(communicationHandler).Execute();
- }
-
- public void SetCommandResponseTimeout(int commandTimeout)
- {
- communicationHandler.SetCommandTimeout(commandTimeout);
- }
-
- public void SetDelayAfterCommand(float delay)
- {
- communicationHandler.SetDelayAfterCommand(delay);
- }
-
- public float GetDelayAfterCommand()
- {
- return communicationHandler.GetDelayAfterCommand();
- }
-
- public string GetServerVersion()
- {
- string serverVersion = new AltGetServerVersion(communicationHandler).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return serverVersion;
- }
-
- public void SetLogging(bool enableLogging)
- {
- if (enableLogging)
- DriverLogManager.ResumeLogging();
- else
- DriverLogManager.StopLogging();
- }
-
- public void LoadScene(string scene, bool loadSingle = true)
- {
- new AltLoadScene(communicationHandler, scene, loadSingle).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public void UnloadScene(string scene)
- {
- new AltUnloadScene(communicationHandler, scene).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public List GetAllLoadedScenes()
- {
- var sceneList = new AltGetAllLoadedScenes(communicationHandler).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return sceneList;
+ : base(host, port, appName, enableLogging, connectTimeout, platform, platformVersion, deviceInstanceId, appId, driverType)
+ {
}
public List FindObjects(By by, string value, By cameraBy = By.NAME, string cameraValue = "", bool enabled = true)
{
- var listOfObjects = new AltFindObjects(communicationHandler, by, value, cameraBy, cameraValue, enabled).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return listOfObjects;
+ return base.FindObjects(new AltBy(by, value), new AltBy(cameraBy, cameraValue), enabled);
}
public List FindObjectsWhichContain(By by, string value, By cameraBy = By.NAME, string cameraValue = "", bool enabled = true)
{
- var listOfObjects = new AltFindObjectsWhichContain(communicationHandler, by, value, cameraBy, cameraValue, enabled).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return listOfObjects;
+ return base.FindObjectsWhichContain(new AltBy(by, value), new AltBy(cameraBy, cameraValue), enabled);
}
public AltObject FindObject(By by, string value, By cameraBy = By.NAME, string cameraValue = "", bool enabled = true)
{
- var findObject = new AltFindObject(communicationHandler, by, value, cameraBy, cameraValue, enabled).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return findObject;
+ return base.FindObject(new AltBy(by, value), new AltBy(cameraBy, cameraValue), enabled);
}
public AltObject FindObjectWhichContains(By by, string value, By cameraBy = By.NAME, string cameraValue = "", bool enabled = true)
{
- var findObject = new AltFindObjectWhichContains(communicationHandler, by, value, cameraBy, cameraValue, enabled).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return findObject;
- }
-
- public void SetTimeScale(float timeScale)
- {
- new AltSetTimeScale(communicationHandler, timeScale).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public float GetTimeScale()
- {
- var timeScale = new AltGetTimeScale(communicationHandler).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return timeScale;
- }
-
- public T CallStaticMethod(string typeName, string methodName, string assemblyName,
- object[] parameters, string[] typeOfParameters = null)
- {
- var result = new AltCallStaticMethod(communicationHandler, typeName, methodName, parameters, typeOfParameters, assemblyName).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return result;
- }
-
- public T GetStaticProperty(string componentName, string propertyName, string assemblyName, int maxDepth = 2)
- {
- var propertyValue = new AltGetStaticProperty(communicationHandler, componentName, propertyName, assemblyName, maxDepth).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return propertyValue;
- }
-
- public void SetStaticProperty(string componentName, string propertyName, string assemblyName, object updatedProperty)
- {
- new AltSetStaticProperty(communicationHandler, componentName, propertyName, assemblyName, updatedProperty).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public void DeletePlayerPref()
- {
- new AltDeletePlayerPref(communicationHandler).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public void DeleteKeyPlayerPref(string keyName)
- {
- new AltDeleteKeyPlayerPref(communicationHandler, keyName).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public void SetKeyPlayerPref(string keyName, int valueName)
- {
- new AltSetKeyPLayerPref(communicationHandler, keyName, valueName).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public void SetKeyPlayerPref(string keyName, float valueName)
- {
- new AltSetKeyPLayerPref(communicationHandler, keyName, valueName).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public void SetKeyPlayerPref(string keyName, string valueName)
- {
- new AltSetKeyPLayerPref(communicationHandler, keyName, valueName).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public int GetIntKeyPlayerPref(string keyName)
- {
- var keyValue = new AltGetIntKeyPlayerPref(communicationHandler, keyName).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return keyValue;
- }
-
- public float GetFloatKeyPlayerPref(string keyName)
- {
- var keyValue = new AltGetFloatKeyPlayerPref(communicationHandler, keyName).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return keyValue;
- }
-
- public string GetStringKeyPlayerPref(string keyName)
- {
- var keyValue = new AltGetStringKeyPlayerPref(communicationHandler, keyName).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return keyValue;
- }
-
- public string GetCurrentScene()
- {
- var sceneName = new AltGetCurrentScene(communicationHandler).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return sceneName;
- }
-
- ///
- /// Simulates a swipe action between two points.
- ///
- /// Coordinates of the screen where the swipe begins
- /// Coordinates of the screen where the swipe ends
- /// The time measured in seconds to move the mouse from start to end location. Defaults to 0.1.
- /// If set wait for command to finish. Defaults to True.
- public void Swipe(AltVector2 start, AltVector2 end, float duration = 0.1f, bool wait = true)
- {
- new AltSwipe(communicationHandler, start, end, duration, wait).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- ///
- /// Simulates a multipoint swipe action.
- ///
- /// A list of positions on the screen where the swipe be made.
- /// The time measured in seconds to swipe from first position to the last position. Defaults to 0.1.
- /// If set wait for command to finish. Defaults to True.
- public void MultipointSwipe(AltVector2[] positions, float duration = 0.1f, bool wait = true)
- {
- new AltMultipointSwipe(communicationHandler, positions, duration, wait).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- ///
- /// Simulates holding left click button down for a specified amount of time at given coordinates.
- ///
- /// The coordinates where the button is held down.
- /// The time measured in seconds to keep the button down.
- /// If set wait for command to finish. Defaults to True.
- public void HoldButton(AltVector2 coordinates, float duration, bool wait = true)
- {
- Swipe(coordinates, coordinates, duration, wait);
- }
-
- ///
- /// Simulates key press action in your app.
- ///
- /// The key code of the key simulated to be pressed.
- /// A value between [-1,1] used for joysticks to indicate how hard the button was pressed. Defaults to 1.
- /// The time measured in seconds from the key press to the key release. Defaults to 0.1
- /// If set wait for command to finish. Defaults to True.
- public void PressKey(AltKeyCode keyCode, float power = 1, float duration = 0.1f, bool wait = true)
- {
- AltKeyCode[] keyCodes = { keyCode };
- PressKeys(keyCodes, power, duration, wait);
- }
-
- ///
- /// Simulates multiple keys pressed action in your app.
- ///
- /// The list of key codes of the keys simulated to be pressed.
- /// A value between [-1,1] used for joysticks to indicate how hard the button was pressed. Defaults to 1.
- /// The time measured in seconds from the key press to the key release. Defaults to 0.1
- /// If set wait for command to finish. Defaults to True.
- public void PressKeys(AltKeyCode[] keyCodes, float power = 1, float duration = 0.1f, bool wait = true)
- {
- new AltPressKeys(communicationHandler, keyCodes, power, duration, wait).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public void KeyDown(AltKeyCode keyCode, float power = 1)
- {
- AltKeyCode[] keyCodes = { keyCode };
- KeysDown(keyCodes, power);
- }
-
- ///
- /// Simulates multiple keys down action in your app.
- ///
- /// The key codes of the keys simulated to be down.
- /// A value between [-1,1] used for joysticks to indicate how hard the button was pressed. Defaults to 1.
- public void KeysDown(AltKeyCode[] keyCodes, float power = 1)
- {
- new AltKeysDown(communicationHandler, keyCodes, power).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public void KeyUp(AltKeyCode keyCode)
- {
- AltKeyCode[] keyCodes = { keyCode };
- KeysUp(keyCodes);
- }
-
- ///
- /// Simulates multiple keys up action in your app.
- ///
- /// The key codes of the keys simulated to be up.
- public void KeysUp(AltKeyCode[] keyCodes)
- {
- new AltKeysUp(communicationHandler, keyCodes).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- ///
- /// Simulate mouse movement in your app.
- ///
- /// The screen coordinates
- /// The time measured in seconds to move the mouse from the current mouse position to the set coordinates. Defaults to 0.1f
- /// If set wait for command to finish. Defaults to True.
- public void MoveMouse(AltVector2 coordinates, float duration = 0.1f, bool wait = true)
- {
- new AltMoveMouse(communicationHandler, coordinates, duration, wait).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- ///
- /// Simulate scroll action in your app.
- ///
- /// Set how fast to scroll. Positive values will scroll up and negative values will scroll down. Defaults to 1
- /// The duration of the scroll in seconds. Defaults to 0.1
- /// If set wait for command to finish. Defaults to True.
- public void Scroll(float speed = 1, float duration = 0.1f, bool wait = true)
- {
- new AltScroll(communicationHandler, speed, 0, duration, wait).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- ///
- /// Simulate scroll action in your app.
- ///
- /// Set how fast to scroll. X is horizontal and Y is vertical. Defaults to 1
- /// The duration of the scroll in seconds. Defaults to 0.1
- /// If set wait for command to finish. Defaults to True.
- public void Scroll(AltVector2 scrollValue, float duration = 0.1f, bool wait = true)
- {
- new AltScroll(communicationHandler, scrollValue.y, scrollValue.x, duration, wait).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- ///
- /// Tap at screen coordinates
- ///
- /// The screen coordinates
- /// Number of taps
- /// Interval between taps in seconds
- /// If set wait for command to finish. Defaults to True.
- public void Tap(AltVector2 coordinates, int count = 1, float interval = 0.1f, bool wait = true)
- {
- new AltTapCoordinates(communicationHandler, coordinates, count, interval, wait).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- ///
- /// Click at screen coordinates
- ///
- /// The screen coordinates
- /// Number of clicks.
- /// Interval between clicks in seconds
- /// If set wait for command to finish. Defaults to True.
- public void Click(AltVector2 coordinates, int count = 1, float interval = 0.1f, bool wait = true)
- {
- new AltClickCoordinates(communicationHandler, coordinates, count, interval, wait).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- ///
- /// Simulates device rotation action in your app.
- ///
- /// The linear acceleration of a device.
- /// How long the rotation will take in seconds. Defaults to 0.1.
- /// If set wait for command to finish. Defaults to True.
- public void Tilt(AltVector3 acceleration, float duration = 0.1f, bool wait = true)
- {
- new AltTilt(communicationHandler, acceleration, duration, wait).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return base.FindObjectWhichContains(new AltBy(by, value), new AltBy(cameraBy, cameraValue), enabled);
}
public List GetAllElements(By cameraBy = By.NAME, string cameraValue = "", bool enabled = true)
{
- var listOfObjects = new AltGetAllElements(communicationHandler, cameraBy, cameraValue, enabled).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return listOfObjects;
+ return base.GetAllElements(new AltBy(cameraBy, cameraValue), enabled);
}
public List GetAllElementsLight(By cameraBy = By.NAME, string cameraValue = "", bool enabled = true)
{
- var listOfObjects = new AltGetAllElementsLight(communicationHandler, cameraBy, cameraValue, enabled).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return listOfObjects;
- }
-
- public void WaitForCurrentSceneToBe(string sceneName, double timeout = 10, double interval = 1)
- {
- new AltWaitForCurrentSceneToBe(communicationHandler, sceneName, timeout, interval).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return base.GetAllElementsLight(new AltBy(cameraBy, cameraValue), enabled);
}
public AltObject WaitForObject(By by, string value, By cameraBy = By.NAME, string cameraValue = "", bool enabled = true, double timeout = 20, double interval = 0.5)
{
- var objectFound = new AltWaitForObject(communicationHandler, by, value, cameraBy, cameraValue, enabled, timeout, interval).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return objectFound;
+ return base.WaitForObject(new AltBy(by, value), new AltBy(cameraBy, cameraValue), enabled, timeout, interval);
}
public void WaitForObjectNotBePresent(By by, string value, By cameraBy = By.NAME, string cameraValue = "", bool enabled = true, double timeout = 20, double interval = 0.5)
{
- new AltWaitForObjectNotBePresent(communicationHandler, by, value, cameraBy, cameraValue, enabled, timeout, interval).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ base.WaitForObjectNotBePresent(new AltBy(by, value), new AltBy(cameraBy, cameraValue), enabled, timeout, interval);
}
public AltObject WaitForObjectWhichContains(By by, string value, By cameraBy = By.NAME, string cameraValue = "", bool enabled = true, double timeout = 20, double interval = 0.5)
{
- var objectFound = new AltWaitForObjectWhichContains(communicationHandler, by, value, cameraBy, cameraValue, enabled, timeout, interval).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return objectFound;
- }
-
- public List GetAllScenes()
- {
- var listOfScenes = new AltGetAllScenes(communicationHandler).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return listOfScenes;
- }
-
- public List GetAllCameras()
- {
- var listOfCameras = new AltGetAllCameras(communicationHandler).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return listOfCameras;
- }
-
- public List GetAllActiveCameras()
- {
- var listOfCameras = new AltGetAllActiveCameras(communicationHandler).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return listOfCameras;
- }
-
- public AltVector2 GetApplicationScreenSize()
- {
- var applicationScreenSize = new AltGetApplicationScreenSize(communicationHandler).Execute();
- return applicationScreenSize;
- }
-
- public AltTextureInformation GetScreenshot(AltVector2 size = default(AltVector2), int screenShotQuality = 100)
- {
- var textureInformation = new AltGetScreenshot(communicationHandler, size, screenShotQuality).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return textureInformation;
- }
-
- public AltTextureInformation GetScreenshot(int id, AltColor color, float width, AltVector2 size = default(AltVector2), int screenShotQuality = 100)
- {
- var textureInformation = new AltGetHighlightObjectScreenshot(communicationHandler, id, color, width, size, screenShotQuality).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return textureInformation;
- }
-
- public AltTextureInformation GetScreenshot(AltVector2 coordinates, AltColor color, float width, out AltObject selectedObject, AltVector2 size = default(AltVector2), int screenShotQuality = 100)
- {
- var textureInformation = new AltGetHighlightObjectFromCoordinatesScreenshot(communicationHandler, coordinates, color, width, size, screenShotQuality).Execute(out selectedObject);
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return textureInformation;
- }
-
- public void GetPNGScreenshot(string path)
- {
- new AltGetPNGScreenshot(communicationHandler, path).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public List GetAllLoadedScenesAndObjects(bool enabled = true)
- {
- var listOfObjects = new AltGetAllLoadedScenesAndObjects(communicationHandler, enabled).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return listOfObjects;
- }
-
- public void SetServerLogging(AltLogger logger, AltLogLevel logLevel)
- {
- new AltSetServerLogging(communicationHandler, logger, logLevel).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public int BeginTouch(AltVector2 screenPosition)
- {
- var touchId = new AltBeginTouch(communicationHandler, screenPosition).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return touchId;
- }
-
- public void MoveTouch(int fingerId, AltVector2 screenPosition)
- {
- new AltMoveTouch(communicationHandler, fingerId, screenPosition).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- public void EndTouch(int fingerId)
- {
- new AltEndTouch(communicationHandler, fingerId).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- }
-
- ///
- /// Retrieves the Unity object at given coordinates.
- /// Uses EventSystem.RaycastAll to find object. If no object is found then it uses UnityEngine.Physics.Raycast and UnityEngine.Physics2D.Raycast and returns the one closer to the camera.
- ///
- /// The screen coordinates
- /// The UI object hit by event system Raycast, null otherwise
- public AltObject FindObjectAtCoordinates(AltVector2 coordinates)
- {
- var objectFound = new AltFindObjectAtCoordinates(communicationHandler, coordinates).Execute();
- communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
- return objectFound;
- }
-
- public void AddNotificationListener(NotificationType notificationType, Action callback, bool overwrite)
- {
- new AddNotificationListener(communicationHandler, notificationType, callback, overwrite).Execute();
- }
-
- public void RemoveNotificationListener(NotificationType notificationType)
- {
- new RemoveNotificationListener(communicationHandler, notificationType).Execute();
+ return base.WaitForObjectWhichContains(new AltBy(by, value), new AltBy(cameraBy, cameraValue), enabled, timeout, interval);
}
}
}
diff --git a/Assets/AltTester/Runtime/AltDriver/AltDriverBase.cs b/Assets/AltTester/Runtime/AltDriver/AltDriverBase.cs
new file mode 100644
index 000000000..5b384c23f
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/AltDriverBase.cs
@@ -0,0 +1,648 @@
+/*
+ Copyright(C) 2025 Altom Consulting
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using AltTester.AltTesterUnitySDK.Driver.Commands;
+using AltTester.AltTesterUnitySDK.Driver.Communication;
+using AltTester.AltTesterUnitySDK.Driver.Logging;
+using AltTester.AltTesterUnitySDK.Driver.Notifications;
+
+namespace AltTester.AltTesterUnitySDK.Driver
+{
+ public enum By
+ {
+ TAG, LAYER, NAME, COMPONENT, PATH, ID, TEXT
+ }
+
+ public class AltDriverBase
+ {
+ private static readonly NLog.Logger logger = DriverLogManager.Instance.GetCurrentClassLogger();
+ protected readonly IDriverCommunication communicationHandler;
+ private static object driverLock = new object();
+ public static readonly string VERSION = "2.2.2";
+
+ public IDriverCommunication CommunicationHandler { get { return communicationHandler; } }
+
+ ///
+ /// Initiates AltDriver and begins connection with the instrumented Unity application through to AltServer.
+ ///
+ /// The IP or hostname AltTester® Server is listening on.
+ /// The port AltTester® Server is listening on.
+ /// If true it enables driver commands logging to log file and Unity.
+ /// The connect timeout in seconds.
+ /// The name of the Unity application.
+ public AltDriverBase(string host = "127.0.0.1", int port = 13000, string appName = "__default__", bool enableLogging = false, int connectTimeout = 60, string platform = "unknown", string platformVersion = "unknown", string deviceInstanceId = "unknown", string appId = "unknown", string driverType = "SDK")
+ {
+ lock (driverLock)
+ {
+#if UNITY_EDITOR || ALTTESTER
+ var defaultLevels = new Dictionary { { AltLogger.File, AltLogLevel.Debug }, { AltLogger.Unity, AltLogLevel.Debug } };
+#else
+ var defaultLevels = new Dictionary { { AltLogger.File, AltLogLevel.Debug }, { AltLogger.Console, AltLogLevel.Debug } };
+#endif
+
+
+ if (enableLogging)
+ {
+ DriverLogManager.SetupAltDriverLogging(defaultLevels);
+ }
+ else
+ {
+ DriverLogManager.StopLogging();
+ }
+
+ logger.Debug(
+ "Connecting to AltTester(R) on host: '{0}', port: '{1}', appName: '{2}', platform: '{3}', platformVersion: '{4}', deviceInstanceId: '{5}' and driverType: '{6}'.",
+ host,
+ port,
+ appName,
+ platform,
+ platformVersion,
+ deviceInstanceId,
+ driverType
+ );
+ while (true)
+ {
+ communicationHandler = new DriverCommunicationHandler(host, port, connectTimeout, appName, platform, platformVersion, deviceInstanceId, appId, driverType);
+ communicationHandler.Connect();
+ try
+ {
+ checkServerVersion();
+ break;
+ }
+ catch (NullReferenceException)//There is a strange situation when sometimes checkServerVersion throws that command params is null. I investigated but didn't find the cause.
+ {
+ communicationHandler.Close();
+ }
+ }
+ }
+ }
+
+ private void splitVersion(string version, out string major, out string minor)
+ {
+ var parts = version.Split(new[] { "." }, StringSplitOptions.None);
+ major = parts[0];
+ minor = parts.Length > 1 ? parts[1] : string.Empty;
+ }
+
+ private void checkServerVersion()
+ {
+ string serverVersion = GetServerVersion();
+
+ string majorServer;
+ string majorDriver;
+ string minorDriver;
+ string minorServer;
+
+ splitVersion(serverVersion, out majorServer, out minorServer);
+ splitVersion(VERSION, out majorDriver, out minorDriver);
+
+ int serverMajor, serverMinor;
+
+ serverMajor = int.Parse(majorServer);
+ serverMinor = int.Parse(minorServer);
+
+ bool isSupported =
+ (serverMajor == 2 && serverMinor == 2) || // Server version 2.2.x
+ (serverMajor == 1 && serverMinor == 0); // Server version 1.0.0
+
+ if (!isSupported)
+ {
+ string message = $"Version mismatch. AltDriver version is {VERSION}. AltTester(R) version is {serverVersion}.";
+ logger.Warn(message);
+ }
+ }
+
+
+ ////////////////////////////////////////////
+ ///
+ /// Common methods for all drivers, they are public and can be used directly in the derived classes
+ ///
+ ////////////////////////////////////////////
+
+ public void Stop()
+ {
+ communicationHandler.Close();
+ }
+
+ public void SetCommandResponseTimeout(int commandTimeout)
+ {
+ communicationHandler.SetCommandTimeout(commandTimeout);
+ }
+
+ public void SetDelayAfterCommand(float delay)
+ {
+ communicationHandler.SetDelayAfterCommand(delay);
+ }
+
+ public float GetDelayAfterCommand()
+ {
+ return communicationHandler.GetDelayAfterCommand();
+ }
+
+ public string GetServerVersion()
+ {
+ string serverVersion = new AltGetServerVersion(communicationHandler).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return serverVersion;
+ }
+
+ public void SetLogging(bool enableLogging)
+ {
+ if (enableLogging)
+ DriverLogManager.ResumeLogging();
+ else
+ DriverLogManager.StopLogging();
+ }
+
+ public void KeyUp(AltKeyCode keyCode)
+ {
+ AltKeyCode[] keyCodes = { keyCode };
+ KeysUp(keyCodes);
+ }
+
+ ///
+ /// Simulates multiple keys up action in your app.
+ ///
+ /// The key codes of the keys simulated to be up.
+ public void KeysUp(AltKeyCode[] keyCodes)
+ {
+ new AltKeysUp(communicationHandler, keyCodes).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ public AltTextureInformation GetScreenshot(AltVector2 size = default(AltVector2), int screenShotQuality = 100)
+ {
+ var textureInformation = new AltGetScreenshot(communicationHandler, size, screenShotQuality).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return textureInformation;
+ }
+
+ public AltTextureInformation GetScreenshot(int id, AltColor color, float width, AltVector2 size = default(AltVector2), int screenShotQuality = 100)
+ {
+ var textureInformation = new AltGetHighlightObjectScreenshot(communicationHandler, id, color, width, size, screenShotQuality).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return textureInformation;
+ }
+
+ public AltTextureInformation GetScreenshot(AltVector2 coordinates, AltColor color, float width, out AltObject selectedObject, AltVector2 size = default(AltVector2), int screenShotQuality = 100)
+ {
+ var textureInformation = new AltGetHighlightObjectFromCoordinatesScreenshot(communicationHandler, coordinates, color, width, size, screenShotQuality).Execute(out selectedObject);
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return textureInformation;
+ }
+
+ public void GetPNGScreenshot(string path)
+ {
+ new AltGetPNGScreenshot(communicationHandler, path).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ public List GetAllLoadedScenesAndObjects(bool enabled = true)
+ {
+ var listOfObjects = new AltGetAllLoadedScenesAndObjects(communicationHandler, enabled).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return listOfObjects;
+ }
+
+ public void SetServerLogging(AltLogger logger, AltLogLevel logLevel)
+ {
+ new AltSetServerLogging(communicationHandler, logger, logLevel).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+
+ public void AddNotificationListener(NotificationType notificationType, Action callback, bool overwrite)
+ {
+ new AddNotificationListener(communicationHandler, notificationType, callback, overwrite).Execute();
+ }
+
+ public void RemoveNotificationListener(NotificationType notificationType)
+ {
+ new RemoveNotificationListener(communicationHandler, notificationType).Execute();
+ }
+
+ ////////////////////////////////////////////
+ ///
+ /// Protected methods that need to be implemented in the derived classes
+ ///
+ ////////////////////////////////////////////
+
+
+ protected void ResetInput()
+ {
+ new AltResetInput(communicationHandler).Execute();
+ }
+
+ protected void LoadScene(string scene, bool loadSingle = true)
+ {
+ new AltLoadScene(communicationHandler, scene, loadSingle).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected void UnloadScene(string scene)
+ {
+ new AltUnloadScene(communicationHandler, scene).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected List GetAllLoadedScenes()
+ {
+ var sceneList = new AltGetAllLoadedScenes(communicationHandler).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return sceneList;
+ }
+
+ protected string GetCurrentScene()
+ {
+ var sceneName = new AltGetCurrentScene(communicationHandler).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return sceneName;
+ }
+
+ protected void WaitForCurrentSceneToBe(string sceneName, double timeout = 10, double interval = 1)
+ {
+ new AltWaitForCurrentSceneToBe(communicationHandler, sceneName, timeout, interval).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected void SetTimeScale(float timeScale)
+ {
+ new AltSetTimeScale(communicationHandler, timeScale).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected float GetTimeScale()
+ {
+ var timeScale = new AltGetTimeScale(communicationHandler).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return timeScale;
+ }
+
+
+ protected void DeletePlayerPref()
+ {
+ new AltDeletePlayerPref(communicationHandler).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected void DeleteKeyPlayerPref(string keyName)
+ {
+ new AltDeleteKeyPlayerPref(communicationHandler, keyName).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected void SetKeyPlayerPref(string keyName, int valueName)
+ {
+ new AltSetKeyPLayerPref(communicationHandler, keyName, valueName).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected void SetKeyPlayerPref(string keyName, float valueName)
+ {
+ new AltSetKeyPLayerPref(communicationHandler, keyName, valueName).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected void SetKeyPlayerPref(string keyName, string valueName)
+ {
+ new AltSetKeyPLayerPref(communicationHandler, keyName, valueName).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected int GetIntKeyPlayerPref(string keyName)
+ {
+ var keyValue = new AltGetIntKeyPlayerPref(communicationHandler, keyName).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return keyValue;
+ }
+
+ protected float GetFloatKeyPlayerPref(string keyName)
+ {
+ var keyValue = new AltGetFloatKeyPlayerPref(communicationHandler, keyName).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return keyValue;
+ }
+
+ protected string GetStringKeyPlayerPref(string keyName)
+ {
+ var keyValue = new AltGetStringKeyPlayerPref(communicationHandler, keyName).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return keyValue;
+ }
+
+ protected List FindObjects(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true)
+ {
+ cameraAltBy ??= new AltBy(By.NAME, "");
+ var listOfObjects = new AltFindObjects(communicationHandler, altBy.By, altBy.Value, cameraAltBy.By, cameraAltBy.Value, enabled).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return listOfObjects;
+ }
+
+ protected List FindObjectsWhichContain(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true)
+ {
+ cameraAltBy ??= new AltBy(By.NAME, "");
+ var listOfObjects = new AltFindObjectsWhichContain(communicationHandler, altBy.By, altBy.Value, cameraAltBy.By, cameraAltBy.Value, enabled).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return listOfObjects;
+ }
+
+ protected AltObject FindObject(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true)
+ {
+ cameraAltBy ??= new AltBy(By.NAME, "");
+ var findObject = new AltFindObject(communicationHandler, altBy.By, altBy.Value, cameraAltBy.By, cameraAltBy.Value, enabled).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return findObject;
+ }
+
+ protected AltObject FindObjectWhichContains(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true)
+ {
+ cameraAltBy ??= new AltBy(By.NAME, "");
+ var findObject = new AltFindObjectWhichContains(communicationHandler, altBy.By, altBy.Value, cameraAltBy.By, cameraAltBy.Value, enabled).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return findObject;
+ }
+
+ protected T CallStaticMethod(string typeName, string methodName, string assemblyName,
+ object[] parameters, string[] typeOfParameters = null)
+ {
+ var result = new AltCallStaticMethod(communicationHandler, typeName, methodName, parameters, typeOfParameters, assemblyName).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return result;
+ }
+
+ protected T GetStaticProperty(string componentName, string propertyName, string assemblyName, int maxDepth = 2)
+ {
+ var propertyValue = new AltGetStaticProperty(communicationHandler, componentName, propertyName, assemblyName, maxDepth).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return propertyValue;
+ }
+
+ protected void SetStaticProperty(string componentName, string propertyName, string assemblyName, object updatedProperty)
+ {
+ new AltSetStaticProperty(communicationHandler, componentName, propertyName, assemblyName, updatedProperty).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ ///
+ /// Simulates a swipe action between two points.
+ ///
+ /// Coordinates of the screen where the swipe begins
+ /// Coordinates of the screen where the swipe ends
+ /// The time measured in seconds to move the mouse from start to end location. Defaults to 0.1.
+ /// If set wait for command to finish. Defaults to True.
+ protected void Swipe(AltVector2 start, AltVector2 end, float duration = 0.1f, bool wait = true)
+ {
+ new AltSwipe(communicationHandler, start, end, duration, wait).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ ///
+ /// Simulates a multipoint swipe action.
+ ///
+ /// A list of positions on the screen where the swipe be made.
+ /// The time measured in seconds to swipe from first position to the last position. Defaults to 0.1.
+ /// If set wait for command to finish. Defaults to True.
+ protected void MultipointSwipe(AltVector2[] positions, float duration = 0.1f, bool wait = true)
+ {
+ new AltMultipointSwipe(communicationHandler, positions, duration, wait).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ ///
+ /// Simulates holding left click button down for a specified amount of time at given coordinates.
+ ///
+ /// The coordinates where the button is held down.
+ /// The time measured in seconds to keep the button down.
+ /// If set wait for command to finish. Defaults to True.
+ protected void HoldButton(AltVector2 coordinates, float duration, bool wait = true)
+ {
+ Swipe(coordinates, coordinates, duration, wait);
+ }
+
+ ///
+ /// Simulates key press action in your app.
+ ///
+ /// The key code of the key simulated to be pressed.
+ /// A value between [-1,1] used for joysticks to indicate how hard the button was pressed. Defaults to 1.
+ /// The time measured in seconds from the key press to the key release. Defaults to 0.1
+ /// If set wait for command to finish. Defaults to True.
+ protected void PressKey(AltKeyCode keyCode, float power = 1, float duration = 0.1f, bool wait = true)
+ {
+ AltKeyCode[] keyCodes = { keyCode };
+ PressKeys(keyCodes, power, duration, wait);
+ }
+
+ ///
+ /// Simulates multiple keys pressed action in your app.
+ ///
+ /// The list of key codes of the keys simulated to be pressed.
+ /// A value between [-1,1] used for joysticks to indicate how hard the button was pressed. Defaults to 1.
+ /// The time measured in seconds from the key press to the key release. Defaults to 0.1
+ /// If set wait for command to finish. Defaults to True.
+ protected void PressKeys(AltKeyCode[] keyCodes, float power = 1, float duration = 0.1f, bool wait = true)
+ {
+ new AltPressKeys(communicationHandler, keyCodes, power, duration, wait).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected void KeyDown(AltKeyCode keyCode, float power = 1)
+ {
+ AltKeyCode[] keyCodes = { keyCode };
+ KeysDown(keyCodes, power);
+ }
+
+ ///
+ /// Simulates multiple keys down action in your app.
+ ///
+ /// The key codes of the keys simulated to be down.
+ /// A value between [-1,1] used for joysticks to indicate how hard the button was pressed. Defaults to 1.
+ protected void KeysDown(AltKeyCode[] keyCodes, float power = 1)
+ {
+ new AltKeysDown(communicationHandler, keyCodes, power).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ ///
+ /// Simulate mouse movement in your app.
+ ///
+ /// The screen coordinates
+ /// The time measured in seconds to move the mouse from the current mouse position to the set coordinates. Defaults to 0.1f
+ /// If set wait for command to finish. Defaults to True.
+ protected void MoveMouse(AltVector2 coordinates, float duration = 0.1f, bool wait = true)
+ {
+ new AltMoveMouse(communicationHandler, coordinates, duration, wait).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ ///
+ /// Simulate scroll action in your app.
+ ///
+ /// Set how fast to scroll. Positive values will scroll up and negative values will scroll down. Defaults to 1
+ /// The duration of the scroll in seconds. Defaults to 0.1
+ /// If set wait for command to finish. Defaults to True.
+ protected void Scroll(float speed = 1, float duration = 0.1f, bool wait = true)
+ {
+ new AltScroll(communicationHandler, speed, 0, duration, wait).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ ///
+ /// Simulate scroll action in your app.
+ ///
+ /// Set how fast to scroll. X is horizontal and Y is vertical. Defaults to 1
+ /// The duration of the scroll in seconds. Defaults to 0.1
+ /// If set wait for command to finish. Defaults to True.
+ protected void Scroll(AltVector2 scrollValue, float duration = 0.1f, bool wait = true)
+ {
+ new AltScroll(communicationHandler, scrollValue.y, scrollValue.x, duration, wait).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ ///
+ /// Tap at screen coordinates
+ ///
+ /// The screen coordinates
+ /// Number of taps
+ /// Interval between taps in seconds
+ /// If set wait for command to finish. Defaults to True.
+ protected void Tap(AltVector2 coordinates, int count = 1, float interval = 0.1f, bool wait = true)
+ {
+ new AltTapCoordinates(communicationHandler, coordinates, count, interval, wait).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ ///
+ /// Click at screen coordinates
+ ///
+ /// The screen coordinates
+ /// Number of clicks.
+ /// Interval between clicks in seconds
+ /// If set wait for command to finish. Defaults to True.
+ public void Click(AltVector2 coordinates, int count = 1, float interval = 0.1f, bool wait = true)
+ {
+ new AltClickCoordinates(communicationHandler, coordinates, count, interval, wait).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ ///
+ /// Simulates device rotation action in your app.
+ ///
+ /// The linear acceleration of a device.
+ /// How long the rotation will take in seconds. Defaults to 0.1.
+ /// If set wait for command to finish. Defaults to True.
+ protected void Tilt(AltVector3 acceleration, float duration = 0.1f, bool wait = true)
+ {
+ new AltTilt(communicationHandler, acceleration, duration, wait).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected List GetAllElements(AltBy cameraAltBy = null, bool enabled = true)
+ {
+ cameraAltBy ??= new AltBy(By.NAME, "");
+ var listOfObjects = new AltGetAllElements(communicationHandler, cameraAltBy.By, cameraAltBy.Value, enabled).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return listOfObjects;
+ }
+
+ protected List GetAllElementsLight(AltBy cameraAltBy = null, bool enabled = true)
+ {
+ cameraAltBy ??= new AltBy(By.NAME, "");
+ var listOfObjects = new AltGetAllElementsLight(communicationHandler, cameraAltBy.By, cameraAltBy.Value, enabled).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return listOfObjects;
+ }
+
+ protected AltObject WaitForObject(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true, double timeout = 20, double interval = 0.5)
+ {
+ cameraAltBy ??= new AltBy(By.NAME, "");
+ var objectFound = new AltWaitForObject(communicationHandler, altBy.By, altBy.Value, cameraAltBy.By, cameraAltBy.Value, enabled, timeout, interval).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return objectFound;
+ }
+
+ protected void WaitForObjectNotBePresent(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true, double timeout = 20, double interval = 0.5)
+ {
+ cameraAltBy ??= new AltBy(By.NAME, "");
+ new AltWaitForObjectNotBePresent(communicationHandler, altBy.By, altBy.Value, cameraAltBy.By, cameraAltBy.Value, enabled, timeout, interval).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected AltObject WaitForObjectWhichContains(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true, double timeout = 20, double interval = 0.5)
+ {
+ cameraAltBy ??= new AltBy(By.NAME, "");
+ var objectFound = new AltWaitForObjectWhichContains(communicationHandler, altBy.By, altBy.Value, cameraAltBy.By, cameraAltBy.Value, enabled, timeout, interval).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return objectFound;
+ }
+
+ protected List GetAllScenes()
+ {
+ var listOfScenes = new AltGetAllScenes(communicationHandler).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return listOfScenes;
+ }
+
+ protected List GetAllCameras()
+ {
+ var listOfCameras = new AltGetAllCameras(communicationHandler).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return listOfCameras;
+ }
+
+ protected List GetAllActiveCameras()
+ {
+ var listOfCameras = new AltGetAllActiveCameras(communicationHandler).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return listOfCameras;
+ }
+
+ protected AltVector2 GetApplicationScreenSize()
+ {
+ var applicationScreenSize = new AltGetApplicationScreenSize(communicationHandler).Execute();
+ return applicationScreenSize;
+ }
+
+ protected int BeginTouch(AltVector2 screenPosition)
+ {
+ var touchId = new AltBeginTouch(communicationHandler, screenPosition).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return touchId;
+ }
+
+ protected void MoveTouch(int fingerId, AltVector2 screenPosition)
+ {
+ new AltMoveTouch(communicationHandler, fingerId, screenPosition).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected void EndTouch(int fingerId)
+ {
+ new AltEndTouch(communicationHandler, fingerId).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ }
+
+ protected AltObject FindObjectAtCoordinates(AltVector2 coordinates)
+ {
+ var objectFound = new AltFindObjectAtCoordinates(communicationHandler, coordinates).Execute();
+ communicationHandler.SleepFor(communicationHandler.GetDelayAfterCommand());
+ return objectFound;
+ }
+ }
+}
diff --git a/Assets/AltTester/Runtime/AltDriver/AltDriverBase.cs.meta b/Assets/AltTester/Runtime/AltDriver/AltDriverBase.cs.meta
new file mode 100644
index 000000000..216c2e9c2
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/AltDriverBase.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7e6845d299e664da28e03dc64053603d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AltTester/Runtime/AltDriver/AltDriverUnity.cs b/Assets/AltTester/Runtime/AltDriver/AltDriverUnity.cs
new file mode 100644
index 000000000..bd06b9494
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/AltDriverUnity.cs
@@ -0,0 +1,342 @@
+/*
+ Copyright(C) 2025 Altom Consulting
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+using System;
+using System.Collections.Generic;
+using AltTester.AltTesterUnitySDK.Driver.Commands;
+
+namespace AltTester.AltTesterUnitySDK.Driver
+{
+ public class AltDriverUnity : AltDriverBase
+ {
+ public AltDriverUnity(string host = "127.0.0.1", int port = 13000, string appName = "__default__", bool enableLogging = false, int connectTimeout = 60, string platform = "unknown", string platformVersion = "unknown", string deviceInstanceId = "unknown", string appId = "unknown", string driverType = "SDK")
+ : base(host, port, appName, enableLogging, connectTimeout, platform, platformVersion, deviceInstanceId, appId, driverType)
+ {
+ }
+
+ public new void ResetInput()
+ {
+ base.ResetInput();
+ }
+ public new void LoadScene(string scene, bool loadSingle = true)
+ {
+ base.LoadScene(scene, loadSingle);
+ }
+
+ public new void UnloadScene(string scene)
+ {
+ base.UnloadScene(scene);
+ }
+
+ public new List GetAllLoadedScenes()
+ {
+ return base.GetAllLoadedScenes();
+ }
+
+ public new string GetCurrentScene()
+ {
+ return base.GetCurrentScene();
+ }
+
+ public new void WaitForCurrentSceneToBe(string sceneName, double timeout = 10, double interval = 1)
+ {
+ base.WaitForCurrentSceneToBe(sceneName, timeout, interval);
+ }
+
+ public new void SetTimeScale(float timeScale)
+ {
+ base.SetTimeScale(timeScale);
+ }
+
+ public new float GetTimeScale()
+ {
+ return base.GetTimeScale();
+ }
+
+
+ public new void DeletePlayerPref()
+ {
+ base.DeletePlayerPref();
+ }
+
+ public new void DeleteKeyPlayerPref(string keyName)
+ {
+ base.DeleteKeyPlayerPref(keyName);
+ }
+
+ public new void SetKeyPlayerPref(string keyName, int valueName)
+ {
+ base.SetKeyPlayerPref(keyName, valueName);
+ }
+
+ public new void SetKeyPlayerPref(string keyName, float valueName)
+ {
+ base.SetKeyPlayerPref(keyName, valueName);
+ }
+
+ public new void SetKeyPlayerPref(string keyName, string valueName)
+ {
+ base.SetKeyPlayerPref(keyName, valueName);
+ }
+
+ public new int GetIntKeyPlayerPref(string keyName)
+ {
+ return base.GetIntKeyPlayerPref(keyName);
+ }
+
+ public new float GetFloatKeyPlayerPref(string keyName)
+ {
+ return base.GetFloatKeyPlayerPref(keyName);
+ }
+
+ public new string GetStringKeyPlayerPref(string keyName)
+ {
+ return base.GetStringKeyPlayerPref(keyName);
+ }
+
+ public new List FindObjects(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true)
+ {
+ return base.FindObjects(altBy, cameraAltBy, enabled);
+ }
+
+ public new List FindObjectsWhichContain(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true)
+ {
+ return base.FindObjectsWhichContain(altBy, cameraAltBy, enabled);
+ }
+
+ public new AltObject FindObject(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true)
+ {
+ return base.FindObject(altBy, cameraAltBy, enabled);
+ }
+
+ public new AltObject FindObjectWhichContains(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true)
+ {
+ return base.FindObjectWhichContains(altBy, cameraAltBy, enabled);
+ }
+
+ public new T CallStaticMethod(string typeName, string methodName, string assemblyName,
+ object[] parameters, string[] typeOfParameters = null)
+ {
+ return base.CallStaticMethod(typeName, methodName, assemblyName, parameters, typeOfParameters);
+ }
+
+ public new T GetStaticProperty(string componentName, string propertyName, string assemblyName, int maxDepth = 2)
+ {
+ return base.GetStaticProperty(componentName, propertyName, assemblyName, maxDepth);
+ }
+
+ public new void SetStaticProperty(string componentName, string propertyName, string assemblyName, object updatedProperty)
+ {
+ base.SetStaticProperty(componentName, propertyName, assemblyName, updatedProperty);
+ }
+
+ ///
+ /// Simulates a swipe action between two points.
+ ///
+ /// Coordinates of the screen where the swipe begins
+ /// Coordinates of the screen where the swipe ends
+ /// The time measured in seconds to move the mouse from start to end location. Defaults to 0.1.
+ /// If set wait for command to finish. Defaults to True.
+ public new void Swipe(AltVector2 start, AltVector2 end, float duration = 0.1f, bool wait = true)
+ {
+ base.Swipe(start, end, duration, wait);
+ }
+
+ ///
+ /// Simulates a multipoint swipe action.
+ ///
+ /// A list of positions on the screen where the swipe be made.
+ /// The time measured in seconds to swipe from first position to the last position. Defaults to 0.1.
+ /// If set wait for command to finish. Defaults to True.
+ public new void MultipointSwipe(AltVector2[] positions, float duration = 0.1f, bool wait = true)
+ {
+ base.MultipointSwipe(positions, duration, wait);
+ }
+
+ ///
+ /// Simulates holding left click button down for a specified amount of time at given coordinates.
+ ///
+ /// The coordinates where the button is held down.
+ /// The time measured in seconds to keep the button down.
+ /// If set wait for command to finish. Defaults to True.
+ public new void HoldButton(AltVector2 coordinates, float duration, bool wait = true)
+ {
+ base.HoldButton(coordinates, duration, wait);
+ }
+
+ ///
+ /// Simulates key press action in your app.
+ ///
+ /// The key code of the key simulated to be pressed.
+ /// A value between [-1,1] used for joysticks to indicate how hard the button was pressed. Defaults to 1.
+ /// The time measured in seconds from the key press to the key release. Defaults to 0.1
+ /// If set wait for command to finish. Defaults to True.
+ public new void PressKey(AltKeyCode keyCode, float power = 1, float duration = 0.1f, bool wait = true)
+ {
+ base.PressKey(keyCode, power, duration, wait);
+ }
+
+ ///
+ /// Simulates multiple keys pressed action in your app.
+ ///
+ /// The list of key codes of the keys simulated to be pressed.
+ /// A value between [-1,1] used for joysticks to indicate how hard the button was pressed. Defaults to 1.
+ /// The time measured in seconds from the key press to the key release. Defaults to 0.1
+ /// If set wait for command to finish. Defaults to True.
+ public new void PressKeys(AltKeyCode[] keyCodes, float power = 1, float duration = 0.1f, bool wait = true)
+ {
+ base.PressKeys(keyCodes, power, duration, wait);
+ }
+
+ public new void KeyDown(AltKeyCode keyCode, float power = 1)
+ {
+ base.KeyDown(keyCode, power);
+ }
+
+ ///
+ /// Simulates multiple keys down action in your app.
+ ///
+ /// The key codes of the keys simulated to be down.
+ /// A value between [-1,1] used for joysticks to indicate how hard the button was pressed. Defaults to 1.
+ public new void KeysDown(AltKeyCode[] keyCodes, float power = 1)
+ {
+ base.KeysDown(keyCodes, power);
+ }
+
+
+ ///
+ /// Simulate mouse movement in your app.
+ ///
+ /// The screen coordinates
+ /// The time measured in seconds to move the mouse from the current mouse position to the set coordinates. Defaults to 0.1f
+ /// If set wait for command to finish. Defaults to True.
+ public new void MoveMouse(AltVector2 coordinates, float duration = 0.1f, bool wait = true)
+ {
+ base.MoveMouse(coordinates, duration, wait);
+ }
+
+ ///
+ /// Simulate scroll action in your app.
+ ///
+ /// Set how fast to scroll. Positive values will scroll up and negative values will scroll down. Defaults to 1
+ /// The duration of the scroll in seconds. Defaults to 0.1
+ /// If set wait for command to finish. Defaults to True.
+ public new void Scroll(float speed = 1, float duration = 0.1f, bool wait = true)
+ {
+ base.Scroll(speed, duration, wait);
+ }
+
+ ///
+ /// Simulate scroll action in your app.
+ ///
+ /// Set how fast to scroll. X is horizontal and Y is vertical. Defaults to 1
+ /// The duration of the scroll in seconds. Defaults to 0.1
+ /// If set wait for command to finish. Defaults to True.
+ public new void Scroll(AltVector2 scrollValue, float duration = 0.1f, bool wait = true)
+ {
+ base.Scroll(scrollValue, duration, wait);
+ }
+
+ ///
+ /// Tap at screen coordinates
+ ///
+ /// The screen coordinates
+ /// Number of taps
+ /// Interval between taps in seconds
+ /// If set wait for command to finish. Defaults to True.
+ public new void Tap(AltVector2 coordinates, int count = 1, float interval = 0.1f, bool wait = true)
+ {
+ base.Tap(coordinates, count, interval, wait);
+ }
+
+ ///
+ /// Simulates device rotation action in your app.
+ ///
+ /// The linear acceleration of a device.
+ /// How long the rotation will take in seconds. Defaults to 0.1.
+ /// If set wait for command to finish. Defaults to True.
+ public new void Tilt(AltVector3 acceleration, float duration = 0.1f, bool wait = true)
+ {
+ base.Tilt(acceleration, duration, wait);
+ }
+
+ public new List GetAllElements(AltBy cameraAltBy = null, bool enabled = true)
+ {
+ return base.GetAllElements(cameraAltBy, enabled);
+ }
+
+ public new List GetAllElementsLight(AltBy cameraAltBy = null, bool enabled = true)
+ {
+ return base.GetAllElementsLight(cameraAltBy, enabled);
+ }
+
+ public new AltObject WaitForObject(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true, double timeout = 20, double interval = 0.5)
+ {
+ return base.WaitForObject(altBy, cameraAltBy, enabled, timeout, interval);
+ }
+
+ public new void WaitForObjectNotBePresent(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true, double timeout = 20, double interval = 0.5)
+ {
+ base.WaitForObjectNotBePresent(altBy, cameraAltBy, enabled, timeout, interval);
+ }
+
+ public new AltObject WaitForObjectWhichContains(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true, double timeout = 20, double interval = 0.5)
+ {
+ return base.WaitForObjectWhichContains(altBy, cameraAltBy, enabled, timeout, interval);
+ }
+
+ public new List GetAllScenes()
+ {
+ return base.GetAllScenes();
+ }
+
+ public new List GetAllCameras()
+ {
+ return base.GetAllCameras();
+ }
+
+ public new List GetAllActiveCameras()
+ {
+ return base.GetAllActiveCameras();
+ }
+ public new AltVector2 GetApplicationScreenSize()
+ {
+ return base.GetApplicationScreenSize();
+ }
+
+
+ public new int BeginTouch(AltVector2 screenPosition)
+ {
+ return base.BeginTouch(screenPosition);
+ }
+
+ public new void MoveTouch(int fingerId, AltVector2 screenPosition)
+ {
+ base.MoveTouch(fingerId, screenPosition);
+ }
+
+ public new void EndTouch(int fingerId)
+ {
+ base.EndTouch(fingerId);
+ }
+
+ public new AltObject FindObjectAtCoordinates(AltVector2 screenPosition)
+ {
+ return base.FindObjectAtCoordinates(screenPosition);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/AltTester/Runtime/AltDriver/AltDriverUnity.cs.meta b/Assets/AltTester/Runtime/AltDriver/AltDriverUnity.cs.meta
new file mode 100644
index 000000000..b30994e87
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/AltDriverUnity.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: abf10e516cd774b878f02f7d35a29c11
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AltTester/Runtime/AltDriver/AltDriverUnreal.cs b/Assets/AltTester/Runtime/AltDriver/AltDriverUnreal.cs
new file mode 100644
index 000000000..c1b22bf22
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/AltDriverUnreal.cs
@@ -0,0 +1,138 @@
+/*
+ Copyright(C) 2025 Altom Consulting
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+
+using System;
+using System.Collections.Generic;
+using AltTester.AltTesterUnitySDK.Driver.Commands;
+
+namespace AltTester.AltTesterUnitySDK.Driver
+{
+ public class AltDriverUnreal : AltDriverBase
+ {
+ public AltDriverUnreal(string host = "127.0.0.1", int port = 13000, string appName = "__default__", bool enableLogging = false, int connectTimeout = 60, string platform = "unknown", string platformVersion = "unknown", string deviceInstanceId = "unknown", string appId = "unknown", string driverType = "SDK")
+ : base(host, port, appName, enableLogging, connectTimeout, platform, platformVersion, deviceInstanceId, appId, driverType)
+ {
+ }
+
+ public AltObjectUnreal FindObject(AltBy altBy, bool enabled = true)
+ {
+ AltObject altObject = base.FindObject(altBy, enabled: enabled);
+ return AltObjectUnreal.Create(altObject);
+ }
+
+ public AltObjectUnreal FindObjectWhichContains(AltBy altBy, bool enabled = true)
+ {
+ return AltObjectUnreal.Create(base.FindObjectWhichContains(altBy, enabled: enabled));
+ }
+
+
+ public List FindObjects(AltBy altBy, bool enabled = true)
+ {
+ return base.FindObjects(altBy, enabled: enabled).ConvertAll(obj => AltObjectUnreal.Create(obj));
+ }
+
+
+ public List FindObjectsWhichContain(AltBy altBy, bool enabled = true)
+ {
+
+ return base.FindObjectsWhichContain(altBy, enabled: enabled).ConvertAll(obj => AltObjectUnreal.Create(obj));
+ }
+
+
+ public List GetAllElements(bool enabled = true)
+ {
+ return base.GetAllElements(enabled: enabled).ConvertAll(obj => AltObjectUnreal.Create(obj));
+ }
+
+ public List GetAllElementsLight(bool enabled = true)
+ {
+ return base.GetAllElementsLight(enabled: enabled);
+ }
+
+
+ public AltObjectUnreal WaitForObject(AltBy altBy, bool enabled = true, int timeout = 20, double interval = 0.5)
+ {
+ return AltObjectUnreal.Create(base.WaitForObject(altBy, enabled: enabled, timeout: timeout, interval: interval));
+ }
+
+ public void WaitForObjectNotBePresent(AltBy altBy, bool enabled = true, int timeout = 20, double interval = 0.5)
+ {
+ base.WaitForObjectNotBePresent(altBy, enabled: enabled, timeout: timeout, interval: interval);
+ }
+
+ public AltObjectUnreal WaitForObjectWhichContains(AltBy altBy, AltBy cameraAltBy = null, bool enabled = true, int timeout = 20, double interval = 0.5)
+ {
+ return AltObjectUnreal.Create(base.WaitForObjectWhichContains(altBy, enabled: enabled, timeout: timeout, interval: interval));
+ }
+
+ public void KeyDown(AltKeyCode key)
+ {
+ base.KeyDown(key, power: 1);
+ }
+
+ public void KeysDown(AltKeyCode[] keyCodes)
+ {
+ base.KeysDown(keyCodes, power: 1);
+ }
+
+ public void PressKey(AltKeyCode key)
+ {
+ base.PressKey(key, power: 1);
+ }
+
+ public void PressKeys(AltKeyCode[] keyCodes)
+ {
+ base.PressKeys(keyCodes, power: 1);
+ }
+
+ public void LoadLevel(string levelName)
+ {
+ base.LoadScene(levelName);
+ }
+
+ public string GetCurrentLevel()
+ {
+ return base.GetCurrentScene();
+ }
+
+ public void WaitForCurrentLevelToBe(string levelName, double timeout = 10, double interval = 1)
+ {
+ base.WaitForCurrentSceneToBe(levelName, timeout, interval);
+ }
+
+ public float GetGlobalTimeDilation()
+ {
+ return base.GetTimeScale();
+ }
+
+ public void SetGlobalTimeDilation(float timeDilation)
+ {
+ base.SetTimeScale(timeDilation);
+ }
+
+ public T CallStaticMethod(string typeName, string methodName, object[] parameters, string[] typeOfParameters = null)
+ {
+ return base.CallStaticMethod(typeName, methodName, "", parameters, typeOfParameters);
+ }
+
+ public new AltObjectUnreal FindObjectAtCoordinates(AltVector2 screenPosition)
+ {
+ return AltObjectUnreal.Create(base.FindObjectAtCoordinates(screenPosition));
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/AltTester/Runtime/AltDriver/AltDriverUnreal.cs.meta b/Assets/AltTester/Runtime/AltDriver/AltDriverUnreal.cs.meta
new file mode 100644
index 000000000..2f295942a
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/AltDriverUnreal.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c1e09b9ef5da6404880cf54a3b115a36
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AltTester/Runtime/AltDriver/Common/AltBy.cs b/Assets/AltTester/Runtime/AltDriver/Common/AltBy.cs
new file mode 100644
index 000000000..6eba5f7a0
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/Common/AltBy.cs
@@ -0,0 +1,40 @@
+/*
+ Copyright(C) 2024 Altom Consulting
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+namespace AltTester.AltTesterUnitySDK.Driver
+{
+ public class AltBy
+ {
+ public By By { get; set; }
+ public string Value { get; set; }
+
+ public AltBy(By by, string value)
+ {
+ this.By = by;
+ this.Value = value;
+ }
+
+ public static AltBy Text(string text) => new(By.TEXT, text);
+ public static AltBy Name(string name) => new(By.NAME, name);
+ public static AltBy Id(string id) => new(By.ID, id);
+ public static AltBy Tag(string tag) => new(By.TAG, tag);
+ public static AltBy Layer(string layer) => new(By.LAYER, layer);
+ public static AltBy Component(string component) => new(By.COMPONENT, component);
+ public static AltBy Path(string path) => new(By.PATH, path);
+
+ }
+}
diff --git a/Assets/AltTester/Runtime/AltDriver/Common/AltBy.cs.meta b/Assets/AltTester/Runtime/AltDriver/Common/AltBy.cs.meta
new file mode 100644
index 000000000..cdd910586
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/Common/AltBy.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d9375e355126846c79ffe3fcea3c8e01
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AltTester/Runtime/AltDriver/Common/AltObject.cs b/Assets/AltTester/Runtime/AltDriver/Common/AltObject.cs
index 0f611b80a..ca7c4b2fc 100644
--- a/Assets/AltTester/Runtime/AltDriver/Common/AltObject.cs
+++ b/Assets/AltTester/Runtime/AltDriver/Common/AltObject.cs
@@ -19,144 +19,70 @@ You should have received a copy of the GNU General Public License
using System.Collections.Generic;
using System.Threading;
using AltTester.AltTesterUnitySDK.Driver.Commands;
+using Newtonsoft.Json;
namespace AltTester.AltTesterUnitySDK.Driver
{
- public class AltObject
+ public class AltObject: AltObjectBase
{
- public string name;
- public int id;
- public int x;
- public int y;
- public int z;
- public int mobileY;
- public string type;
- public bool enabled;
- public float worldX;
- public float worldY;
- public float worldZ;
- public int idCamera;
- public int transformParentId;
- public int transformId;
- [Newtonsoft.Json.JsonIgnore]
- public IDriverCommunication CommHandler;
-
+
+ [JsonConstructor]
public AltObject(string name, int id = 0, int x = 0, int y = 0, int z = 0, int mobileY = 0, string type = "", bool enabled = true, float worldX = 0, float worldY = 0, float worldZ = 0, int idCamera = 0, int transformParentId = 0, int transformId = 0)
+ : base(name, id, x, y, z, mobileY, type, enabled, worldX, worldY, worldZ, idCamera, transformParentId, transformId)
{
- this.name = name;
- this.id = id;
- this.x = x;
- this.y = y;
- this.z = z;
- this.mobileY = mobileY;
- this.type = type;
- this.enabled = enabled;
- this.worldX = worldX;
- this.worldY = worldY;
- this.worldZ = worldZ;
- this.idCamera = idCamera;
- this.transformParentId = transformParentId;
- this.transformId = transformId;
- }
-
- public AltObject UpdateObject()
- {
- var altObject = new AltFindObject(CommHandler, By.ID, this.id.ToString(), By.NAME, "", this.enabled).Execute();
- x = altObject.x;
- y = altObject.y;
- z = altObject.z;
- id = altObject.id;
- name = altObject.name;
- mobileY = altObject.mobileY;
- type = altObject.type;
- enabled = altObject.enabled;
- worldX = altObject.worldX;
- worldY = altObject.worldY;
- worldZ = altObject.worldZ;
- idCamera = altObject.idCamera;
- transformParentId = altObject.transformParentId;
- transformId = altObject.transformId;
-
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return this;
- }
- public AltObject GetParent()
- {
- var altObject = new AltFindObject(CommHandler, By.PATH, "//*[@id=" + this.id + "]/..", By.NAME, "", true).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
- }
-
- [Obsolete("getParent is deprecated, please use GetParent instead.")]
- public AltObject getParent()
- {
- var altObject = new AltFindObject(CommHandler, By.PATH, "//*[@id=" + this.id + "]/..", By.NAME, "", true).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
- }
- public AltObject FindObjectFromObject(By by, string value, By cameraBy = By.NAME, string cameraValue = "", bool enabled = true)
- {
- var findObject = new AltFindObjectFromObject(CommHandler, by, value, cameraBy, cameraValue, enabled, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return findObject;
- }
- public AltVector2 GetScreenPosition()
- {
- return new AltVector2(x, y);
}
- [Obsolete("getScreenPosition is deprecated, please use GetScreenPosition instead.")]
- public AltVector2 getScreenPosition()
+ public AltObject(AltObjectBase altObjectBase)
+ : base(altObjectBase.name, altObjectBase.id, altObjectBase.x, altObjectBase.y, altObjectBase.z, altObjectBase.mobileY, altObjectBase.type, altObjectBase.enabled, altObjectBase.worldX, altObjectBase.worldY, altObjectBase.worldZ, altObjectBase.idCamera, altObjectBase.transformParentId, altObjectBase.transformId)
{
- return new AltVector2(x, y);
+ this.name = altObjectBase.name;
+ this.id = altObjectBase.id;
+ this.x = altObjectBase.x;
+ this.y = altObjectBase.y;
+ this.z = altObjectBase.z;
+ this.mobileY = altObjectBase.mobileY;
+ this.type = altObjectBase.type;
+ this.enabled = altObjectBase.enabled;
+ this.worldX = altObjectBase.worldX;
+ this.worldY = altObjectBase.worldY;
+ this.worldZ = altObjectBase.worldZ;
+ this.idCamera = altObjectBase.idCamera;
+ this.transformParentId = altObjectBase.transformParentId;
+ this.transformId = altObjectBase.transformId;
+ this.CommHandler = altObjectBase.CommHandler;
}
- public AltVector3 GetWorldPosition()
+
+ public new AltObject UpdateObject()
{
- return new AltVector3(worldX, worldY, worldZ);
+ return base.UpdateObject();
}
- [Obsolete("getWorldPosition is deprecated, please use GetWorldPosition instead.")]
- public AltVector3 getWorldPosition()
+ public new AltObject FindObjectFromObject(By by, string value, By cameraBy = By.NAME, string cameraValue = "", bool enabled = true)
{
- return new AltVector3(worldX, worldY, worldZ);
- }
- public T GetComponentProperty(string componentName, string propertyName, string assemblyName, int maxDepth = 2)
- {
- var propertyValue = new AltGetComponentProperty(CommHandler, componentName, propertyName, assemblyName, maxDepth, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return propertyValue;
+ return base.FindObjectFromObject(by, value, cameraBy, cameraValue, enabled);
}
- public T WaitForComponentProperty(string componentName, string propertyName, T propertyValue, string assemblyName, double timeout = 20, double interval = 0.5, bool getPropertyAsString = false, int maxDepth = 2)
+
+ public new T GetComponentProperty(string componentName, string propertyName, string assemblyName, int maxDepth = 2)
{
- var propertyFound = new AltWaitForComponentProperty(CommHandler, componentName, propertyName, propertyValue, assemblyName, timeout, interval, getPropertyAsString, maxDepth, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return propertyFound;
+ return base.GetComponentProperty(componentName, propertyName, assemblyName, maxDepth);
}
- public void SetComponentProperty(string componentName, string propertyName, object value, string assemblyName)
+ public new T WaitForComponentProperty(string componentName, string propertyName, T propertyValue, string assemblyName, double timeout = 20, double interval = 0.5, bool getPropertyAsString = false, int maxDepth = 2)
{
- new AltSetComponentProperty(CommHandler, componentName, propertyName, value, assemblyName, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return base.WaitForComponentProperty(componentName, propertyName, propertyValue, assemblyName, timeout, interval, getPropertyAsString, maxDepth);
}
-
- public T CallComponentMethod(string componentName, string methodName, string assemblyName, object[] parameters, string[] typeOfParameters = null)
+ public new void SetComponentProperty(string componentName, string propertyName, object value, string assemblyName)
{
- var result = new AltCallComponentMethod(CommHandler, componentName, methodName, parameters, typeOfParameters, assemblyName, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return result;
+ base.SetComponentProperty(componentName, propertyName, value, assemblyName);
}
- public string GetText()
+ public new T CallComponentMethod(string componentName, string methodName, string assemblyName, object[] parameters, string[] typeOfParameters = null)
{
- var text = new AltGetText(CommHandler, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return text;
+ return base.CallComponentMethod(componentName, methodName, assemblyName, parameters, typeOfParameters);
}
- public AltObject SetText(string text, bool submit = false)
+ public new AltObject SetText(string text, bool submit = false)
{
- var altObject = new AltSetText(CommHandler, this, text, submit).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
+ return base.SetText(text, submit);
}
///
@@ -166,63 +92,29 @@ public AltObject SetText(string text, bool submit = false)
/// Interval between clicks in seconds
/// Wait for command to finish
/// The clicked object
- public AltObject Click(int count = 1, float interval = 0.1f, bool wait = true)
+ public new AltObject Click(int count = 1, float interval = 0.1f, bool wait = true)
{
- var altObject = new AltClickElement(CommHandler, this, count, interval, wait).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
- }
-
- [Obsolete("PointerUpFromObject is deprecated, please use PointerUp instead.")]
- public AltObject PointerUpFromObject()
- {
- return PointerUp();
- }
-
- public AltObject PointerUp()
- {
- var altObject = new AltPointerUpFromObject(CommHandler, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
- }
-
- [Obsolete("PointerDownFromObject is deprecated, please use PointerDown instead.")]
- public AltObject PointerDownFromObject()
- {
- return PointerDown();
- }
-
- public AltObject PointerDown()
- {
- var altObject = new AltPointerDownFromObject(CommHandler, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
+ return base.Click(count, interval, wait);
}
- [Obsolete("PointerEnterObject is deprecated, please use PointerEnter instead.")]
- public AltObject PointerEnterObject()
+ public new AltObject PointerUp()
{
- return PointerEnter();
+ return base.PointerUp();
}
- public AltObject PointerEnter()
+ public new AltObject PointerDown()
{
- var altObject = new AltPointerEnterObject(CommHandler, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
+ return base.PointerDown();
}
- [Obsolete("PointerExitObject is deprecated, please use PointerExit instead.")]
- public AltObject PointerExitObject()
+ public new AltObject PointerEnter()
{
- return PointerExit();
+ return base.PointerEnter();
}
- public AltObject PointerExit()
+ public new AltObject PointerExit()
{
- var altObject = new AltPointerExitObject(CommHandler, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
+ return base.PointerExit();
}
///
@@ -232,49 +124,33 @@ public AltObject PointerExit()
/// Interval in seconds
/// Wait for command to finish
/// The tapped object
- public AltObject Tap(int count = 1, float interval = 0.1f, bool wait = true)
+ public new AltObject Tap(int count = 1, float interval = 0.1f, bool wait = true)
{
- var altObject = new AltTapElement(CommHandler, this, count, interval, wait).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
+ return base.Tap(count, interval, wait);
}
- public System.Collections.Generic.List GetAllComponents()
+ public new System.Collections.Generic.List GetAllComponents()
{
- var altObject = new AltGetAllComponents(CommHandler, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
+ return base.GetAllComponents();
}
- public System.Collections.Generic.List GetAllProperties(AltComponent altComponent, AltPropertiesSelections altPropertiesSelections = AltPropertiesSelections.ALLPROPERTIES)
+ public new System.Collections.Generic.List GetAllProperties(AltComponent altComponent, AltPropertiesSelections altPropertiesSelections = AltPropertiesSelections.ALLPROPERTIES)
{
- var altObject = new AltGetAllProperties(CommHandler, altComponent, this, altPropertiesSelections).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
+ return base.GetAllProperties(altComponent, altPropertiesSelections);
}
- public System.Collections.Generic.List GetAllFields(AltComponent altComponent, AltFieldsSelections altFieldsSelections = AltFieldsSelections.ALLFIELDS)
+ public new System.Collections.Generic.List GetAllFields(AltComponent altComponent, AltFieldsSelections altFieldsSelections = AltFieldsSelections.ALLFIELDS)
{
- var altObject = new AltGetAllFields(CommHandler, altComponent, this, altFieldsSelections).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
+ return base.GetAllFields(altComponent, altFieldsSelections);
}
- public System.Collections.Generic.List GetAllMethods(AltComponent altComponent, AltMethodSelection methodSelection = AltMethodSelection.ALLMETHODS)
+ public new System.Collections.Generic.List GetAllMethods(AltComponent altComponent, AltMethodSelection methodSelection = AltMethodSelection.ALLMETHODS)
{
- var altObject = new AltGetAllMethods(CommHandler, altComponent, methodSelection).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return altObject;
+ return base.GetAllMethods(altComponent, methodSelection);
}
- public T GetVisualElementProperty(string propertyName)
+ public new T GetVisualElementProperty(string propertyName)
{
- if (type != "UIToolkit")
- {
- throw new WrongAltObjectTypeException("This method is only available for VisualElement objects");
- }
- var propertyValue = new AltGetVisualElementProperty(CommHandler, propertyName, this).Execute();
- CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
- return propertyValue;
+ return base.GetVisualElementProperty(propertyName);
}
public T WaitForVisualElementProperty(string propertyName, T propertyValue, double timeout = 20, double interval = 0.5, bool getPropertyAsString = false)
{
diff --git a/Assets/AltTester/Runtime/AltDriver/Common/AltObjectBase.cs b/Assets/AltTester/Runtime/AltDriver/Common/AltObjectBase.cs
new file mode 100644
index 000000000..2b1556789
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/Common/AltObjectBase.cs
@@ -0,0 +1,296 @@
+/*
+ Copyright(C) 2025 Altom Consulting
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+using System;
+using System.Threading;
+using AltTester.AltTesterUnitySDK.Driver.Commands;
+
+namespace AltTester.AltTesterUnitySDK.Driver
+{
+ public class AltObjectBase
+ {
+ public string name;
+ public int id;
+ public int x;
+ public int y;
+ public int z;
+ public int mobileY;
+ public string type;
+ public bool enabled;
+ public float worldX;
+ public float worldY;
+ public float worldZ;
+ public int idCamera;
+ public int transformParentId;
+ public int transformId;
+ [Newtonsoft.Json.JsonIgnore]
+ public IDriverCommunication CommHandler;
+
+ public AltObjectBase(string name, int id = 0, int x = 0, int y = 0, int z = 0, int mobileY = 0, string type = "", bool enabled = true, float worldX = 0, float worldY = 0, float worldZ = 0, int idCamera = 0, int transformParentId = 0, int transformId = 0)
+ {
+ this.name = name;
+ this.id = id;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.mobileY = mobileY;
+ this.type = type;
+ this.enabled = enabled;
+ this.worldX = worldX;
+ this.worldY = worldY;
+ this.worldZ = worldZ;
+ this.idCamera = idCamera;
+ this.transformParentId = transformParentId;
+ this.transformId = transformId;
+ }
+
+ protected AltObject UpdateObject()
+ {
+ var altObject = new AltFindObject(CommHandler, By.ID, this.id.ToString(), By.NAME, "", this.enabled).Execute();
+ x = altObject.x;
+ y = altObject.y;
+ z = altObject.z;
+ id = altObject.id;
+ name = altObject.name;
+ mobileY = altObject.mobileY;
+ type = altObject.type;
+ enabled = altObject.enabled;
+ worldX = altObject.worldX;
+ worldY = altObject.worldY;
+ worldZ = altObject.worldZ;
+ idCamera = altObject.idCamera;
+ transformParentId = altObject.transformParentId;
+ transformId = altObject.transformId;
+
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return new AltObject(this);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null || GetType() != obj.GetType())
+ {
+ return false;
+ }
+
+ AltObject altObject = (AltObject)obj;
+ return id == altObject.id;
+ }
+
+ public override int GetHashCode()
+ {
+ return id;
+ }
+
+ public AltObject GetParent()
+ {
+ var altObject = new AltFindObject(CommHandler, By.PATH, "//*[@id=" + this.id + "]/..", By.NAME, "", true).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+
+ [Obsolete("getParent is deprecated, please use GetParent instead.")]
+ protected AltObject getParent()
+ {
+ var altObject = new AltFindObject(CommHandler, By.PATH, "//*[@id=" + this.id + "]/..", By.NAME, "", true).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+ protected AltObject FindObjectFromObject(By by, string value, By cameraBy = By.NAME, string cameraValue = "", bool enabled = true)
+ {
+ var findObject = new AltFindObjectFromObject(CommHandler, by, value, cameraBy, cameraValue, enabled, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return findObject;
+ }
+ public AltVector2 GetScreenPosition()
+ {
+ return new AltVector2(x, y);
+ }
+
+ [Obsolete("getScreenPosition is deprecated, please use GetScreenPosition instead.")]
+ protected AltVector2 getScreenPosition()
+ {
+ return new AltVector2(x, y);
+ }
+ public AltVector3 GetWorldPosition()
+ {
+ return new AltVector3(worldX, worldY, worldZ);
+ }
+
+ [Obsolete("getWorldPosition is deprecated, please use GetWorldPosition instead.")]
+ protected AltVector3 getWorldPosition()
+ {
+ return new AltVector3(worldX, worldY, worldZ);
+ }
+ protected T GetComponentProperty(string componentName, string propertyName, string assemblyName, int maxDepth = 2)
+ {
+ var propertyValue = new AltGetComponentProperty(CommHandler, componentName, propertyName, assemblyName, maxDepth, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return propertyValue;
+ }
+ protected T WaitForComponentProperty(string componentName, string propertyName, T propertyValue, string assemblyName, double timeout = 20, double interval = 0.5, bool getPropertyAsString = false, int maxDepth = 2)
+ {
+ var propertyFound = new AltWaitForComponentProperty(CommHandler, componentName, propertyName, propertyValue, assemblyName, timeout, interval, getPropertyAsString, maxDepth, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return propertyFound;
+ }
+ protected void SetComponentProperty(string componentName, string propertyName, object value, string assemblyName)
+ {
+ new AltSetComponentProperty(CommHandler, componentName, propertyName, value, assemblyName, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ }
+
+ protected T CallComponentMethod(string componentName, string methodName, string assemblyName, object[] parameters, string[] typeOfParameters = null)
+ {
+ var result = new AltCallComponentMethod(CommHandler, componentName, methodName, parameters, typeOfParameters, assemblyName, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return result;
+ }
+
+ public string GetText()
+ {
+ var text = new AltGetText(CommHandler, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return text;
+ }
+
+ protected AltObject SetText(string text, bool submit = false)
+ {
+ var altObject = new AltSetText(CommHandler, new AltObject(this), text, submit).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+
+ ///
+ /// Click current object
+ ///
+ /// Number of times to click
+ /// Interval between clicks in seconds
+ /// Wait for command to finish
+ /// The clicked object
+ protected AltObject Click(int count = 1, float interval = 0.1f, bool wait = true)
+ {
+ var altObject = new AltClickElement(CommHandler, new AltObject(this), count, interval, wait).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+
+ [Obsolete("PointerUpFromObject is deprecated, please use PointerUp instead.")]
+ protected AltObject PointerUpFromObject()
+ {
+ return PointerUp();
+ }
+
+ protected AltObject PointerUp()
+ {
+ var altObject = new AltPointerUpFromObject(CommHandler, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+
+ [Obsolete("PointerDownFromObject is deprecated, please use PointerDown instead.")]
+ protected AltObject PointerDownFromObject()
+ {
+ return PointerDown();
+ }
+
+ protected AltObject PointerDown()
+ {
+ var altObject = new AltPointerDownFromObject(CommHandler, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+
+ [Obsolete("PointerEnterObject is deprecated, please use PointerEnter instead.")]
+ protected AltObject PointerEnterObject()
+ {
+ return PointerEnter();
+ }
+
+ protected AltObject PointerEnter()
+ {
+ var altObject = new AltPointerEnterObject(CommHandler, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+
+ [Obsolete("PointerExitObject is deprecated, please use PointerExit instead.")]
+ protected AltObject PointerExitObject()
+ {
+ return PointerExit();
+ }
+
+ protected AltObject PointerExit()
+ {
+ var altObject = new AltPointerExitObject(CommHandler, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+
+ ///
+ /// Tap current object
+ ///
+ /// Number of taps
+ /// Interval in seconds
+ /// Wait for command to finish
+ /// The tapped object
+ protected AltObject Tap(int count = 1, float interval = 0.1f, bool wait = true)
+ {
+ var altObject = new AltTapElement(CommHandler, new AltObject(this), count, interval, wait).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+
+ public System.Collections.Generic.List GetAllComponents()
+ {
+ var altObject = new AltGetAllComponents(CommHandler, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+
+ protected System.Collections.Generic.List GetAllProperties(AltComponent altComponent, AltPropertiesSelections altPropertiesSelections = AltPropertiesSelections.ALLPROPERTIES)
+ {
+ var altObject = new AltGetAllProperties(CommHandler, altComponent, new AltObject(this), altPropertiesSelections).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+
+ protected System.Collections.Generic.List GetAllFields(AltComponent altComponent, AltFieldsSelections altFieldsSelections = AltFieldsSelections.ALLFIELDS)
+ {
+ var altObject = new AltGetAllFields(CommHandler, altComponent, new AltObject(this), altFieldsSelections).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+
+ protected System.Collections.Generic.List GetAllMethods(AltComponent altComponent, AltMethodSelection methodSelection = AltMethodSelection.ALLMETHODS)
+ {
+ var altObject = new AltGetAllMethods(CommHandler, altComponent, methodSelection).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return altObject;
+ }
+ protected T GetVisualElementProperty(string propertyName)
+ {
+ if (type != "UIToolkit")
+ {
+ throw new WrongAltObjectTypeException("This method is only available for VisualElement objects");
+ }
+ var propertyValue = new AltGetVisualElementProperty(CommHandler, propertyName, new AltObject(this)).Execute();
+ CommHandler.SleepFor(CommHandler.GetDelayAfterCommand());
+ return propertyValue;
+ }
+ }
+}
diff --git a/Assets/AltTester/Runtime/AltDriver/Common/AltObjectBase.cs.meta b/Assets/AltTester/Runtime/AltDriver/Common/AltObjectBase.cs.meta
new file mode 100644
index 000000000..2e1472753
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/Common/AltObjectBase.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 04b413ad3dd2b41d9b74ec810c49eb62
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AltTester/Runtime/AltDriver/Common/AltObjectUnreal.cs b/Assets/AltTester/Runtime/AltDriver/Common/AltObjectUnreal.cs
new file mode 100644
index 000000000..bb0a92c53
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/Common/AltObjectUnreal.cs
@@ -0,0 +1,82 @@
+/*
+ Copyright(C) 2025 Altom Consulting
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+
+using Newtonsoft.Json;
+
+namespace AltTester.AltTesterUnitySDK.Driver
+{
+ public class AltObjectUnreal: AltObjectBase
+ {
+ [JsonConstructor]
+ public AltObjectUnreal(string name, int id = 0, int x = 0, int y = 0, int z = 0, int mobileY = 0, string type = "", bool enabled = true, float worldX = 0, float worldY = 0, float worldZ = 0, int idCamera = 0, int transformParentId = 0, int transformId = 0)
+ : base(name, id, x, y, z, mobileY, type, enabled, worldX, worldY, worldZ, idCamera, transformParentId, transformId)
+ {
+ }
+
+ private AltObjectUnreal(AltObject altObject)
+ : base(altObject.name, altObject.id, altObject.x, altObject.y, altObject.z, altObject.mobileY, altObject.type, altObject.enabled, altObject.worldX, altObject.worldY, altObject.worldZ, altObject.idCamera, altObject.transformParentId, altObject.transformId)
+ {
+ this.CommHandler = altObject.CommHandler;
+ }
+
+ public new AltObjectUnreal UpdateObject()
+ {
+ return AltObjectUnreal.Create(base.UpdateObject());
+ }
+
+ public static AltObjectUnreal Create(AltObject altObject)
+ {
+ if (altObject == null)
+ {
+ return null;
+ }
+
+ return new AltObjectUnreal(altObject);
+ }
+
+ public AltObjectUnreal Click()
+ {
+ return AltObjectUnreal.Create(base.Click());
+ }
+
+ public T GetComponentProperty(string componentName, string propertyName)
+ {
+ return base.GetComponentProperty(componentName, propertyName, "", 2);
+ }
+
+ public T WaitForComponentProperty(string componentName, string propertyName, T propertyValue, double timeout = 20, double interval = 0.5, bool getPropertyAsString = false)
+ {
+ return base.WaitForComponentProperty(componentName, propertyName, propertyValue, "", timeout, interval, getPropertyAsString, 2);
+ }
+
+ public void SetComponentProperty(string componentName, string propertyName, object value)
+ {
+ base.SetComponentProperty(componentName, propertyName, value, "");
+ }
+
+ public T CallComponentMethod(string componentName, string methodName, object[] parameters, string[] typeOfParameters = null)
+ {
+ return base.CallComponentMethod(componentName, methodName, "", parameters, typeOfParameters);
+ }
+
+ public AltObjectUnreal SetText(string text)
+ {
+ return AltObjectUnreal.Create(base.SetText(text, false));
+ }
+ }
+}
diff --git a/Assets/AltTester/Runtime/AltDriver/Common/AltObjectUnreal.cs.meta b/Assets/AltTester/Runtime/AltDriver/Common/AltObjectUnreal.cs.meta
new file mode 100644
index 000000000..c8de864a7
--- /dev/null
+++ b/Assets/AltTester/Runtime/AltDriver/Common/AltObjectUnreal.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 828743fae22944d10aa2f0c86ef00312
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AltTester/Runtime/Commands/FindObject/OldFindObject/AltOldFindObjectCommand.cs b/Assets/AltTester/Runtime/Commands/FindObject/OldFindObject/AltOldFindObjectCommand.cs
index 059638e6e..d03e75731 100644
--- a/Assets/AltTester/Runtime/Commands/FindObject/OldFindObject/AltOldFindObjectCommand.cs
+++ b/Assets/AltTester/Runtime/Commands/FindObject/OldFindObject/AltOldFindObjectCommand.cs
@@ -28,7 +28,6 @@ public AltOldFindObjectCommand(BaseFindObjectsParams cmdParam) : base(cmdParam)
public override AltObject Execute()
{
- UnityEngine.Debug.Log("OlfFindObject " + CommandParams.path);
var path = new OldPathSelector(CommandParams.path);
var foundGameObject = FindObjects(null, path.FirstBound, true, CommandParams.enabled);
UnityEngine.Camera camera = null;
diff --git a/Assets/AltTester/Runtime/Commands/FindObject/OldFindObject/AltOldFindObjectsCommand.cs b/Assets/AltTester/Runtime/Commands/FindObject/OldFindObject/AltOldFindObjectsCommand.cs
index 6188b0a0d..4868803fc 100644
--- a/Assets/AltTester/Runtime/Commands/FindObject/OldFindObject/AltOldFindObjectsCommand.cs
+++ b/Assets/AltTester/Runtime/Commands/FindObject/OldFindObject/AltOldFindObjectsCommand.cs
@@ -28,7 +28,6 @@ public AltOldFindObjectsCommand(BaseFindObjectsParams cmdParams) : base(cmdParam
public override List Execute()
{
- UnityEngine.Debug.Log("OlfFindObject " + CommandParams.path);
UnityEngine.Camera camera = null;
if (!CommandParams.cameraPath.Equals("//"))
{
diff --git a/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnity.cs b/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnity.cs
new file mode 100644
index 000000000..86ea640b7
--- /dev/null
+++ b/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnity.cs
@@ -0,0 +1,51 @@
+/*
+ Copyright(C) 2024 Altom Consulting
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+using AltTester.AltTesterUnitySDK.Driver;
+using AltTester.AltTesterUnitySDK.Driver.Logging;
+using AltTester.AltTesterUnitySDK.Driver.Tests;
+using NUnit.Framework;
+
+public class TestBaseAltDriverUnity
+{
+ protected AltDriverUnity altDriver;
+ protected string sceneName;
+ private int defaultCommandResponseTimeout = 5;
+
+ [OneTimeSetUp]
+ public void SetUp()
+ {
+ altDriver = TestsHelper.GetAltDriverUnity();
+ DriverLogManager.SetMinLogLevel(AltLogger.Console, AltLogLevel.Info);
+ DriverLogManager.SetMinLogLevel(AltLogger.Unity, AltLogLevel.Info);
+ }
+
+ [OneTimeTearDown]
+ public void TearDown()
+ {
+ altDriver.Stop();
+ }
+
+ [SetUp]
+ protected void LoadLevel()
+ {
+ altDriver.ResetInput();
+
+ altDriver.SetCommandResponseTimeout(defaultCommandResponseTimeout);
+ altDriver.LoadScene(this.sceneName, true);
+ }
+}
diff --git a/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnity.cs.meta b/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnity.cs.meta
new file mode 100644
index 000000000..41aa70534
--- /dev/null
+++ b/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnity.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a603d14553c9b46ecaf7b5fa3a512eaa
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnreal.cs b/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnreal.cs
new file mode 100644
index 000000000..2bb7940d5
--- /dev/null
+++ b/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnreal.cs
@@ -0,0 +1,54 @@
+/*
+ Copyright(C) 2024 Altom Consulting
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+
+using System.Threading;
+using AltTester.AltTesterUnitySDK.Driver;
+using AltTester.AltTesterUnitySDK.Driver.Logging;
+using AltTester.AltTesterUnitySDK.Driver.Tests;
+using NUnit.Framework;
+
+public class TestBaseAltDriverUnreal
+{
+ protected AltDriverUnreal altDriver;
+ protected string sceneName;
+ private int defaultCommandResponseTimeout = 5;
+
+ [OneTimeSetUp]
+ public void SetUp()
+ {
+ altDriver = TestsHelper.GetAltDriverUnreal();
+ DriverLogManager.SetMinLogLevel(AltLogger.Console, AltLogLevel.Info);
+ DriverLogManager.SetMinLogLevel(AltLogger.Unity, AltLogLevel.Info);
+ }
+
+ [OneTimeTearDown]
+ public void TearDown()
+ {
+ altDriver.Stop();
+ }
+
+ [SetUp]
+ protected void LoadLevel()
+ {
+ if (!string.IsNullOrEmpty(sceneName)) // Ensure sceneName is not null or empty
+ {
+ // altDriver.ResetInput();
+ altDriver.SetCommandResponseTimeout(defaultCommandResponseTimeout);
+ altDriver.LoadLevel(sceneName);
+ }
+ }
+}
diff --git a/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnreal.cs.meta b/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnreal.cs.meta
new file mode 100644
index 000000000..e7bd7dbd4
--- /dev/null
+++ b/Assets/Examples/Test/Editor/Driver/TestBaseAltDriverUnreal.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: cb2254a5a52774b2ca66dfb4504756a9
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Examples/Test/Editor/Driver/TestforScene1TestSampleWithAltDriverUnreal.cs b/Assets/Examples/Test/Editor/Driver/TestforScene1TestSampleWithAltDriverUnreal.cs
new file mode 100644
index 000000000..34285abcf
--- /dev/null
+++ b/Assets/Examples/Test/Editor/Driver/TestforScene1TestSampleWithAltDriverUnreal.cs
@@ -0,0 +1,716 @@
+using System.Text.RegularExpressions;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Threading;
+using Newtonsoft.Json.Linq;
+using NUnit.Framework;
+
+
+
+namespace AltTester.AltTesterUnitySDK.Driver.Tests
+{
+ [Ignore("These tests will be run from the Unreal Engine SDK Test repo")]
+ [TestFixture]
+ [Parallelizable]
+ [Timeout(30000)]
+ public class TestForScene1TestSampleWithAltDriverUnreal : TestBaseAltDriverUnreal
+ {
+ public TestForScene1TestSampleWithAltDriverUnreal()
+ {
+ sceneName = "Scene1";
+ }
+
+ // working tests
+ // ---------------------------------------------------------------------------------------------------------------
+
+ [Test]
+ public void TestGetCurrentLevel()
+ {
+ Assert.That(altDriver.GetCurrentLevel(), Is.EqualTo(sceneName));
+ }
+
+ [TestCase("//*[contains(@name,AltTesterConnectionOverlay)]/*[contains(@name,CanvasPanel_)]/ConnectionMenu", "ConnectionMenu")]
+ [TestCase("//*[contains(@name,AltTesterConnectionOverlay)]/*[contains(@name,CanvasPanel_)]/ConnectionMenu/AltTesterInfoText", "AltTesterInfoText")]
+ [TestCase("/BP_Cube", "BP_Cube")]
+ public void TestFindDisabledObject(string path, string name)
+ {
+ AltObjectUnreal altObject = altDriver.FindObject(AltBy.Path(path), enabled: false);
+ Assert.That(altObject, Is.Not.Null);
+ Assert.That(altObject.name, Does.Match($"^{Regex.Escape(name)}.*"));
+ }
+
+ // [TestCase(By.ID, "13b211d0-eafa-452d-8708-cc70f5075e93", "//Capsule")] - AltID not implemented
+ [TestCase(By.LAYER, "Wat", "//BP_Capsule")]
+ [TestCase(By.COMPONENT, "Capsule", "//BP_Capsule")]
+ [TestCase(By.NAME, "Cap", "//BP_Capsule")]
+ [TestCase(By.TAG, "MainCamera", "//MainCamera")]
+ [TestCase(By.TEXT, "Change Camera", "//*[contains(@name,W_UserInterface_C_)]/*[contains(@name,CanvasPanel_)]/*[contains(@name,Button_)]/*[contains(@name,TextBlock_)]")]
+ public void TestFindObjectWhichContains(By by, string value, string path)
+ {
+ AltObjectUnreal expectedObject = altDriver.FindObject(AltBy.Path(path));
+ AltObjectUnreal altObject = altDriver.FindObjectWhichContains(new AltBy(by, value));
+
+ Assert.That(altObject, Is.Not.Null);
+ Assert.That(altObject.id, Is.EqualTo(expectedObject.id));
+ }
+
+ [Test]
+ public void TestFindElementThatContainsText()
+ {
+ const string text = "Change Camera";
+ AltObjectUnreal altElement = altDriver.FindObject(AltBy.Path("//*[contains(@text," + text + ")]"));
+ Assert.That(altElement, Is.Not.Null);
+ }
+
+ [TestCase(By.COMPONENT, "NonExistent")]
+ [TestCase(By.ID, "NonExistent")]
+ [TestCase(By.LAYER, "NonExistent")]
+ [TestCase(By.NAME, "NonExistent")]
+ [TestCase(By.TAG, "NonExistent")]
+ [TestCase(By.TEXT, "NonExistent")]
+ public void TestFindNonExistentObjectWhichContains(By by, string value)
+ {
+ Assert.Throws(() => altDriver.FindObjectWhichContains(new AltBy(by, value)));
+ }
+
+ [TestCase(By.NAME, "Cap", "//BP_Capsule", "//CapsuleInfo")]
+ [TestCase(By.TAG, "camera", "//MainCamera", "//SecondaryCamera")]
+ public void TestFindObjectsWhichContain2(By by, string value, string path1, string path2)
+ {
+ AltObjectUnreal expectedObject1 = altDriver.FindObject(AltBy.Path(path1));
+ AltObjectUnreal expectedObject2 = altDriver.FindObject(AltBy.Path(path2));
+ List altObjects = altDriver.FindObjectsWhichContain(new AltBy(by, value));
+
+ Assert.That(altObjects, Has.Count.EqualTo(2));
+ Assert.That(
+ (altObjects[0].id == expectedObject1.id && altObjects[1].id == expectedObject2.id) ||
+ (altObjects[0].id == expectedObject2.id && altObjects[1].id == expectedObject1.id),
+ Is.True, "The ids do not match the expected values in either order.");
+ }
+ [TestCase(By.COMPONENT, "NonExistent")]
+ [TestCase(By.ID, "NonExistent")]
+ [TestCase(By.LAYER, "NonExistent")]
+ [TestCase(By.NAME, "NonExistent")]
+ [TestCase(By.TAG, "NonExistent")]
+ [TestCase(By.TEXT, "NonExistent")]
+ public void TestFindNonExistentObjectsWhichContain(By by, string value)
+ {
+ List altObjects = altDriver.FindObjectsWhichContain(new AltBy(by, value));
+ Assert.That(altObjects, Is.Empty);
+ }
+
+ [Test]
+ public void TestWaitForCurrentLevelToBe()
+ {
+ DateTime timeStart = DateTime.Now;
+ altDriver.WaitForCurrentLevelToBe(sceneName);
+ DateTime timeEnd = DateTime.Now;
+ TimeSpan time = timeEnd - timeStart;
+ Assert.That(time.TotalSeconds, Is.LessThan(20));
+
+ string currentScene = altDriver.GetCurrentLevel();
+ Assert.That(currentScene, Is.EqualTo(sceneName));
+ }
+
+ // [TestCase(By.ID, "13b211d0-eafa-452d-8708-cc70f5075e93", "//Capsule")]
+ [TestCase(By.LAYER, "Wat", "//BP_Capsule")]
+ [TestCase(By.COMPONENT, "Capsule", "//BP_Capsule")]
+ [TestCase(By.TEXT, "Change Camera", "//*[contains(@name,W_UserInterface_C_)]/*[contains(@name,CanvasPanel_)]/*[contains(@name,Button_)]/*[contains(@name,TextBlock_)]")]
+ public void TestFindObjectsWhichContain(By by, string value, string path)
+ {
+ AltObjectUnreal expectedObject = altDriver.FindObject(AltBy.Path(path));
+ List altObjects = altDriver.FindObjectsWhichContain(new AltBy(by, value));
+ Assert.That(altObjects, Has.Count.EqualTo(1));
+ Assert.That(altObjects[0].id, Is.EqualTo(expectedObject.id));
+ }
+
+ // [TestCase(By.ID, "13b211d0-eafa-452d-8708-cc70f5075e93", "//Capsule")]
+ // [TestCase(By.PATH, "//*[@id=13b211d0-eafa-452d-8708-cc70f5075e93]", "//Capsule")]
+ // [TestCase(By.PATH, "//*[@tag=plane][@layer=Default][@name=Plane][@component=MeshCollider][@id=58af4167-0971-415f-901c-7c5226c3c170]", "//Plane")]
+ // [TestCase(By.PATH, "//*[@tag=Untagged][@layer=UI][@name=Text][@component=CanvasRenderer][@id=0ffed8a8-3d77-4b03-965b-5ae094ba9511][@text=Change Camera Mode]", "/Canvas/Button/Text")]
+ // [TestCase(By.PATH, "//*[contains(@id,13b211d0-eafa-452d-8708-cc70f5075e93)]", "//Capsule")]
+ // [TestCase(By.PATH, "//*[contains(@tag,pla)][contains(@layer,Def)][contains(@name,Pla)][contains(@component,MeshColl)][contains(@id,58af4167-0971-415f-901c-7c5226c3c170)]", "//Plane")]
+ // [TestCase(By.PATH, "//*[contains(@tag,Untag)][contains(@layer,U)][contains(@name,Tex)][contains(@component,CanvasRender)][contains(@id,0ffed8a8-3d77-4b03-965b-5ae094ba9511)][contains(@text,Change Camera)]", "/Canvas/Button/Text")]
+ [TestCase(By.LAYER, "Water", "//BP_Capsule")]
+ [TestCase(By.PATH, "//*[@layer=Water]", "//BP_Capsule")]
+ [TestCase(By.COMPONENT, "Capsule", "//BP_Capsule")]
+ [TestCase(By.COMPONENT, "SkyAtmosphereComponent", "//SkyAtmosphere")]
+ [TestCase(By.NAME, "BP_Capsule", "//BP_Capsule")]
+ [TestCase(By.PATH, "/Sphere", "//Sphere")]
+ [TestCase(By.PATH, "//PlaneS/..", "//Sphere")]
+ [TestCase(By.PATH, "//Sphere/*", "//PlaneS")]
+ [TestCase(By.PATH, "//*[@tag=MainCamera]", "//MainCamera")]
+ [TestCase(By.PATH, "//*[@name=BP_Capsule]", "//BP_Capsule")]
+ [TestCase(By.PATH, "//*[@component=Capsule]", "//BP_Capsule")]
+ [TestCase(By.PATH, "//*[@text=Change Camera Mode]", "//*[contains(@name,W_UserInterface_C_)]/*[contains(@name,CanvasPanel_)]/*[contains(@name,Button_)]/*[contains(@name,TextBlock_)]")]
+ [TestCase(By.PATH, "//*[contains(@tag,MainCam)]", "//MainCamera")]
+ [TestCase(By.PATH, "//*[contains(@name,Cap)]", "//BP_Capsule")]
+ [TestCase(By.PATH, "//*[contains(@component,Capsule)]", "//BP_Capsule")]
+ [TestCase(By.PATH, "//*[contains(@text,Change Camera)]", "//*[contains(@name,W_UserInterface_C_)]/*[contains(@name,CanvasPanel_)]/*[contains(@name,Button_)]/*[contains(@name,TextBlock_)]")]
+ [TestCase(By.PATH, "//*[contains(@layer,Wat)]", "//BP_Capsule")]
+ [TestCase(By.PATH, "//*[@tag=plane][@layer=Default]", "//Plane")]
+ [TestCase(By.PATH, "//*[@tag=plane][@layer=Default][@name=Plane]", "//Plane")]
+ [TestCase(By.PATH, "//*[@tag=plane][@layer=Default][@name=Plane][@component=StaticMeshComponent0]", "//Plane")]
+ [TestCase(By.PATH, "//*[contains(@tag,pla)][contains(@layer,Def)]", "//Plane")]
+ [TestCase(By.PATH, "//*[contains(@tag,pla)][contains(@layer,Def)][contains(@name,Pla)]", "//Plane")]
+ [TestCase(By.PATH, "//*[contains(@tag,pla)][contains(@layer,Def)][contains(@name,Pla)][contains(@component,StaticMeshComp)]", "//Plane")]
+ [TestCase(By.TAG, "MainCamera", "//MainCamera")]
+ [TestCase(By.TEXT, "Capsule Info", "//CapsuleInfo")]
+ [TestCase(By.TEXT, "Change Camera Mode", "//*[contains(@name,W_UserInterface_C_)]/*[contains(@name,CanvasPanel_)]/*[contains(@name,Button_)]/*[contains(@name,TextBlock_)]")]
+ public void TestFindObject(By by, string value, string path)
+ {
+ int referenceId = altDriver.FindObject(AltBy.Path(path)).id;
+ AltObjectUnreal altObject = altDriver.FindObject(new AltBy(by, value));
+ Assert.That(altObject, Is.Not.Null);
+ Assert.That(altObject.id, Is.EqualTo(referenceId));
+ }
+
+ [TestCase(By.COMPONENT, "NonExistent")]
+ [TestCase(By.ID, "NonExistent")]
+ [TestCase(By.LAYER, "NonExistent")]
+ [TestCase(By.NAME, "NonExistent")]
+ [TestCase(By.PATH, "/NonExistent")]
+ [TestCase(By.PATH, "//NonExistent/..")]
+ [TestCase(By.PATH, "//NonExistent/*")]
+ [TestCase(By.PATH, "//*[@tag=NonExistent]")]
+ [TestCase(By.PATH, "//*[@layer=NonExistent]")]
+ [TestCase(By.PATH, "//*[@name=NonExistent]")]
+ [TestCase(By.PATH, "//*[@component=NonExistent]")]
+ [TestCase(By.PATH, "//*[@id=NonExistent]")]
+ [TestCase(By.PATH, "//*[@text=NonExistent]")]
+ [TestCase(By.PATH, "//*[@tag=plane][@layer=NonExistent]")]
+ [TestCase(By.PATH, "//*[@tag=plane][@layer=Default][@name=NonExistent]")]
+ [TestCase(By.PATH, "//*[@tag=plane][@layer=Default][@name=Plane][@component=NonExistent]")]
+ [TestCase(By.PATH, "//*[@tag=plane][@layer=Default][@name=Plane][@component=StaticMeshComponent0][@id=NonExistent]")]
+ // [TestCase(By.PATH, "//*[@tag=Untagged][@layer=UI][@name=Text][@component=CanvasRenderer][@id=f9dc3b3c-2791-42dc-9c0f-87ef7ff5e11d][@text=NonExistent]")]
+ [TestCase(By.PATH, "//*[contains(@tag,NonExistent)]")]
+ [TestCase(By.PATH, "//*[contains(@layer,NonExistent)]")]
+ [TestCase(By.PATH, "//*[contains(@name,NonExistent)]")]
+ [TestCase(By.PATH, "//*[contains(@component,NonExistent)]")]
+ [TestCase(By.PATH, "//*[contains(@id,NonExistent)]")]
+ [TestCase(By.PATH, "//*[contains(@text,NonExistent)]")]
+ [TestCase(By.PATH, "//*[contains(@tag,pla)][contains(@layer,NonExistent)]")]
+ [TestCase(By.PATH, "//*[contains(@tag,pla)][contains(@layer,Def)][contains(@name,NonExistent)]")]
+ [TestCase(By.PATH, "//*[contains(@tag,pla)][contains(@layer,Def)][contains(@name,Pla)][contains(@component,NonExistent)]")]
+ [TestCase(By.PATH, "//*[contains(@tag,pla)][contains(@layer,Def)][contains(@name,Pla)][contains(@component,StaticMeshComp)][contains(@id,NonExistent)]")]
+ // [TestCase(By.PATH, "//*[contains(@tag,Untag)][contains(@layer,U)][contains(@name,Tex)][contains(@component,CanvasRender)][contains(@id,f9dc3b3c-2791-42dc-9c0f-87ef7ff5e11d)][contains(@text,NonExistent)]")]
+ [TestCase(By.PATH, "//Canvas[100]")]
+ [TestCase(By.PATH, "//Canvas[-100]")]
+ [TestCase(By.TAG, "NonExistent")]
+ [TestCase(By.TEXT, "NonExistent")]
+ [TestCase(By.PATH, "//DisabledObject")]
+ [TestCase(By.PATH, "//DisabledObject/DisabledChild")]
+ public void TestFindNonExistentObject(By by, string value)
+ {
+ Assert.Throws(() => altDriver.FindObject(new AltBy(by, value)));
+ }
+
+ [Test]
+ public void TestGetComponentPropertyPrivate()
+ {
+ const string componentName = "AltExampleScriptCapsule";
+ const string propertyName = "privateVariable";
+
+ AltObjectUnreal altElement = altDriver.FindObject(AltBy.Name("BP_Capsule"));
+ Assert.That(altElement, Is.Not.Null);
+
+ int propertyValue = altElement.GetComponentProperty(componentName, propertyName);
+ Assert.That(propertyValue, Is.EqualTo(0));
+ }
+
+ [Test]
+ public void TestGetComponentPropertyStatic()
+ {
+ const string componentName = "AltExampleScriptCapsule";
+ const string propertyName = "privateStaticVariable";
+
+ AltObjectUnreal altElement = altDriver.FindObject(AltBy.Name("BP_Capsule"));
+ Assert.That(altElement, Is.Not.Null);
+
+ // Can't access static variables from Unreal
+ // int propertyValue = altElement.GetComponentProperty(componentName, propertyName, "");
+ // Assert.That(propertyValue, Is.EqualTo(0));
+
+ try
+ {
+ altElement.GetComponentProperty(componentName, propertyName);
+ Assert.Fail();
+ }
+ catch (PropertyNotFoundException exception)
+ {
+ Assert.That(exception.Message, Is.EqualTo($"Property {propertyName} not found"));
+ }
+ }
+
+ [Test]
+ public void TestGetComponentPropertyStaticPublic()
+ {
+ const string componentName = "AltExampleScriptCapsule";
+ const string propertyName = "PublicStaticVariable";
+
+ AltObjectUnreal altElement = altDriver.FindObject(AltBy.Name("BP_Capsule"));
+ Assert.That(altElement, Is.Not.Null);
+
+ // Can't access static variables from Unreal
+ // int propertyValue = altElement.GetComponentProperty(componentName, propertyName, "");
+ // Assert.That(propertyValue, Is.EqualTo(0));
+
+ try
+ {
+ altElement.GetComponentProperty(componentName, propertyName);
+ Assert.Fail();
+ }
+ catch (PropertyNotFoundException exception)
+ {
+ Assert.That(exception.Message, Is.EqualTo($"Property {propertyName} not found"));
+ }
+ }
+
+ [Test]
+ public void TestSetComponentProperty()
+ {
+ const string componentName = "AltExampleScriptCapsule";
+ const string propertyName = "stringToSetFromTests";
+
+ AltObjectUnreal altElement = altDriver.FindObject(AltBy.Name("BP_Capsule"));
+ Assert.That(altElement, Is.Not.Null);
+ altElement.SetComponentProperty(componentName, propertyName, "2");
+
+ string propertyValue = altElement.GetComponentProperty(componentName, propertyName);
+ Assert.That(propertyValue, Is.EqualTo("2"));
+ }
+
+ [Test]
+ public void TestCallMethodWithOptionalParameters()
+ {
+ const string componentName = "AltExampleScriptCapsule";
+ const string methodName = "TestMethodWithOptionalIntParameters";
+ string[] parameters = new string[] {"1", "2"};
+
+ AltObjectUnreal altElement = altDriver.FindObject(AltBy.Name("BP_Capsule"));
+ string data = altElement.CallComponentMethod(componentName, methodName, parameters);
+ Assert.That(data, Is.EqualTo("3"));
+ }
+
+ [Test]
+ public void TestCallMethodWithOptionalParametersString()
+ {
+ const string componentName = "AltExampleScriptCapsule";
+ const string methodName = "TestMethodWithOptionalStringParameters";
+
+ object[] parameters = new object[] { "FirstParameter", "SecondParameter" };
+ string[] typeOfParameters = new string[] { "System.String", "System.String" };
+
+ AltObjectUnreal altElement = altDriver.FindObject(AltBy.Name("BP_Capsule"));
+ string data = altElement.CallComponentMethod(componentName, methodName, parameters, typeOfParameters);
+ Assert.That(data, Is.EqualTo("FirstParameterSecondParameter"));
+ }
+
+ [Test]
+ public void TestCallMethodWithOptionalParametersString2()
+ {
+ const string componentName = "AltExampleScriptCapsule";
+ const string methodName = "TestMethodWithOptionalStringParameters";
+
+ object[] parameters = new object[] {"FirstParameter", ""};
+ string[] typeOfParameters = new string[] {"System.String", "System.String"};
+
+ AltObjectUnreal altElement = altDriver.FindObject(AltBy.Name("BP_Capsule"));
+ string data = altElement.CallComponentMethod(componentName, methodName, parameters, typeOfParameters);
+ Assert.That(data, Is.EqualTo("FirstParameter"));
+ }
+
+ [Test]
+ public void TestWaitForObjectToNotExist()
+ {
+ altDriver.WaitForObjectNotBePresent(AltBy.Name("ObjectDestroyedIn5Secs"));
+ altDriver.WaitForObjectNotBePresent(AltBy.Name("BP_Capsulee"), timeout: 1, interval: 0.5f);
+ }
+
+ [Test]
+ public void TestWaitForObjectToNotExistFail()
+ {
+ try
+ {
+ altDriver.WaitForObjectNotBePresent(AltBy.Name("BP_Capsule"), timeout: 1, interval: 0.5f);
+ Assert.Fail();
+ }
+ catch (WaitTimeOutException exception)
+ {
+ Assert.That(exception.Message, Is.EqualTo("Element //BP_Capsule still found after 1 seconds"));
+ }
+ }
+
+ [Test]
+ public void TestWaitForCurrentLevelToBeANonExistingScene()
+ {
+ const string name = "AltDriverTestScene";
+ try
+ {
+ altDriver.WaitForCurrentLevelToBe(name, 1);
+ Assert.Fail();
+ }
+ catch (WaitTimeOutException exception)
+ {
+ Assert.That(exception.Message, Is.EqualTo("Scene AltDriverTestScene not loaded after 1 seconds"));
+ }
+ }
+
+ [Test]
+ public void TestGetAllComponents()
+ {
+ List components = altDriver.FindObject(AltBy.Name("MainCamera")).GetAllComponents();
+ Assert.That(components, Has.Count.EqualTo(3));
+ Assert.That(components[0].componentName, Is.EqualTo("SceneComponent"));
+ Assert.That(components[0].assemblyName, Is.EqualTo("SceneComponent"));
+ }
+
+ [TestCase("ChineseLetters", "哦伊娜哦")]
+ [TestCase("NonEnglishText", "BJÖRN'S PASS")]
+ public void TestGetChineseLetters(string name, string nonEnglishText)
+ {
+ string text = altDriver.FindObject(AltBy.Name(name)).GetText();
+ Assert.That(text, Is.EqualTo(nonEnglishText));
+ }
+
+ [Test]
+ public void TestForSetText()
+ {
+ AltObjectUnreal text = altDriver.FindObject(AltBy.Name("NonEnglishText"));
+ string originalText = text.GetText();
+ string afterText = text.SetText("ModifiedText").GetText();
+ Assert.That(afterText, Is.Not.EqualTo(originalText));
+ }
+
+ [Test]
+ public void TestGetVersion()
+ {
+ Assert.That(altDriver.GetServerVersion(), Is.EqualTo("1.0.0"));
+ }
+
+ [Test]
+ public void TestInvalidPaths()
+ {
+ Assert.Throws(() => altDriver.FindObject(AltBy.Path("//[1]")));
+ Assert.Throws(() => altDriver.FindObject(AltBy.Path("CapsuleInfo[@tag=UI]")));
+ Assert.Throws(() => altDriver.FindObject(AltBy.Path("//CapsuleInfo[@tag=UI/Text")));
+ Assert.Throws(() => altDriver.FindObject(AltBy.Path("//CapsuleInfo[0/Text")));
+ }
+
+ [Test]
+ public void TestCallPrivateMethod()
+ {
+ AltObjectUnreal altObject = altDriver.FindObject(AltBy.Name("BP_Capsule"));
+ altObject.CallComponentMethod("AltExampleScriptCapsule", "CallJump", Array.Empty