public virtual TNode AddToXml(TNode parentNode, bool recursive) { // A result node looks like a test node with extra info added TNode thisNode = Test.AddToXml(parentNode, false); thisNode.AddAttribute("result", ResultState.Status.ToString()); if (ResultState.Label != string.Empty) // && ResultState.Label != ResultState.Status.ToString()) { thisNode.AddAttribute("label", ResultState.Label); } if (ResultState.Site != FailureSite.Test) { thisNode.AddAttribute("site", ResultState.Site.ToString()); } thisNode.AddAttribute("start-time", StartTime.ToString("o")); thisNode.AddAttribute("end-time", EndTime.ToString("o")); thisNode.AddAttribute("duration", Duration.ToString("0.000000", NumberFormatInfo.InvariantInfo)); if (Test is TestSuite) { thisNode.AddAttribute("total", TotalCount.ToString()); thisNode.AddAttribute("passed", PassCount.ToString()); thisNode.AddAttribute("failed", FailCount.ToString()); thisNode.AddAttribute("warnings", WarningCount.ToString()); thisNode.AddAttribute("inconclusive", InconclusiveCount.ToString()); thisNode.AddAttribute("skipped", SkipCount.ToString()); } thisNode.AddAttribute("asserts", AssertCount.ToString()); switch (ResultState.Status) { case TestStatus.Failed: AddFailureElement(thisNode); break; case TestStatus.Skipped: case TestStatus.Passed: case TestStatus.Inconclusive: case TestStatus.Warning: if (Message != null && Message.Trim().Length > 0) { TNode reasonNode = thisNode.AddElement("reason"); reasonNode.AddElementWithCDATA("message", Message); } break; } if (Output.Length > 0) { AddOutputElement(thisNode); } if (AssertionResults.Count > 0) { AddAssertionsElement(thisNode); } if (_testAttachments.Count > 0) { AddAttachmentsElement(thisNode); } if (recursive && HasChildren) { foreach (var child in Children) { child.AddToXml(thisNode, recursive); } } return(thisNode); }
public void OnWindowDraw() { // update the count of different types of logs RefreshCount(); // update collapse logs count RefreshCollapseCount(); // draw the clear button and show the toggles of lock scroll and three types of log filters GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Clear", GUILayout.Width(100f))) { m_logs.Clear(); } m_collapse = GUILayout.Toggle(m_collapse, "Collapse", GUILayout.Width(120f)); m_infoFilter = GUILayout.Toggle(m_infoFilter, string.Format("Info ({0}) \t", InfoCount.ToString()), GUILayout.Width(80f)); m_warningFilter = GUILayout.Toggle(m_warningFilter, string.Format("Warning ({0}) \t", WarningCount.ToString()), GUILayout.Width(100f)); m_errorFilter = GUILayout.Toggle(m_errorFilter, string.Format("Error ({0}) \t", ErrorCount.ToString()), GUILayout.Width(100f)); GUILayout.FlexibleSpace(); m_lockScroll = GUILayout.Toggle(m_lockScroll, "Lock Scroll", GUILayout.Width(100f)); } GUILayout.EndHorizontal(); // draw the log message console panel GUILayout.BeginVertical("box"); { if (m_lockScroll) { m_logScrollPosition.y = float.MaxValue; } m_logScrollPosition = GUILayout.BeginScrollView(m_logScrollPosition, GUILayout.Height(200f)); { bool selected = false; for (LinkedListNode <LogMsg> i = m_logs.First; i != null; i = i.Next) { switch (i.Value.LogType) { case LogType.Log: if (!m_infoFilter) { continue; } break; case LogType.Warning: if (!m_warningFilter) { continue; } break; case LogType.Error: if (!m_errorFilter) { continue; } break; } if (m_collapse) { LogType type = i.Value.LogType; string msg = i.Value.LogMessage; string stack = i.Value.StackTrack; string keyCheck = type.ToString() + msg + stack; if (m_collapseLogs[keyCheck] == i.Value) { string s = string.Format("[{0}] {1} ", m_collapseCheckLogs[keyCheck], GetLogMsgString(i.Value)); if (GUILayout.Toggle(m_selectedLog == i, s)) { selected = true; if (m_selectedLog != i) { m_selectedLog = i; m_stackScrollPosition = Vector2.zero; } } } } else { // not collapse if (GUILayout.Toggle(m_selectedLog == i, GetLogMsgString(i.Value))) { selected = true; if (m_selectedLog != i) { m_selectedLog = i; m_stackScrollPosition = Vector2.zero; } } } } if (!selected) { m_selectedLog = null; } } GUILayout.EndScrollView(); } GUILayout.EndVertical(); // draw the log stack console panel GUILayout.BeginVertical("box"); { m_stackScrollPosition = GUILayout.BeginScrollView(m_stackScrollPosition, GUILayout.Height(100f)); { if (m_selectedLog != null) { GUILayout.BeginHorizontal(); Color32 color = GetLogMsgColor(m_selectedLog.Value.LogType); GUILayout.Label(string.Format("<color=#{0}{1}{2}{3}><b>{4}</b></color>", color.r.ToString("x2"), color.g.ToString("x2"), color.b.ToString("x2"), color.a.ToString("x2"), m_selectedLog.Value.LogMessage)); if (GUILayout.Button("COPY", GUILayout.Width(60f), GUILayout.Height(30f))) { TextEditor textEditor = new TextEditor(); textEditor.text = string.Format("{0}\n\n{1}", m_selectedLog.Value.LogMessage, m_selectedLog.Value.StackTrack); textEditor.OnFocus(); textEditor.Copy(); } GUILayout.EndHorizontal(); GUILayout.Label(m_selectedLog.Value.StackTrack); } GUILayout.EndScrollView(); } } GUILayout.EndVertical(); }