From 844d8173c1f8d84ffdab532b56aa5803a1a2c046 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Thu, 3 Mar 2016 10:49:01 +0000 Subject: [PATCH] Updated test tools to fix compiler warnings --- .../Assertions/Editor/AssertionComponentEditor.cs | 3 +++ .../Settings/IntegrationTestsRunnerSettings.asset.meta | 4 ++-- Assets/UnityTestTools/IntegrationTestsFramework/Libs.meta | 2 +- .../Libs/Mono.Cecil.Mdb.dll.meta | 2 +- .../IntegrationTestsFramework/Libs/Mono.Cecil.dll.meta | 6 +++++- .../IntegrationTestsFramework/TestRunner/Editor/Batch.cs | 3 ++- .../TestRunner/Editor/EditorReferencesUtil.cs.meta | 2 +- .../TestRunner/Editor/IntegrationTestsRunnerWindow.cs | 8 +++++--- .../Editor/PlatformRunner/PlatformRunnerConfiguration.cs | 5 +++-- .../Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs | 5 +++-- .../TestRunner/Editor/TestComponentEditor.cs | 5 +++-- .../IntegrationTestsFramework/TestRunner/ResultDTO.cs | 7 ++++--- .../IntegrationTestsFramework/TestRunner/TestComponent.cs | 5 +++-- .../IntegrationTestsFramework/TestRunner/TestRunner.cs | 7 ++++--- 14 files changed, 40 insertions(+), 24 deletions(-) diff --git a/Assets/UnityTestTools/Assertions/Editor/AssertionComponentEditor.cs b/Assets/UnityTestTools/Assertions/Editor/AssertionComponentEditor.cs index c806621c..a2736a72 100644 --- a/Assets/UnityTestTools/Assertions/Editor/AssertionComponentEditor.cs +++ b/Assets/UnityTestTools/Assertions/Editor/AssertionComponentEditor.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Reflection; using UnityEditor; using UnityEngine; +using UnityEditor.SceneManagement; namespace UnityTest { @@ -81,6 +82,8 @@ namespace UnityTest DrawCompareToType(script.Action as ComparerBase); } } + if(GUI.changed) + EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } private void DrawOptionsForAfterPeriodOfTime(AssertionComponent script) diff --git a/Assets/UnityTestTools/Common/Settings/IntegrationTestsRunnerSettings.asset.meta b/Assets/UnityTestTools/Common/Settings/IntegrationTestsRunnerSettings.asset.meta index 6c3c4b27..6919ec46 100644 --- a/Assets/UnityTestTools/Common/Settings/IntegrationTestsRunnerSettings.asset.meta +++ b/Assets/UnityTestTools/Common/Settings/IntegrationTestsRunnerSettings.asset.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: ad7c6353939274fc8a5e756095b99a64 -timeCreated: 1450715835 +guid: ec24e4a07acd24ffaa1cd1df7fa11d54 +timeCreated: 1455275624 licenseType: Free NativeFormatImporter: userData: diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/Libs.meta b/Assets/UnityTestTools/IntegrationTestsFramework/Libs.meta index 1b749751..5b8287ab 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/Libs.meta +++ b/Assets/UnityTestTools/IntegrationTestsFramework/Libs.meta @@ -2,7 +2,7 @@ fileFormatVersion: 2 guid: e22ba039de7077c4aa95758ef723b803 folderAsset: yes timeCreated: 1445282049 -licenseType: Store +licenseType: Pro DefaultImporter: userData: assetBundleName: diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.Mdb.dll.meta b/Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.Mdb.dll.meta index a040b4f3..4ee72945 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.Mdb.dll.meta +++ b/Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.Mdb.dll.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 713231d47408a06408a45470c967bae8 timeCreated: 1441797177 -licenseType: Store +licenseType: Pro PluginImporter: serializedVersion: 1 iconMap: {} diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.dll.meta b/Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.dll.meta index 1123a8ae..16dbe19f 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.dll.meta +++ b/Assets/UnityTestTools/IntegrationTestsFramework/Libs/Mono.Cecil.dll.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 28fc22990733f8f4ea1137f15e363609 timeCreated: 1441797177 -licenseType: Store +licenseType: Pro PluginImporter: serializedVersion: 1 iconMap: {} @@ -15,6 +15,10 @@ PluginImporter: enabled: 1 settings: DefaultValueInitialized: true + WindowsStoreApps: + enabled: 0 + settings: + CPU: AnyCPU userData: assetBundleName: assetBundleVariant: diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Batch.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Batch.cs index 14a82c64..b4490bf7 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Batch.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Batch.cs @@ -6,6 +6,7 @@ using UnityEditor; using UnityEditorInternal; using UnityEngine; using UnityTest.IntegrationTests; +using UnityEditor.SceneManagement; namespace UnityTest { @@ -89,7 +90,7 @@ namespace UnityTest return; } EditorBuildSettings.scenes = (testScenes.Concat(otherBuildScenes).ToList()).Select(s => new EditorBuildSettingsScene(s, true)).ToArray(); - EditorApplication.OpenScene(testScenes.First()); + EditorSceneManager.OpenScene(testScenes.First()); GuiHelper.SetConsoleErrorPause(false); var config = new PlatformRunnerConfiguration diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/EditorReferencesUtil.cs.meta b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/EditorReferencesUtil.cs.meta index 78bcfabf..abad897d 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/EditorReferencesUtil.cs.meta +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/EditorReferencesUtil.cs.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: aad501c968b324cf3a8d1c52eb09ca04 timeCreated: 1437322927 -licenseType: Store +licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs index 961503cf..2a5ed8d1 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs @@ -6,6 +6,7 @@ using System.Text.RegularExpressions; using UnityEditor; using UnityEngine; using UnityTest.IntegrationTestRunner; +using UnityEngine.SceneManagement; namespace UnityTest { @@ -83,10 +84,11 @@ namespace UnityTest private static void BackgroundSceneChangeWatch() { if (!s_Instance) return; - if (s_Instance.m_CurrectSceneName != null && s_Instance.m_CurrectSceneName == EditorApplication.currentScene) return; + var currentScene = SceneManager.GetActiveScene().path; + if (s_Instance.m_CurrectSceneName != null && s_Instance.m_CurrectSceneName == currentScene) return; if (EditorApplication.isPlayingOrWillChangePlaymode) return; TestComponent.DestroyAllDynamicTests(); - s_Instance.m_CurrectSceneName = EditorApplication.currentScene; + s_Instance.m_CurrectSceneName = currentScene; s_Instance.m_ResultList.Clear(); s_Instance.RebuildTestList(); } @@ -239,7 +241,7 @@ namespace UnityTest if (!EditorApplication.isPlayingOrWillChangePlaymode) { var dynamicTestsOnScene = TestComponent.FindAllDynamicTestsOnScene(); - var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(EditorApplication.currentScene); + var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().path); foreach (var dynamicTestType in dynamicTestTypes) { diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerConfiguration.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerConfiguration.cs index 0d67e854..1c0a7856 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerConfiguration.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerConfiguration.cs @@ -6,6 +6,7 @@ using System.Net; using System.Net.Sockets; using UnityEditor; using UnityEngine; +using UnityEngine.SceneManagement; [Serializable] public class PlatformRunnerConfiguration @@ -14,7 +15,7 @@ public class PlatformRunnerConfiguration public List testScenes; public BuildTarget buildTarget; public bool runInEditor; - public string projectName = EditorApplication.currentScene; + public string projectName = SceneManager.GetActiveScene().path; public string resultsDir = null; public bool sendResultsOverNetwork; @@ -24,7 +25,7 @@ public class PlatformRunnerConfiguration public PlatformRunnerConfiguration(BuildTarget buildTarget) { this.buildTarget = buildTarget; - projectName = EditorApplication.currentScene; + projectName = SceneManager.GetActiveScene().path; } public PlatformRunnerConfiguration() diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs index 757968ab..bc83ef37 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs @@ -6,6 +6,7 @@ using System.Net; using UnityEditor; using UnityEngine; using Object = UnityEngine.Object; +using UnityEngine.SceneManagement; namespace UnityTest.IntegrationTests { @@ -47,7 +48,7 @@ namespace UnityTest.IntegrationTests position.Set(position.xMin, position.yMin, 200, position.height); m_AllScenesInProject = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.unity", SearchOption.AllDirectories).ToList(); m_AllScenesInProject.Sort(); - var currentScene = (Directory.GetCurrentDirectory() + EditorApplication.currentScene).Replace("\\", "").Replace("/", ""); + var currentScene = (Directory.GetCurrentDirectory() + SceneManager.GetActiveScene().path).Replace("\\", "").Replace("/", ""); var currentScenePath = m_AllScenesInProject.Where(s => s.Replace("\\", "").Replace("/", "") == currentScene); m_SelectedScenes.AddRange(currentScenePath); @@ -264,7 +265,7 @@ namespace UnityTest.IntegrationTests buildTarget = m_BuildTarget, buildScenes = m_OtherScenesToBuild, testScenes = m_IntegrationTestScenes, - projectName = m_IntegrationTestScenes.Count > 1 ? "IntegrationTests" : Path.GetFileNameWithoutExtension(EditorApplication.currentScene), + projectName = m_IntegrationTestScenes.Count > 1 ? "IntegrationTests" : Path.GetFileNameWithoutExtension(SceneManager.GetActiveScene().path), resultsDir = m_Settings.resultsPath, sendResultsOverNetwork = m_Settings.sendResultsOverNetwork, ipList = m_Interfaces.Skip(1).ToList(), diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/TestComponentEditor.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/TestComponentEditor.cs index 8502eca4..1b30f558 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/TestComponentEditor.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/TestComponentEditor.cs @@ -4,6 +4,7 @@ using System.Linq; using UnityEditor; using UnityEngine; using Object = UnityEngine.Object; +using UnityEditor.SceneManagement; namespace UnityTest { @@ -101,8 +102,8 @@ namespace UnityTest if (!component.dynamic) serializedObject.ApplyModifiedProperties(); - if(GUI.changed) - EditorApplication.MarkSceneDirty(); + if (GUI.changed) + EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } private string[] GetListOfIgnoredPlatforms(string[] enumList, int flags) diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs index 40224e4b..e8a8e4e8 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using UnityEngine; +using UnityEngine.SceneManagement; namespace UnityTest { @@ -18,9 +19,9 @@ namespace UnityTest private ResultDTO(MessageType messageType) { this.messageType = messageType; - levelCount = Application.levelCount; - loadedLevel = Application.loadedLevel; - loadedLevelName = Application.loadedLevelName; + levelCount = UnityEngine.SceneManagement.SceneManager.sceneCount; + loadedLevel = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex; + loadedLevelName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; } public enum MessageType : byte diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestComponent.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestComponent.cs index b083674e..d8d91646 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestComponent.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestComponent.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using UnityEngine; +using UnityEngine.SceneManagement; #if UNITY_EDITOR using UnityEditor; @@ -308,9 +309,9 @@ namespace UnityTest public static bool AnyDynamicTestForCurrentScene() { #if UNITY_EDITOR - return TestComponent.GetTypesWithHelpAttribute(EditorApplication.currentScene).Any(); + return TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name).Any(); #else - return TestComponent.GetTypesWithHelpAttribute(Application.loadedLevelName).Any(); + return TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name).Any(); #endif } diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunner.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunner.cs index aed12485..4af9fc74 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunner.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunner.cs @@ -8,6 +8,7 @@ using System.Reflection; using UnityEngine; using UnityTest.IntegrationTestRunner; using System.IO; +using UnityEngine.SceneManagement; namespace UnityTest { @@ -74,7 +75,7 @@ namespace UnityTest } TestComponent.DestroyAllDynamicTests(); - var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(Application.loadedLevelName); + var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name); foreach (var dynamicTestType in dynamicTestTypes) TestComponent.CreateDynamicTest(dynamicTestType); @@ -309,7 +310,7 @@ namespace UnityTest string testScene = m_Configurator.GetIntegrationTestScenes (TestSceneNumber); if (testScene != null) - Application.LoadLevel(Path.GetFileNameWithoutExtension(testScene)); + SceneManager.LoadScene(Path.GetFileNameWithoutExtension(testScene)); else { TestRunnerCallback.AllScenesFinished(); @@ -363,7 +364,7 @@ namespace UnityTest currentTest = null; if (!testResult.IsSuccess && testResult.Executed - && !testResult.IsIgnored) k_ResultRenderer.AddResults(Application.loadedLevelName, testResult); + && !testResult.IsIgnored) k_ResultRenderer.AddResults(SceneManager.GetActiveScene().name, testResult); } #region Test Runner Helpers