Exemplo n.º 1
0
        private bool DrawRecordTestButton(IEditorImguiTest test)
        {
            EditorGUILayout.BeginHorizontal();
            {
                if (EditorWindowTestRecorder.IsRecording && recordedTest == test)
                {
                    if (GUILayout.Button("Save the record"))
                    {
                        recorder.SendEvent(EditorGUIUtility.CommandEvent("SaveAndTerminate"));
                        return(true);
                    }

                    if (GUILayout.Button("Abort", GUILayout.Width(60f)))
                    {
                        recorder.SendEvent(EditorGUIUtility.CommandEvent("Abort"));
                        return(true);
                    }
                }
                else
                {
                    EditorGUI.BeginDisabledGroup(IsUiDisabled);
                    {
                        if (GUILayout.Button("Record"))
                        {
                            testMetadatas[test].State = TestState.Normal;
                            StartRecording(test);
                            return(true);
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
            }
            EditorGUILayout.EndHorizontal();
            return(false);
        }
Exemplo n.º 2
0
        private void DrawTestDescription(IEditorImguiTest test)
        {
            GUIStyle multilineLabel = new GUIStyle(EditorStyles.label)
            {
                wordWrap = true
            };

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Given", EditorStyles.label, GUILayout.Width(60f));
                EditorGUILayout.LabelField(test.GivenDescription, multilineLabel);
            }
            EditorGUILayout.EndHorizontal();

            GUILayoutUtility.GetRect(3f, 3f);

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("When", EditorStyles.label, GUILayout.Width(60f));
                EditorGUILayout.LabelField(test.WhenDescription, multilineLabel);
            }
            EditorGUILayout.EndHorizontal();

            GUILayoutUtility.GetRect(3f, 3f);

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Then", EditorStyles.label, GUILayout.Width(60f));
                EditorGUILayout.LabelField(test.ThenDescription, multilineLabel);
            }
            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 3
0
        private void UpdateCurrentTest()
        {
            testMetadatas[executedTest].State = TestState.Pending;
            bool isTestRunning;

            try
            {
                isTestRunning = currentTestExecutionEnumerator.MoveNext();
            }
            catch (Exception e)
            {
                logger.ErrorFormat("Test {0} failed:", e, executedTest.GetType().GetNameWithNesting());
                testMetadatas[executedTest].State = TestState.Failed;
                isTestRunning = false;
            }

            if (isTestRunning)
            {
                return;
            }

            executedTest.Teardown();
            executedTest = null;
            currentTestExecutionEnumerator = null;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Starts recording given <paramref name="test"/>.
        /// </summary>
        public void StartRecording(IEditorImguiTest test)
        {
            IsRecording = true;

            recordedWindow = test.BaseGiven();
            this.test      = test;

            userActions.Clear();

            TestableEditorElements.StartRecording();
        }
Exemplo n.º 5
0
 private void DrawRunTestButton(IEditorImguiTest test)
 {
     EditorGUI.BeginDisabledGroup(IsUiDisabled);
     {
         if (GUILayout.Button("Run", GUILayout.Width(40f)))
         {
             StartTest(test);
         }
     }
     EditorGUI.EndDisabledGroup();
 }
Exemplo n.º 6
0
        private void StartRecording(IEditorImguiTest test)
        {
            foreach (EditorWindowTestRecorder w in Resources.FindObjectsOfTypeAll <EditorWindowTestRecorder>())
            {
                w.Close();
            }

            recordedTest = test;

            recorder = CreateInstance <EditorWindowTestRecorder>();
            recorder.ShowUtility();

            recorder.StartRecording(test);
        }
Exemplo n.º 7
0
        private void DrawTestView(IEditorImguiTest test)
        {
            EditorGUILayout.BeginHorizontal();
            {
                // GUILayout does not support indentation so draw one in front of GUILayoutButton manually.
                GUILayout.Space(20f);

                DrawRunTestButton(test);

                EditorGUILayout.BeginVertical();
                {
                    // Draw foldout.
                    GUIStyle foldout = new GUIStyle(EditorStyles.foldout);
                    if (testMetadatas[test].FoldedOut)
                    {
                        foldout.fontStyle = FontStyle.Bold;
                    }

                    testMetadatas[test].FoldedOut = EditorGUILayout.Foldout(testMetadatas[test].FoldedOut, test.GetType().Name, foldout);

                    // Draw a test state indicator to the left of the foldout.
                    Rect foldoutRect = GUILayoutUtility.GetLastRect();
                    DrawTestStateIndicator(new Vector2(61f, foldoutRect.y), testMetadatas[test].State);

                    // Draw foldout contents, if necessary.
                    if (testMetadatas[test].FoldedOut)
                    {
                        DrawTestDescription(test);
                        if (DrawRecordTestButton(test))
                        {
                            // Workaround for EndHorizontal.
                            return;
                        }
                        GUILayoutUtility.GetRect(3f, 3f);
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 8
0
 private void StartTest(IEditorImguiTest test)
 {
     executedTest                   = test;
     executedTest.Finished         += OnCurrentTestFinished;
     currentTestExecutionEnumerator = test.Test();
 }