Exemple #1
0
        protected internal virtual void Render(int indend, RenderingOptions options)
        {
            if (!IsVisible(options))
            {
                return;
            }
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(indend * 10);

            var tempColor = GUI.color;

            if (IsRunning())
            {
                var frame = Mathf.Abs(Mathf.Cos(Time.realtimeSinceStartup * 4)) * 0.6f + 0.4f;
                GUI.color = new Color(1, 1, 1, frame);
            }

            var isSelected = Selection.gameObjects.Contains(gameObject);

            var value = GetResult();
            var icon  = GuiHelper.GetIconForResult(value);

            var label     = new GUIContent(name, icon);
            var labelRect = GUILayoutUtility.GetRect(label, EditorStyles.label, GUILayout.ExpandWidth(true), GUILayout.Height(18));

            OnLeftMouseButtonClick(labelRect);
            OnContextClick(labelRect);
            DrawLine(labelRect, label, isSelected, options);

            if (IsRunning())
            {
                GUI.color = tempColor;
            }
            EditorGUILayout.EndHorizontal();
        }
        public static void OnHierarchyWindowItemDraw(int id, Rect rect)
        {
            var o = EditorUtility.InstanceIDToObject(id);

            if (o is GameObject)
            {
                var go = o as GameObject;
                var tc = go.GetComponent <TestComponent> ();

                if (tc != null)
                {
                    if (!EditorApplication.isPlayingOrWillChangePlaymode &&
                        rect.Contains(Event.current.mousePosition) &&
                        Event.current.type == EventType.MouseDown &&
                        Event.current.button == 1)
                    {
                        IntegrationTestRendererBase.DrawContextMenu(tc);
                    }

                    EditorGUIUtility.SetIconSize(new Vector2(15, 15));
                    var result = Instance.resultList.Find(r => r.GameObject == go);

                    if (result != null)
                    {
                        var icon = result.Executed ? GuiHelper.GetIconForResult(result.resultType) : Icons.unknownImg;
                        EditorGUI.LabelField(new Rect(rect.xMax - 18, rect.yMin - 2, rect.width, rect.height), new GUIContent(icon));
                    }

                    EditorGUIUtility.SetIconSize(Vector2.zero);
                }

                if (Event.current.type == EventType.MouseDown &&
                    Event.current.button == 0 &&
                    rect.Contains(Event.current.mousePosition))
                {
                    var temp = go.transform;

                    while (temp != null)
                    {
                        var c = temp.GetComponent <TestComponent> ();

                        if (c != null)
                        {
                            break;
                        }

                        temp = temp.parent;
                    }

                    if (temp != null)
                    {
                        SelectInHierarchy(temp.gameObject);
                    }
                }
            }
        }
Exemple #3
0
        protected override void DrawLine(bool isSelected, RenderingOptions options)
        {
            var resultIcon = GetResult().HasValue ? GuiHelper.GetIconForResult(GetResult().Value) : Icons.unknownImg;

            var guiContent = new GUIContent(renderedName, resultIcon, fullName);

            var rect = GUILayoutUtility.GetRect(guiContent, Styles.foldout, GUILayout.MaxHeight(16));

            OnLeftMouseButtonClick(rect);
            OnContextClick(rect);

            EditorGUI.BeginChangeCheck();
            var expanded = !EditorGUI.Foldout(rect, !Folded, guiContent, false, isSelected ? Styles.selectedFoldout : Styles.foldout);

            if (EditorGUI.EndChangeCheck())
            {
                Folded = expanded;
            }
        }
        private bool PrintFoldoutAndCheckIfCollapsed(string fullName, string displayName, IEnumerable <UnitTestResult> unitTestResult)
        {
            Texture resultState = Icons.unknownImg;

            if (unitTestResult.Any(t => t.ResultState == TestResultState.Failure || t.ResultState == TestResultState.Error))
            {
                resultState = GuiHelper.GetIconForResult(TestResultState.Failure);
            }
            else if (unitTestResult.Any(t => t.ResultState == TestResultState.Success))
            {
                resultState = GuiHelper.GetIconForResult(TestResultState.Success);
            }
            else if (unitTestResult.All(t => t.IsIgnored))
            {
                resultState = GuiHelper.GetIconForResult(TestResultState.Ignored);
            }

            var isClassFolded = PrintFoldout(fullName, displayName, resultState);

            return(isClassFolded);
        }
Exemple #5
0
        protected override void DrawLine(bool isSelected, RenderingOptions options)
        {
            if (!IsVisible(options))
            {
                return;
            }

            var tempColor = GUI.color;

            if (result.Executed && result.Outdated)
            {
                GUI.color = new Color(1, 1, 1, 0.7f);
            }

            var icon = result.Executed || result.IsIgnored || result.ResultState == TestResultState.NotRunnable
                       ? GuiHelper.GetIconForResult(result.ResultState)
                       : Icons.UnknownImg;

            if (m_Test.RunState == RunState.Ignored)
            {
                icon = GuiHelper.GetIconForResult(TestResultState.Ignored);
            }

            m_Content.image = icon;

            var rect = GUILayoutUtility.GetRect(m_Content, Styles.testName, GUILayout.ExpandWidth(true));

            OnLeftMouseButtonClick(rect);
            OnContextClick(rect);

            if (Event.current.type == EventType.repaint)
            {
                Styles.testName.Draw(rect, m_Content, false, false, false, isSelected);
            }

            if (result.Outdated)
            {
                GUI.color = tempColor;
            }
        }
Exemple #6
0
        protected override void DrawLine(bool isSelected, RenderingOptions options)
        {
            if (!IsVisible(options))
            {
                return;
            }

            var tempColor = GUI.color;

            if (result.Executed && result.Outdated)
            {
                GUI.color = new Color(1, 1, 1, 0.7f);
            }

            var icon = result.Executed || result.IsIgnored || result.ResultState == TestResultState.NotRunnable
                       ? GuiHelper.GetIconForResult(result.ResultState)
                       : Icons.UnknownImg;

            if (m_Test.RunState == RunState.Ignored)
            {
                icon = GuiHelper.GetIconForResult(TestResultState.Ignored);
            }

            var guiContent = new GUIContent(m_RenderedName, icon, m_FullName);

            GUILayout.Space(10);
            var rect = GUILayoutUtility.GetRect(guiContent, EditorStyles.label, GUILayout.ExpandWidth(true) /*, GUILayout.MaxHeight (18)*/);

            OnLeftMouseButtonClick(rect);
            OnContextClick(rect);

            EditorGUI.LabelField(rect, guiContent, isSelected ? Styles.selectedLabel : Styles.label);

            if (result.Outdated)
            {
                GUI.color = tempColor;
            }
        }
        private void PrintTest(string printedName, UnitTestResult test)
        {
            EditorGUIUtility.SetIconSize(new Vector2(15, 15));
            GUILayout.BeginHorizontal(GUILayout.Height(18));

            var foldoutGUIContent = new GUIContent(printedName,
                                                   test.Executed || test.IsIgnored || test.ResultState == TestResultState.NotRunnable
                                                                ? GuiHelper.GetIconForResult(test.ResultState)
                                                                : Icons.unknownImg,
                                                   test.Test.FullName);

            Indent();
            GUILayout.Space(10);
            var rect = GUILayoutUtility.GetRect(foldoutGUIContent,
                                                EditorStyles.label, GUILayout.ExpandWidth(true) /*, GUILayout.MaxHeight (18)*/);

            if (rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                SelectTest(test);
                GUI.FocusControl("");
                if (Event.current.clickCount == 2 && selectedTests.Count == 1)
                {
                    OpenFailedTestOnError();
                }
            }
            else if (rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.ContextClick)
            {
                Event.current.Use();
                PrintTestContextMenu(test);
            }

            var style = IsTestSelected(test) ? Styles.selectedLabel : Styles.label;

            EditorGUI.LabelField(rect, foldoutGUIContent, style);

            GUILayout.EndHorizontal();
            EditorGUIUtility.SetIconSize(Vector2.zero);
        }