├── .gitignore ├── APIREADME.md ├── Assets ├── Examples.meta ├── Examples │ ├── ScreenShotTests.cs │ ├── ScreenShotTests.cs.meta │ ├── Test1.cs │ ├── Test1.cs.meta │ ├── Test2.cs │ ├── Test2.cs.meta │ ├── Test3.cs │ ├── Test3.cs.meta │ ├── Tests For Scene 1.meta │ ├── Tests For Scene 1 │ │ ├── 1.unity │ │ ├── 1.unity.meta │ │ ├── TestObject.cs │ │ └── TestObject.cs.meta │ ├── UITestCheck.cs │ ├── UITestCheck.cs.meta │ ├── UITestSuccess.cs │ ├── UITestSuccess.cs.meta │ ├── UITestWaitFail.cs │ └── UITestWaitFail.cs.meta ├── Plugins.meta ├── ThirdParty.meta ├── ThirdParty │ ├── NewtonSoft.meta │ └── NewtonSoft │ │ ├── Newtonsoft.Json.dll │ │ ├── Newtonsoft.Json.dll.mdb │ │ ├── Newtonsoft.Json.dll.mdb.meta │ │ └── Newtonsoft.Json.dll.meta ├── UITestTools.meta └── UITestTools │ ├── Actions.meta │ ├── Actions │ ├── AsyncWait.cs │ ├── AsyncWait.cs.meta │ ├── Check.cs │ ├── Check.cs.meta │ ├── Interact.cs │ ├── Interact.cs.meta │ ├── Wait.cs │ └── Wait.cs.meta │ ├── ClassFileFinder.cs │ ├── ClassFileFinder.cs.meta │ ├── Editor.meta │ ├── Editor │ ├── EditorParameterDrawers.cs │ ├── EditorParameterDrawers.cs.meta │ ├── ParameterDrawersFactorycs.cs │ ├── ParameterDrawersFactorycs.cs.meta │ ├── Resources.meta │ ├── Resources │ │ ├── failed.png │ │ ├── failed.png.meta │ │ ├── ignored.png │ │ ├── ignored.png.meta │ │ ├── normal.png │ │ ├── normal.png.meta │ │ ├── passed.png │ │ ├── passed.png.meta │ │ ├── test_record_color.png │ │ ├── test_record_color.png.meta │ │ ├── test_record_grayscale.png │ │ └── test_record_grayscale.png.meta │ ├── UITestFlowRecorderController.cs │ ├── UITestFlowRecorderController.cs.meta │ ├── UITestFlowRecorderWindow.cs │ ├── UITestFlowRecorderWindow.cs.meta │ ├── UITestToolsHelperWindow.cs │ ├── UITestToolsHelperWindow.cs.meta │ ├── UserFlowModel.cs │ └── UserFlowModel.cs.meta │ ├── MockNUnit.cs │ ├── MockNUnit.cs.meta │ ├── PlayModeTestRunner.meta │ ├── PlayModeTestRunner │ ├── ConsoleArgumentHelper.cs │ ├── ConsoleArgumentHelper.cs.meta │ ├── CurrentTestInfo.cs │ ├── CurrentTestInfo.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── Resources.meta │ │ └── Resources │ │ │ ├── ReferenceScreenshots.meta │ │ │ └── ReferenceScreenshots │ │ │ ├── resolution_1024_768 │ │ │ └── TestMakeScreenShotAndCompare.meta │ │ │ ├── resolution_750_1334.meta │ │ │ └── resolution_750_1334 │ │ │ ├── C25419_ForBoostsPriorToGameplay.meta │ │ │ ├── C25419_ForBoostsPriorToGameplay │ │ │ ├── CheckBooster.png │ │ │ └── CheckBooster.png.meta │ │ │ ├── TestMakeScreenShotAndCompare.meta │ │ │ ├── TestMakeScreenShotAndCompare │ │ │ ├── reference.png │ │ │ └── reference.png.meta │ │ │ ├── TestMakeScreenShotReference.meta │ │ │ └── TestMakeScreenShotReference │ │ │ ├── reference.png │ │ │ └── reference.png.meta │ ├── EditorTargetResolution.cs │ ├── EditorTargetResolution.cs.meta │ ├── GameViewResizer.cs │ ├── GameViewResizer.cs.meta │ ├── ITestRunnerCallbackReceiver.cs │ ├── ITestRunnerCallbackReceiver.cs.meta │ ├── LogSaver.cs │ ├── LogSaver.cs.meta │ ├── Nodes.meta │ ├── Nodes │ │ ├── ClassNode.cs │ │ ├── ClassNode.cs.meta │ │ ├── Factories.meta │ │ ├── Factories │ │ │ ├── MethodTestSettingsFactory.cs │ │ │ ├── MethodTestSettingsFactory.cs.meta │ │ │ ├── NodeFactory.cs │ │ │ └── NodeFactory.cs.meta │ │ ├── Helpers.meta │ │ ├── Helpers │ │ │ ├── CustomResolution.cs │ │ │ ├── CustomResolution.cs.meta │ │ │ ├── MethodTestSettings.cs │ │ │ ├── MethodTestSettings.cs.meta │ │ │ ├── TestRailsData.cs │ │ │ └── TestRailsData.cs.meta │ │ ├── MethodNode.cs │ │ ├── MethodNode.cs.meta │ │ ├── Node.cs │ │ └── Node.cs.meta │ ├── PermittedErrors.meta │ ├── PermittedErrors │ │ ├── PermittedError.cs │ │ ├── PermittedError.cs.meta │ │ ├── PermittedErrors.cs │ │ └── PermittedErrors.cs.meta │ ├── PlayModeLogger.cs │ ├── PlayModeLogger.cs.meta │ ├── PlayModeTestRunner.cs │ ├── PlayModeTestRunner.cs.meta │ ├── PlayModeTestRunnerGUI.cs │ ├── PlayModeTestRunnerGUI.cs.meta │ ├── PlaymodeTestRunnerView.meta │ ├── PlaymodeTestRunnerView │ │ ├── AddBaseClassWindow.cs │ │ ├── AddBaseClassWindow.cs.meta │ │ ├── EditorUITools.cs │ │ ├── EditorUITools.cs.meta │ │ ├── NodesView.meta │ │ ├── NodesView │ │ │ ├── BaseNodeView.cs │ │ │ ├── BaseNodeView.cs.meta │ │ │ ├── ClassNodeView.cs │ │ │ ├── ClassNodeView.cs.meta │ │ │ ├── MethodNodeView.cs │ │ │ └── MethodNodeView.cs.meta │ │ ├── RuntimeTestRunnerWindow.cs │ │ ├── RuntimeTestRunnerWindow.cs.meta │ │ ├── ScriptCompilationWaiter.cs │ │ ├── ScriptCompilationWaiter.cs.meta │ │ ├── SelectedNode.cs │ │ ├── SelectedNode.cs.meta │ │ ├── TestToolBuildScript.cs │ │ ├── TestToolBuildScript.cs.meta │ │ ├── UITestToolWindowFooter.cs │ │ └── UITestToolWindowFooter.cs.meta │ ├── RunTestsMode.cs │ ├── RunTestsMode.cs.meta │ ├── RuntimeTestScene.unity │ ├── RuntimeTestScene.unity.meta │ ├── SelectedTestsSerializable.cs │ ├── SelectedTestsSerializable.cs.meta │ ├── SmokeTestAttribute.cs │ ├── SmokeTestAttribute.cs.meta │ ├── TargetResolutionAttribute.cs │ ├── TargetResolutionAttribute.cs.meta │ ├── TestCoroutiner.cs │ ├── TestCoroutiner.cs.meta │ ├── TestRailAttribute.cs │ ├── TestRailAttribute.cs.meta │ ├── TestStep.cs │ └── TestStep.cs.meta │ ├── Tools.meta │ ├── Tools │ ├── AsyncWait.cs │ ├── AsyncWait.cs.meta │ ├── CoroutineProvider.cs │ ├── CoroutineProvider.cs.meta │ ├── GenerationCode.cs │ ├── GenerationCode.cs.meta │ ├── Metrics.meta │ ├── Metrics │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── OpenMetricsFolder.cs │ │ │ └── OpenMetricsFolder.cs.meta │ │ ├── FPSCounter.cs │ │ ├── FPSCounter.cs.meta │ │ ├── PreloaderTimeTracker.cs │ │ ├── PreloaderTimeTracker.cs.meta │ │ ├── TestMetrics.cs │ │ └── TestMetrics.cs.meta │ ├── RaycastChanger.cs │ ├── RaycastChanger.cs.meta │ ├── TestScreenshotTools.cs │ ├── TestScreenshotTools.cs.meta │ ├── UITestUtils.cs │ ├── UITestUtils.cs.meta │ ├── WaitResults.cs │ └── WaitResults.cs.meta │ ├── UITestAttributes.cs │ ├── UITestAttributes.cs.meta │ ├── UITestToolsVersionInfo.cs │ └── UITestToolsVersionInfo.cs.meta ├── Documentation.XML ├── LICENSE ├── Logs └── Packages-Update.log ├── Packages └── manifest.json ├── README.md ├── documentation └── images │ ├── action-item.png │ ├── play-mode-testrunner.png │ ├── recorder-interface.png │ ├── recorder_window.gif │ ├── test-helper.png │ └── test-runner_context_menu.png ├── tg-unity-uitest.Editor.csproj └── tg-unity-uitest.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | ProjectSettings/ 7 | */Plugins/* 8 | Assets/AssetStoreTools* 9 | Assets/InitTestScene* 10 | 11 | # Visual Studio 2015 cache directory 12 | /.vs/ 13 | /.idea/ 14 | 15 | # Autogenerated VS/MD/Consulo solution and project files 16 | ExportedObj/ 17 | .consulo/ 18 | *.unityproj 19 | *.sln 20 | *.suo 21 | *.tmp 22 | *.user 23 | *.userprefs 24 | *.pidb 25 | *.booproj 26 | *.svd 27 | *.pdb 28 | *.csproj 29 | 30 | # Unity3D generated meta files 31 | *.pidb.meta 32 | *.pdb.meta 33 | 34 | # Unity3D Generated File On Crash Reports 35 | sysinfo.txt 36 | 37 | # Builds 38 | *.apk 39 | *.unitypackage 40 | /.gitignore 41 | SelectedTests.* 42 | -------------------------------------------------------------------------------- /Assets/Examples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f73623eda10f644afab42015a6c22ca7 3 | folderAsset: yes 4 | timeCreated: 1475075251 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Examples/ScreenShotTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using UnityEngine; 3 | using UnityEngine.SceneManagement; 4 | 5 | namespace PlayQ.UITestTools 6 | { 7 | public class ScreenShotTests 8 | { 9 | private bool sceneUnloaded; 10 | 11 | [SetUp] 12 | public IEnumerator LoadSceneSetUp() 13 | { 14 | SceneManager.sceneLoaded += OnSceneLoaded; 15 | 16 | sceneLoaded = false; 17 | 18 | SceneManager.LoadScene("1", LoadSceneMode.Additive); 19 | 20 | while (!sceneLoaded) 21 | { 22 | yield return null; 23 | } 24 | } 25 | 26 | void OnSceneLoaded(Scene scene, LoadSceneMode mode) 27 | { 28 | sceneLoaded = true; 29 | 30 | SceneManager.sceneLoaded -= OnSceneLoaded; 31 | } 32 | 33 | private bool sceneLoaded; 34 | 35 | [TearDown] 36 | public IEnumerator UnloadSceneTearDown() 37 | { 38 | SceneManager.sceneUnloaded += OnSceneUnloaded; 39 | 40 | sceneUnloaded = false; 41 | 42 | SceneManager.UnloadSceneAsync("1"); 43 | 44 | while (!sceneUnloaded) 45 | { 46 | yield return null; 47 | } 48 | 49 | PermittedErrors.ClearAll(); 50 | } 51 | 52 | void OnSceneUnloaded(Scene scene) 53 | { 54 | sceneUnloaded = true; 55 | 56 | SceneManager.sceneUnloaded -= OnSceneUnloaded; 57 | } 58 | 59 | [UnityTest] 60 | public IEnumerator TestMakeScreenShot() 61 | { 62 | yield return Interact.MakeScreenShot("test_screen"); 63 | } 64 | 65 | [UnityTest] 66 | public IEnumerator TestMakeScreenShotReference() 67 | { 68 | yield return Interact.MakeScreenShotReference("reference"); 69 | } 70 | 71 | [UnityTest] 72 | [EditorResolution(750, 1334)] 73 | public IEnumerator TestMakeScreenShotAndCompare() 74 | { 75 | yield return Interact.MakeScreenShotReference("reference"); 76 | yield return Interact.MakeScreenshotAndCompare("test", "reference"); 77 | } 78 | 79 | [UnityTest] 80 | [EditorResolution(750, 1334)] 81 | public IEnumerator TestMakeScreenshotDontFail() 82 | { 83 | string expectedWarning = "Screenshot comparing fail was ignored: "+ 84 | "can't find reference screen shot with path: ReferenceScreenshots/resolution_750_1334/TestMakeScreenshotDontFail/reference to compare it with screen shot: test"; 85 | var waiter = AsyncWait.StartWaitingForLog(expectedWarning, 86 | LogType.Warning); 87 | yield return Interact.MakeScreenshotAndCompare("test", "reference", 0.9f, 88 | true); 89 | yield return waiter; 90 | 91 | string expectedError = "Screenshot equals failed: \n"+ 92 | "can't find reference screen shot with path: ReferenceScreenshots/resolution_750_1334/TestMakeScreenshotDontFail/reference to compare it with screen shot: test"; 93 | PermittedErrors.Add(expectedError); 94 | waiter = AsyncWait.StartWaitingForLog(expectedError, LogType.Error); 95 | Interact.FailIfScreenShotsNotEquals(); 96 | yield return waiter; 97 | } 98 | 99 | 100 | // public class TestClass : ScreenShotTests 101 | // { 102 | // [UnityTest] 103 | // public IEnumerator Test() 104 | // { 105 | // yield return null; 106 | // } 107 | // } 108 | 109 | } 110 | } -------------------------------------------------------------------------------- /Assets/Examples/ScreenShotTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a17e397292f747c295c06e0e7dbd3f11 3 | timeCreated: 1559742277 -------------------------------------------------------------------------------- /Assets/Examples/Test1.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace PlayQ.UITestTools 4 | { 5 | public class Test1 : ITestRunnerCallbackReceiver 6 | { 7 | public void OnBeforeTestsRunEvent() 8 | { 9 | Debug.LogWarning("Test1: OnBeforeTestsRunEvent()"); 10 | } 11 | 12 | public void OnAfterTestsRunEvent() 13 | { 14 | Debug.LogWarning("Test1: OnAfterTestsRunEvent()"); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/Examples/Test1.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f5d9de617e877425b8a305e663d127d6 3 | timeCreated: 1537271983 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Examples/Test2.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace PlayQ.UITestTools 4 | { 5 | public class Test2 : ITestRunnerCallbackReceiver 6 | { 7 | public void OnBeforeTestsRunEvent() 8 | { 9 | Debug.LogWarning("Test2: OnBeforeTestsRunEvent()"); 10 | } 11 | 12 | public void OnAfterTestsRunEvent() 13 | { 14 | Debug.LogWarning("Test2: OnAfterTestsRunEvent()"); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/Examples/Test2.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23661c6f46a704642889f8b59b4c3687 3 | timeCreated: 1537271990 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Examples/Test3.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace PlayQ.UITestTools 4 | { 5 | public class Test3 : ITestRunnerCallbackReceiver 6 | { 7 | public void OnBeforeTestsRunEvent() 8 | { 9 | Debug.LogWarning("Test3: OnBeforeTestsRunEvent()"); 10 | } 11 | 12 | public void OnAfterTestsRunEvent() 13 | { 14 | Debug.LogWarning("Test3: OnAfterTestsRunEvent()"); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/Examples/Test3.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a401d0352eeff4b9f9dbedeb3dee8bf5 3 | timeCreated: 1537271997 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Examples/Tests For Scene 1.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1b8e39568c06134fb8a7e6cf1ddbae4 3 | folderAsset: yes 4 | timeCreated: 1513095329 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Examples/Tests For Scene 1/1.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/Examples/Tests For Scene 1/1.unity -------------------------------------------------------------------------------- /Assets/Examples/Tests For Scene 1/1.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5274ffd88290e94395a662ef3f9a21d 3 | timeCreated: 1513078683 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Examples/Tests For Scene 1/TestObject.cs: -------------------------------------------------------------------------------- 1 |  2 | using UnityEngine; 3 | 4 | namespace PlayQ.UITestTools.Tests 5 | { 6 | public class TestObject : MonoBehaviour 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Assets/Examples/Tests For Scene 1/TestObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d92a2a921b58cfa49987ab23ac5bf635 3 | timeCreated: 1513611909 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Examples/UITestCheck.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c174b4f089795a4e82dfb9ee2e7522d 3 | timeCreated: 1475078584 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Examples/UITestSuccess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using UnityEngine; 4 | using UnityEngine.SceneManagement; 5 | using Object = UnityEngine.Object; 6 | using AssertionException = PlayQ.UITestTools.Assert.AssertionException; 7 | 8 | namespace PlayQ.UITestTools.Tests 9 | { 10 | public class UITestSuccess 11 | { 12 | [SetUp] 13 | public IEnumerator LoadSceneSetUp() 14 | { 15 | SceneManager.sceneLoaded += OnSceneLoaded; 16 | 17 | sceneLoaded = false; 18 | 19 | SceneManager.LoadScene("1", LoadSceneMode.Additive); 20 | 21 | while (!sceneLoaded) 22 | { 23 | yield return null; 24 | } 25 | } 26 | 27 | void OnSceneLoaded(Scene scene, LoadSceneMode mode) 28 | { 29 | sceneLoaded = true; 30 | 31 | SceneManager.sceneLoaded -= OnSceneLoaded; 32 | } 33 | 34 | private bool sceneLoaded; 35 | 36 | [TearDown] 37 | public IEnumerator UnloadSceneTearDown() 38 | { 39 | SceneManager.sceneUnloaded += OnSceneUnloaded; 40 | 41 | sceneUnloaded = false; 42 | 43 | SceneManager.UnloadSceneAsync("1"); 44 | 45 | while (!sceneUnloaded) 46 | { 47 | yield return null; 48 | } 49 | } 50 | 51 | void OnSceneUnloaded(Scene scene) 52 | { 53 | sceneUnloaded = true; 54 | 55 | SceneManager.sceneUnloaded -= OnSceneUnloaded; 56 | } 57 | 58 | private bool sceneUnloaded; 59 | 60 | 61 | [UnityTest] 62 | public IEnumerator Screen() 63 | { 64 | yield return null; 65 | 66 | Interact.MakeScreenShot("some path"); 67 | } 68 | 69 | [UnityTest] 70 | [TargetResolution(1024, 768)] 71 | public IEnumerator FindObjectByPixels() 72 | { 73 | yield return null; 74 | 75 | var obj = UITestUtils.FindObjectByPixels(630.0f, 325.0f); 76 | Assert.IsNotNull(obj); 77 | Assert.AreEqual(obj.name, "Image"); 78 | } 79 | 80 | [UnityTest] 81 | [TargetResolution(1024, 768)] 82 | public IEnumerator ClickOnObject() 83 | { 84 | yield return null; 85 | 86 | Interact.ClickPixels(512, 41); 87 | var openedWindow = UITestUtils.FindAnyGameObject("Window"); 88 | Assert.IsTrue(openedWindow.activeInHierarchy); 89 | } 90 | 91 | [UnityTest] 92 | public IEnumerator WaitForObjectOnScene() 93 | { 94 | //search for object with name "child_enabled" in parent object "container" 95 | //if object is not found - waits for object appearing for duration 96 | yield return Wait.ObjectInstantiated("container"); 97 | 98 | //search for object with component "Child" on it" 99 | //if object is not found - waits for object appearing for duration 100 | yield return Wait.ObjectInstantiated(); 101 | 102 | //search for object with component "Child" on it and hierarchy "container/child_enabled" 103 | //if object is not found - waits for object appearing for duration 104 | yield return Wait.ObjectInstantiated("container"); 105 | } 106 | 107 | [UnityTest] 108 | public IEnumerator WaitForObjectDestraction() 109 | { 110 | //manually search for object in scene 111 | var objectInstance = UITestUtils.FindAnyGameObject().gameObject; 112 | Object.Destroy(objectInstance); 113 | 114 | //wait during interval for destraction of object with component "ObjectThatWillBeDestroyedInSecond" 115 | yield return Wait.ObjectDestroyed(); 116 | 117 | //wait during interval for object destraction by object name "Object_that_will_be_destroyed_in_second" 118 | yield return Wait.ObjectDestroyed("container"); 119 | 120 | //wait during interval for object destraction by object instance 121 | yield return Wait.ObjectDestroyed(objectInstance); 122 | } 123 | 124 | [UnityTest] 125 | public IEnumerator WaitForObjectDisabled() 126 | { 127 | //get manual reference to the object 128 | var objectInstance = UITestUtils.FindAnyGameObject(); 129 | 130 | //manually disable object 131 | objectInstance.gameObject.SetActive(false); 132 | 133 | //check for disabled 134 | yield return Wait.ObjectDisabled("container"); 135 | 136 | //check for disabled 137 | yield return Wait.ObjectDisabled(); 138 | 139 | } 140 | 141 | 142 | [UnityTest] 143 | public IEnumerator WaitForObjectEnabled() 144 | { 145 | //get manual reference to the object 146 | var objectInstance = UITestUtils.FindAnyGameObject(); 147 | 148 | //manually enable object 149 | objectInstance.gameObject.SetActive(true); 150 | 151 | //check for enabled by component type 152 | yield return Wait.ObjectEnabled(); 153 | 154 | //check for enabled by path in hierarchy 155 | yield return Wait.ObjectEnabled("container"); 156 | 157 | } 158 | 159 | [UnityTest] 160 | public IEnumerator WaitForButtonAccesible() 161 | { 162 | var button = UITestUtils.FindAnyGameObject("container/Button"); 163 | 164 | yield return Wait.ButtonAccessible(button); 165 | } 166 | 167 | [UnityTest] 168 | public IEnumerator CheckAppendText() 169 | { 170 | yield return null; 171 | 172 | Interact.AppendText("container/InputField", "appednend text"); 173 | Interact.SetText("container/InputField", "appednend text"); 174 | 175 | try 176 | { 177 | Interact.SetText("container/Text", "appednend text"); 178 | Assert.Fail(); 179 | } 180 | catch (AssertionException ex) 181 | { 182 | if (!ex.Message.EndsWith("have not InputField component.")) 183 | { 184 | throw; 185 | } 186 | } 187 | 188 | try 189 | { 190 | Interact.AppendText("container/Text", "appednend text"); 191 | Assert.Fail(); 192 | } 193 | catch (AssertionException ex) 194 | { 195 | if (!ex.Message.EndsWith("have not InputField component.")) 196 | { 197 | throw; 198 | } 199 | } 200 | } 201 | 202 | [UnityTest] 203 | [TargetResolution(1024, 768)] 204 | public IEnumerator DragByCoords() 205 | { 206 | Vector2 from = new Vector2(45, 526); 207 | Vector2 to = new Vector2(934, 0); 208 | yield return Interact.DragPixels(from, to); 209 | 210 | var handle = UITestUtils.FindAnyGameObject("Handle"); 211 | var center = UITestUtils.CenterPointOfObject(handle.transform as RectTransform); 212 | 213 | Assert.AreEqual(center.x, 934, 0.1f); 214 | Assert.AreEqual(center.y, 526, 0.1f); 215 | } 216 | 217 | [UnityTest] 218 | [TargetResolution(1024, 768)] 219 | public IEnumerator DragByReference() 220 | { 221 | Vector2 to = new Vector2(934, 0); 222 | 223 | var handle = UITestUtils.FindAnyGameObject("Handle"); 224 | yield return Interact.DragPixels(handle, to); 225 | var center = UITestUtils.CenterPointOfObject(handle.transform as RectTransform); 226 | 227 | Assert.AreEqual(center.x, 934, 0.1f); 228 | Assert.AreEqual(center.y, 526, 0.1f); 229 | } 230 | 231 | [UnityTest] 232 | [TargetResolution(1024, 768)] 233 | public IEnumerator DragByPath() 234 | { 235 | Vector2 to = new Vector2(934, 0); 236 | 237 | var handle = UITestUtils.FindAnyGameObject("Handle"); 238 | yield return Interact.DragPixels("container/Slider/Handle Slide Area/Handle", to); 239 | var center = UITestUtils.CenterPointOfObject(handle.transform as RectTransform); 240 | 241 | Assert.AreEqual(center.x, 934, 0.1f); 242 | Assert.AreEqual(center.y, 526, 0.1f); 243 | } 244 | 245 | [UnityTest] 246 | [TargetResolution(1024, 768)] 247 | public IEnumerator ClickOnObjectFail() 248 | { 249 | yield return null; 250 | 251 | try 252 | { 253 | Interact.ClickPixels(20, 20); 254 | Assert.Fail(); 255 | } 256 | catch (Exception ex) 257 | { 258 | Assert.IsTrue(ex.Message.Contains("Cannot click to pixels")); 259 | } 260 | } 261 | 262 | [UnityTest] 263 | [TargetResolution(1024, 768)] 264 | public IEnumerator FindObjectByPixelsFail() 265 | { 266 | yield return null; 267 | 268 | var obj = UITestUtils.FindObjectByPixels(20, 20); 269 | Assert.IsNull(obj); 270 | } 271 | } 272 | } -------------------------------------------------------------------------------- /Assets/Examples/UITestSuccess.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cf1eb601bce74fbfa42c55e10c0aa10 3 | timeCreated: 1475078584 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Examples/UITestWaitFail.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using UnityEngine; 3 | using UnityEngine.SceneManagement; 4 | using Object = UnityEngine.Object; 5 | 6 | namespace PlayQ.UITestTools.Tests 7 | { 8 | public class UITestWaitFail 9 | { 10 | [TearDown] 11 | public void TearsDown() 12 | { 13 | PermittedErrors.ClearAll(); 14 | } 15 | 16 | [SetUp] 17 | public IEnumerator LoadSceneSetUp() 18 | { 19 | SceneManager.sceneLoaded += OnSceneLoaded; 20 | 21 | sceneLoaded = false; 22 | 23 | SceneManager.LoadScene("1", LoadSceneMode.Additive); 24 | 25 | while (!sceneLoaded) 26 | { 27 | yield return null; 28 | } 29 | } 30 | 31 | void OnSceneLoaded(Scene scene, LoadSceneMode mode) 32 | { 33 | sceneLoaded = true; 34 | 35 | SceneManager.sceneLoaded -= OnSceneLoaded; 36 | } 37 | 38 | private bool sceneLoaded; 39 | 40 | [TearDown] 41 | public IEnumerator UnloadSceneTearDown() 42 | { 43 | SceneManager.sceneUnloaded += OnSceneUnloaded; 44 | 45 | sceneUnloaded = false; 46 | 47 | SceneManager.UnloadSceneAsync("1"); 48 | 49 | while (!sceneUnloaded) 50 | { 51 | yield return null; 52 | } 53 | } 54 | 55 | void OnSceneUnloaded(Scene scene) 56 | { 57 | sceneUnloaded = true; 58 | 59 | SceneManager.sceneUnloaded -= OnSceneUnloaded; 60 | } 61 | 62 | private bool sceneUnloaded; 63 | 64 | 65 | [UnityTest] 66 | public IEnumerator WaitForObjectByName() 67 | { 68 | var testObject = UITestUtils.FindAnyGameObject().gameObject; 69 | Object.DestroyImmediate(testObject); 70 | 71 | var exceptionMessage = "Exception: Operation timed out: Wait failed, reason: WaitForObject path: container"; 72 | PermittedErrors.Add(exceptionMessage); 73 | var waiter = AsyncWait.StartWaitingForLog(exceptionMessage, LogType.Exception); 74 | 75 | yield return Wait.ObjectInstantiated("container"); 76 | 77 | yield return waiter; 78 | } 79 | 80 | [UnityTest] 81 | public IEnumerator WaitForObjectByComponent() 82 | { 83 | var testObject = UITestUtils.FindAnyGameObject(); 84 | Object.DestroyImmediate(testObject); 85 | 86 | var exceptionMessage = "Exception: Operation timed out: Wait failed, reason: WaitForObject"; 87 | PermittedErrors.Add(exceptionMessage); 88 | var waiter = AsyncWait.StartWaitingForLog(exceptionMessage, LogType.Exception); 89 | 90 | yield return Wait.ObjectInstantiated(); 91 | yield return waiter; 92 | } 93 | 94 | [UnityTest] 95 | public IEnumerator WaitForObjectByComponentAndName() 96 | { 97 | var testObject = UITestUtils.FindAnyGameObject().gameObject; 98 | Object.DestroyImmediate(testObject); 99 | 100 | var exceptionMessage = "Exception: Operation timed out: Wait failed, reason: WaitForObject"; 101 | PermittedErrors.Add(exceptionMessage); 102 | var waiter = AsyncWait.StartWaitingForLog(exceptionMessage, LogType.Exception); 103 | 104 | yield return Wait.ObjectInstantiated("container"); 105 | yield return waiter; 106 | } 107 | 108 | [UnityTest] 109 | public IEnumerator WaitForObjectDestractionByComponent() 110 | { 111 | var exceptionMessage = "Exception: Operation timed out: Wait failed, reason: WaitForDestroy"; 112 | PermittedErrors.Add(exceptionMessage); 113 | var waiter = AsyncWait.StartWaitingForLog(exceptionMessage, LogType.Exception); 114 | 115 | yield return Wait.ObjectDestroyed(1); 116 | yield return waiter; 117 | } 118 | 119 | [UnityTest] 120 | public IEnumerator WaitForObjectDestractionByInstance() 121 | { 122 | var objectInstance = UITestUtils.FindAnyGameObject().gameObject; 123 | 124 | var exceptionMessage = "Exception: Operation timed out: Wait failed, reason: WaitForDestroy UnityEngine.GameObject"; 125 | PermittedErrors.Add(exceptionMessage); 126 | var waiter = AsyncWait.StartWaitingForLog(exceptionMessage, LogType.Exception); 127 | 128 | yield return Wait.ObjectDestroyed(objectInstance); 129 | yield return waiter; 130 | } 131 | 132 | [UnityTest] 133 | public IEnumerator WaitForObjectDestractionByName() 134 | { 135 | var exceptionMessage = "Exception: Operation timed out: Wait failed, reason: WaitForDestroy path: container"; 136 | PermittedErrors.Add(exceptionMessage); 137 | var waiter = AsyncWait.StartWaitingForLog(exceptionMessage, LogType.Exception); 138 | 139 | yield return Wait.ObjectDestroyed("container"); 140 | yield return waiter; 141 | } 142 | 143 | [UnityTest] 144 | public IEnumerator WaitForObjectDisabledByName() 145 | { 146 | var exceptionMessage = "Exception: Operation timed out: Wait failed, reason: WaitObjectDisabled path: Object_enabled_at_start"; 147 | PermittedErrors.Add(exceptionMessage); 148 | var waiter = AsyncWait.StartWaitingForLog(exceptionMessage, LogType.Exception); 149 | 150 | yield return Wait.ObjectDisabled("Object_enabled_at_start"); 151 | yield return waiter; 152 | 153 | } 154 | 155 | 156 | [UnityTest] 157 | public IEnumerator WaitForObjectDisabledByComponent() 158 | { 159 | var exceptionMessage = "Exception: Operation timed out: Wait failed, reason: WaitObjectDisabled"; 160 | PermittedErrors.Add(exceptionMessage); 161 | var waiter = AsyncWait.StartWaitingForLog(exceptionMessage, LogType.Exception); 162 | 163 | yield return Wait.ObjectDisabled(); 164 | yield return waiter; 165 | } 166 | 167 | 168 | [UnityTest] 169 | public IEnumerator WaitForObjectEnabledByComponent() 170 | { 171 | var exceptionMessage = "Exception: Operation timed out: Wait failed, reason: WaitObjectEnabled"; 172 | PermittedErrors.Add(exceptionMessage); 173 | var waiter = AsyncWait.StartWaitingForLog(exceptionMessage, LogType.Exception); 174 | 175 | var testObject = UITestUtils.FindAnyGameObject().gameObject; 176 | testObject.SetActive(false); 177 | //check for enabled by component type 178 | yield return Wait.ObjectEnabled(); 179 | yield return waiter; 180 | } 181 | 182 | [UnityTest] 183 | public IEnumerator WaitForObjectEnabledByName() 184 | { 185 | var exceptionMessage = "Exception: Operation timed out: Wait failed, reason: WaitObjectEnabled path: container"; 186 | PermittedErrors.Add(exceptionMessage); 187 | var waiter = AsyncWait.StartWaitingForLog(exceptionMessage, LogType.Exception); 188 | 189 | var testObject = UITestUtils.FindAnyGameObject().gameObject; 190 | testObject.SetActive(false); 191 | 192 | //check for enabled by path in hierarchy 193 | yield return Wait.ObjectEnabled("container"); 194 | yield return waiter; 195 | } 196 | 197 | [UnityTest] 198 | public IEnumerator WaitForButtonAccesible() 199 | { 200 | var exceptionMessage = "Exception: Operation timed out: Wait failed, reason: ButtonAccessible UnityEngine.GameObject"; 201 | PermittedErrors.Add(exceptionMessage); 202 | var waiter = AsyncWait.StartWaitingForLog(exceptionMessage, LogType.Exception); 203 | 204 | var button = UITestUtils.FindAnyGameObject("container"); 205 | yield return Wait.ButtonAccessible(button); 206 | yield return waiter; 207 | } 208 | 209 | } 210 | 211 | } -------------------------------------------------------------------------------- /Assets/Examples/UITestWaitFail.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 907ca872922e3a94da3ce89c1ee890a4 3 | timeCreated: 1475078584 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 533d56914a301405181c16f414b7d047 3 | folderAsset: yes 4 | timeCreated: 1562757461 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ThirdParty.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89a944e3ef36bee4494688b819928ba3 3 | folderAsset: yes 4 | timeCreated: 1519055556 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ThirdParty/NewtonSoft.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22425b8a69c5b6741b4340ce6c0d6c58 3 | folderAsset: yes 4 | timeCreated: 1519055654 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ThirdParty/NewtonSoft/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/ThirdParty/NewtonSoft/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /Assets/ThirdParty/NewtonSoft/Newtonsoft.Json.dll.mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/ThirdParty/NewtonSoft/Newtonsoft.Json.dll.mdb -------------------------------------------------------------------------------- /Assets/ThirdParty/NewtonSoft/Newtonsoft.Json.dll.mdb.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d84eeb258e65c169f0958973f6d2099 3 | DefaultImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: -------------------------------------------------------------------------------- /Assets/ThirdParty/NewtonSoft/Newtonsoft.Json.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 878a269ee50954f5843ce9e2d98a44a6 3 | PluginImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | isPreloaded: 0 8 | platformData: 9 | '': 10 | enabled: 1 11 | settings: {} 12 | Android: 13 | enabled: 0 14 | settings: 15 | CPU: AnyCPU 16 | Any: 17 | enabled: 1 18 | settings: {} 19 | Editor: 20 | enabled: 0 21 | settings: 22 | CPU: AnyCPU 23 | DefaultValueInitialized: true 24 | OS: AnyOS 25 | Linux: 26 | enabled: 0 27 | settings: 28 | CPU: x86 29 | Linux64: 30 | enabled: 0 31 | settings: 32 | CPU: x86_64 33 | OSXIntel: 34 | enabled: 0 35 | settings: 36 | CPU: AnyCPU 37 | OSXIntel64: 38 | enabled: 0 39 | settings: 40 | CPU: AnyCPU 41 | Win: 42 | enabled: 0 43 | settings: 44 | CPU: AnyCPU 45 | Win64: 46 | enabled: 0 47 | settings: 48 | CPU: AnyCPU 49 | WindowsStoreApps: 50 | enabled: 0 51 | settings: 52 | CPU: AnyCPU 53 | iOS: 54 | enabled: 0 55 | settings: 56 | CompileFlags: 57 | FrameworkDependencies: 58 | userData: 59 | assetBundleName: 60 | assetBundleVariant: 61 | -------------------------------------------------------------------------------- /Assets/UITestTools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 837a2dde6f9f46c45b3c0e2a2b332ce0 3 | folderAsset: yes 4 | timeCreated: 1512462515 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/Actions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7280eaf377d0e495ab8b025fde575e73 3 | folderAsset: yes 4 | timeCreated: 1536924861 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/Actions/AsyncWait.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a199e15a97f3948d59aaa1c375f4c054 3 | timeCreated: 1536924861 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/Actions/Check.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e92c71427cfb546e38b29a06931ddc00 3 | timeCreated: 1536924861 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/Actions/Interact.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab1d75ef8238e4b06bf4488564548890 3 | timeCreated: 1536924861 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/Actions/Wait.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a653a6d8e14494dbebde9fb0b8bc958c 3 | timeCreated: 1536924861 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/ClassFileFinder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Text.RegularExpressions; 6 | 7 | public static class ClassFileFinder 8 | { 9 | private static bool isInited; 10 | private static Dictionary csFiles = new Dictionary(); 11 | private static HashSet duplicatedFileNames = new HashSet(); 12 | 13 | private static readonly string testsFolder = Application.dataPath + "/Tests"; 14 | 15 | public static string FindStackTrace(string className, string methodName, int yieldInstructionIndex) 16 | { 17 | if (!isInited) 18 | { 19 | FindAllCsFiles(testsFolder); 20 | isInited = true; 21 | } 22 | 23 | if (duplicatedFileNames.Contains(className)) 24 | { 25 | return "Mutltiple files have simmilar name: \"" + className + "\". " + 26 | "You need to use unique file names."; 27 | } 28 | 29 | string classPath; 30 | if (!csFiles.TryGetValue(className, out classPath)) 31 | { 32 | return 33 | "Unknown StackTrace (class: \"" + className + "\", method: \"" + methodName + "\"). " + 34 | "You need to have file name equals to class name and not intersection of namespaces"; 35 | } 36 | 37 | var fileText = File.ReadAllText(classPath); 38 | var regex = new Regex("IEnumerator\\s+" + methodName); 39 | var matchResult = regex.Match(fileText); 40 | 41 | if (!matchResult.Success) 42 | { 43 | return "Can't find method \"" + methodName + "\" in class \"" + className + "\"."; 44 | } 45 | 46 | var searchIndex = matchResult.Index; 47 | var findedYieldInstructions = 0; 48 | while (findedYieldInstructions != yieldInstructionIndex) 49 | { 50 | searchIndex = fileText.IndexOf("yield", searchIndex+1, StringComparison.Ordinal); 51 | if (searchIndex == -1) 52 | { 53 | return "Can't find " + (findedYieldInstructions + 1) + " yield instruction in \"" + methodName + 54 | "\" in class \"" + className + "\"."; 55 | } 56 | if (!IsCommented(fileText, searchIndex)) 57 | findedYieldInstructions++; 58 | } 59 | 60 | string[] strings = fileText.Split('\n'); 61 | int charsCount = 0; 62 | int strIndex; 63 | for (strIndex = 0; strIndex < strings.Length; strIndex++) 64 | { 65 | charsCount += strings[strIndex].Length+1; 66 | if (charsCount > searchIndex) 67 | { 68 | break; 69 | } 70 | } 71 | 72 | return "\n.\n.\nFailed at: " +methodName + " (" + classPath + ":" + (strIndex + 1) + ")\n"+ 73 | "\"" + strings[strIndex] + "\"."; 74 | } 75 | 76 | private static bool IsCommented(string text, int index) 77 | { 78 | int lastNextLineIndex = text.LastIndexOf('\n', index); 79 | 80 | if (lastNextLineIndex == -1) 81 | { 82 | lastNextLineIndex = 0; 83 | } 84 | 85 | int doubleSlashIndex = text.IndexOf("//", lastNextLineIndex, index - lastNextLineIndex, StringComparison.Ordinal); 86 | 87 | if (doubleSlashIndex != -1) 88 | { 89 | return true; 90 | } 91 | 92 | int multilineCommentOpenIndex = text.LastIndexOf("/*", index, StringComparison.Ordinal); 93 | 94 | if (multilineCommentOpenIndex == -1) 95 | { 96 | return false; 97 | } 98 | 99 | int multilineCommentCloseIndex = text.IndexOf("*/", multilineCommentOpenIndex, index - multilineCommentOpenIndex, StringComparison.Ordinal); 100 | 101 | if (multilineCommentCloseIndex == -1) 102 | { 103 | return true; 104 | } 105 | 106 | return false; 107 | } 108 | 109 | private static void FindAllCsFiles(string startDir) 110 | { 111 | if (!Directory.Exists(startDir)) 112 | { 113 | return; 114 | } 115 | foreach (string file in Directory.GetFiles(startDir)) 116 | { 117 | if (file.EndsWith(".cs", StringComparison.Ordinal)) 118 | { 119 | string key = Path.GetFileNameWithoutExtension(file); 120 | if (csFiles.ContainsKey(key)) 121 | { 122 | duplicatedFileNames.Add(key); 123 | continue; 124 | } 125 | csFiles.Add(key, file); 126 | } 127 | } 128 | foreach (string dir in Directory.GetDirectories(startDir)) 129 | { 130 | FindAllCsFiles(dir); 131 | } 132 | } 133 | } -------------------------------------------------------------------------------- /Assets/UITestTools/ClassFileFinder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7727977b9d2ef430eaab833078da747d 3 | timeCreated: 1536675109 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b704cd477d894c3b8c3170e0c36d0fb 3 | folderAsset: yes 4 | timeCreated: 1512995991 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/EditorParameterDrawers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using UnityEngine; 5 | using UnityEditor; 6 | 7 | namespace PlayQ.UITestTools 8 | { 9 | public abstract class AbstractParameterDrawer 10 | { 11 | public abstract Type ExpectedType { get; } 12 | 13 | public abstract void EditorDraw(AbstractParameter parameter, 14 | Rect rect, MethodInfo methodInfo); 15 | } 16 | 17 | public abstract class AbstractParameterDrawer : AbstractParameterDrawer 18 | where T : AbstractParameter 19 | { 20 | public override Type ExpectedType 21 | { 22 | get { return typeof(T); } 23 | } 24 | 25 | protected abstract void EditorDrawInner(T parameter, 26 | Rect rect, MethodInfo methodInfo); 27 | 28 | public sealed override void EditorDraw(AbstractParameter parameter, 29 | Rect rect, MethodInfo methodInfo) 30 | { 31 | if (parameter.GetType() != typeof(T)) 32 | { 33 | Debug.LogError("Parameter drawer of type: " + GetType() + 34 | " can draw only instances of type: " + typeof(T) + 35 | " but you pass instance of type: " + parameter.GetType()); 36 | return; 37 | } 38 | 39 | EditorDrawInner((T) parameter, rect, methodInfo); 40 | } 41 | } 42 | 43 | public class ParameterIntDrawer : AbstractParameterDrawer 44 | { 45 | protected override void EditorDrawInner(ParameterInt parameter, Rect rect, MethodInfo methodInfo) 46 | { 47 | var index = parameter.CurrentParameterIndex(); 48 | var parameters = methodInfo.GetParameters(); 49 | if (parameters.Length <= index) 50 | { 51 | Debug.LogWarning("missmatch parameters amount for: " + methodInfo.Name); 52 | return; 53 | } 54 | var paramName = parameters[index].Name; 55 | if (parameter.ParameterValue != null) 56 | { 57 | parameter.ParameterValue = 58 | EditorGUI.IntField(rect, new GUIContent(paramName.FirstCharToUpper() + ":", paramName.FirstCharToUpper()), parameter.ParameterValue); 59 | } 60 | } 61 | } 62 | 63 | public class ParameterFloatDrawer : AbstractParameterDrawer 64 | { 65 | protected override void EditorDrawInner(ParameterFloat parameter, Rect rect, MethodInfo methodInfo) 66 | { 67 | var index = parameter.CurrentParameterIndex(); 68 | var parameters = methodInfo.GetParameters(); 69 | if (parameters.Length <= index) 70 | { 71 | Debug.LogWarning("missmatch parameters amount for: " + methodInfo.Name); 72 | return; 73 | } 74 | var paramName = parameters[index].Name; 75 | parameter.ParameterValue = 76 | EditorGUI.FloatField(rect, new GUIContent(paramName.FirstCharToUpper() + ":", paramName.FirstCharToUpper()), parameter.ParameterValue); 77 | } 78 | } 79 | 80 | public class ParameterDoubleDrawer : AbstractParameterDrawer 81 | { 82 | protected override void EditorDrawInner(ParameterDouble parameter, Rect rect, MethodInfo methodInfo) 83 | { 84 | var index = parameter.CurrentParameterIndex(); 85 | var parameters = methodInfo.GetParameters(); 86 | if (parameters.Length <= index) 87 | { 88 | Debug.LogWarning("missmatch parameters amount for: " + methodInfo.Name); 89 | return; 90 | } 91 | var paramName = parameters[index].Name; 92 | if (parameter.ParameterValue != null) 93 | { 94 | parameter.ParameterValue = 95 | EditorGUI.DoubleField(rect, new GUIContent(paramName.FirstCharToUpper() + ":", paramName.FirstCharToUpper()), parameter.ParameterValue); 96 | } 97 | } 98 | } 99 | 100 | public class ParameterBoolDrawer : AbstractParameterDrawer 101 | { 102 | protected override void EditorDrawInner(ParameterBool parameter, Rect rect, MethodInfo methodInfo) 103 | { 104 | var index = parameter.CurrentParameterIndex(); 105 | var parameters = methodInfo.GetParameters(); 106 | if (parameters.Length <= index) 107 | { 108 | Debug.LogWarning("missmatch parameters amount for: " + methodInfo.Name); 109 | return; 110 | } 111 | var paramName = parameters[index].Name; 112 | if (parameter.ParameterValue != null) 113 | { 114 | parameter.ParameterValue = 115 | EditorGUI.Toggle(rect, new GUIContent(paramName.FirstCharToUpper() + ":", paramName.FirstCharToUpper()), parameter.ParameterValue); 116 | } 117 | } 118 | } 119 | 120 | public class ParameterStringDrawer : AbstractParameterDrawer 121 | { 122 | 123 | protected override void EditorDrawInner(ParameterString parameter, Rect rect, MethodInfo methodInfo) 124 | { 125 | var index = parameter.CurrentParameterIndex(); 126 | var parameters = methodInfo.GetParameters(); 127 | if (parameters.Length <= index) 128 | { 129 | Debug.LogWarning("missmatch parameters amount for: " + methodInfo.Name); 130 | return; 131 | } 132 | var paramName = parameters[index].Name; 133 | if (parameter.ParameterValue != null) 134 | { 135 | parameter.ParameterValue = EditorGUI.TextField(rect, new GUIContent(paramName.FirstCharToUpper() + ":",paramName.FirstCharToUpper()), parameter.ParameterValue); 136 | } 137 | } 138 | } 139 | 140 | public class ParameterEnumDrawer : AbstractParameterDrawer 141 | { 142 | protected override void EditorDrawInner(ParameterEnum parameter, Rect rect, MethodInfo methodInfo) 143 | { 144 | var index = parameter.CurrentParameterIndex(); 145 | var parameters = methodInfo.GetParameters(); 146 | if (parameters.Length <= index) 147 | { 148 | Debug.LogWarning("missmatch parameters amount for: " + methodInfo.Name); 149 | return; 150 | } 151 | var paramName = parameters[index].Name; 152 | if (parameter.NonSerializedEnum == null) 153 | { 154 | parameter.NonSerializedEnum = (Enum) Enum.Parse(parameter.EnumType, parameter.ParameterValue); 155 | } 156 | 157 | var newNonSerializedEnum = EditorGUI.EnumPopup(rect, new GUIContent(paramName.FirstCharToUpper() + ":", paramName.FirstCharToUpper()), parameter.NonSerializedEnum); 158 | if (newNonSerializedEnum != parameter.NonSerializedEnum) 159 | { 160 | parameter.ParameterValue = newNonSerializedEnum.ToString(); 161 | } 162 | 163 | parameter.NonSerializedEnum = newNonSerializedEnum; 164 | } 165 | } 166 | 167 | public class ParameterPathToGameObjectDrawer : AbstractParameterDrawer 168 | { 169 | private const int SELECT_BUTTON_WIDTH = 100; 170 | private const int SPACE = 2; 171 | 172 | protected override void EditorDrawInner(ParameterPathToGameObject parameter, Rect rect, MethodInfo methodInfo) 173 | { 174 | var index = parameter.CurrentParameterIndex(); 175 | var parameters = methodInfo.GetParameters(); 176 | if (parameters.Length <= index) 177 | { 178 | Debug.LogWarning("missmatch parameters amount for: " + methodInfo.Name); 179 | return; 180 | } 181 | var paramName = parameters[index].Name; 182 | if (parameter.ParameterValue != null) 183 | { 184 | Rect parameterRect = new Rect(rect.min, rect.size + new Vector2(-(SELECT_BUTTON_WIDTH + SPACE), 0f)); 185 | Rect buttonRect = new Rect(new Vector2(parameterRect.max.x + SPACE, rect.min.y), new Vector2(SELECT_BUTTON_WIDTH, rect.size.y)); 186 | 187 | parameter.ParameterValue = 188 | EditorGUI.TextField(parameterRect, new GUIContent(paramName.FirstCharToUpper() + ":",paramName.FirstCharToUpper()), parameter.ParameterValue); 189 | 190 | if (GUI.Button(buttonRect, "Select")) 191 | { 192 | GameObject target = UITestUtils.FindAnyGameObject(parameter.ParameterValue); 193 | 194 | if (target != null) 195 | Selection.activeGameObject = target; 196 | } 197 | } 198 | } 199 | } 200 | 201 | public static class StringUtils 202 | { 203 | public static string FirstCharToUpper(this string input) 204 | { 205 | switch (input) 206 | { 207 | case null: 208 | throw new ArgumentNullException(); 209 | case "": 210 | return ""; 211 | default: 212 | return input.First().ToString().ToUpper() + input.Substring(1); 213 | break; 214 | } 215 | } 216 | 217 | } 218 | } -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/EditorParameterDrawers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6656b7f3b0494e79abd2d4e8cd0f2254 3 | timeCreated: 1527236292 -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/ParameterDrawersFactorycs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace PlayQ.UITestTools 7 | { 8 | public class ParameterDrawersFactory 9 | { 10 | private Dictionary drawersByParameterType; 11 | 12 | public ParameterDrawersFactory() 13 | { 14 | drawersByParameterType = new Dictionary(); 15 | var types = GetType().Assembly.GetTypes(); 16 | var drawers = types.Where(type => 17 | { 18 | if (type.IsGenericType || type.IsAbstract) 19 | { 20 | return false; 21 | } 22 | return typeof(AbstractParameterDrawer).IsAssignableFrom(type); 23 | }).ToList(); 24 | 25 | foreach (var drawerType in drawers) 26 | { 27 | var drawer = Activator.CreateInstance(drawerType) as AbstractParameterDrawer; 28 | drawersByParameterType.Add(drawer.ExpectedType, drawer); 29 | } 30 | } 31 | 32 | public AbstractParameterDrawer GetDrawer(AbstractParameter parameter) 33 | { 34 | AbstractParameterDrawer paramDrawer; 35 | var result = drawersByParameterType.TryGetValue(parameter.GetType(), out paramDrawer); 36 | if (!result) 37 | { 38 | Debug.LogError("Fail to get ParamDrawer for type: " + parameter.GetType() + 39 | " probably drawer is not implemented or not added to factory."); 40 | } 41 | return paramDrawer; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/ParameterDrawersFactorycs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e7fa929bc3c46f28acd6c996eaf4885 3 | timeCreated: 1527239448 -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 660deebe5986447fdb305347008d5cdd 3 | folderAsset: yes 4 | timeCreated: 1514984669 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/failed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/UITestTools/Editor/Resources/failed.png -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/failed.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b571f44f08ff14e31bafff6fc87a4c91 3 | timeCreated: 1513155358 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: 1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 0 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 0 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: Android 70 | maxTextureSize: 2048 71 | textureFormat: -1 72 | textureCompression: 0 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: WebGL 78 | maxTextureSize: 2048 79 | textureFormat: -1 80 | textureCompression: 0 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | spriteSheet: 86 | serializedVersion: 2 87 | sprites: [] 88 | outline: [] 89 | spritePackingTag: 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/ignored.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/UITestTools/Editor/Resources/ignored.png -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/ignored.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa67ce366688b43309e8269539438ba8 3 | timeCreated: 1513155358 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: 1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 0 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 0 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: Android 70 | maxTextureSize: 2048 71 | textureFormat: -1 72 | textureCompression: 0 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: WebGL 78 | maxTextureSize: 2048 79 | textureFormat: -1 80 | textureCompression: 0 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | spriteSheet: 86 | serializedVersion: 2 87 | sprites: [] 88 | outline: [] 89 | spritePackingTag: 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/UITestTools/Editor/Resources/normal.png -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/normal.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c934042d0e6fe4ca5822c09b32eadeda 3 | timeCreated: 1513155358 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: 1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 0 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 0 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: Android 70 | maxTextureSize: 2048 71 | textureFormat: -1 72 | textureCompression: 0 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: WebGL 78 | maxTextureSize: 2048 79 | textureFormat: -1 80 | textureCompression: 0 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | spriteSheet: 86 | serializedVersion: 2 87 | sprites: [] 88 | outline: [] 89 | spritePackingTag: 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/passed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/UITestTools/Editor/Resources/passed.png -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/passed.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7fbd7bdd8a7764e88872845c60979019 3 | timeCreated: 1513155358 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: 1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 0 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 0 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: Android 70 | maxTextureSize: 2048 71 | textureFormat: -1 72 | textureCompression: 0 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: WebGL 78 | maxTextureSize: 2048 79 | textureFormat: -1 80 | textureCompression: 0 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | spriteSheet: 86 | serializedVersion: 2 87 | sprites: [] 88 | outline: [] 89 | spritePackingTag: 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/test_record_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/UITestTools/Editor/Resources/test_record_color.png -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/test_record_color.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f6e2adcd3d724480994c680dd195da9b 3 | timeCreated: 1515061738 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 1 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 1 46 | spriteTessellationDetail: -1 47 | textureType: 8 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | spriteSheet: 62 | serializedVersion: 2 63 | sprites: [] 64 | outline: [] 65 | spritePackingTag: 66 | userData: 67 | assetBundleName: 68 | assetBundleVariant: 69 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/test_record_grayscale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/UITestTools/Editor/Resources/test_record_grayscale.png -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/Resources/test_record_grayscale.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c21d540e65c8480b8c5e4e7a6110bcb 3 | timeCreated: 1515061738 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 1 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 1 46 | spriteTessellationDetail: -1 47 | textureType: 8 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | spriteSheet: 62 | serializedVersion: 2 63 | sprites: [] 64 | outline: [] 65 | spritePackingTag: 66 | userData: 67 | assetBundleName: 68 | assetBundleVariant: 69 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/UITestFlowRecorderController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | using UnityEngine.UI; 6 | 7 | namespace PlayQ.UITestTools 8 | { 9 | [Serializable] 10 | public class UITestUserFlowRecorderController 11 | { 12 | private Vector2 startMousePos; 13 | public bool IsRecording { get; private set; } 14 | private bool isClickMode = true; 15 | public bool IsAssertationMode { get; private set; } 16 | public bool IsForceRaycastEnabled { get; private set; } 17 | public bool IsTimeScaleZero { get; private set; } 18 | public string GeneratedCode; 19 | private GameObject screenBlocker; 20 | private UserFlowModel userFlowModel = new UserFlowModel(); 21 | 22 | private List fakeUserActions; 23 | public List UserActions 24 | { 25 | get 26 | { 27 | if (userFlowModel == null) 28 | { 29 | if (fakeUserActions == null) 30 | { 31 | fakeUserActions = new List(); 32 | } 33 | return fakeUserActions; 34 | } 35 | else 36 | { 37 | return userFlowModel.UserActions; 38 | } 39 | } 40 | } 41 | 42 | public UITestUserFlowRecorderController() 43 | { 44 | userFlowModel.FetchAssertationMethods(); 45 | } 46 | 47 | private bool previousEditorPaused; 48 | private bool previousEditorStateIsPlaying; 49 | public bool Update() 50 | { 51 | if (!EditorApplication.isPlaying) 52 | { 53 | if (previousEditorStateIsPlaying && IsRecording) 54 | { 55 | StartOrStopRecording(); 56 | IsForceRaycastEnabled = false; 57 | userFlowModel.ForceEnableRaycast(IsForceRaycastEnabled); 58 | previousEditorStateIsPlaying = EditorApplication.isPlaying; 59 | IsTimeScaleZero = false; 60 | return true; 61 | } 62 | return false; 63 | } 64 | previousEditorStateIsPlaying = EditorApplication.isPlaying; 65 | 66 | if (Input.GetMouseButtonDown(0)) 67 | { 68 | startMousePos = Input.mousePosition; 69 | } 70 | 71 | if (Input.GetMouseButtonUp(0)) 72 | { 73 | Vector2 currentPos = Input.mousePosition; 74 | if (isClickMode) 75 | { 76 | HandleClick(currentPos); 77 | } 78 | else 79 | { 80 | HandleDrag(startMousePos, currentPos); 81 | } 82 | return true; 83 | } 84 | 85 | if (previousEditorPaused != EditorApplication.isPaused) 86 | { 87 | previousEditorPaused = EditorApplication.isPaused; 88 | return true; 89 | } 90 | previousEditorPaused = EditorApplication.isPaused; 91 | return false; 92 | } 93 | 94 | private void HandleDrag(Vector2 startPos, Vector2 endPos) 95 | { 96 | 97 | } 98 | 99 | private void HandleClick(Vector2 pos) 100 | { 101 | userFlowModel.HandleClick(pos); 102 | } 103 | 104 | 105 | private void HideScreenBlocker() 106 | { 107 | if (screenBlocker) 108 | { 109 | screenBlocker.SetActive(false); 110 | } 111 | } 112 | 113 | public void CreateNoGameobjectAction() 114 | { 115 | userFlowModel.CreateNoGameobjectAction(); 116 | } 117 | 118 | public void HandleGameObject(GameObject go) 119 | { 120 | userFlowModel.HandleGameObject(go); 121 | } 122 | 123 | 124 | public void EnableOrDisableForceRaycast() 125 | { 126 | IsForceRaycastEnabled = !IsForceRaycastEnabled; 127 | userFlowModel.ForceEnableRaycast(IsForceRaycastEnabled); 128 | } 129 | 130 | public void EnableOrDisableTimescalePause() 131 | { 132 | IsTimeScaleZero = !IsTimeScaleZero; 133 | Time.timeScale = IsTimeScaleZero ? 0 : 1; 134 | } 135 | 136 | private void AddScreenBlocker() 137 | { 138 | if (!screenBlocker) 139 | { 140 | screenBlocker = new GameObject(); 141 | screenBlocker.name = UserFlowModel.UI_TEST_SCREEN_BLOCKER; 142 | var canvas = screenBlocker.AddComponent(); 143 | screenBlocker.AddComponent(); 144 | var image = screenBlocker.AddComponent(); 145 | screenBlocker.AddComponent(); 146 | 147 | image.color = new Color(0, 0, 0, 0); 148 | canvas.sortingOrder = 9999; 149 | canvas.renderMode = RenderMode.ScreenSpaceOverlay; 150 | } 151 | screenBlocker.SetActive(true); 152 | } 153 | 154 | public void ApplyAction(UserActionInfo action) 155 | { 156 | if (userFlowModel != null) 157 | { 158 | userFlowModel.ApplyAction(action); 159 | } 160 | } 161 | 162 | public void GenerateCode() 163 | { 164 | GeneratedCode = userFlowModel.GeneratedCode(); 165 | CopyToBuffer(); 166 | } 167 | 168 | public void CopyToBuffer() 169 | { 170 | if (!String.IsNullOrEmpty(GeneratedCode)) 171 | { 172 | EditorGUIUtility.systemCopyBuffer = GeneratedCode; 173 | } 174 | } 175 | 176 | //todo create 2 methods 177 | public void StartOrStopRecording() 178 | { 179 | IsRecording = !IsRecording; 180 | if (IsRecording) 181 | { 182 | userFlowModel.FetchAssertationMethods(); 183 | } 184 | else 185 | { 186 | if (IsAssertationMode) 187 | { 188 | ChagneAssertation(); 189 | } 190 | } 191 | } 192 | 193 | public void ChagneAssertation() 194 | { 195 | IsAssertationMode = !IsAssertationMode; 196 | if (IsAssertationMode) 197 | { 198 | AddScreenBlocker(); 199 | } 200 | else 201 | { 202 | HideScreenBlocker(); 203 | IsForceRaycastEnabled = false; 204 | userFlowModel.ForceEnableRaycast(IsForceRaycastEnabled); 205 | } 206 | } 207 | 208 | public void Clean() 209 | { 210 | if (userFlowModel != null) 211 | { 212 | userFlowModel.CleanFlow(); 213 | GeneratedCode = null; 214 | } 215 | } 216 | } 217 | 218 | } -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/UITestFlowRecorderController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ec77268f796043fe9ae22a52681ad1d 3 | timeCreated: 1534860414 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/UITestFlowRecorderWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 66f81e435be334a66b95d7886bcecf29 3 | timeCreated: 1534860415 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/UITestToolsHelperWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a68b3565858a452ab919950449e4ced 3 | timeCreated: 1512995798 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/Editor/UserFlowModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d75ab8d0e43a054cb6dd35de45110c5 3 | timeCreated: 1514549531 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/MockNUnit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c466e7f574c4a068a8921e0f03f1528 3 | timeCreated: 1521117857 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12b77c3eb8af4190b4f7573f2313960c 3 | timeCreated: 1513089877 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/ConsoleArgumentHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | 3 | namespace PlayQ.UITestTools 4 | { 5 | public class ConsoleArgumentHelper 6 | { 7 | public static string GetArg(string name) 8 | { 9 | var args = System.Environment.GetCommandLineArgs(); 10 | if (args == null) 11 | { 12 | return null; 13 | } 14 | 15 | for (int i = 0; i < args.Length; i++) 16 | { 17 | if (args[i] == name && args.Length > i + 1) 18 | { 19 | return args[i + 1]; 20 | } 21 | } 22 | return null; 23 | } 24 | 25 | public static bool IsArgExist(string name) 26 | { 27 | var args = System.Environment.GetCommandLineArgs(); 28 | if (args == null) 29 | { 30 | return false; 31 | } 32 | return args.Any(arg => arg == name); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/ConsoleArgumentHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 687d64187d4c4748bce8ce7bb7df65b6 3 | timeCreated: 1519312086 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/CurrentTestInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Reflection; 3 | using UnityEngine; 4 | 5 | namespace PlayQ.UITestTools 6 | { 7 | public static class CurrentTestInfo 8 | { 9 | public static Vector2[] TestMethodTargetResolution 10 | { 11 | get 12 | { 13 | MethodInfo testMethodInfo = null; 14 | 15 | if (PlayModeTestRunner.CurrentPlayingMethodNode.Node != null) 16 | { 17 | testMethodInfo = PlayModeTestRunner.CurrentPlayingMethodNode.Node.TestSettings.MethodInfo; 18 | } 19 | 20 | if (testMethodInfo == null) 21 | { 22 | return new Vector2[] { }; 23 | } 24 | 25 | var customAttributes = testMethodInfo.GetCustomAttributes(true); 26 | if (customAttributes.Any()) 27 | { 28 | var targetResolutions = customAttributes 29 | .Where(attribute => 30 | { 31 | return attribute.GetType() == typeof(TargetResolutionAttribute); 32 | }); 33 | if (targetResolutions.Any()) 34 | { 35 | return targetResolutions.Select(attribute => 36 | { 37 | var targetResolution = (TargetResolutionAttribute) attribute; 38 | return new Vector2(targetResolution.Width, targetResolution.Height); 39 | }).ToArray(); 40 | } 41 | } 42 | 43 | return new Vector2[] { }; 44 | } 45 | } 46 | 47 | 48 | public static string TestSuitName 49 | { 50 | get 51 | { 52 | if (PlayModeTestRunner.IsRunning) 53 | { 54 | return PlayModeTestRunner.CurrentPlayingMethodNode.Node != null 55 | ? PlayModeTestRunner.CurrentPlayingMethodNode.Node.ParentClass.Name 56 | : null; 57 | } 58 | return null; 59 | } 60 | } 61 | 62 | public static string TestMethodName 63 | { 64 | get 65 | { 66 | if (PlayModeTestRunner.IsRunning) 67 | { 68 | return PlayModeTestRunner.CurrentPlayingMethodNode.Node != null 69 | ? PlayModeTestRunner.CurrentPlayingMethodNode.Node.Name 70 | : null; 71 | } 72 | return null; 73 | } 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/CurrentTestInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c8cd9bac23841938782d25a2268703e 3 | timeCreated: 1519133655 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a35a7f3df43cc4a82941ba11ad4a8ff5 3 | folderAsset: yes 4 | timeCreated: 1514894413 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 658c40d921a2e854d8799e97990c04cf 3 | folderAsset: yes 4 | timeCreated: 1513155358 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67f004db7ebd4471eac6b3fa5a580e7e 3 | folderAsset: yes 4 | timeCreated: 1559746022 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_1024_768/TestMakeScreenShotAndCompare.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b03d9a300c504b62b3f2cf9558c8fe8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c9d346a445e2849e5b08313cf0f72a84 3 | folderAsset: yes 4 | timeCreated: 1559904555 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/C25419_ForBoostsPriorToGameplay.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb74b522d227742fead24a9a25655557 3 | folderAsset: yes 4 | timeCreated: 1560255901 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/C25419_ForBoostsPriorToGameplay/CheckBooster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/C25419_ForBoostsPriorToGameplay/CheckBooster.png -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/C25419_ForBoostsPriorToGameplay/CheckBooster.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f083edda47f044c45a3e8e137552c178 3 | timeCreated: 1560428388 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 1 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 1 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 1 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 0 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | spriteSheet: 62 | serializedVersion: 2 63 | sprites: [] 64 | outline: [] 65 | spritePackingTag: 66 | userData: 67 | assetBundleName: 68 | assetBundleVariant: 69 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/TestMakeScreenShotAndCompare.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d35f0e9f5017c424da28a0a1c42b129d 3 | folderAsset: yes 4 | timeCreated: 1559904556 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/TestMakeScreenShotAndCompare/reference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/TestMakeScreenShotAndCompare/reference.png -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/TestMakeScreenShotAndCompare/reference.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c54aedd845e543bb89490cac9a1b404 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 10 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 1 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 0 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | spriteSheet: 73 | serializedVersion: 2 74 | sprites: [] 75 | outline: [] 76 | physicsShape: [] 77 | bones: [] 78 | spriteID: 79 | internalID: 0 80 | vertices: [] 81 | indices: 82 | edges: [] 83 | weights: [] 84 | secondaryTextures: [] 85 | spritePackingTag: 86 | pSDRemoveMatte: 0 87 | pSDShowRemoveMatteOption: 0 88 | userData: 89 | assetBundleName: 90 | assetBundleVariant: 91 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/TestMakeScreenShotReference.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf2f7f3efb0174f1fae052553627dca9 3 | folderAsset: yes 4 | timeCreated: 1559904555 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/TestMakeScreenShotReference/reference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/TestMakeScreenShotReference/reference.png -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Editor/Resources/ReferenceScreenshots/resolution_750_1334/TestMakeScreenShotReference/reference.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62add54dfb10f4801ae375c87d31d7ab 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 10 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 1 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 0 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | spriteSheet: 73 | serializedVersion: 2 74 | sprites: [] 75 | outline: [] 76 | physicsShape: [] 77 | bones: [] 78 | spriteID: 79 | internalID: 0 80 | vertices: [] 81 | indices: 82 | edges: [] 83 | weights: [] 84 | secondaryTextures: [] 85 | spritePackingTag: 86 | pSDRemoveMatte: 0 87 | pSDShowRemoveMatteOption: 0 88 | userData: 89 | assetBundleName: 90 | assetBundleVariant: 91 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/EditorTargetResolution.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PlayQ.UITestTools 5 | { 6 | [AttributeUsage(AttributeTargets.Method)] 7 | public class EditorResolutionAttribute : Attribute 8 | { 9 | public readonly int Width; 10 | public readonly int Height; 11 | 12 | public EditorResolutionAttribute(int width, int height) 13 | { 14 | Width = width; 15 | Height = height; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/EditorTargetResolution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1b88165a91104d63be1e9b6a9515172 3 | timeCreated: 1534174041 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/GameViewResizer.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | 3 | using UnityEditor; 4 | using System; 5 | using System.Reflection; 6 | 7 | namespace PlayQ.UITestTools 8 | { 9 | public static class GameViewResizer 10 | { 11 | static GameViewResizer() 12 | { 13 | GameViewType = Type.GetType("UnityEditor.GameView, UnityEditor.dll"); 14 | GameViewSizeType = Type.GetType("UnityEditor.GameViewSize, UnityEditor.dll"); 15 | GameViewSizeEnum = Type.GetType("UnityEditor.GameViewSizeType, UnityEditor.dll"); 16 | 17 | 18 | var gameViewSizesType = Type.GetType("UnityEditor.GameViewSizes, UnityEditor.dll"); 19 | var gameViewSizeGroupType = Type.GetType("UnityEditor.GameViewSizeGroup, UnityEditor.dll"); 20 | var singletonOfGameViewSizes = Type.GetType("UnityEditor.ScriptableSingleton`1, UnityEditor.dll") 21 | .MakeGenericType(gameViewSizesType); 22 | 23 | GetMainGameViewMethod = FindMethod(GameViewType, "GetMainGameView"); 24 | SetSelectionMethod = FindMethod(GameViewType, "SizeSelectionCallback"); 25 | AddCustomSizeMethod = FindMethod(gameViewSizeGroupType, "AddCustomSize"); 26 | GetTotalGroupCountMethod = FindMethod(gameViewSizeGroupType, "GetTotalCount"); 27 | 28 | SingletonOfGameViewSizesInstance = FindProperty(singletonOfGameViewSizes, "instance", gameViewSizesType); 29 | CurrentGroupProperty = FindProperty(gameViewSizesType, "currentGroup", gameViewSizeGroupType); 30 | } 31 | 32 | private static readonly Type GameViewType; 33 | private static readonly Type GameViewSizeType; 34 | private static readonly Type GameViewSizeEnum; 35 | 36 | private static readonly MethodInfo GetMainGameViewMethod; 37 | private static readonly MethodInfo SetSelectionMethod; 38 | private static readonly MethodInfo AddCustomSizeMethod; 39 | private static readonly MethodInfo GetTotalGroupCountMethod; 40 | 41 | private static readonly PropertyInfo SingletonOfGameViewSizesInstance; 42 | private static readonly PropertyInfo CurrentGroupProperty; 43 | 44 | private static PropertyInfo FindProperty(Type defineType, string name, Type returnType) 45 | { 46 | return defineType.GetProperty(name, 47 | BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, 48 | returnType, new Type[0], null); 49 | } 50 | 51 | private static MethodInfo FindMethod(Type defineType, string name) 52 | { 53 | return defineType.GetMethod(name, BindingFlags.Static |BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 54 | } 55 | 56 | public static void SetResolution(int width, int height) 57 | { 58 | #if UNITY_EDITOR 59 | var window = GetWindow(); 60 | 61 | var instance = SingletonOfGameViewSizesInstance.GetValue(null, null); 62 | var currentGroup = CurrentGroupProperty.GetValue(instance, null); 63 | var sizeTypeObject = Enum.ToObject(GameViewSizeEnum, 1); 64 | var targetSize = Activator.CreateInstance(GameViewSizeType, sizeTypeObject, width, height, "Test size"); 65 | AddCustomSizeMethod.Invoke(currentGroup, new object[] {targetSize}); 66 | var count = (int) GetTotalGroupCountMethod.Invoke(currentGroup, new object[0]); 67 | SetSelectionMethod.Invoke(window, new object[] {count - 1, null}); 68 | #endif 69 | } 70 | 71 | private static EditorWindow GetWindow() 72 | { 73 | var currentWindow = EditorWindow.mouseOverWindow; 74 | if (currentWindow != null && GameViewType == currentWindow.GetType()) 75 | { 76 | return currentWindow; 77 | } 78 | 79 | currentWindow = EditorWindow.focusedWindow; 80 | if (currentWindow != null && GameViewType == currentWindow.GetType()) 81 | { 82 | return currentWindow; 83 | } 84 | 85 | return GetMainGameViewMethod.Invoke(null, null) as EditorWindow; 86 | } 87 | } 88 | } 89 | #endif -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/GameViewResizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 142389a38bee485e999ef0b66b1e6e7f 3 | timeCreated: 1513682809 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/ITestRunnerCallbackReceiver.cs: -------------------------------------------------------------------------------- 1 | namespace PlayQ.UITestTools 2 | { 3 | public interface ITestRunnerCallbackReceiver 4 | { 5 | void OnBeforeTestsRunEvent(); 6 | void OnAfterTestsRunEvent(); 7 | } 8 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/ITestRunnerCallbackReceiver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e12d34e9987aa4941a82d366f55afb6a 3 | timeCreated: 1537189079 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/LogSaver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using Newtonsoft.Json.Linq; 4 | 5 | namespace PlayQ.UITestTools 6 | { 7 | public class LogSaver 8 | { 9 | private readonly string path; 10 | private StreamWriter writer; 11 | 12 | public void SaveTestInfo(TestInfoData data) 13 | { 14 | var json = JObject.FromObject(data).ToString(); 15 | TestMetrics.CheckAndCreateFolder(); 16 | File.WriteAllText(TestMetrics.PathTo("tests.json"), json); 17 | } 18 | 19 | public LogSaver(string path) 20 | { 21 | this.path = path; 22 | } 23 | 24 | public void StartWrite() 25 | { 26 | writer = new StreamWriter(File.Create(path)); 27 | } 28 | 29 | public void Write(string log, string stacktrace) 30 | { 31 | writer.WriteLine(DateTime.UtcNow.ToString(PlayModeLogger.TC_DATE_FORMAT) + ": " + log); 32 | writer.WriteLine(stacktrace); 33 | } 34 | 35 | public void Close() 36 | { 37 | writer.Close(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/LogSaver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1063c68f67194624bb9c3c42e517c582 3 | timeCreated: 1513084911 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75953700252ca454199fd26a19ad7a65 3 | folderAsset: yes 4 | timeCreated: 1535021552 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/ClassNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using Newtonsoft.Json; 6 | 7 | namespace Tests.Nodes 8 | { 9 | public class ClassNode : Node 10 | { 11 | [JsonProperty] private string assemblySerialized; 12 | [JsonProperty] private string typeSerialized; 13 | 14 | private Type type; 15 | [JsonIgnore] 16 | public Type Type 17 | { 18 | get 19 | { 20 | if (type == null) 21 | { 22 | var assemblies = AppDomain.CurrentDomain.GetAssemblies(); 23 | var assembly = assemblies.FirstOrDefault(a => a.GetName().Name == assemblySerialized); 24 | if (assembly != null) 25 | { 26 | type = assembly.GetType(typeSerialized); 27 | } 28 | } 29 | return type; 30 | } 31 | private set 32 | { 33 | type = value; 34 | typeSerialized = type.FullName; 35 | assemblySerialized = type.Assembly.GetName().Name; 36 | } 37 | } 38 | 39 | private List Getter(Type type, 40 | ref List infos, List names) 41 | { 42 | if (infos == null) 43 | { 44 | infos = MethodNamesToInfos(type, names); 45 | } 46 | return infos; 47 | } 48 | private void Setter(IEnumerable value, 49 | ref List infos, ref List names) 50 | { 51 | infos = (List)value; 52 | names = MethodInfosToNames(infos); 53 | } 54 | 55 | [JsonProperty] private List setUpMethodsNames = new List(); 56 | [JsonProperty] private List oneTimeSetUpMethodsNames = new List(); 57 | [JsonProperty] private List tearDownMethodsNames = new List(); 58 | [JsonProperty] private List oneTimeTearDownMethodsNames = new List(); 59 | 60 | private List setUpMethods; 61 | private List oneTimeSetUpMethods; 62 | private List tearDownMethods; 63 | private List oneTimeTearDownMethods; 64 | 65 | [JsonIgnore] 66 | public IEnumerable SetUpMethods 67 | { 68 | get 69 | { 70 | return Getter(Type, ref setUpMethods, setUpMethodsNames); 71 | } 72 | set 73 | { 74 | Setter(value, ref setUpMethods, ref setUpMethodsNames); 75 | } 76 | } 77 | 78 | [JsonIgnore] 79 | public IEnumerable OneTimeSetUpMethods 80 | { 81 | get 82 | { 83 | return Getter(Type, ref oneTimeSetUpMethods, oneTimeSetUpMethodsNames); 84 | } 85 | set 86 | { 87 | Setter(value, ref oneTimeSetUpMethods, ref oneTimeSetUpMethodsNames); 88 | } 89 | } 90 | 91 | [JsonIgnore] 92 | public IEnumerable TearDownMethods 93 | { 94 | get 95 | { 96 | return Getter(Type, ref tearDownMethods, tearDownMethodsNames); 97 | } 98 | set 99 | { 100 | Setter(value, ref tearDownMethods, ref tearDownMethodsNames); 101 | } 102 | } 103 | 104 | [JsonIgnore] 105 | public IEnumerable OneTimeTearDownMethods 106 | { 107 | get 108 | { 109 | return Getter(Type, ref oneTimeTearDownMethods, oneTimeTearDownMethodsNames); 110 | } 111 | set 112 | { 113 | Setter(value, ref oneTimeTearDownMethods, ref oneTimeTearDownMethodsNames); 114 | } 115 | } 116 | 117 | 118 | [JsonProperty] 119 | private string fullName; 120 | 121 | [JsonIgnore] 122 | public readonly string FilePath; 123 | 124 | public void UpdateType(Type type) 125 | { 126 | Type = type; 127 | fullName = Type.FullName; 128 | } 129 | 130 | 131 | public ClassNode(Type type, Node parentNode, string filePath = null) 132 | : base (type.Name, parentNode) 133 | { 134 | FilePath = filePath; 135 | Type = type; 136 | fullName = Type.FullName; 137 | } 138 | 139 | [JsonConstructor] 140 | public ClassNode() 141 | { 142 | } 143 | 144 | public ClassNode(string name, Node parentNode) 145 | : base (name, parentNode) 146 | { 147 | if (parentNode != null) 148 | { 149 | fullName = parent.FullName + "." + name; 150 | } 151 | else 152 | { 153 | fullName = name; 154 | } 155 | 156 | } 157 | 158 | [JsonIgnore] 159 | public override string FullName 160 | { 161 | get { return fullName; } 162 | } 163 | 164 | [JsonIgnore] 165 | public override TestState State 166 | { 167 | get 168 | { 169 | if (stateIsDirty) 170 | { 171 | stateIsDirty = false; 172 | bool isAnyIgnored = false; 173 | bool isAnyUndefined = false; 174 | bool isAnyFail = false; 175 | 176 | foreach (var child in children) 177 | { 178 | if (child.State == TestState.Failed) 179 | { 180 | isAnyFail = true; 181 | break; 182 | } 183 | if (child.State == TestState.Undefined) 184 | { 185 | isAnyUndefined = true; 186 | } 187 | if (child.State == TestState.Ignored) 188 | { 189 | isAnyIgnored = true; 190 | } 191 | } 192 | 193 | if (isAnyFail) 194 | { 195 | cachedState = TestState.Failed; 196 | } 197 | else if (isAnyUndefined) 198 | { 199 | cachedState = TestState.Undefined; 200 | } 201 | else if(isAnyIgnored) 202 | { 203 | cachedState = TestState.Ignored; 204 | } 205 | else 206 | { 207 | cachedState = TestState.Passed; 208 | } 209 | 210 | return cachedState; 211 | } 212 | else 213 | { 214 | return cachedState; 215 | } 216 | } 217 | } 218 | 219 | protected override void SetDataFromNode(Node other) 220 | { 221 | base.SetDataFromNode(other); 222 | if (other is ClassNode) 223 | { 224 | var otherClassNode = (ClassNode) other; 225 | cachedState = otherClassNode.cachedState; 226 | } 227 | } 228 | } 229 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/ClassNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c3dab662b90dc4c0b9847512bb97e0dd 3 | timeCreated: 1535013998 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Factories.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea525c2054d54a268b7e34ab11e2c31c 3 | timeCreated: 1553268340 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Factories/MethodTestSettingsFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Reflection; 4 | using PlayQ.UITestTools; 5 | 6 | namespace Tests 7 | { 8 | public static class MethodTestSettingsFactory 9 | { 10 | private const float DEFAULT_TIME_OUT = 30000f; 11 | 12 | public static MethodTestSettings Build(MethodInfo methodInfo, string ignoreReason) 13 | { 14 | float timeOut = DEFAULT_TIME_OUT; 15 | bool isIgnored = ignoreReason != null; 16 | bool isSmoke = false; 17 | List targetResolutions = new List(); 18 | CustomResolution editorTargetResolution = null; 19 | List testRailURLs = new List(); 20 | 21 | var attributes = methodInfo.GetCustomAttributes(false); 22 | 23 | //Attributes are getting added in a reverse order that they're written by c# 24 | //i.e. if you have [A] above [B] above target method in your source code, 25 | //this list will be in order B: 0, A: 1 26 | //If you have order-sensitive attributes then you need this list reversed against its initial state 27 | //Ordering is needed to set correct resolution from target resolution attribute in editor 28 | attributes.Reverse(); 29 | 30 | foreach (var attribute in attributes) 31 | { 32 | var timeOutAttribute = attribute as TimeoutAttribute; 33 | if (timeOutAttribute != null) 34 | { 35 | timeOut = (int)timeOutAttribute.Properties.Get("Timeout"); 36 | continue; 37 | } 38 | 39 | var ignoreAttribute = attribute as IgnoreAttribute; 40 | if (ignoreAttribute != null) 41 | { 42 | isIgnored = true; 43 | ignoreReason = ignoreAttribute.Reason; 44 | continue; 45 | } 46 | 47 | var smokeTestAttribute = attribute as SmokeTestAttribute; 48 | if (smokeTestAttribute != null) 49 | { 50 | isSmoke = true; 51 | continue; 52 | } 53 | 54 | var targetResolutionAttribute = attribute as TargetResolutionAttribute; 55 | if (targetResolutionAttribute != null) 56 | { 57 | targetResolutions.Add(new CustomResolution(targetResolutionAttribute.Width, targetResolutionAttribute.Height)); 58 | 59 | continue; 60 | } 61 | 62 | var editorTargetResolutionAttribute = attribute as EditorResolutionAttribute; 63 | if (editorTargetResolutionAttribute != null) 64 | { 65 | editorTargetResolution = new CustomResolution(editorTargetResolutionAttribute.Width, editorTargetResolutionAttribute.Height); 66 | continue; 67 | } 68 | 69 | if (attribute is TestRailAttribute) 70 | { 71 | var testRail = (TestRailAttribute) attribute; 72 | testRailURLs.Add(new TestRailsData(testRail.TestRailURL, testRail.Description)); 73 | continue; 74 | } 75 | } 76 | 77 | return new MethodTestSettings(methodInfo, timeOut, isIgnored, ignoreReason, isSmoke, testRailURLs, targetResolutions, editorTargetResolution); 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Factories/MethodTestSettingsFactory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c4afb98466d734bc798e85328c41e688 3 | timeCreated: 1535021880 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Factories/NodeFactory.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0926d90dc8f594af683c465c1acf22a9 3 | timeCreated: 1535025079 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Helpers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b44f1a477a14a97a53fcb57b0bd3ab4 3 | timeCreated: 1553268387 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Helpers/CustomResolution.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace Tests 4 | { 5 | public class CustomResolution 6 | { 7 | public CustomResolution(int width, int height) 8 | { 9 | Width = width; 10 | Height = height; 11 | } 12 | 13 | [JsonProperty] 14 | public readonly int Width; 15 | [JsonProperty] 16 | public readonly int Height; 17 | } 18 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Helpers/CustomResolution.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc3620d7a4c2649e1a54a8c1732e6fb0 3 | timeCreated: 1535022245 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Helpers/MethodTestSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using Newtonsoft.Json; 6 | 7 | namespace Tests 8 | { 9 | public class MethodTestSettings 10 | { 11 | [JsonProperty] private string assemblySerialized; 12 | [JsonProperty] private string typeSerialized; 13 | [JsonProperty] private string methodName; 14 | 15 | private Type ownerType; 16 | private MethodInfo methodInfo; 17 | 18 | [JsonIgnore] 19 | public MethodInfo MethodInfo 20 | { 21 | get 22 | { 23 | if (methodInfo == null) 24 | { 25 | if (ownerType == null) 26 | { 27 | var assemblies = AppDomain.CurrentDomain.GetAssemblies(); 28 | var assembly = assemblies.FirstOrDefault(a => a.GetName().Name == assemblySerialized); 29 | if (assembly != null) 30 | { 31 | ownerType = assembly.GetType(typeSerialized); 32 | } 33 | } 34 | 35 | if (ownerType != null) 36 | { 37 | methodInfo = ownerType.GetMethod(methodName); 38 | } 39 | } 40 | 41 | return methodInfo; 42 | } 43 | set 44 | { 45 | ownerType = value.DeclaringType; 46 | typeSerialized = ownerType.FullName; 47 | assemblySerialized = ownerType.Assembly.GetName().Name; 48 | methodName = value.Name; 49 | methodInfo = value; 50 | } 51 | } 52 | 53 | public readonly float TimeOut = 400000; 54 | public readonly bool IsIgnored; 55 | public readonly string IgnoreReason; 56 | [JsonProperty] 57 | private List targetResolutions; 58 | [JsonProperty] 59 | public readonly CustomResolution EditorTargetResolution; 60 | public readonly bool IsSmoke; 61 | public readonly List TestRailURLs; 62 | 63 | 64 | [JsonConstructor] 65 | public MethodTestSettings( 66 | float timeOut, 67 | bool isIgnored, 68 | string ignoreReason, 69 | bool isSmoke, 70 | List testRailUrls, 71 | List targetResolutions, 72 | CustomResolution editorTargetResolution) 73 | { 74 | TestRailURLs = testRailUrls; 75 | TimeOut = timeOut; 76 | IsIgnored = isIgnored; 77 | IgnoreReason = ignoreReason; 78 | this.targetResolutions = targetResolutions; 79 | EditorTargetResolution = editorTargetResolution; 80 | IsSmoke = isSmoke; 81 | } 82 | 83 | public MethodTestSettings(MethodInfo methodInfo, 84 | float timeOut, 85 | bool isIgnored, 86 | string ignoreReason, 87 | bool isSmoke, 88 | List testRailUrl, 89 | List targetResolutions, 90 | CustomResolution editorTargetResolution) 91 | { 92 | TestRailURLs = testRailUrl; 93 | MethodInfo = methodInfo; 94 | TimeOut = timeOut; 95 | IsIgnored = isIgnored; 96 | IgnoreReason = ignoreReason; 97 | this.targetResolutions = targetResolutions; 98 | EditorTargetResolution = editorTargetResolution; 99 | IsSmoke = isSmoke; 100 | } 101 | 102 | public bool ContainsTargetResolution(int width, int height) 103 | { 104 | if (targetResolutions == null || targetResolutions.Count == 0) 105 | { 106 | return true; 107 | } 108 | 109 | return targetResolutions.FirstOrDefault(item => item.Width == width && item.Height == height) != null; 110 | } 111 | 112 | [JsonIgnore] 113 | public CustomResolution DefaultTargetResolution 114 | { 115 | get 116 | { 117 | if (targetResolutions == null || targetResolutions.Count == 0) 118 | { 119 | return new CustomResolution(800, 600); 120 | } 121 | return targetResolutions[0]; 122 | } 123 | } 124 | } 125 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Helpers/MethodTestSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 078db5053fb3943b28b0a4198182a590 3 | timeCreated: 1535021595 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Helpers/TestRailsData.cs: -------------------------------------------------------------------------------- 1 | namespace Tests 2 | { 3 | public struct TestRailsData 4 | { 5 | public string URL; 6 | public string Description; 7 | 8 | public TestRailsData(string url, string description) 9 | { 10 | URL = url; 11 | Description = description; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Helpers/TestRailsData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb9ef5f2760748b2bb1e26acdc0a415a 3 | timeCreated: 1562666960 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/MethodNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Tests.Nodes 6 | { 7 | public class MethodNode : Node 8 | { 9 | [JsonProperty] 10 | public int PassedAmount { get; private set; } 11 | [JsonProperty] 12 | public int IgnoredAmount { get; private set; } 13 | [JsonProperty] 14 | public int FailedAmount { get; private set; } 15 | 16 | public void ResetTestState() 17 | { 18 | PassedAmount = 0; 19 | IgnoredAmount = 0; 20 | FailedAmount = 0; 21 | UpdateParentTestState(); 22 | } 23 | 24 | public void SetTestState(TestState state) 25 | { 26 | switch (state) 27 | { 28 | case TestState.Passed: 29 | PassedAmount++; 30 | break; 31 | case TestState.Ignored: 32 | IgnoredAmount++; 33 | break; 34 | case TestState.Failed: 35 | FailedAmount++; 36 | break; 37 | } 38 | UpdateParentTestState(); 39 | } 40 | 41 | public List Logs = new List(); 42 | 43 | [JsonProperty] 44 | private int step; 45 | 46 | [JsonIgnore] 47 | public int Step 48 | { 49 | get { return step; } 50 | } 51 | 52 | public void SetStep(int step) 53 | { 54 | this.step = step; 55 | } 56 | 57 | [JsonProperty] 58 | private string methodFullName; 59 | [JsonProperty] 60 | private ClassNode parentClass; 61 | 62 | [JsonIgnore] 63 | public ClassNode ParentClass 64 | { 65 | get { return parentClass; } 66 | } 67 | 68 | [JsonProperty] 69 | private MethodTestSettings testSettings; 70 | 71 | [JsonIgnore] 72 | public MethodTestSettings TestSettings { get { return testSettings; } } 73 | 74 | [JsonIgnore] 75 | public override string FullName 76 | { 77 | get 78 | { 79 | return methodFullName; 80 | } 81 | } 82 | 83 | [JsonIgnore] 84 | public override TestState State 85 | { 86 | get 87 | { 88 | if (FailedAmount > 0) 89 | { 90 | return TestState.Failed; 91 | } 92 | 93 | if (IgnoredAmount > 0) 94 | { 95 | return TestState.Ignored; 96 | } 97 | 98 | if (PassedAmount > 0) 99 | { 100 | return TestState.Passed; 101 | } 102 | 103 | return TestState.Undefined; 104 | } 105 | } 106 | 107 | [JsonConstructor] 108 | private MethodNode() 109 | { 110 | } 111 | 112 | public MethodNode(MethodTestSettings testSettings, ClassNode parentNode) 113 | : base(testSettings.MethodInfo.Name, parentNode) 114 | { 115 | this.testSettings = testSettings; 116 | parentClass = parentNode; 117 | methodFullName = parentClass.FullName + "." + testSettings.MethodInfo.Name; 118 | } 119 | 120 | public override bool Contains(string pattern) 121 | { 122 | return Name.IndexOf(pattern, StringComparison.Ordinal) > -1; 123 | } 124 | 125 | protected override void SetDataFromNode(Node other) 126 | { 127 | base.SetDataFromNode(other); 128 | if (other is MethodNode) 129 | { 130 | var otherMethodNode = (MethodNode) other; 131 | step = otherMethodNode.Step; 132 | PassedAmount = otherMethodNode.PassedAmount; 133 | IgnoredAmount = otherMethodNode.IgnoredAmount; 134 | FailedAmount = otherMethodNode.FailedAmount; 135 | Logs = otherMethodNode.Logs; 136 | } 137 | } 138 | } 139 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/MethodNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9ef54e806a254d54b710409d1449d3a 3 | timeCreated: 1535021513 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/Nodes/Node.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 238a43bc8509d4249a907448eae371a4 3 | timeCreated: 1535013586 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PermittedErrors.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc488a268455240b1ae9d13fd2fe7ae0 3 | folderAsset: yes 4 | timeCreated: 1561378688 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PermittedErrors/PermittedError.cs: -------------------------------------------------------------------------------- 1 | namespace PlayQ.UITestTools 2 | { 3 | public class PermittedErrorInfo 4 | { 5 | public readonly string Message; 6 | public readonly bool IsRegExpMessage; 7 | public readonly string Stacktrace; 8 | 9 | public PermittedErrorInfo(string message, bool isRegExpMessage, string stacktrace) 10 | { 11 | Message = message; 12 | IsRegExpMessage = isRegExpMessage; 13 | Stacktrace = stacktrace; 14 | } 15 | 16 | public void Remove() 17 | { 18 | PermittedErrors.Remove(this); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PermittedErrors/PermittedError.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f51488343a1a457c8c3212fe49b46900 3 | timeCreated: 1561378746 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PermittedErrors/PermittedErrors.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text.RegularExpressions; 4 | 5 | namespace PlayQ.UITestTools 6 | { 7 | public static class PermittedErrors 8 | { 9 | private static readonly List errorsInfos = new List(); 10 | 11 | public static PermittedErrorInfo Add(string message, string stacktrace = "", bool regExp = false) 12 | { 13 | PermittedErrorInfo errorInfo = new PermittedErrorInfo(message, regExp, stacktrace); 14 | errorsInfos.Add(errorInfo); 15 | return errorInfo; 16 | } 17 | 18 | public static void ClearAll() 19 | { 20 | errorsInfos.Clear(); 21 | } 22 | 23 | public static void Remove(PermittedErrorInfo error) 24 | { 25 | errorsInfos.Remove(error); 26 | } 27 | 28 | private static bool IsPermittedError(List errorInfos, string message, string stacktrace) 29 | { 30 | foreach (var errorInfo in errorInfos) 31 | { 32 | var messageCheck = false; 33 | if (errorInfo.IsRegExpMessage) 34 | { 35 | var regexp = new Regex(errorInfo.Message); 36 | messageCheck = regexp.IsMatch(message); 37 | } 38 | else 39 | { 40 | messageCheck = message.IndexOf(errorInfo.Message, StringComparison.Ordinal) != -1; 41 | } 42 | 43 | var stacktraceCheck = true; 44 | if (string.IsNullOrEmpty(errorInfo.Stacktrace)) 45 | { 46 | stacktraceCheck = stacktrace.IndexOf(errorInfo.Stacktrace, StringComparison.Ordinal) != -1; 47 | } 48 | 49 | if (messageCheck && stacktraceCheck) 50 | { 51 | return true; 52 | } 53 | } 54 | 55 | return false; 56 | } 57 | 58 | public static bool IsPermittedError(string message, string stacktrace) 59 | { 60 | return IsPermittedError(errorsInfos, message, stacktrace); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PermittedErrors/PermittedErrors.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c99d15176221445380bbcd6354c108e4 3 | timeCreated: 1529064827 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlayModeLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | 6 | namespace PlayQ.UITestTools 7 | { 8 | /// 9 | /// https://confluence.jetbrains.com/display/TCD9/Build+Script+Interaction+with+TeamCity 10 | /// 11 | public class PlayModeLogger 12 | { 13 | public const string TC_DATE_FORMAT = "yyyy-MM-ddThh:mm:ss.fff"; 14 | public const string FILE_DATE_FORMAT = "yyyy-MM-ddThh.mm.ss.fff"; 15 | 16 | public List Logs = new List(); 17 | 18 | private const string DELIMETER = 19 | "==================================================================================="; 20 | 21 | public List LogsCopy { get { return new List(Logs); } } 22 | 23 | public void IgnoreLog(string methodName, string reason) 24 | { 25 | reason = reason.Replace("'", ""); 26 | HookToDebugLogs(); 27 | 28 | Debug.Log(DELIMETER); 29 | Debug.LogFormat("\"{0}\" ignored. Reason: {1}", methodName, reason); 30 | Debug.LogFormat("##teamcity[testIgnored timestamp='{0}' name='{1}' message='{2}']", 31 | DateTime.UtcNow.ToString(TC_DATE_FORMAT), methodName, reason); 32 | 33 | UnhookFromDebugLogs(); 34 | } 35 | 36 | public void StartLog(string methodName) 37 | { 38 | Logs.Clear(); 39 | HookToDebugLogs(); 40 | 41 | Debug.Log(DELIMETER); 42 | Debug.LogFormat("\"{0}\" setup", methodName); 43 | Debug.LogFormat("##teamcity[testStarted timestamp='{0}' name='{1}']", 44 | DateTime.UtcNow.ToString(TC_DATE_FORMAT), methodName); 45 | } 46 | 47 | private void HookToDebugLogs() 48 | { 49 | Application.logMessageReceived += CaptureLog; 50 | //Application.logMessageReceivedThreaded += CaptureLogThread; 51 | } 52 | 53 | private void UnhookFromDebugLogs() 54 | { 55 | Application.logMessageReceived -= CaptureLog; 56 | //Application.logMessageReceivedThreaded -= CaptureLogThread; 57 | } 58 | 59 | void CaptureLog(string condition, string stacktrace, LogType type) 60 | { 61 | string log; 62 | if (type == LogType.Log) 63 | { 64 | log = condition; 65 | } 66 | else 67 | { 68 | log = String.Format("{2}: {0}\n{1}", condition, stacktrace, type.ToString().ToUpper()); 69 | } 70 | 71 | Logs.Add(log); 72 | } 73 | 74 | void CaptureLogThread(string condition, string stacktrace, LogType type) 75 | { 76 | lock (Logs) 77 | { 78 | CaptureLog(condition, stacktrace, type); 79 | } 80 | } 81 | 82 | public void EndLog(string methodName) 83 | { 84 | Debug.LogFormat("##teamcity[testFinished timestamp='{0}' name='{1}']", 85 | DateTime.UtcNow.ToString(TC_DATE_FORMAT), methodName); 86 | Debug.LogFormat("\"{0}\" success", methodName); 87 | Debug.Log(DELIMETER); 88 | 89 | UnhookFromDebugLogs(); 90 | } 91 | 92 | public void FailLog(string methodName) 93 | { 94 | Debug.LogFormat("##teamcity[testFailed timestamp='{0}' name='{1}']", 95 | DateTime.UtcNow.ToString(TC_DATE_FORMAT), 96 | methodName); 97 | Debug.LogFormat("\"{0}\" fail", methodName); 98 | EndLog(methodName); 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlayModeLogger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6f1f215bf39474e9b908cf64afb0c4a 3 | timeCreated: 1513080989 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlayModeTestRunner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d181a40ff1060e1478e2f9668af2e17d 3 | timeCreated: 1559315304 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: -10 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlayModeTestRunnerGUI.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace PlayQ.UITestTools 5 | { 6 | public class PlayModeTestRunnerGUI 7 | { 8 | private string currentTest; 9 | 10 | private List failedTests = new List(); 11 | private Vector2 scrollState; 12 | 13 | public void SetCurrentTest(string text) 14 | { 15 | currentTest = "Current: \"" + text + "\""; 16 | } 17 | 18 | public void AddFailedTest(string failedTest) 19 | { 20 | failedTests.Add(failedTest); 21 | } 22 | 23 | public void Draw() 24 | { 25 | GUI.color = Color.black; 26 | GUILayout.BeginVertical(GUI.skin.box); 27 | scrollState = GUILayout.BeginScrollView(scrollState); 28 | 29 | if (currentTest != null) 30 | { 31 | GUI.color = Color.white; 32 | GUILayout.Label(currentTest); 33 | GUI.color = Color.black; 34 | } 35 | 36 | if (failedTests.Count > 0) 37 | { 38 | GUI.color = Color.white; 39 | GUILayout.Label("Failed: "); 40 | foreach (var test in failedTests) 41 | { 42 | GUILayout.Label(test); 43 | } 44 | GUI.color = Color.black; 45 | } 46 | GUILayout.EndScrollView(); 47 | GUILayout.EndVertical(); 48 | GUI.color = Color.white; 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlayModeTestRunnerGUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3c3e5e0c6b341fa91ff4d0c213cf797 3 | timeCreated: 1513161220 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05970d23590e46feab31847595d35256 3 | timeCreated: 1553512119 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/AddBaseClassWindow.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using Tests.Nodes; 6 | using UnityEditor; 7 | using UnityEngine; 8 | 9 | public class AddBaseClassWindow : EditorWindow 10 | { 11 | private List classes; 12 | private string[] filteredClasses; 13 | 14 | private void OnEnable() 15 | { 16 | titleContent.text = "Choose Base Class"; 17 | maxSize = new Vector2(250, 100); 18 | minSize = new Vector2(250, 100); 19 | 20 | classes = new List(); 21 | 22 | //we can cache it and reset after compilation 23 | var assemblies = NodeFactory.GetAllSuitableAssemblies(); 24 | foreach (var assembly in assemblies) 25 | { 26 | var typesInAssemblyList = assembly.GetTypes(); 27 | foreach (var type in typesInAssemblyList) 28 | { 29 | classes.Add(type.FullName); 30 | } 31 | } 32 | 33 | classes.Sort(); 34 | } 35 | 36 | void OnLostFocus() 37 | { 38 | Close(); 39 | } 40 | 41 | private int selectedIndex; 42 | public Action Result = s => { }; 43 | private string filer = String.Empty; 44 | 45 | private void OnGUI() 46 | { 47 | const int padding = 10; 48 | Rect content = new Rect(padding, padding, position.width - padding * 2, EditorGUIUtility.singleLineHeight); 49 | var isChanged = EditorUITools.UIHelper.SearchField(ref filer, content); 50 | 51 | content.y += EditorGUIUtility.singleLineHeight * 1.5f; 52 | 53 | if (isChanged || filteredClasses == null) 54 | { 55 | var filteredCollection = classes.Where(x => x.ToLower().Contains(filer.ToLower())); 56 | if (filteredCollection.Any()) 57 | { 58 | filteredClasses = filteredCollection.ToArray(); 59 | } 60 | else 61 | { 62 | filteredClasses = classes.ToArray(); 63 | } 64 | 65 | } 66 | selectedIndex = EditorGUI.Popup(content, selectedIndex, filteredClasses); 67 | 68 | content.y += EditorGUIUtility.singleLineHeight * 1.5f; 69 | if (GUI.Button(content, "Accept")) 70 | { 71 | Result(filteredClasses[selectedIndex]); 72 | Close(); 73 | } 74 | 75 | content.y += EditorGUIUtility.singleLineHeight * 1.2f; 76 | if (GUI.Button(content, "Cancel")) 77 | { 78 | Close(); 79 | } 80 | } 81 | } 82 | 83 | #endif -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/AddBaseClassWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 235346adca5884cc79f897b7305e967f 3 | timeCreated: 1559914786 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/EditorUITools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96ab922bc884e4653965b4d0454a67ca 3 | timeCreated: 1534847598 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/NodesView.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87decf7357d8a40da9ea8df8602868e4 3 | folderAsset: yes 4 | timeCreated: 1553168924 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/NodesView/BaseNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1acc878c46147e98f55897556a0bcbb 3 | timeCreated: 1553249018 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/NodesView/ClassNodeView.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using Tests.Nodes; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace PlayQ.UITestTools 7 | { 8 | public class RootView : BaseNodeView 9 | { 10 | private ClassNode classNode; 11 | public RootView(ClassNode node, SelectedNode selectedNode) 12 | : base(node, selectedNode) 13 | { 14 | classNode = node; 15 | } 16 | 17 | public override bool Draw() 18 | { 19 | bool isDirty = false; 20 | EditorGUILayout.BeginVertical(); 21 | 22 | foreach (var childNode in classNode.Children) 23 | { 24 | isDirty |= childNode.View.Draw(); 25 | } 26 | 27 | EditorGUILayout.EndVertical(); 28 | 29 | return isDirty; 30 | } 31 | } 32 | public class ClassNodeView : BaseNodeView 33 | { 34 | private const int CLASS_MARGIN = 3; 35 | private const int PARENT_MARGIN = 1; 36 | 37 | private GUIStyle offsetStyle; 38 | private ClassNode classNode; 39 | private PlayModeTestRunner.PlayingMethodNode currentPlayingTest; 40 | 41 | private void OpenSource() 42 | { 43 | if (!string.IsNullOrEmpty(classNode.FilePath)) 44 | { 45 | var asset = AssetDatabase.LoadAssetAtPath 46 | (classNode.FilePath); 47 | if (asset != null) 48 | { 49 | AssetDatabase.OpenAsset(asset); 50 | } 51 | } 52 | } 53 | 54 | private void RunClass() 55 | { 56 | foreach (var method in classNode.GetChildrenOfType()) 57 | { 58 | method.ResetTestState(); 59 | } 60 | 61 | PlayModeTestRunner.RunTestByDoubleClick( 62 | PlayModeTestRunner.SpecificTestType.Class, 63 | classNode); 64 | } 65 | 66 | private bool drawContextMenu; 67 | private void PreDraw() 68 | { 69 | if (drawContextMenu) 70 | { 71 | drawContextMenu = false; 72 | GenericMenu menu = new GenericMenu(); 73 | menu.AddItem(new GUIContent("Run"), false, RunClass); 74 | menu.AddItem(new GUIContent("Open source"), false, OpenSource); 75 | menu.AddItem(new GUIContent("Copy Name"), false, CopyName); 76 | menu.ShowAsContext(); 77 | } 78 | } 79 | 80 | public override bool Draw() 81 | { 82 | PreDraw(); 83 | 84 | if (classNode.IsHided) 85 | { 86 | return false; 87 | } 88 | 89 | GUILayout.Space(CLASS_MARGIN); 90 | 91 | Rect rect = EditorGUILayout.BeginHorizontal(); 92 | 93 | if (!IsNodeOpened && currentPlayingTest.Node != null && 94 | currentPlayingTest.Node.IsChildOf(classNode)) 95 | { 96 | DrawCurrentTestBackground(rect); 97 | } 98 | else 99 | { 100 | DrawBackgroundIfSelected(rect); 101 | } 102 | 103 | 104 | var isOpenedOld = IsNodeOpened; 105 | var isOpenedNew = DrawFoldout(); 106 | if (IsOpenFiltered.HasValue) 107 | { 108 | IsOpenFiltered = isOpenedNew; 109 | } 110 | else 111 | { 112 | classNode.SetOpened(isOpenedNew); 113 | } 114 | 115 | HandleKeyboardEvent(RunClass); 116 | 117 | var prevSelection = classNode.IsSelected; 118 | 119 | DrawTestLine(rect, 120 | () => { selectedNode.UpdateSelectedNode(classNode); }, 121 | () => 122 | { 123 | foreach (var method in classNode.GetChildrenOfType()) 124 | { 125 | method.ResetTestState(); 126 | } 127 | 128 | PlayModeTestRunner.RunTestByDoubleClick( 129 | PlayModeTestRunner.SpecificTestType.Class, 130 | classNode); 131 | }, 132 | () => 133 | { 134 | selectedNode.UpdateSelectedNode(classNode); 135 | drawContextMenu = true; 136 | }, 137 | string.Empty); 138 | 139 | var isDirty = IsNodeOpened != isOpenedOld; 140 | isDirty |= prevSelection != classNode.IsSelected; 141 | 142 | 143 | GUILayout.FlexibleSpace(); 144 | EditorGUILayout.EndHorizontal(); 145 | 146 | if (IsNodeOpened) 147 | { 148 | GUILayout.Space(PARENT_MARGIN); 149 | EditorGUILayout.BeginVertical(offsetStyle); 150 | 151 | foreach (var childNode in classNode.Children) 152 | { 153 | isDirty |= childNode.View.Draw(); 154 | } 155 | 156 | 157 | EditorGUILayout.EndVertical(); 158 | } 159 | return isDirty; 160 | } 161 | 162 | public ClassNodeView(ClassNode node, SelectedNode selectedNode, 163 | PlayModeTestRunner.PlayingMethodNode currentPlayingTest) 164 | : base(node, selectedNode) 165 | { 166 | this.currentPlayingTest = currentPlayingTest; 167 | classNode = node; 168 | offsetStyle = new GUIStyle {margin = {left = 14, right = 0}}; 169 | } 170 | } 171 | 172 | } 173 | #endif -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/NodesView/ClassNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d757841158e54a4f89b237e52a35c69a 3 | timeCreated: 1553521135 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/NodesView/MethodNodeView.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using Tests.Nodes; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace PlayQ.UITestTools 7 | { 8 | public class MethodNodeView : BaseNodeView 9 | { 10 | private MethodNode methodNode; 11 | private PlayModeTestRunner.PlayingMethodNode currentPlayingTest; 12 | 13 | private void OpenSource() 14 | { 15 | if (!string.IsNullOrEmpty(methodNode.ParentClass.FilePath)) 16 | { 17 | var asset = AssetDatabase.LoadAssetAtPath 18 | (methodNode.ParentClass.FilePath); 19 | int lineCount = 1; 20 | 21 | if (asset != null) 22 | { 23 | var content = asset.text; 24 | 25 | var index = content.IndexOf("IEnumerator " + methodNode.Name); 26 | for (int i = 0; i <= index; i++) 27 | { 28 | if (content[i] == '\n') 29 | { 30 | lineCount++; 31 | } 32 | } 33 | 34 | AssetDatabase.OpenAsset(asset, lineCount); 35 | } 36 | } 37 | } 38 | 39 | private bool drawContextMenu; 40 | private void PreDraw() 41 | { 42 | if (drawContextMenu) 43 | { 44 | drawContextMenu = false; 45 | GenericMenu menu = new GenericMenu(); 46 | if (methodNode.TestSettings.TestRailURLs != null) 47 | { 48 | foreach (var testRail in methodNode.TestSettings.TestRailURLs) 49 | { 50 | menu.AddItem(new GUIContent("Open TestRail " + testRail.Description), false, 51 | () => { Application.OpenURL(testRail.URL); }); 52 | } 53 | } 54 | 55 | menu.AddItem(new GUIContent("Run"), false, RunTest); 56 | menu.AddItem(new GUIContent("Open Source"), false, OpenSource); 57 | menu.AddItem(new GUIContent("Copy Name"), false, CopyName); 58 | menu.ShowAsContext(); 59 | } 60 | } 61 | 62 | public override bool Draw() 63 | { 64 | PreDraw(); 65 | 66 | if (methodNode.IsHided) 67 | { 68 | return false; 69 | } 70 | 71 | GUILayout.Space(METHOD_MARGIN); 72 | 73 | Rect rect = EditorGUILayout.BeginHorizontal(); 74 | 75 | 76 | if (currentPlayingTest.Node == methodNode) 77 | { 78 | DrawCurrentTestBackground(rect); 79 | } 80 | else 81 | { 82 | DrawBackgroundIfSelected(rect); 83 | } 84 | 85 | GUILayout.Space(20); 86 | 87 | 88 | HandleKeyboardEvent(RunTest); 89 | 90 | var prevSelection = methodNode.IsSelected; 91 | 92 | DrawTestLine(rect, 93 | () => 94 | { 95 | selectedNode.UpdateSelectedNode(methodNode); 96 | }, 97 | () => 98 | { 99 | methodNode.ResetTestState(); 100 | PlayModeTestRunner.RunTestByDoubleClick( 101 | PlayModeTestRunner.SpecificTestType.Method, 102 | methodNode); 103 | }, 104 | () => 105 | { 106 | selectedNode.UpdateSelectedNode(methodNode); 107 | drawContextMenu = true; 108 | }, 109 | NamePostfix()); 110 | 111 | bool isDirty = prevSelection != methodNode.IsSelected; 112 | 113 | EditorGUILayout.EndHorizontal(); 114 | 115 | return isDirty; 116 | } 117 | 118 | private void RunTest() 119 | { 120 | methodNode.ResetTestState(); 121 | PlayModeTestRunner.RunTestByDoubleClick( 122 | PlayModeTestRunner.SpecificTestType.Method, 123 | methodNode); 124 | } 125 | 126 | private string NamePostfix() 127 | { 128 | string namePostfix = ""; 129 | if (methodNode.PassedAmount > 1 && 130 | methodNode.FailedAmount == 0) 131 | { 132 | namePostfix = " [Passed: " + methodNode.PassedAmount + "]"; 133 | } 134 | else if (methodNode.PassedAmount == 0 && 135 | methodNode.FailedAmount > 1) 136 | { 137 | namePostfix = " [Failed: " + methodNode.FailedAmount + "]"; 138 | } 139 | else if (methodNode.PassedAmount + 140 | methodNode.FailedAmount > 1) 141 | { 142 | namePostfix = " [Passed: " + methodNode.PassedAmount + " Failed: " + 143 | methodNode.FailedAmount + "]"; 144 | } 145 | 146 | return namePostfix; 147 | } 148 | 149 | protected override bool IsNodeOpened 150 | { 151 | get { return true; } 152 | } 153 | 154 | public MethodNodeView(MethodNode node, SelectedNode selectedNode, 155 | PlayModeTestRunner.PlayingMethodNode currentPlayingTest) : base(node, selectedNode) 156 | { 157 | methodNode = node; 158 | this.currentPlayingTest = currentPlayingTest; 159 | } 160 | } 161 | 162 | } 163 | #endif -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/NodesView/MethodNodeView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b001cfeceac62464fab9dae8e9885300 3 | timeCreated: 1553168924 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/RuntimeTestRunnerWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14995025cd47481caee40cef28161247 3 | timeCreated: 1513093679 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/ScriptCompilationWaiter.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using PlayQ.UITestTools; 3 | 4 | namespace UnityEditor 5 | { 6 | public static class ScriptCompilationChecker 7 | { 8 | #if UNITY_EDITOR 9 | [Callbacks.DidReloadScripts] 10 | private static void OnScriptsReloaded() 11 | { 12 | if (EditorApplication.isPlaying && GameObject.FindObjectOfType() != null) 13 | { 14 | Debug.LogError("===============================" + 15 | "Compilation is started during Playmode. Tests will be restarted" + 16 | "==============================="); 17 | EditorApplication.update += Update; 18 | } 19 | } 20 | 21 | private static void Update() 22 | { 23 | if (EditorApplication.isPlaying) 24 | { 25 | EditorApplication.isPlaying = false; 26 | return; 27 | } 28 | else 29 | { 30 | EditorApplication.update -= Update; 31 | EditorApplication.isPlaying = true; 32 | } 33 | } 34 | #endif 35 | } 36 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/ScriptCompilationWaiter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 192219e8d68cb4683af9548b4a53f947 3 | timeCreated: 1534880410 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/SelectedNode.cs: -------------------------------------------------------------------------------- 1 | using Tests.Nodes; 2 | 3 | public class SelectedNode 4 | { 5 | public SelectedNode(Node node) 6 | { 7 | this.node = node; 8 | } 9 | private Node node; 10 | public Node Node 11 | { 12 | get 13 | { 14 | return node; 15 | } 16 | } 17 | 18 | public void UpdateSelectedNode(Node node) 19 | { 20 | this.node = node; 21 | } 22 | 23 | public bool IsGivenNodeSelected(Node node) 24 | { 25 | return this.node == node; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/SelectedNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b14b97887ae745ddbb998126ec37e2a 3 | timeCreated: 1535533863 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/TestToolBuildScript.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using System; 3 | using System.Globalization; 4 | using System.IO; 5 | using System.Linq; 6 | using JetBrains.Annotations; 7 | using PlayQ.UITestTools; 8 | using UnityEditor; 9 | using UnityEditor.Callbacks; 10 | using UnityEngine; 11 | using Debug = UnityEngine.Debug; 12 | 13 | public class TestToolBuildScript 14 | { 15 | private static void PrepareBuild() 16 | { 17 | AddTestSceneToBuild(); 18 | ResolveTestMode(); 19 | AddScreenshotsToBuild(); 20 | } 21 | 22 | //For executing from command line 23 | [UsedImplicitly] 24 | private static void TestBuild() 25 | { 26 | SetTimeScaleFromCommandLineArgument(); 27 | PrepareBuild(); 28 | 29 | string[] list = EditorBuildSettings.scenes.Where(x => x.enabled).Select(x => x.path).ToArray(); 30 | BuildPipeline.BuildPlayer(list, 31 | ConsoleArgumentHelper.GetArg("-testBuildPath"), BuildTarget.Android, 32 | BuildOptions.None); 33 | } 34 | 35 | //for executing from command line 36 | [UsedImplicitly] 37 | public static void RunPlayModeTests() 38 | { 39 | SetTimeScaleFromCommandLineArgument(); 40 | SetTestsNamespacesFromCommandLineArgument(); 41 | 42 | PlayerPrefs.SetString("PackageUpdaterLastChecked68207", DateTime.Now.ToString(CultureInfo.InvariantCulture)); 43 | 44 | PlayModeTestRunner.QuitAppAfterCompleteTests = true; 45 | ResolveTestMode(); 46 | PlayModeTestRunner.Run(); 47 | } 48 | 49 | [UsedImplicitly] 50 | public static void RunPlayModeTests(bool runOnlySelected, bool runOnlySmoke, 51 | float timeScale = 1, string[] namespaces = null, bool quitAppAfterCompleteTests = false) 52 | { 53 | PlayModeTestRunner.DefaultTimescale = timeScale; 54 | PlayModeTestRunner.Namespaces = namespaces; 55 | PlayerPrefs.SetString("PackageUpdaterLastChecked68207", DateTime.Now.ToString(CultureInfo.InvariantCulture)); 56 | PlayModeTestRunner.QuitAppAfterCompleteTests = quitAppAfterCompleteTests; 57 | ResolveTestMode(runOnlySelected, runOnlySmoke); 58 | PlayModeTestRunner.Run(); 59 | } 60 | 61 | private static void SetTestsNamespacesFromCommandLineArgument() 62 | { 63 | string namespaceString = ConsoleArgumentHelper.GetArg("-testNamespaces"); 64 | 65 | int timeScale = 0; 66 | if (!string.IsNullOrEmpty(namespaceString)) 67 | { 68 | namespaceString = namespaceString.Replace(" ", String.Empty); 69 | string[] strings = namespaceString.Split(';'); 70 | 71 | if (strings.Length > 0) 72 | { 73 | PlayModeTestRunner.Namespaces = strings.Where(s => !string.IsNullOrEmpty(s)).ToArray(); 74 | if (PlayModeTestRunner.Namespaces.Length > 0) 75 | { 76 | Debug.LogFormat("TestTools: namespace string {0} Test Namespaces count: {1}", 77 | namespaceString, 78 | PlayModeTestRunner.Namespaces.Length); 79 | 80 | foreach (var name in PlayModeTestRunner.Namespaces) 81 | { 82 | Debug.Log("namespace: " + name); 83 | } 84 | return; 85 | } 86 | } 87 | } 88 | 89 | Debug.Log("TestTools: No Test Namespaces:"); 90 | PlayModeTestRunner.Namespaces = null; 91 | } 92 | 93 | private static void SetTimeScaleFromCommandLineArgument() 94 | { 95 | string timeScaleString = ConsoleArgumentHelper.GetArg("-timeScale"); 96 | 97 | int timeScale = 0; 98 | if (timeScaleString != null) 99 | { 100 | int.TryParse(timeScaleString, out timeScale); 101 | } 102 | if (timeScale <= 0) 103 | { 104 | timeScale = 1; 105 | } 106 | PlayModeTestRunner.DefaultTimescale = timeScale; 107 | } 108 | 109 | private static void AddTestSceneToBuild() 110 | { 111 | string scenePath = PlayModeTestRunner.GetTestScenePath(); 112 | if (string.IsNullOrEmpty(scenePath)) 113 | { 114 | Debug.LogError("Cant find test scene"); 115 | return; 116 | } 117 | 118 | var scenes = EditorBuildSettings.scenes.ToList(); 119 | var allScenes = scenes.Aggregate("", (concated, scene) => scene.path + "; " + concated); 120 | 121 | Debug.Log("----------- test scene path: " + scenePath + 122 | " all scenes amount: " + scenes.Count + 123 | " all scene names " + allScenes); 124 | 125 | if (scenes.Count == 0 || scenes[0].path != scenePath || scenes[0].enabled == false) 126 | { 127 | if (scenes.Count > 0) 128 | { 129 | Debug.Log("----------- scenes[0].path: " + scenes[0].path + 130 | " scenes[0].enabled: " + scenes[0].enabled); 131 | } 132 | var index = scenes.FindIndex(s => s.path.Contains(PlayModeTestRunner.TEST_NAME_SCENE)); 133 | if (index != -1) 134 | { 135 | scenes.RemoveAt(index); 136 | } 137 | Debug.Log("----------- test scene index " + index); 138 | 139 | scenes.Insert(0, new EditorBuildSettingsScene(scenePath, true)); 140 | EditorBuildSettings.scenes = scenes.ToArray(); 141 | 142 | Debug.Log("------- EditorBuildSettings.scenes " 143 | + EditorBuildSettings.scenes.Aggregate("", (concated, scene) => scene.path + "; " + concated)); 144 | } 145 | } 146 | 147 | private static void ResolveTestMode() 148 | { 149 | bool runOnlySelected = ConsoleArgumentHelper.IsArgExist("-runOnlySelectedTests"); 150 | bool runOnlySmoke = ConsoleArgumentHelper.IsArgExist("-runOnlySmokeTests"); 151 | 152 | ResolveTestMode(runOnlySelected, runOnlySmoke); 153 | } 154 | 155 | private static void ResolveTestMode(bool runOnlySelected, bool runOnlySmoke) 156 | { 157 | if (runOnlySelected && runOnlySmoke) 158 | { 159 | Debug.LogError("You trying to launck selected and smoke tests together."); 160 | } 161 | if (runOnlySelected) 162 | { 163 | RunTestsMode.SelectOnlySelectedTests(); 164 | } 165 | else 166 | { 167 | if (runOnlySmoke) 168 | { 169 | RunTestsMode.SelectOnlySmokeTests(); 170 | } 171 | else 172 | { 173 | RunTestsMode.SelectAllTests(); 174 | } 175 | } 176 | } 177 | 178 | private static void MoveContentFromFolderToFolder(string folderSrc, string folderDst) 179 | { 180 | if (!Directory.Exists(folderSrc) || 181 | !Directory.Exists(folderDst)) 182 | { 183 | return; 184 | } 185 | 186 | var buildFiles = Directory.GetFiles(folderDst); 187 | foreach (var file in buildFiles) 188 | { 189 | File.Delete(file); 190 | } 191 | 192 | var buildFolders = Directory.GetDirectories(folderDst); 193 | foreach (var folder in buildFolders) 194 | { 195 | Directory.Delete(folder, true); 196 | } 197 | 198 | var editorFiles = Directory.GetFiles(folderSrc); 199 | foreach (var file in editorFiles) 200 | { 201 | var fileToMove = new FileInfo(file); 202 | File.Move(file,folderDst + '/' + fileToMove.Name); 203 | } 204 | var editorFolders = Directory.GetDirectories(folderSrc); 205 | foreach (var folder in editorFolders) 206 | { 207 | var folderToMove = new DirectoryInfo(folder); 208 | Directory.Move(folder,folderDst + '/' + folderToMove.Name); 209 | } 210 | } 211 | 212 | private static void AddScreenshotsToBuild() 213 | { 214 | MoveContentFromFolderToFolder(SelectedTestsSerializable.EditorResourceDirectory, 215 | SelectedTestsSerializable.BuildResourceDirectory); 216 | } 217 | 218 | [PostProcessBuild(1)] 219 | public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) 220 | { 221 | Debug.Log("OnPostprocessBuild: move Reference Screensots from Resources back to editor folder."); 222 | MoveContentFromFolderToFolder(SelectedTestsSerializable.BuildResourceDirectory, 223 | SelectedTestsSerializable.EditorResourceDirectory); 224 | } 225 | 226 | [MenuItem("Window/UI Test Tools/Prepare For Device Build")] 227 | public static void MenuPreBuild() 228 | { 229 | AddTestSceneToBuild(); 230 | AddScreenshotsToBuild(); 231 | } 232 | [MenuItem("Window/UI Test Tools/Move build resources back to editor resources")] 233 | public static void MenuPostBuild() 234 | { 235 | MoveContentFromFolderToFolder(SelectedTestsSerializable.BuildResourceDirectory, 236 | SelectedTestsSerializable.EditorResourceDirectory); 237 | } 238 | } 239 | #endif -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/TestToolBuildScript.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4eca8a9acc7dd1044b15b824a81da518 3 | timeCreated: 1516807282 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/UITestToolWindowFooter.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace PlayQ.UITestTools 6 | { 7 | public class UITestToolWindowFooter 8 | { 9 | public const int HEIGHT = 22; 10 | private void DrawStatusBar(Rect position, Color color, string labelText) 11 | { 12 | Rect window = position; 13 | 14 | const int panelHeight = 45; 15 | 16 | Rect panel = window; 17 | 18 | panel.y = panel.height - panelHeight; 19 | 20 | panel.height = panelHeight; 21 | 22 | panel.x = 0; 23 | 24 | const int labelHeight = 20; 25 | 26 | window = new Rect(0, panel.y + labelHeight, panel.width, labelHeight); 27 | 28 | const int statusBarOffset = 2; 29 | 30 | Rect statusBarRect = new Rect(statusBarOffset, window.y, window.width - 2 * statusBarOffset, HEIGHT); 31 | 32 | GUI.backgroundColor = color; 33 | 34 | GUI.Box(statusBarRect, "", EditorStyles.helpBox); 35 | 36 | GUI.Label(new Rect(0, statusBarRect.y + 3, statusBarRect.width - 5, 15), 37 | UITestToolsVersionInfo.StringVersion, 38 | new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleRight }); 39 | 40 | GUI.Label(new Rect(5, statusBarRect.y + 3, statusBarRect.width, 15), 41 | labelText, 42 | new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleLeft }); 43 | 44 | GUI.backgroundColor = Color.white; 45 | } 46 | 47 | public void Draw(Rect position, bool isDirty = false) 48 | { 49 | string label; 50 | Color color; 51 | if (isDirty) 52 | { 53 | color = Color.red; 54 | #if UNITY_EDITOR_OSX 55 | label = "Press Cmd+S to serialize the asset to disk"; 56 | #else 57 | label = "Press Ctrl+S to serialize the asset to disk"; 58 | #endif 59 | } 60 | else 61 | { 62 | color = Color.white; 63 | label = "Status OK."; 64 | } 65 | DrawStatusBar(position, color, label); 66 | } 67 | 68 | } 69 | } 70 | #endif -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/PlaymodeTestRunnerView/UITestToolWindowFooter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e4c4795e78c4bb49f2c6b0e25dd6a62 3 | timeCreated: 1535791389 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/RunTestsMode.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Tests.Nodes; 3 | using UnityEditor; 4 | 5 | namespace PlayQ.UITestTools 6 | { 7 | public static class RunTestsMode 8 | { 9 | public enum RunTestsModeEnum 10 | { 11 | All, 12 | Smoke, 13 | DoubleClick, 14 | Selected 15 | } 16 | 17 | public static void SelectOnlySmokeTests() 18 | { 19 | Mode = RunTestsModeEnum.Smoke; 20 | } 21 | 22 | public static RunTestsModeEnum Mode 23 | { 24 | get 25 | { 26 | return PlayModeTestRunner.SerializedTests.TestRunMode; 27 | } 28 | private set 29 | { 30 | PlayModeTestRunner.SerializedTests.TestRunMode = value; 31 | } 32 | } 33 | 34 | public static void SelectOnlySelectedTests() 35 | { 36 | Mode = RunTestsModeEnum.Selected; 37 | } 38 | 39 | public static int RunTestsGivenAmountOfTimes 40 | { 41 | get 42 | { 43 | return PlayModeTestRunner.SerializedTests.RepeatTestsNTimes < 1 ? 44 | 1 : PlayModeTestRunner.SerializedTests.RepeatTestsNTimes; 45 | } 46 | set 47 | { 48 | PlayModeTestRunner.SerializedTests.RepeatTestsNTimes = value < 1 ? 1 : value; 49 | } 50 | } 51 | 52 | public static string SpecificTestOrClassName 53 | { 54 | get 55 | { 56 | return PlayModeTestRunner.SerializedTests.SpecificTestOrClassName; 57 | } 58 | private set 59 | { 60 | PlayModeTestRunner.SerializedTests.SpecificTestOrClassName = value; 61 | } 62 | } 63 | 64 | public static PlayModeTestRunner.SpecificTestType RunSpecificTestType 65 | { 66 | get 67 | { 68 | return PlayModeTestRunner.SerializedTests.RunSpecificTestType; 69 | } 70 | private set 71 | { 72 | PlayModeTestRunner.SerializedTests.RunSpecificTestType = value; 73 | } 74 | } 75 | 76 | public static string NodeToRunFullName 77 | { 78 | get 79 | { 80 | return PlayModeTestRunner.SerializedTests.SelectedNodeFullName; 81 | } 82 | } 83 | 84 | public static void RunTestByDoubleClick(PlayModeTestRunner.SpecificTestType type, 85 | Node node) 86 | { 87 | RunSpecificTestType = type; 88 | PlayModeTestRunner.SerializedTests.SelectedNodeFullName = node.FullName; 89 | Mode = RunTestsModeEnum.DoubleClick; 90 | } 91 | 92 | public static void SelectAllTests() 93 | { 94 | Mode = RunTestsModeEnum.All; 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/RunTestsMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df780f57c3c045859431c87ca99bad05 3 | timeCreated: 1531814555 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/RuntimeTestScene.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 8 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0.37311926, g: 0.38073996, b: 0.35872698, a: 1} 42 | --- !u!157 &3 43 | LightmapSettings: 44 | m_ObjectHideFlags: 0 45 | serializedVersion: 9 46 | m_GIWorkflowMode: 1 47 | m_GISettings: 48 | serializedVersion: 2 49 | m_BounceScale: 1 50 | m_IndirectOutputScale: 1 51 | m_AlbedoBoost: 1 52 | m_TemporalCoherenceThreshold: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 1 56 | m_LightmapEditorSettings: 57 | serializedVersion: 8 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_TextureWidth: 1024 61 | m_TextureHeight: 1024 62 | m_AO: 0 63 | m_AOMaxDistance: 1 64 | m_CompAOExponent: 1 65 | m_CompAOExponentDirect: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 3 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVRFiltering: 0 81 | m_PVRFilteringMode: 1 82 | m_PVRCulling: 1 83 | m_PVRFilteringGaussRadiusDirect: 1 84 | m_PVRFilteringGaussRadiusIndirect: 5 85 | m_PVRFilteringGaussRadiusAO: 2 86 | m_PVRFilteringAtrousColorSigma: 1 87 | m_PVRFilteringAtrousNormalSigma: 1 88 | m_PVRFilteringAtrousPositionSigma: 1 89 | m_LightingDataAsset: {fileID: 0} 90 | m_ShadowMaskMode: 2 91 | --- !u!196 &4 92 | NavMeshSettings: 93 | serializedVersion: 2 94 | m_ObjectHideFlags: 0 95 | m_BuildSettings: 96 | serializedVersion: 2 97 | agentTypeID: 0 98 | agentRadius: 0.5 99 | agentHeight: 2 100 | agentSlope: 45 101 | agentClimb: 0.4 102 | ledgeDropHeight: 0 103 | maxJumpAcrossDistance: 0 104 | minRegionArea: 2 105 | manualCellSize: 0 106 | cellSize: 0.16666667 107 | manualTileSize: 0 108 | tileSize: 256 109 | accuratePlacement: 0 110 | m_NavMeshData: {fileID: 0} 111 | --- !u!1 &20995222 112 | GameObject: 113 | m_ObjectHideFlags: 0 114 | m_PrefabParentObject: {fileID: 0} 115 | m_PrefabInternal: {fileID: 0} 116 | serializedVersion: 5 117 | m_Component: 118 | - component: {fileID: 20995224} 119 | - component: {fileID: 20995223} 120 | m_Layer: 0 121 | m_Name: TestRunner 122 | m_TagString: Untagged 123 | m_Icon: {fileID: 0} 124 | m_NavMeshLayer: 0 125 | m_StaticEditorFlags: 0 126 | m_IsActive: 1 127 | --- !u!114 &20995223 128 | MonoBehaviour: 129 | m_ObjectHideFlags: 0 130 | m_PrefabParentObject: {fileID: 0} 131 | m_PrefabInternal: {fileID: 0} 132 | m_GameObject: {fileID: 20995222} 133 | m_Enabled: 1 134 | m_EditorHideFlags: 0 135 | m_Script: {fileID: 11500000, guid: d181a40ff1060e1478e2f9668af2e17d, type: 3} 136 | m_Name: 137 | m_EditorClassIdentifier: 138 | --- !u!4 &20995224 139 | Transform: 140 | m_ObjectHideFlags: 0 141 | m_PrefabParentObject: {fileID: 0} 142 | m_PrefabInternal: {fileID: 0} 143 | m_GameObject: {fileID: 20995222} 144 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 145 | m_LocalPosition: {x: 0, y: 0, z: 0} 146 | m_LocalScale: {x: 1, y: 1, z: 1} 147 | m_Children: [] 148 | m_Father: {fileID: 0} 149 | m_RootOrder: 0 150 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 151 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/RuntimeTestScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90c67eb9e366bff4ba6c35f786521cf8 3 | timeCreated: 1513078641 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/SelectedTestsSerializable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using PlayQ.UITestTools; 4 | using UnityEngine; 5 | using System.IO; 6 | #if UNITY_EDITOR 7 | using UnityEditor; 8 | #endif 9 | 10 | public class SelectedTestsSerializable : ScriptableObject 11 | { 12 | #if UNITY_EDITOR 13 | private static string editorResourceDirectory; 14 | public static string EditorResourceDirectory 15 | { 16 | get 17 | { 18 | if (string.IsNullOrEmpty(editorResourceDirectory)) 19 | { 20 | string path = FindPath("PlayModeTestRunner", Application.dataPath); 21 | if (!string.IsNullOrEmpty(path)) 22 | { 23 | path = "Assets" + path.Substring(Application.dataPath.Length); 24 | path += "/Editor/Resources"; 25 | editorResourceDirectory = path; 26 | 27 | if (!Directory.Exists(editorResourceDirectory)) 28 | { 29 | Directory.CreateDirectory(editorResourceDirectory); 30 | } 31 | } 32 | else 33 | { 34 | throw new Exception("SelectedTestsSerializable: UNABLE TO FIND FOLDER NAMED \"PlayModeTestRunner\""); 35 | } 36 | } 37 | 38 | return editorResourceDirectory; 39 | } 40 | } 41 | private static string buildResourceDirectory; 42 | public static string BuildResourceDirectory 43 | { 44 | get 45 | { 46 | if (string.IsNullOrEmpty(buildResourceDirectory)) 47 | { 48 | string path = FindPath("PlayModeTestRunner", Application.dataPath); 49 | if (!string.IsNullOrEmpty(path)) 50 | { 51 | path = "Assets" + path.Substring(Application.dataPath.Length); 52 | path += "/Resources"; 53 | buildResourceDirectory = path; 54 | if (!Directory.Exists(buildResourceDirectory)) 55 | { 56 | Directory.CreateDirectory(buildResourceDirectory); 57 | } 58 | } 59 | else 60 | { 61 | throw new Exception("SelectedTestsSerializable: UNABLE TO FIND FOLDER NAMED \"PlayModeTestRunner\""); 62 | } 63 | } 64 | 65 | return buildResourceDirectory; 66 | } 67 | } 68 | #endif 69 | 70 | public RunTestsMode.RunTestsModeEnum TestRunMode; 71 | public PlayModeTestRunner.SpecificTestType RunSpecificTestType; 72 | public int RepeatTestsNTimes; 73 | public string SpecificTestOrClassName; 74 | public bool QuitAferComplete; 75 | public float DefaultTimescale = 1; 76 | public string SerializedTestsData; 77 | public string SelectedNodeFullName; 78 | public string[] Namespaces; 79 | public bool ForceMakeReferenceScreenshot; 80 | public List BaseTypes = new List(); 81 | public bool UpdateTestsOnEveryCompilation = true; 82 | 83 | 84 | #if UNITY_EDITOR 85 | public static SelectedTestsSerializable CreateOrLoad() 86 | { 87 | var asset = Resources.Load("SelectedTests"); 88 | 89 | if (!asset) 90 | { 91 | asset = CreateInstance(); 92 | var path = EditorResourceDirectory + '/' + "SelectedTests.asset"; 93 | 94 | AssetDatabase.CreateAsset(asset, path); 95 | AssetDatabase.SaveAssets(); 96 | } 97 | 98 | return asset; 99 | } 100 | 101 | //Breadth-first search 102 | public static string FindPath(string targetDirectory, string directoryPath) 103 | { 104 | var directories = Directory.GetDirectories(directoryPath, targetDirectory, SearchOption.AllDirectories); 105 | return directories.Length == 0 ? null : directories[0]; 106 | } 107 | #endif 108 | 109 | 110 | public static SelectedTestsSerializable Load() 111 | { 112 | return Resources.Load("SelectedTests"); 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/SelectedTestsSerializable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 825c94a0152363f46a14ee91221566d3 3 | timeCreated: 1516637109 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/SmokeTestAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PlayQ.UITestTools 4 | { 5 | public class SmokeTestAttribute : Attribute 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/SmokeTestAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b753543f98fc44a4ea66d70bede48047 3 | timeCreated: 1513680945 4 | -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/TargetResolutionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PlayQ.UITestTools 4 | { 5 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] 6 | public class TargetResolutionAttribute : Attribute 7 | { 8 | public readonly int Width; 9 | public readonly int Height; 10 | 11 | public TargetResolutionAttribute(int width, int height) 12 | { 13 | Width = width; 14 | Height = height; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/TargetResolutionAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb8a8a1a47394aba8e0f3fedacd5c62f 3 | timeCreated: 1513680945 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/TestCoroutiner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db1fcc7bb51e41b2afe62b6557dd1758 3 | timeCreated: 1534865576 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/TestRailAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PlayQ.UITestTools 4 | { 5 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] 6 | public class TestRailAttribute : Attribute 7 | { 8 | public string TestRailURL 9 | { 10 | get 11 | { 12 | return "https://" + 13 | subdomen + 14 | ".testrail.net/index.php?/cases/view/" + 15 | testId; 16 | } 17 | } 18 | 19 | private readonly string subdomen; 20 | private readonly int testId; 21 | public readonly string Description; 22 | 23 | public TestRailAttribute(string subdomen, int testId, string description) 24 | { 25 | this.subdomen = subdomen; 26 | this.testId = testId; 27 | this.Description = description; 28 | } 29 | 30 | public TestRailAttribute(string subdomen, int testId) 31 | { 32 | this.subdomen = subdomen; 33 | this.testId = testId; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/TestRailAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64e686f3b2054309ac2cae9bd9394d2c 3 | timeCreated: 1553090001 -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/TestStep.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PlayQ.UITestTools 5 | { 6 | public static class TestStep 7 | { 8 | public static event Action OnTestStepUpdated; 9 | public static void Step(string step) 10 | { 11 | currentStep = step; 12 | CurrentIndex++; 13 | Debug.Log("Step " + CurrentIndex + " (" + step + ") started."); 14 | if (OnTestStepUpdated != null) 15 | { 16 | OnTestStepUpdated(); 17 | } 18 | } 19 | 20 | public static void Reset() 21 | { 22 | currentStep = null; 23 | CurrentIndex = 0; 24 | if (OnTestStepUpdated != null) 25 | { 26 | OnTestStepUpdated(); 27 | } 28 | } 29 | 30 | public static int CurrentIndex { get; private set; } 31 | 32 | private static string currentStep; 33 | 34 | public static CurrentStep GetCurrentStep(int stepsCount) 35 | { 36 | if (currentStep == null) 37 | { 38 | return null; 39 | } 40 | 41 | if (stepsCount <= 0) 42 | { 43 | stepsCount = 1; 44 | } 45 | return new CurrentStep(currentStep, CurrentIndex, Math.Min((float) CurrentIndex / stepsCount, 1)); 46 | } 47 | 48 | public class CurrentStep 49 | { 50 | public readonly string Text; 51 | public readonly float Progress; 52 | public readonly int Index; 53 | 54 | public override string ToString() 55 | { 56 | return "Step " + Index + " - " + Text; 57 | } 58 | 59 | public CurrentStep(string text, int index, float percent) 60 | { 61 | Index = index; 62 | Text = text; 63 | Progress = percent; 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /Assets/UITestTools/PlayModeTestRunner/TestStep.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53749ea130d84cd381a91a6ca177eeda 3 | timeCreated: 1533635950 -------------------------------------------------------------------------------- /Assets/UITestTools/Tools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 463447cf2d74949ef8b9a47255d51914 3 | folderAsset: yes 4 | timeCreated: 1520006445 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/AsyncWait.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c98c73c1d897435086758daa54b8f2ca 3 | timeCreated: 1527161760 -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/CoroutineProvider.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace PlayQ.UITestTools 4 | { 5 | public static class CoroutineProvider 6 | { 7 | private static EmptyMono mono; 8 | public static MonoBehaviour Mono 9 | { 10 | get 11 | { 12 | if (!mono) 13 | { 14 | var go = new GameObject(); 15 | mono = go.AddComponent(); 16 | mono.gameObject.name = "UI_TEST_TOOL_COROUTINE"; 17 | GameObject.DontDestroyOnLoad(mono); 18 | } 19 | return mono; 20 | } 21 | } 22 | 23 | private class EmptyMono : MonoBehaviour 24 | { 25 | 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/CoroutineProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b8fe5d7204349e4a952a4643c2c4021 3 | timeCreated: 1522165607 -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/GenerationCode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02ffe0e60d1b4823b67e69cc904b0e71 3 | timeCreated: 1526341065 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/Metrics.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b9daed417ec54c5299ee09b3ca28614 3 | folderAsset: yes 4 | timeCreated: 1549550120 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/Metrics/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6482bb4b977d4ac28ecd8c7e09ff3738 3 | timeCreated: 1549550332 -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/Metrics/Editor/OpenMetricsFolder.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnityEditor; 3 | 4 | namespace PlayQ.UITestTools.Editor 5 | { 6 | public class OpenMetricsFolder 7 | { 8 | [MenuItem("Window/UI Test Tools/Open Tests Metrics")] 9 | static void OpenTestsMetrics() 10 | { 11 | if (Directory.Exists(TestMetrics.MetricsFolder)) 12 | { 13 | EditorUtility.RevealInFinder(TestMetrics.MetricsFolder); 14 | } 15 | else 16 | { 17 | EditorUtility.DisplayDialog("Error", "Metrics folder doesn't exist yet.", "Ok"); 18 | } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/Metrics/Editor/OpenMetricsFolder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ed37568f44b4e85b8c649389a62f44b 3 | timeCreated: 1549550345 -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/Metrics/FPSCounter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using Newtonsoft.Json.Linq; 6 | using UnityEngine; 7 | 8 | namespace PlayQ.UITestTools 9 | { 10 | public class FPSCounter 11 | { 12 | private float framesPassed; 13 | private float secondsPassed; 14 | private float minDeltaTime = float.MaxValue; 15 | private float maxDeltaTime = 0f; 16 | 17 | private const string METRICS_FILE_NAME = "fps.json"; 18 | 19 | private static string FPSMettricsFileFullPath 20 | { 21 | get 22 | { 23 | return TestMetrics.PathTo(METRICS_FILE_NAME); 24 | } 25 | } 26 | 27 | private class FPSData 28 | { 29 | public int Min; 30 | public int Avg; 31 | public int Max; 32 | } 33 | 34 | private class FPSMetrics 35 | { 36 | public string Build; 37 | public Dictionary Fps; 38 | } 39 | 40 | public int AverageFPS 41 | { 42 | get 43 | { 44 | if (secondsPassed == 0) 45 | { 46 | return 0; 47 | } 48 | return (int) Math.Round(framesPassed / secondsPassed); 49 | } 50 | } 51 | 52 | public int MaxFPS 53 | { 54 | get 55 | { 56 | if (minDeltaTime == 0) 57 | { 58 | return 0; 59 | } 60 | return (int) Math.Round(1f / minDeltaTime); 61 | } 62 | } 63 | 64 | public int MixFPS 65 | { 66 | get 67 | { 68 | if (maxDeltaTime == 0) 69 | { 70 | return 0; 71 | } 72 | return (int) Math.Round(1f / maxDeltaTime); 73 | } 74 | } 75 | 76 | private Coroutine updateCoroutine; 77 | public void Reset() 78 | { 79 | if (updateCoroutine == null) 80 | { 81 | updateCoroutine = CoroutineProvider.Mono.StartCoroutine(Update()); 82 | } 83 | 84 | framesPassed = 0; 85 | secondsPassed = 0; 86 | minDeltaTime = float.MaxValue; 87 | maxDeltaTime = 0; 88 | } 89 | 90 | private IEnumerator Update() 91 | { 92 | while (true) 93 | { 94 | yield return null; 95 | 96 | framesPassed++; 97 | secondsPassed += Time.unscaledDeltaTime; 98 | if (maxDeltaTime < Time.unscaledDeltaTime) 99 | { 100 | maxDeltaTime = Time.unscaledDeltaTime; 101 | } 102 | if (minDeltaTime > Time.unscaledDeltaTime) 103 | { 104 | minDeltaTime = Time.unscaledDeltaTime; 105 | } 106 | } 107 | } 108 | 109 | 110 | public void ClearFPSMetrics() 111 | { 112 | if (File.Exists(FPSMettricsFileFullPath)) 113 | { 114 | File.Delete(FPSMettricsFileFullPath); 115 | } 116 | } 117 | 118 | public void SaveFPS(string tag) 119 | { 120 | FPSMetrics metrics = new FPSMetrics(); 121 | string textData; 122 | if (File.Exists(FPSMettricsFileFullPath)) 123 | { 124 | try 125 | { 126 | textData = File.ReadAllText(FPSMettricsFileFullPath); 127 | metrics = JObject.Parse(textData).ToObject(); 128 | 129 | } 130 | catch (Exception ex) 131 | { 132 | Debug.LogWarning("file with fps metrics exists but can't be read " + ex.Message); 133 | } 134 | } 135 | 136 | metrics.Build = Application.version; 137 | var buildVersion = ConsoleArgumentHelper.GetArg("-buildNumber"); 138 | if (!string.IsNullOrEmpty(buildVersion)) 139 | { 140 | metrics.Build = metrics.Build + ":" + buildVersion; 141 | } 142 | 143 | if (metrics.Fps == null) 144 | { 145 | metrics.Fps = new Dictionary(); 146 | } 147 | 148 | if (metrics.Fps.ContainsKey(tag)) 149 | { 150 | tag = tag + "_" +Time.realtimeSinceStartup; 151 | } 152 | 153 | metrics.Fps.Add(tag, new FPSData 154 | { 155 | Min = MixFPS, 156 | Avg = AverageFPS, 157 | Max = MaxFPS 158 | }); 159 | 160 | TestMetrics.CheckAndCreateFolder(); 161 | 162 | textData = JObject.FromObject(metrics).ToString(); 163 | File.WriteAllText(FPSMettricsFileFullPath, textData); 164 | } 165 | } 166 | } -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/Metrics/FPSCounter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7158b2f7af6fa94a90a61f9cc3dfd2f 3 | timeCreated: 1516030157 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/Metrics/PreloaderTimeTracker.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnityEngine; 3 | 4 | namespace PlayQ.UITestTools 5 | { 6 | public class PreloaderTimeTracker 7 | { 8 | private float starTime; 9 | private bool done; 10 | 11 | public void Start() 12 | { 13 | starTime = Time.time; 14 | } 15 | 16 | public void Done() 17 | { 18 | if (!done) 19 | { 20 | PlayModeTestRunner.SavePreloadingTime(Time.time - starTime); 21 | done = true; 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/Metrics/PreloaderTimeTracker.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a769cf0ead01405695248c8258f6c4f3 3 | timeCreated: 1549549238 -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/Metrics/TestMetrics.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnityEngine; 3 | 4 | namespace PlayQ.UITestTools 5 | { 6 | public static class TestMetrics 7 | { 8 | public static FPSCounter FPSCounter = new FPSCounter(); 9 | public static PreloaderTimeTracker PreloaderTimeTracker = new PreloaderTimeTracker(); 10 | 11 | public static void CheckAndCreateFolder() 12 | { 13 | if (!Directory.Exists(MetricsFolder)) 14 | { 15 | Directory.CreateDirectory(MetricsFolder); 16 | } 17 | } 18 | 19 | public static string PathTo(string file) 20 | { 21 | return MetricsFolder + Path.DirectorySeparatorChar + file; 22 | } 23 | 24 | public static string MetricsFolder 25 | { 26 | get 27 | { 28 | return Application.persistentDataPath + 29 | Path.DirectorySeparatorChar + "Metrics"; 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/Metrics/TestMetrics.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09ca0f94a6d449068957335be95a4544 3 | timeCreated: 1549550296 -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/RaycastChanger.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | 5 | namespace PlayQ.UITestTools 6 | { 7 | public static partial class RaycastChanger 8 | { 9 | private static List unityGraphic = new List(); 10 | [RaycastChanger] 11 | public static void ChangeForUnityText(bool isEnable) 12 | { 13 | if (isEnable && unityGraphic.Count > 0) 14 | { 15 | return; 16 | } 17 | if (isEnable) 18 | { 19 | var graphic = Resources.FindObjectsOfTypeAll(); 20 | foreach (var text in graphic) 21 | { 22 | if (!text.raycastTarget && text.gameObject.scene.isLoaded) 23 | { 24 | text.raycastTarget = true; 25 | unityGraphic.Add(text); 26 | } 27 | } 28 | } 29 | else 30 | { 31 | foreach (var graphic in unityGraphic) 32 | { 33 | if (graphic) 34 | { 35 | graphic.raycastTarget = false; 36 | } 37 | } 38 | unityGraphic.Clear(); 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/RaycastChanger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1219b9a2b436294c9543c3fdddc431f 3 | timeCreated: 1515069605 4 | -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/TestScreenshotTools.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | 7 | namespace PlayQ.UITestTools 8 | { 9 | public static class TestScreenshotTools 10 | { 11 | public const string REFERENCE_SCREENSHOT_DIRECTORY = "ReferenceScreenshots"; 12 | public const string SCREENSHOT_DIRECTORY = "Screenshots"; 13 | 14 | public static string GenerateScreenshotNameWithTime(string name) 15 | { 16 | var adjustedName = new StringBuilder() 17 | .Append(name) 18 | .Append('-') 19 | .Append(DateTime.UtcNow.ToString(PlayModeLogger.FILE_DATE_FORMAT)) 20 | .Append(".png").ToString(); 21 | 22 | return adjustedName; 23 | } 24 | 25 | public static string GenerateReferenceScreenshotNameToSave(string name) 26 | { 27 | var adjustedName = new StringBuilder() 28 | .Append(name) 29 | .Append(".png").ToString(); 30 | 31 | return adjustedName; 32 | } 33 | 34 | public static string ScreenshotDirectoryToCaptureByUnity 35 | { 36 | get 37 | { 38 | string path; 39 | #if UNITY_EDITOR 40 | path = Application.persistentDataPath + '/' + SCREENSHOT_DIRECTORY; 41 | #else 42 | //On mobile platforms the filename is appended to the persistent data path. 43 | path = '/' + SCREENSHOT_DIRECTORY; 44 | #endif 45 | 46 | return path + '/' + SubDirectoriesForCurrentTest; 47 | } 48 | } 49 | 50 | public static string ScreenshotDirectoryToLoadByFileSystem 51 | { 52 | get 53 | { 54 | var path = Application.persistentDataPath + '/' + 55 | SCREENSHOT_DIRECTORY + '/' + 56 | SubDirectoriesForCurrentTest; 57 | 58 | return path; 59 | } 60 | } 61 | 62 | #if UNITY_EDITOR 63 | public static string ReferenceScreenshotDirectoryToSaveByFileSystem 64 | { 65 | get 66 | { 67 | var editorResources = SelectedTestsSerializable.EditorResourceDirectory; 68 | var path = editorResources + "/" + REFERENCE_SCREENSHOT_DIRECTORY; 69 | if (string.IsNullOrEmpty(path)) 70 | { 71 | return null; 72 | } 73 | return path + '/' + SubDirectoriesForCurrentTest; 74 | } 75 | } 76 | #endif 77 | public static string ReferenceScreenshotDirectoryToLoadFromResources 78 | { 79 | get 80 | { 81 | return REFERENCE_SCREENSHOT_DIRECTORY + '/' + SubDirectoriesForCurrentTest; 82 | } 83 | } 84 | 85 | public static string SubDirectoriesForCurrentTest 86 | { 87 | get 88 | { 89 | var camera = UITestUtils.FindAnyGameObject(); 90 | 91 | var pathBuilder = new StringBuilder(); 92 | pathBuilder.Append("resolution_") 93 | .Append(camera.pixelWidth) 94 | .Append("_") 95 | .Append(camera.pixelHeight); 96 | 97 | var testMethodName = CurrentTestInfo.TestMethodName; 98 | if (!string.IsNullOrEmpty(testMethodName)) 99 | { 100 | pathBuilder.Append(Path.DirectorySeparatorChar); 101 | pathBuilder.Append(testMethodName); 102 | } 103 | 104 | var result = pathBuilder.ToString(); 105 | if (!Directory.Exists(result)) 106 | { 107 | Directory.CreateDirectory(result); 108 | } 109 | 110 | return result; 111 | } 112 | } 113 | 114 | 115 | #if UNITY_EDITOR 116 | public static void ClearScreenshotsEmptyFolders() 117 | { 118 | var screenshotDirectory = Application.persistentDataPath + '/' + SCREENSHOT_DIRECTORY; 119 | var directories = Directory.GetDirectories(screenshotDirectory); 120 | if (directories.Any()) 121 | { 122 | foreach (var dirName in directories) 123 | { 124 | ClearScreenshotsEmptyFoldersRec(dirName); 125 | } 126 | } 127 | } 128 | 129 | private static void ClearScreenshotsEmptyFoldersRec(string targetPath) 130 | { 131 | var files = Directory.GetFiles(targetPath, "*.png", SearchOption.AllDirectories); 132 | if (!files.Any()) 133 | { 134 | Directory.Delete(targetPath, true); 135 | } 136 | else 137 | { 138 | var directories = Directory.GetDirectories(targetPath); 139 | if (directories.Any()) 140 | { 141 | foreach (var dirName in directories) 142 | { 143 | ClearScreenshotsEmptyFoldersRec(dirName); 144 | } 145 | } 146 | } 147 | } 148 | #endif 149 | 150 | } 151 | } -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/TestScreenshotTools.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 284c6b1e17ee54e29aa02d9790e94dde 3 | timeCreated: 1520006232 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/UITestUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7183e09ddda42ed8bfc815e0f1f18d8 3 | timeCreated: 1514385765 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/WaitResults.cs: -------------------------------------------------------------------------------- 1 | namespace PlayQ.UITestTools.WaitResults 2 | { 3 | public abstract class WaitResult 4 | {} 5 | 6 | public class WaitSuccess : WaitResult 7 | { 8 | public override string ToString() 9 | { 10 | return "Wait success"; 11 | } 12 | } 13 | 14 | public class WaitFailed : WaitResult 15 | { 16 | private readonly string message; 17 | public WaitFailed(string message) 18 | { 19 | this.message = message; 20 | } 21 | 22 | public override string ToString() 23 | { 24 | return "Wait failed, reason: " + message; 25 | } 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /Assets/UITestTools/Tools/WaitResults.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db28d6fbc696459eaf1c0bb0079fa767 3 | timeCreated: 1525770439 -------------------------------------------------------------------------------- /Assets/UITestTools/UITestAttributes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PlayQ.UITestTools 5 | { 6 | public class ShowInEditorAttribute : Attribute 7 | { 8 | public readonly string Description; 9 | public readonly Type ClassType; 10 | public bool IsDefault; 11 | 12 | public ShowInEditorAttribute(Type classType, string description, bool isDefault = false) 13 | { 14 | if (classType.IsAssignableFrom(typeof(ShowHelperBase))) 15 | { 16 | Debug.LogError("Class type for " + description + " is not ShowHelperBase"); 17 | return; 18 | } 19 | Description = description; 20 | ClassType = classType; 21 | IsDefault = isDefault; 22 | } 23 | } 24 | 25 | public class RaycastChangerAttribute : Attribute 26 | { 27 | } 28 | } -------------------------------------------------------------------------------- /Assets/UITestTools/UITestAttributes.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6aa1d1d761cd49d3990e65fa8c9eba2b 3 | timeCreated: 1514385962 -------------------------------------------------------------------------------- /Assets/UITestTools/UITestToolsVersionInfo.cs: -------------------------------------------------------------------------------- 1 | namespace PlayQ.UITestTools 2 | { 3 | public static class UITestToolsVersionInfo 4 | { 5 | public const int MAJOR = 1; 6 | public const int MINOR = 1; 7 | public const int PATCH = 0; 8 | 9 | public static string StringVersion 10 | { 11 | get { return "v." + MAJOR + "." + MINOR + "." + PATCH; } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Assets/UITestTools/UITestToolsVersionInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d84cf4aa8af1240659e04ef7ae26ed0d 3 | timeCreated: 1535726703 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Logs/Packages-Update.log: -------------------------------------------------------------------------------- 1 | 2 | === Thu Aug 15 11:53:49 2019 3 | 4 | Packages were changed. 5 | Update Mode: resetToDefaultDependencies 6 | 7 | The following packages were added: 8 | com.unity.analytics@3.3.2 9 | com.unity.purchasing@2.0.6 10 | com.unity.ads@2.0.8 11 | com.unity.textmeshpro@2.0.1 12 | com.unity.package-manager-ui@2.1.2 13 | com.unity.collab-proxy@1.2.16 14 | com.unity.timeline@1.0.0 15 | com.unity.modules.ai@1.0.0 16 | com.unity.modules.animation@1.0.0 17 | com.unity.modules.assetbundle@1.0.0 18 | com.unity.modules.audio@1.0.0 19 | com.unity.modules.cloth@1.0.0 20 | com.unity.modules.director@1.0.0 21 | com.unity.modules.imageconversion@1.0.0 22 | com.unity.modules.imgui@1.0.0 23 | com.unity.modules.jsonserialize@1.0.0 24 | com.unity.modules.particlesystem@1.0.0 25 | com.unity.modules.physics@1.0.0 26 | com.unity.modules.physics2d@1.0.0 27 | com.unity.modules.screencapture@1.0.0 28 | com.unity.modules.terrain@1.0.0 29 | com.unity.modules.terrainphysics@1.0.0 30 | com.unity.modules.tilemap@1.0.0 31 | com.unity.modules.ui@1.0.0 32 | com.unity.modules.uielements@1.0.0 33 | com.unity.modules.umbra@1.0.0 34 | com.unity.modules.unityanalytics@1.0.0 35 | com.unity.modules.unitywebrequest@1.0.0 36 | com.unity.modules.unitywebrequestassetbundle@1.0.0 37 | com.unity.modules.unitywebrequestaudio@1.0.0 38 | com.unity.modules.unitywebrequesttexture@1.0.0 39 | com.unity.modules.unitywebrequestwww@1.0.0 40 | com.unity.modules.vehicles@1.0.0 41 | com.unity.modules.video@1.0.0 42 | com.unity.modules.vr@1.0.0 43 | com.unity.modules.wind@1.0.0 44 | com.unity.modules.xr@1.0.0 45 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.ads": "2.0.8", 4 | "com.unity.analytics": "3.3.2", 5 | "com.unity.collab-proxy": "1.2.16", 6 | "com.unity.package-manager-ui": "2.1.2", 7 | "com.unity.purchasing": "2.0.6", 8 | "com.unity.textmeshpro": "2.0.1", 9 | "com.unity.timeline": "1.0.0", 10 | "com.unity.modules.ai": "1.0.0", 11 | "com.unity.modules.animation": "1.0.0", 12 | "com.unity.modules.assetbundle": "1.0.0", 13 | "com.unity.modules.audio": "1.0.0", 14 | "com.unity.modules.cloth": "1.0.0", 15 | "com.unity.modules.director": "1.0.0", 16 | "com.unity.modules.imageconversion": "1.0.0", 17 | "com.unity.modules.imgui": "1.0.0", 18 | "com.unity.modules.jsonserialize": "1.0.0", 19 | "com.unity.modules.particlesystem": "1.0.0", 20 | "com.unity.modules.physics": "1.0.0", 21 | "com.unity.modules.physics2d": "1.0.0", 22 | "com.unity.modules.screencapture": "1.0.0", 23 | "com.unity.modules.terrain": "1.0.0", 24 | "com.unity.modules.terrainphysics": "1.0.0", 25 | "com.unity.modules.tilemap": "1.0.0", 26 | "com.unity.modules.ui": "1.0.0", 27 | "com.unity.modules.uielements": "1.0.0", 28 | "com.unity.modules.umbra": "1.0.0", 29 | "com.unity.modules.unityanalytics": "1.0.0", 30 | "com.unity.modules.unitywebrequest": "1.0.0", 31 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 32 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 33 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 34 | "com.unity.modules.unitywebrequestwww": "1.0.0", 35 | "com.unity.modules.vehicles": "1.0.0", 36 | "com.unity.modules.video": "1.0.0", 37 | "com.unity.modules.vr": "1.0.0", 38 | "com.unity.modules.wind": "1.0.0", 39 | "com.unity.modules.xr": "1.0.0" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /documentation/images/action-item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/documentation/images/action-item.png -------------------------------------------------------------------------------- /documentation/images/play-mode-testrunner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/documentation/images/play-mode-testrunner.png -------------------------------------------------------------------------------- /documentation/images/recorder-interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/documentation/images/recorder-interface.png -------------------------------------------------------------------------------- /documentation/images/recorder_window.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/documentation/images/recorder_window.gif -------------------------------------------------------------------------------- /documentation/images/test-helper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/documentation/images/test-helper.png -------------------------------------------------------------------------------- /documentation/images/test-runner_context_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PlayQ/unity-uitest-tool/fdbb3af13591721b8fc3107f1fae30f38ea868e6/documentation/images/test-runner_context_menu.png --------------------------------------------------------------------------------