public void PrintHeadPanel()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            if (GUILayout.Button(m_GUIRunAllTests, EditorStyles.toolbarButton))
            {
                RunTests(TestComponent.FindAllTestsOnScene().Cast <ITestComponent>().ToList());
            }
            EditorGUI.BeginDisabledGroup(!Selection.gameObjects.Any(t => t.GetComponent(typeof(ITestComponent))));
            if (GUILayout.Button(m_GUIRunSelectedTests, EditorStyles.toolbarButton))
            {
                RunTests(Selection.gameObjects.Select(t => t.GetComponent(typeof(TestComponent))).Cast <ITestComponent>().ToList());
            }
            EditorGUI.EndDisabledGroup();
            if (GUILayout.Button(m_GUICreateNewTest, EditorStyles.toolbarButton))
            {
                var test = TestComponent.CreateTest();
                if (Selection.gameObjects.Length == 1 &&
                    Selection.activeGameObject != null &&
                    Selection.activeGameObject.GetComponent <TestComponent>())
                {
                    test.transform.parent = Selection.activeGameObject.transform.parent;
                }
                Selection.activeGameObject = test;
                RebuildTestList();
            }
            EditorGUI.EndDisabledGroup();

            GUILayout.FlexibleSpace();

            m_FilterSettings.OnGUI();

            EditorGUILayout.EndHorizontal();
        }
Beispiel #2
0
        public void Start()
        {
            if (isInitializedByRunner)
            {
                return;
            }

            if (m_Configurator.sendResultsOverNetwork)
            {
                var nrs = m_Configurator.ResolveNetworkConnection();
                if (nrs != null)
                {
                    TestRunnerCallback.Add(nrs);
                }
            }

            TestComponent.DestroyAllDynamicTests();
            var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(Application.loadedLevelName);

            foreach (var dynamicTestType in dynamicTestTypes)
            {
                TestComponent.CreateDynamicTest(dynamicTestType);
            }

            var tests = TestComponent.FindAllTestsOnScene();

            InitRunner(tests, dynamicTestTypes.Select(type => type.AssemblyQualifiedName).ToList());
        }
        public static void OnHierarchyChangeUpdate()
        {
            if (!s_Instance || s_Instance.m_TestLines == null || EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            // create a test runner if it doesn't exist
            TestRunner.GetTestRunner();

            // make tests are not places under a go that is not a test itself
            foreach (var test in TestComponent.FindAllTestsOnScene())
            {
                if (test.gameObject.transform.parent != null && test.gameObject.transform.parent.gameObject.GetComponent <TestComponent>() == null)
                {
                    test.gameObject.transform.parent = null;
                    Debug.LogWarning("Tests need to be on top of the hierarchy or directly under another test.");
                }
            }
            if (selectedInHierarchy)
            {
                selectedInHierarchy = false;
            }
            else
            {
                s_Instance.RebuildTestList();
            }
        }
        private static void SelectInHierarchy(GameObject gameObject)
        {
            if (!s_Instance)
            {
                return;
            }
            if (gameObject == s_Instance.m_SelectedLine && gameObject.activeInHierarchy)
            {
                return;
            }
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }
            if (!gameObject.activeSelf)
            {
                selectedInHierarchy = true;
                gameObject.SetActive(true);
            }

            var tests    = TestComponent.FindAllTestsOnScene();
            var skipList = gameObject.GetComponentsInChildren(typeof(TestComponent), true).ToList();

            tests.RemoveAll(skipList.Contains);
            foreach (var test in tests)
            {
                var enable = test.GetComponentsInChildren(typeof(TestComponent), true).Any(c => c.gameObject == gameObject);
                if (test.gameObject.activeSelf != enable)
                {
                    test.gameObject.SetActive(enable);
                }
            }
        }
        private static void SelectInHierarchy(GameObject gameObject)
        {
            if (gameObject == Instance.selectedLine)
            {
                return;
            }
            if (!gameObject.activeSelf)
            {
                selectedInHierarchy = true;
                gameObject.SetActive(true);
            }

            var tests    = TestComponent.FindAllTestsOnScene();
            var skipList = gameObject.GetComponentsInChildren(typeof(TestComponent), true);

            tests.RemoveAll(skipList.Contains);
            foreach (var test in tests)
            {
                var enable = test.GetComponentsInChildren(typeof(TestComponent), true).Any(c => c.gameObject == gameObject);
                if (test.gameObject.activeSelf != enable)
                {
                    test.gameObject.SetActive(enable);
                }
            }
        }
Beispiel #6
0
        public void Start()
        {
            // Preventing OnDestroy call with invalid internal state
            currentTest = null;

            if (isInitializedByRunner)
            {
                return;
            }

            if (m_Configurator.sendResultsOverNetwork)
            {
                var nrs = m_Configurator.ResolveNetworkConnection();
                if (nrs != null)
                {
                    TestRunnerCallback.Add(nrs);
                }
            }

            TestComponent.DestroyAllDynamicTests();
            var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name);

            foreach (var dynamicTestType in dynamicTestTypes)
            {
                TestComponent.CreateDynamicTest(dynamicTestType);
            }

            var tests = TestComponent.FindAllTestsOnScene();

            InitRunner(tests, dynamicTestTypes.Select(type => type.AssemblyQualifiedName).ToList());
        }
        public void Start()
        {
            if (isInitializedByRunner)
            {
                return;
            }

            if (m_Configurator.sendResultsOverNetwork)
            {
                var nrs = m_Configurator.ResolveNetworkConnection();
                if (nrs != null)
                {
                    TestRunnerCallback.Add(nrs);
                }
            }

            TestComponent.DestroyAllDynamicTests();

#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
            var loadedLevelName = Application.loadedLevelName;
#else
            var loadedLevelName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
#endif

            var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(loadedLevelName);
            foreach (var dynamicTestType in dynamicTestTypes)
            {
                TestComponent.CreateDynamicTest(dynamicTestType);
            }

            var tests = TestComponent.FindAllTestsOnScene();

            InitRunner(tests, dynamicTestTypes.Select(type => type.AssemblyQualifiedName).ToList());
        }
Beispiel #8
0
        public void Start()
        {
            Debug.Log("TestRunner.Start");
            if (isInitializedByRunner)
            {
                return;
            }
            if (m_Configurator.sendResultsOverNetwork)
            {
                ITestRunnerCallback testRunnerCallback = m_Configurator.ResolveNetworkConnection();
                if (testRunnerCallback != null)
                {
                    TestRunnerCallback.Add(testRunnerCallback);
                }
            }
            TestComponent.DestroyAllDynamicTests();
            IEnumerable <Type> typesWithHelpAttribute = TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name);

            foreach (Type item in typesWithHelpAttribute)
            {
                TestComponent.CreateDynamicTest(item);
            }
            List <TestComponent> list = TestComponent.FindAllTestsOnScene();

            Debug.Log("Found tests in scene:\n" + string.Join("\n", list.Select((TestComponent t) => t.Name).ToArray()));
            InitRunner(list, typesWithHelpAttribute.Select((Type type) => type.AssemblyQualifiedName).ToList());
        }
        public void PrintHeadPanel( )
        {
            GUILayout.Space(10);
            EditorGUILayout.BeginHorizontal();
            var layoutOptions = new[] { GUILayout.Height(24), GUILayout.Width(32) };

            if (GUILayout.Button(guiRunAllTests, Styles.buttonLeft, layoutOptions) &&
                !EditorApplication.isPlayingOrWillChangePlaymode)
            {
                RunTests(TestComponent.FindAllTestsOnScene().Cast <ITestComponent> ().ToList());
            }
            if (GUILayout.Button(guiRunSelectedTests, Styles.buttonMid, layoutOptions) &&
                !EditorApplication.isPlayingOrWillChangePlaymode)
            {
                RunTests(Selection.gameObjects.Select(t => t.GetComponent(typeof(TestComponent))).Cast <ITestComponent> ().ToList());
            }
            if (GUILayout.Button(guiCreateNewTest, Styles.buttonRight, layoutOptions) &&
                !EditorApplication.isPlayingOrWillChangePlaymode)
            {
                var test = TestComponent.CreateTest();
                if (Selection.gameObjects.Length == 1 &&
                    Selection.activeGameObject != null &&
                    Selection.activeGameObject.GetComponent <TestComponent> ())
                {
                    test.transform.parent = Selection.activeGameObject.transform.parent;
                }
                Selection.activeGameObject = test;
                RebuildTestList();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(showOptions ? guiOptionsHideLabel : guiOptionsShowLabel, GUILayout.Height(24), GUILayout.Width(80)))
            {
                showOptions = !showOptions;
            }
            EditorGUILayout.EndHorizontal();

            if (showOptions)
            {
                PrintOptions();
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Filter:", GUILayout.Width(35));
            filterString = EditorGUILayout.TextField(filterString);
            if (GUILayout.Button(showAdvancedFilter ? guiAdvancedFilterHide : guiAdvancedFilterShow, GUILayout.Width(80), GUILayout.Height(16)))
            {
                showAdvancedFilter = !showAdvancedFilter;
            }
            EditorGUILayout.EndHorizontal();

            if (showAdvancedFilter)
            {
                PrintAdvancedFilter();
            }
        }
Beispiel #10
0
        public void Start()
        {
#if UNITY_EDITOR && !IMITATE_BATCH_MODE
            if (!UnityEditorInternal.InternalEditorUtility.inBatchMode)
            {
                return;
            }
#endif
            TestComponent.DestroyAllDynamicTests();
            var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(Application.loadedLevelName);
            foreach (var dynamicTestType in dynamicTestTypes)
            {
                TestComponent.CreateDynamicTest(dynamicTestType);
            }

            var tests = TestComponent.FindAllTestsOnScene();

            InitRunner(tests, dynamicTestTypes.Select(type => type.AssemblyQualifiedName).ToList());
        }
        public static void OnHierarchyChangeUpdate()
        {
            if (Instance.testLines == null || EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            //create a test runner if it doesn't exist
            TestRunner.GetTestRunner();

            if (Instance.settings.addNewGameObjectUnderSelectedTest &&
                Instance.selectedLine != null &&
                Selection.activeGameObject != null)
            {
                var go = Selection.activeGameObject;
                if (go.transform.parent == null &&
                    go.GetComponent <TestComponent> () == null &&
                    go.GetComponent <TestRunner> () == null)
                {
                    go.transform.parent = Instance.selectedLine.transform;
                }
            }

            //make tests are not places under a go that is not a test itself
            foreach (var test in TestComponent.FindAllTestsOnScene())
            {
                if (test.gameObject.transform.parent != null && test.gameObject.transform.parent.gameObject.GetComponent <TestComponent> () == null)
                {
                    test.gameObject.transform.parent = null;
                    Debug.LogWarning("Tests need to be on top of hierarchy or directly under another test.");
                }
            }
            if (selectedInHierarchy)
            {
                selectedInHierarchy = false;
            }
            else
            {
                Instance.RebuildTestList();
            }
        }