Пример #1
0
        public void PrintOptions()
        {
            EditorGUILayout.BeginVertical();
            EditorGUI.BeginChangeCheck();

            var style = EditorStyles.toggle;

            //Temporary disabled
            //focusOnSelection = EditorGUILayoutExt.ToggleLeft((new GUIContent("Focus on selected test", "Focus on selected test")),
            //												focusOnSelection,
            //												style);

            addNewGameObjectUnderSelectedTest = EditorGUILayout.Toggle(guiAddGOUderTest,
                                                                       addNewGameObjectUnderSelectedTest,
                                                                       style);

            blockUIWhenRunning = EditorGUILayout.Toggle(guiBlockUI,
                                                        blockUIWhenRunning,
                                                        style);

            EditorGUI.BeginChangeCheck();
            hideTestsInHierarchy = EditorGUILayout.Toggle(guiHideTestInHierarchy,
                                                          hideTestsInHierarchy,
                                                          style);
            if (EditorGUI.EndChangeCheck())
            {
                TestManager.ShowOrHideTestInHierarchy(hideTestsInHierarchy);
                if (selectedTests.Count == 1)
                {
                    TestManager.SelectInHierarchy(selectedTests.Single().go, hideTestsInHierarchy);
                }
                EditorApplication.RepaintHierarchyWindow();
            }
            EditorGUI.BeginChangeCheck();
            showTestRunnerObjectOnScene = !EditorGUILayout.Toggle(guiHideTestRunner,
                                                                  !showTestRunnerObjectOnScene,
                                                                  style);
            if (EditorGUI.EndChangeCheck())
            {
                ShowTestRunnerObjectOnScene(showTestRunnerObjectOnScene);
            }

            if (EditorGUI.EndChangeCheck())
            {
                SaveSettings();
            }

            EditorGUILayout.EndVertical();
        }
Пример #2
0
        public void SelectInHierarchy(IEnumerable <GameObject> go)
        {
            selectedTests.Clear();
            selectedTests.AddRange(go.Select(o => testManager.GetResultFor(o)));
            if (selectedTests.Count() == 1)
            {
                TestManager.SelectInHierarchy(selectedTests.Single().go,
                                              hideTestsInHierarchy);
            }

            if (focusOnSelection && SceneView.currentDrawingSceneView != null)
            {
                SceneView.lastActiveSceneView.FrameSelected();
            }
        }
        public void OnGUI()
        {
            if (isRunning)
            {
                Repaint();
                if (!EditorApplication.isPlaying)
                {
                    isRunning = false;
                    Debug.Log("Test run was interrupted. Reseting Test Runner.");
                }
            }


#if !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2
            if (BuildPipeline.isBuildingPlayer)
            {
                isBuilding = true;
            }
            else if (isBuilding)
            {
                isBuilding = false;
                renderer.InvalidateTestList();
                Repaint();
            }
#endif
            if (!TestManager.AnyTestsOnScene())
            {
                renderer.PrintHeadPanel(isRunning);
                GUILayout.Label("No tests found on the scene",
                                EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
            }
            else
            {
                renderer.PrintHeadPanel(isRunning);
                renderer.PrintTestList();
                renderer.PrintSelectedTestDetails();
            }

            if (renderer.forceRepaint)
            {
                renderer.forceRepaint = false;
                Repaint();
            }
        }
Пример #4
0
        public void OnHierarchyChange(bool isRunning)
        {
            if (isRunning ||
                EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            if (addNewGameObjectUnderSelectedTest &&
                Selection.activeGameObject != null)
            {
                var go = Selection.activeGameObject;
                if (selectedTests.Count == 1 &&
                    go.transform.parent == null &&
                    go.GetComponent <TestComponent>() == null &&
                    go.GetComponent <TestRunner>() == null)
                {
                    go.transform.parent = selectedTests.Single().go.transform;
                }
            }

            if (keepTestComponentObjectsOnTop)
            {
                foreach (var test in TestManager.GetAllTestGameObjects())
                {
                    if (test.transform.parent != null)
                    {
                        test.transform.parent = null;
                        Debug.LogWarning("Tests need to be on top of hierarchy.");
                    }
                }
            }

            if (Selection.gameObjects.Count() > 1 &&
                Selection.gameObjects.All(o => o is GameObject && o.GetComponent <TestComponent>()))
            {
                selectedTests.Clear();
                selectedTests.AddRange(Selection.gameObjects.Select(go => testManager.GetResultFor(go)));
                forceRepaint = true;
            }
        }
Пример #5
0
        public IntegrationTestRunnerRenderer(Action <IList <GameObject> > RunTest)
        {
            testManager  = new TestManager();
            this.RunTest = RunTest;

            if (EditorPrefs.HasKey("ITR-addNewGameObjectUnderSelectedTest"))
            {
                addNewGameObjectUnderSelectedTest = EditorPrefs.GetBool("ITR-addNewGameObjectUnderSelectedTest");
                focusOnSelection              = EditorPrefs.GetBool("ITR-focusOnSelection");
                hideTestsInHierarchy          = EditorPrefs.GetBool("ITR-hideTestsInHierarchy");
                keepTestComponentObjectsOnTop = EditorPrefs.GetBool("ITR-keepTestComponentObjectsOnTop");
                showOptions = EditorPrefs.GetBool("ITR-showOptions");
                showTestRunnerObjectOnScene = EditorPrefs.GetBool("ITR-showTestRunnerObjectOnScene");
                blockUIWhenRunning          = EditorPrefs.GetBool("ITR-blockUIWhenRunning");
                showAdvancedFilter          = EditorPrefs.GetBool("ITR-showAdvancedFilter");
                filterString      = EditorPrefs.GetString("ITR-filterString");
                showSucceededTest = EditorPrefs.GetBool("ITR-showSucceededTest");
                showFailedTest    = EditorPrefs.GetBool("ITR-showFailedTest");
                showIgnoredTest   = EditorPrefs.GetBool("ITR-showIgnoredTest");
                showNotRunnedTest = EditorPrefs.GetBool("ITR-showNotRunnedTest");
            }
        }
		public IntegrationTestRunnerRenderer (Action<IList<GameObject>> RunTest)
		{
			testManager = new TestManager ();
			this.RunTest = RunTest;

			if (EditorPrefs.HasKey ("ITR-addNewGameObjectUnderSelectedTest"))
			{
				addNewGameObjectUnderSelectedTest = EditorPrefs.GetBool ("ITR-addNewGameObjectUnderSelectedTest");
				focusOnSelection = EditorPrefs.GetBool ("ITR-focusOnSelection");
				hideTestsInHierarchy = EditorPrefs.GetBool ("ITR-hideTestsInHierarchy");
				keepTestComponentObjectsOnTop = EditorPrefs.GetBool ("ITR-keepTestComponentObjectsOnTop");
				showOptions = EditorPrefs.GetBool ("ITR-showOptions");
				showTestRunnerObjectOnScene = EditorPrefs.GetBool ("ITR-showTestRunnerObjectOnScene");
				blockUIWhenRunning = EditorPrefs.GetBool ("ITR-blockUIWhenRunning");
				showAdvancedFilter = EditorPrefs.GetBool ("ITR-showAdvancedFilter");
				filterString = EditorPrefs.GetString ("ITR-filterString");
				showSucceededTest = EditorPrefs.GetBool ("ITR-showSucceededTest");
				showFailedTest = EditorPrefs.GetBool ("ITR-showFailedTest");
				showIgnoredTest = EditorPrefs.GetBool ("ITR-showIgnoredTest");
				showNotRunnedTest = EditorPrefs.GetBool ("ITR-showNotRunnedTest");
			}
		}
Пример #7
0
        public IntegrationTestRunnerRenderer(Action <IList <TestComponent> > RunTest)
        {
            testManager  = new TestManager();
            this.RunTest = RunTest;

            if (EditorPrefs.HasKey("ITR-addNewGameObjectUnderSelectedTest"))
            {
                addNewGameObjectUnderSelectedTest = EditorPrefs.GetBool("ITR-addNewGameObjectUnderSelectedTest");
                showOptions        = EditorPrefs.GetBool("ITR-showOptions");
                blockUIWhenRunning = EditorPrefs.GetBool("ITR-blockUIWhenRunning");
                showAdvancedFilter = EditorPrefs.GetBool("ITR-showAdvancedFilter");
                filterString       = EditorPrefs.GetString("ITR-filterString");
                showSucceededTest  = EditorPrefs.GetBool("ITR-showSucceededTest");
                showFailedTest     = EditorPrefs.GetBool("ITR-showFailedTest");
                showIgnoredTest    = EditorPrefs.GetBool("ITR-showIgnoredTest");
                showNotRunnedTest  = EditorPrefs.GetBool("ITR-showNotRunnedTest");
            }

#if !(UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2)
            Undo.undoRedoPerformed += InvalidateTestList;
#endif
        }
        public void OnSelectionChange()
        {
            if (isRunning || EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }
            if (Selection.objects != null &&
                Selection.objects.All(o => o is GameObject) &&
                Selection.objects.All(o => (o as GameObject).GetComponent <TestComponent>() != null))
            {
                renderer.SelectInHierarchy(Selection.objects.Select(o => o as GameObject));
                Repaint();
            }

            if (Selection.activeGameObject != null && Selection.activeGameObject.transform.parent != null)
            {
                var testGO = TestManager.FindTopGameObject(Selection.activeGameObject);
                if (testGO.GetComponent <TestComponent>() != null)
                {
                    renderer.SelectInHierarchy(new[] { testGO });
                }
            }
        }
 public void RunSelectedTest()
 {
     if (Selection.activeGameObject != null)
     {
         var activeGO    = Selection.activeGameObject;
         var topActiveGO = TestManager.FindTopGameObject(activeGO);
         if (topActiveGO.GetComponent <TestComponent>() != null)
         {
             RunTests(new List <GameObject>()
             {
                 topActiveGO
             });
         }
         else
         {
             Debug.LogWarning("Selected object or it's parent has no TestComponent attached.");
         }
     }
     else
     {
         Debug.LogWarning("No object is selected");
     }
 }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            if (!serializedObject.isEditingMultipleObjects)
            {
                var component = (TestComponent)target;
                component.name = EditorGUILayout.TextField(guiTestName, component.name);
                component.includedPlatforms = (TestComponent.IncludedPlatforms)EditorGUILayout.EnumMaskField(guiIncludePlatforms, component.includedPlatforms, EditorStyles.popup);
            }
            EditorGUILayout.PropertyField(timeout, guiTimeout);
            EditorGUILayout.PropertyField(ignored, guiIgnore);
            EditorGUILayout.PropertyField(succeedAssertions, guiSuccedOnAssertions);
            EditorGUILayout.PropertyField(expectException, guiExpectException);
            if (expectException.boolValue)
            {
                EditorGUILayout.PropertyField(expectedExceptionList, guiExpectExceptionList);
                EditorGUILayout.PropertyField(succeedWhenExceptionIsThrown, guiSucceedWhenExceptionIsThrown);
            }

            if (serializedObject.ApplyModifiedProperties() || GUI.changed)
            {
                TestManager.InvalidateTestList();
            }
        }
		public IntegrationTestRunnerRenderer (Action<IList<TestComponent>> RunTest)
		{
			testManager = new TestManager ();
			this.RunTest = RunTest;

			if (EditorPrefs.HasKey ("ITR-addNewGameObjectUnderSelectedTest"))
			{
				addNewGameObjectUnderSelectedTest = EditorPrefs.GetBool ("ITR-addNewGameObjectUnderSelectedTest");
				showOptions = EditorPrefs.GetBool ("ITR-showOptions");
				blockUIWhenRunning = EditorPrefs.GetBool ("ITR-blockUIWhenRunning");
				showAdvancedFilter = EditorPrefs.GetBool ("ITR-showAdvancedFilter");
				filterString = EditorPrefs.GetString ("ITR-filterString");
				showSucceededTest = EditorPrefs.GetBool ("ITR-showSucceededTest");
				showFailedTest = EditorPrefs.GetBool ("ITR-showFailedTest");
				showIgnoredTest = EditorPrefs.GetBool ("ITR-showIgnoredTest");
				showNotRunnedTest = EditorPrefs.GetBool ("ITR-showNotRunnedTest");
			}

#if !(UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2)
			Undo.undoRedoPerformed += InvalidateTestList;
#endif
		}