Exemplo n.º 1
0
        private void DrawHeader(int width)
        {
            GUI.enabled = !Application.isPlaying && rootNode != null;

            const int buttonOffset = 3;

            width -= 10;

            GUILayout.Space(5f);

            EditorGUILayout.BeginHorizontal();

            int buttonSize = width / 4 - buttonOffset;

            if (GUILayout.Button("Select all", GUILayout.Width(buttonSize)))
            {
                if (rootNode != null)
                {
                    rootNode.SetSelected(true);
                }
            }

            if (GUILayout.Button("Deselect all", GUILayout.Width(buttonSize)))
            {
                if (rootNode != null)
                {
                    if (rootNode.IsSemiSelected)
                    {
                        rootNode.SetSelected(true);
                    }

                    rootNode.SetSelected(false);
                }
            }

            if (GUILayout.Button("Run all", GUILayout.Width(buttonSize)))
            {
                if (rootNode != null)
                {
                    foreach (var method in AllMethodNodes)
                    {
                        method.ResetTestState();
                    }

                    RunTestsMode.SelectAllTests();
                    PlayModeTestRunner.Run();
                }
            }

            if (GUILayout.Button("Run smoke", GUILayout.Width(buttonSize)))
            {
                if (rootNode != null)
                {
                    ClearAllSmokeMethods();
                    RunTestsMode.SelectOnlySmokeTests();
                    PlayModeTestRunner.Run();
                }
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();


            if (GUILayout.Button("Run selected", GUILayout.Width(width * 0.25f - buttonOffset)))
            {
                if (rootNode != null)
                {
                    var children = rootNode.GetChildrenOfType <MethodNode>(true, false,
                                                                           node => node.IsSelected);

                    foreach (var testInfo in children)
                    {
                        testInfo.ResetTestState();
                    }

                    RunTestsMode.SelectOnlySelectedTests();
                    PlayModeTestRunner.Run();
                }
            }

            if (runTestsGivenAmountOfTimes == -1)
            {
                runTestsGivenAmountOfTimes = PlayModeTestRunner.RunTestsGivenAmountOfTimes;
            }


            GUI.enabled = true;
            GUI.SetNextControlName("Repeating");

            int newTimes = EditorGUILayout.IntSlider("Repeat Tests N Times:",
                                                     runTestsGivenAmountOfTimes, 1, 50);

            if (newTimes != runTestsGivenAmountOfTimes)
            {
                runTestsGivenAmountOfTimes = newTimes;

                PlayModeTestRunner.RunTestsGivenAmountOfTimes = newTimes;
            }

            EditorGUILayout.EndHorizontal();

            if (currentTimescale == -1)
            {
                currentTimescale = (int)PlayModeTestRunner.DefaultTimescale;
            }

            GUI.SetNextControlName("Timescale");

            int newTimescale = EditorGUILayout.IntSlider("Default Timescale:", currentTimescale, 1, 20);

            if (newTimescale != currentTimescale)
            {
                currentTimescale = newTimescale;
                PlayModeTestRunner.DefaultTimescale = currentTimescale;
            }

            GUI.enabled = !Application.isPlaying;

            var oldValue = ShowAdvancedOptions;

            ShowAdvancedOptions = EditorGUILayout.Foldout(ShowAdvancedOptions, "Advanced Options", true);
            if (ShowAdvancedOptions)
            {
                GUILayout.BeginVertical(EditorStyles.helpBox);
                AdvancedSettings();
                GUILayout.EndVertical();
            }

            if (oldValue != ShowAdvancedOptions)
            {
                editorUpdateEnabledForFrames = 10;
            }

            EditorGUILayout.LabelField("Playmode tests: ", EditorStyles.boldLabel);
            GUI.enabled = true;
        }
 public static void RunTestByDoubleClick(SpecificTestType type, Node node)
 {
     RunTestsMode.RunTestByDoubleClick(type, node);
     Run();
 }