protected virtual string PathTo(TreeNode givenNode) { StringBuilder nodePath = new StringBuilder(); List<TreeNode> selectedNodePath = tree.GetPathTo(givenNode); foreach (TreeNode currentNode in selectedNodePath) { nodePath.AppendFormat("\"{0}\"", currentNode.Name); if (!selectedNodePath[selectedNodePath.Count - 1].Equals(currentNode)) nodePath.Append(","); } return nodePath.ToString(); }
private static TestGroup ParseTestGroup(TreeNode testGroupNode) { TestGroup testGroup = new TestGroup(testGroupNode.Text); testGroupNode.Expand(); for (int i = 0; i < testGroupNode.Nodes.Count; i++) { if (i < testGroupNode.Nodes.Count - 1) { EnsureTestCaseNodeIsOnScreen(testGroupNode.Nodes[i + 1]); } testGroup.Add(ParseTestCase(testGroupNode.Nodes[i])); } return testGroup; }
private static TestCase ParseTestCase(TreeNode testNode) { TestCase testResult = new TestCase(); testNode.Get<Label>("TestListViewDisplayNameTextBlock").Click(); testNode.Nodes.Count.Should().Be(0, "Test case tree node expected to have no children."); SearchCriteria isControlTypeLabel = SearchCriteria.ByControlType(typeof(Label), WindowsFramework.Wpf); // ReSharper disable once PossibleInvalidCastExceptionInForeachLoop foreach (Label label in GetTestExplorerDetailsPanel().GetMultiple(isControlTypeLabel)) { if (label.IsOffScreen || string.IsNullOrWhiteSpace(label.Text)) continue; AddInfoFromDetailPane(testResult, label); } return testResult; }
public TreeNodeSelectEvent(Tree tree, TreeNode node) : base(tree) { selectedNode = node; }
private void CheckEntityProperties(TreeNode node, string entityType, string entityProperty, string propertyValue) { Dte.ExecuteCommand("View.EntityDataModelBrowser"); ((ExpandCollapsePattern)node.AutomationElement.GetCurrentPattern(ExpandCollapsePattern.Pattern)).Expand(); foreach (var childNode in node.Nodes) { var currentNode = _entityNames.Find(el => el.Equals(childNode.Text)); if (string.IsNullOrEmpty(currentNode)) { continue; } Assert.AreEqual(string.Format(entityType, currentNode), childNode.Text); Dte.ExecuteCommand("View.EntityDataModelBrowser"); ((ExpandCollapsePattern)childNode.AutomationElement.GetCurrentPattern(ExpandCollapsePattern.Pattern)).Expand(); foreach (var propertyNode in childNode.Nodes) { Dte.ExecuteCommand("View.EntityDataModelBrowser"); ((SelectionItemPattern)propertyNode.AutomationElement.GetCurrentPattern(SelectionItemPattern.Pattern)).Select(); var cleanProperty = propertyNode.Text.Replace(entityProperty, ""); CheckProperties(string.Format(propertyValue, ModelName, currentNode, cleanProperty)); Assert.IsTrue(_entityAttributes.Contains(cleanProperty)); } } }
public TreeNodeClickedEvent(Tree tree, TreeNode node, bool isExpanded) : base(tree) { clickedNode = node; this.isExpanded = isExpanded; }
public virtual void Accept(TreeNode treeNode) { if (treeNode.Bounds.Top <= Mouse.Instance.Location.Y && treeNode.Bounds.Bottom >= Mouse.Instance.Location.Y) clickedNode = treeNode; }
/// <summary> /// Finds path to the TreeNode. It doesn't expand the nodes to find it. /// </summary> /// <param name="node"></param> /// <returns></returns> public virtual List<TreeNode> GetPathTo(TreeNode node) { return Nodes.GetPathTo(node); }
private static bool SafeIsNodeOnScreen(TreeNode node) { try { return node.Visible; } catch (ElementNotAvailableException) { return false; } }
// ReSharper disable once UnusedMethodReturnValue.Local private static bool EnsureTestCaseNodeIsOnScreen(TreeNode node) { if (SafeIsNodeOnScreen(node)) { return true; } Tree tree = GetTestCaseTree(); IVScrollBar scrollBar = tree.ScrollBars.Vertical; double initialValue = scrollBar.Value; while (scrollBar.Value < scrollBar.MaximumValue && !SafeIsNodeOnScreen(node)) { scrollBar.ScrollDownLarge(); } if (!SafeIsNodeOnScreen(node)) { scrollBar.SetToMinimum(); while (scrollBar.Value < initialValue && !SafeIsNodeOnScreen(node)) { scrollBar.ScrollDownLarge(); } } return SafeIsNodeOnScreen(node); }
private static bool EnsureTestGroupNodeIsOnScreen(TreeNode testGroupNode) { if (!SafeIsNodeOnScreen(testGroupNode) && testGroupNode.Nodes.Count > 0) { EnsureTestCaseNodeIsOnScreen(testGroupNode.Nodes[0]); } return SafeIsNodeOnScreen(testGroupNode); }
private static void ClickNode(TreeNode node) { EnsureTestCaseNodeIsOnScreen(node); node.Get<Label>("TestListViewDisplayNameTextBlock").Click(); }
private static IDictionary<string, TreeNode> FindTestCaseNodes(TreeNode testGroupNode, List<string> displayNames) { IDictionary<string, TreeNode> result = new Dictionary<string, TreeNode>(); testGroupNode.Expand(); for (int i = 0; result.Count < displayNames.Count && i < testGroupNode.Nodes.Count; i++) { TreeNode node = testGroupNode.Nodes[i]; EnsureTestCaseNodeIsOnScreen(node); foreach (string displayName in displayNames) { if (node.Text.StartsWith(displayName)) { result.Add(displayName, node); } } } return result; }