private void OnTestErrorAsync(object sender, TestResultEventArgs args) { lock (this) { SmartTreeNode assemblyNode = FindAssemblyNode(sender as ITestAssembly); SmartTreeNode node = FindTestMethodNode(assemblyNode.Nodes, args.ClassName + "." + args.MethodName); if (node == null) { node = FindTestFixtureNode(assemblyNode.Nodes, args.ClassName); } AddCommentNode(ref node, string.Format("File {0}, Line {1}", args.FileName.Substring(args.FileName.LastIndexOf("\\") + 1), args.LineNumber)); SmartTreeNode commentNode = AddCommentNode(ref node, "Error: " + args.Reason); SetNodeError(ref node, Constants.ColorError); if (_config.ExpandCommentNodes) { commentNode.ExpandAll(); commentNode.LastNode.EnsureVisible(); } else { node.EnsureVisible(); } } }
private static SmartTreeNode CreateOrFindClassNode(ITestAssembly ta, SmartTreeNodeCollection nodes, string[] classFullNameParts, int index) { foreach (SmartTreeNode node in nodes) { if (node.Text == classFullNameParts[index]) { index++; if (index < classFullNameParts.Length) { return(CreateOrFindClassNode(ta, node.Nodes, classFullNameParts, index)); } else { return(node); } } } SmartTreeNode newNode = new SmartTreeNode(classFullNameParts[index]); newNode.ImageIndex = 1; newNode.Tag = new UiElementInfo(ta, new TestSuite(classFullNameParts, index)); nodes.Add(newNode); while (++index < classFullNameParts.Length) { SmartTreeNode child = new SmartTreeNode(classFullNameParts[index]); child.ImageIndex = 1; child.Tag = new UiElementInfo(ta, new TestSuite(classFullNameParts, index)); newNode.Nodes.Add(child); newNode = child; } newNode.ImageIndex = 2; newNode.Tag = null; return(newNode); }
private void CreateNodesFor(ITestAssembly ta, int assemblyNodePosition) { TestFixtureInfoCollection tests = ta.TestFixtureInfos; SmartTreeNode root = CreateOrFindAssemblyNode(ta, assemblyNodePosition); foreach (TestFixtureInfo tf in tests) { SmartTreeNode classNode = CreateOrFindClassNode(ta, root.Nodes, tf.FullName.Split(new char[] { '.', '+' }), 0); classNode.Tag = new UiElementInfo(ta, tf, null); classNode.ImageIndex = 2; foreach (TestMethodInfo tm in tf.TestMethods) { SmartTreeNode methodNode = CreateOrFindMethodNode(classNode.Nodes, tm); methodNode.Tag = new UiElementInfo(ta, tf, tm); } } TreeViewEventHandler temp = AfterSelect; AfterSelect = null; try { RestoreCheckState(root); SetCheckedStatus(_treeTestHierarchy.Nodes); } finally { AfterSelect = temp; } if (_config.AutoExpandTestHierarchy) { root.ExpandAll(); } }
private void OnTestPassedAsync(object sender, TestResultEventArgs args) { lock (this) { SmartTreeNode assemblyNode = FindAssemblyNode(sender as ITestAssembly); SmartTreeNode node = FindTestMethodNode(assemblyNode.Nodes, args.ClassName + "." + args.MethodName); SetNodeSuccess(ref node); if (node.IsVisible) { node.EnsureVisible(); } else { SmartTreeNode parent = node.Parent; while (parent != null) { if (parent.IsVisible) { parent.EnsureVisible(); break; } else { parent = parent.Parent; } } } } }
private static void UncheckNode(SmartTreeNode node) { node.Checked = false; foreach (SmartTreeNode child in node.Nodes) { UncheckNode(child); } }
private static void PropagateDown(SmartTreeNode node) { foreach (SmartTreeNode child in node.Nodes) { child.Checked = node.Checked; PropagateDown(child); } }
public void AddNodeViaIndexer() { _ownerTree.Nodes.Add(_rootNode); SmartTreeNode replacement = new SmartTreeNode("Replacement"); _ownerTree.Nodes[0] = replacement; Assert.Equals(_ownerTree, replacement.TreeView); }
public void LinksSetProperly() { SmartTreeNode first = new SmartTreeNode("First child"); SmartTreeNode last = new SmartTreeNode("Last child"); _rootNode.Nodes.Add(first); _rootNode.Nodes.Add(last); Assert.Equals(last, first.NextNode); Assert.Equals(first, last.PreviousNode); }
public void ParentProperlySet() { SmartTreeNode child = new SmartTreeNode("Child node"); _rootNode.Nodes.Add(child); Assert.Equals(_rootNode, child.Parent); Assert.Equals(1, _rootNode.Nodes.Count); }
public void AddRange() { SmartTreeNode first = new SmartTreeNode("First child"); SmartTreeNode last = new SmartTreeNode("Last child"); SmartTreeNode[] nodes = new SmartTreeNode[]{first, last}; _rootNode.Nodes.AddRange(nodes); Assert.Equals(2, _rootNode.Nodes.Count); Assert.Equals(last, first.NextNode); Assert.Equals(first, last.PreviousNode); }
public void RemoveUpdatesLinks() { SmartTreeNode first = new SmartTreeNode("First child"); SmartTreeNode last = new SmartTreeNode("Last child"); _rootNode.Nodes.Add(first); _rootNode.Nodes.Add(last); _rootNode.Nodes.Remove(last); Assert.Null(first.NextNode); Assert.Null(first.PreviousNode); }
public void RemovedNodeHasNoParent() { SmartTreeNode first = new SmartTreeNode("First child"); SmartTreeNode last = new SmartTreeNode("Last child"); _rootNode.Nodes.Add(first); _rootNode.Nodes.Add(last); _rootNode.Nodes.Remove(first); Assert.Null(first.Parent); }
private void _resultsList_DoubleClick(object sender, EventArgs e) { SmartTreeNode selectedItem = _resultsList.SelectedItem as SmartTreeNode; if (selectedItem != null) { //_treeTestHierarchy.SelectedNode = selectedItem; // TODO: implement this method [17apr08, ml] HideSearchPanel(); } }
public void AddRange() { SmartTreeNode first = new SmartTreeNode("First child"); SmartTreeNode last = new SmartTreeNode("Last child"); SmartTreeNode[] nodes = new SmartTreeNode[] { first, last }; _rootNode.Nodes.AddRange(nodes); Assert.Equals(2, _rootNode.Nodes.Count); Assert.Equals(last, first.NextNode); Assert.Equals(first, last.PreviousNode); }
private void OnMouseUp(object sender, MouseEventArgs args) { if (args.Button == MouseButtons.Right) { SmartTreeNode node = _treeTestHierarchy.GetNodeAt(args.X, args.Y); if (node != null) { _treeTestHierarchy.SelectedNodes.Add(node); UiElementInfo uiElemInfo = node.Tag as UiElementInfo; if (uiElemInfo != null) { // Convert from tree coordinates to screen coordinates, and then back // to form coordinates so that the context menu pops up at the right // position Point spot = PointToClient(_treeTestHierarchy.PointToScreen(new Point(args.X, args.Y))); _contextMenuStrip = new ContextMenuStrip(); if (FillContextMenu != null) { FillContextMenu(this, new CsUnitControlEventArgs(_contextMenuStrip, uiElemInfo)); } AppendMenuItemsForExpandCollapse(); _contextMenuStrip.Show(this, spot); _contextMenuStrip = null; } } //_treeTestHierarchy.SelectedNode = _treeTestHierarchy.GetNodeAt(args.X, args.Y); //if(_treeTestHierarchy.SelectedNode != null // && _treeTestHierarchy.SelectedNode.Tag != null // && _treeTestHierarchy.SelectedNode.Tag.GetType() == typeof(UiElementInfo)) { // UiElementInfo uiElemInfo = (UiElementInfo)_treeTestHierarchy.SelectedNode.Tag; // // Convert from tree coordinates to screen coordinates, and then back // // to form coordinates so that the context menu pops up at the right // // position // Point spot = PointToClient(_treeTestHierarchy.PointToScreen(new Point(args.X, args.Y))); // _contextMenuStrip = new ContextMenuStrip(); // if(FillContextMenu != null) { // FillContextMenu(this, new CsUnitControlEventArgs(_contextMenuStrip, uiElemInfo)); // } // AppendMenuItemsForExpandCollapse(); // _contextMenuStrip.Show(this, spot); // _contextMenuStrip = null; //} } }
public void LastNodeIsUnlinkedWhenRemoved() { SmartTreeNode first = new SmartTreeNode("First child"); SmartTreeNode last = new SmartTreeNode("Last child"); _rootNode.Nodes.Add(first); _rootNode.Nodes.Add(last); _rootNode.Nodes.Remove(last); Assert.Null(last.NextNode); Assert.Null(last.PreviousNode); }
public void UpdateCheckedItems(UiElementInfoCollection checkedItems) { UncheckAllNodes(); foreach (UiElementInfo info in checkedItems) { SmartTreeNode node = FindNodeFor(info); if (node != null) { node.Checked = true; } } }
/// <summary> /// Sets the background color of a node to 'newColor'. Then sets the /// background color of all parents recursively to the same 'newColor' as /// well. /// </summary> /// <param name="node">The node to start with.</param> /// <param name="newColor">The new background color.</param> private static void SetNodeFailed(ref SmartTreeNode node, Color newColor) { while (node.ImageIndex < 15) { node.ImageIndex += 5; } node.SelectedImageIndex = node.ImageIndex; if (node.Parent != null) { SmartTreeNode parent = node.Parent; SetNodeFailed(ref parent, newColor); } node.Expand(); }
public void ReplacingViaIndexerSetsParentAndOwner() { _ownerTree.Nodes.Add(_rootNode); Assert.Equals(_ownerTree, _rootNode.TreeView); SmartTreeNode first = new SmartTreeNode("First child"); SmartTreeNode last = new SmartTreeNode("Last child"); SmartTreeNode replacement = new SmartTreeNode("Replacement"); _rootNode.Nodes.Add(first); _rootNode.Nodes.Add(last); _rootNode.Nodes[1] = replacement; Assert.Equals(_rootNode, replacement.Parent); Assert.Equals(_ownerTree, replacement.TreeView); }
/// <summary> /// Sets the background color of a node to blue. Then sets the background /// color of all parents recursively to blue, if they have not been set /// yet to yellow or red. /// </summary> /// <param name="node">The node to start with.</param> private static void SetNodeSkipped(SmartTreeNode node) { while (node.ImageIndex < 10) { node.ImageIndex += 5; } node.SelectedImageIndex = node.ImageIndex; if (node.Parent != null) { SmartTreeNode parent = node.Parent; SetNodeSkipped(parent); } node.Expand(); }
private SmartTreeNode FindNodeFor(UiElementInfo info) { SmartTreeNode found = null; foreach (SmartTreeNode node in _treeTestHierarchy.Nodes) { found = SearchIn(node, info); if (found != null) { break; } } return(found); }
private static SmartTreeNode CreateOrFindMethodNode(SmartTreeNodeCollection nodes, ITestMethodInfo tm) { foreach (SmartTreeNode node in nodes) { if (node.Text == tm.Name) { return(node); } } SmartTreeNode newNode = new SmartTreeNode(tm.Name); newNode.ImageIndex = 3; nodes.Add(newNode); return(newNode); }
private void RestoreCheckState(SmartTreeNode root) { if ((root.Tag as UiElementInfo) != null) { UiElementInfo element = root.Tag as UiElementInfo; root.Checked = _checkedTestSelector.Contains(element); if (root.Checked) { root.EnsureVisible(); } } foreach (SmartTreeNode node in root.Nodes) { RestoreCheckState(node); } }
private static SmartTreeNode AddCommentNode(ref SmartTreeNode node, string comment) { SmartTreeNode commentNode = new SmartTreeNode(); commentNode.Tag = "CommentNode"; if (comment.IndexOf(" in ") != -1 && comment.IndexOf(" at ") != -1) { commentNode = AddCallStack(ref node, comment); } else { commentNode.Text = comment.Trim(); InsertNode(ref node, 0, ref commentNode); } return(commentNode); }
private static void PropagateUp(SmartTreeNode node) { if (node != null) { foreach (SmartTreeNode child in node.Nodes) { if (!child.Checked) { node.Checked = false; PropagateUp(node.Parent); return; } } node.Checked = true; PropagateUp(node.Parent); } }
/// <summary> /// Sets the background color of a node to green. If any of the parent /// nodes has no background color yet, their color is set to green as /// well. /// </summary> /// <param name="node">The node to start with.</param> private static void SetNodeSuccess(ref SmartTreeNode node) { if (node.ImageIndex < 5) { node.ImageIndex += 5; } node.SelectedImageIndex = node.ImageIndex; if (node.Parent != null) { SmartTreeNode parent = node.Parent; SetNodeSuccess(ref parent); } if (RecipeFactory.Current.TestRunKind == TestRunKind.RunChecked && node.Checked) { node.EnsureVisible(); } }
private void RemoveNodesFor(ITestAssembly ta) { SmartTreeNode assemblyNode = FindAssemblyNode(ta); if (assemblyNode != null) { for (int i = 0; i < _treeTestHierarchy.Nodes.Count; i++) { if (assemblyNode.Equals(_treeTestHierarchy.Nodes[i])) { break; } } assemblyNode.Remove(); } return; }
private void OnTestSkippedAsync(object sender, TestResultEventArgs args) { lock (this) { SmartTreeNode assemblyNode = FindAssemblyNode(sender as ITestAssembly); SmartTreeNode node = FindTestMethodNode(assemblyNode.Nodes, args.ClassName + "." + args.MethodName); if (node == null) { node = FindTestFixtureNode(assemblyNode.Nodes, args.ClassName); foreach (SmartTreeNode child in node.Nodes) { if (child.Tag is UiElementInfo) { SetNodeSkipped(child); } } } SetNodeSkipped(node); AddCommentNode(ref node, "Skip reason: " + args.Reason).EnsureVisible(); } }
private static SmartTreeNode AddCallStack(ref SmartTreeNode node, string comment) { int indexOfNewLine = comment.IndexOf('\n'); SmartTreeNode tn = new SmartTreeNode(comment.Substring(0, indexOfNewLine).Trim()); tn.Tag = "CommentNode"; InsertNode(ref node, 0, ref tn); string modified = comment.Substring(indexOfNewLine).Replace(" in ", "\nin "); string[] parts = modified.Split(new char[] { '\n' }); SmartTreeNode firstNode = node.FirstNode; for (int i = 1; i < parts.Length; i++) { SmartTreeNode commentPart = new SmartTreeNode(parts[i].Trim()); InsertNode(ref firstNode, i, ref commentPart); } return(tn); }
private static void Reset(SmartTreeNode node, List <SmartTreeNode> toBeRemoved) { foreach (SmartTreeNode child in node.Nodes) { while (child.ImageIndex > 4) { child.ImageIndex -= 5; } child.SelectedImageIndex = child.ImageIndex; child.BackColor = Constants.ColorReset; child.Collapse(); if (child.Tag is string && ((string)child.Tag).Equals("CommentNode")) { toBeRemoved.Add(child); } else { Reset(child, toBeRemoved); } } }
private static SmartTreeNode SearchIn(SmartTreeNode node, UiElementInfo info) { UiElementInfo currentInfo = node.Tag as UiElementInfo; if (currentInfo != null && currentInfo == info) { return(node); } else { foreach (SmartTreeNode currentNode in node.Nodes) { SmartTreeNode found = SearchIn(currentNode, info); if (found != null) { return(found); } } } return(null); }
public void FirstNodeIsUnlinkedWhenRemoved() { SmartTreeNode first = new SmartTreeNode("First child"); SmartTreeNode last = new SmartTreeNode("Last child"); _rootNode.Nodes.Add(first); _rootNode.Nodes.Add(last); _rootNode.Nodes.Remove(first); Assert.Null(first.NextNode); Assert.Null(first.PreviousNode); }
public void Setup() { _rootNode = new SmartTreeNode("Root Node"); }
public void Setup() { _ownerTree = new SmartTree(); _rootNode = new SmartTreeNode("Root Node"); }