Beispiel #1
0
        public void ObjectBrowserFindAllReferencesTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\MultiModule.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                System.Threading.Thread.Sleep(1000);

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(3, nodeCount, "Node count: " + nodeCount.ToString());

                string str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("MyModule.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
                Assert.AreEqual("Program.py", str, "");

                objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(6, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[4].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                Condition con = new PropertyCondition(
                                        AutomationElement.ClassNameProperty,
                                        "ContextMenu"
                                    );
                AutomationElement el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                Menu menu = new Menu(el);
                int itemCount = menu.Items.Count;
                Assert.AreEqual(13, itemCount, "Item count: " + itemCount.ToString());
                menu.Items[4].Check();
                System.Threading.Thread.Sleep(1000);

                //this needs to be updated for bug #4840
                str = app.Dte.ActiveWindow.Caption;
                Assert.IsTrue(str.Contains("2 matches found"), str);

                objectBrowser.TypeBrowserPane.Nodes[2].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                menu = new Menu(el);
                menu.Items[4].Check();
                System.Threading.Thread.Sleep(1000);

                str = app.Dte.ActiveWindow.Caption;
                Assert.IsTrue(str.Contains("2 matches found"), str);
            }
        }
Beispiel #2
0
        public void ObjectBrowserTypeBrowserSortTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\MultiModule.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                System.Threading.Thread.Sleep(1000);

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(3, nodeCount, "Node count: " + nodeCount.ToString());

                string str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("MyModule.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
                Assert.AreEqual("Program.py", str, "");

                objectBrowser.TypeBrowserPane.Nodes[1].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                Condition con = new PropertyCondition(
                                        AutomationElement.ClassNameProperty,
                                        "ContextMenu"
                                    );
                AutomationElement el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                Menu menu = new Menu(el);
                int itemCount = menu.Items.Count;
                Assert.AreEqual(7, itemCount, "Item count: " + itemCount.ToString());
                menu.Items[6].Check();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(4, nodeCount, "Node count: " + nodeCount.ToString());
                objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(5, nodeCount, "Node count: " + nodeCount.ToString());
                Assert.AreEqual("Namespaces", objectBrowser.TypeBrowserPane.Nodes[3].Value, "");
                Assert.AreEqual("Namespaces", objectBrowser.TypeBrowserPane.Nodes[1].Value, "");
                objectBrowser.TypeBrowserPane.Nodes[3].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(6, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[3].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                objectBrowser.TypeBrowserPane.Nodes[0].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                menu = new Menu(el);
                itemCount = menu.Items.Count;
                Assert.AreEqual(7, itemCount, "Item count: " + itemCount.ToString());
                Assert.IsTrue(menu.Items[6].ToggleStatus);
                menu.Items[3].Check();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(4, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[3].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(6, nodeCount, "Node count: " + nodeCount.ToString());

                str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("MyModule.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
                Assert.AreEqual("SchoolMember", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[3].Value;
                Assert.AreEqual("Program.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[4].Value;
                Assert.AreEqual("Student", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[5].Value;
                Assert.AreEqual("Teacher", str, "");
            }
        }
Beispiel #3
0
        public void ObjectBrowserNavigateVarContextMenuTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\MultiModule.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                objectBrowser.EnsureLoaded();

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(3, nodeCount, "Node count: " + nodeCount.ToString());

                string str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("MyModule.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
                Assert.AreEqual("Program.py", str, "");

                objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(6, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[4].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                Condition con = new PropertyCondition(
                                        AutomationElement.ClassNameProperty,
                                        "ContextMenu"
                                    );
                AutomationElement el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                Menu menu = new Menu(el);
                int itemCount = menu.Items.Count;
                Assert.AreEqual(13, itemCount, "Item count: " + itemCount.ToString());
                menu.Items[0].Check();
                System.Threading.Thread.Sleep(1000);

                str = app.Dte.ActiveDocument.Name;
                Assert.AreEqual("Program.py", str, "");

                int lineNo = ((TextSelection)app.Dte.ActiveDocument.Selection).ActivePoint.Line;
                Assert.AreEqual(14, lineNo, "Line number: " + lineNo.ToString());

                app.OpenObjectBrowser();
                objectBrowser.TypeBrowserPane.Nodes[5].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                menu = new Menu(el);
                menu.Items[0].Check();
                System.Threading.Thread.Sleep(1000);

                lineNo = ((TextSelection)app.Dte.ActiveDocument.Selection).ActivePoint.Line;
                Assert.AreEqual(3, lineNo, "Line number: " + lineNo.ToString());
            }
        }
Beispiel #4
0
        public void ObjectBrowserContextMenuBasicTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\MultiModule.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                System.Threading.Thread.Sleep(1000);

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(3, nodeCount, "Node count: " + nodeCount.ToString());

                string str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("MyModule.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
                Assert.AreEqual("Program.py", str, "");

                objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(6, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[1].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                Condition con = new PropertyCondition(
                                        AutomationElement.ClassNameProperty,
                                        "ContextMenu"
                                    );
                AutomationElement el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                Menu menu = new Menu(el);
                int itemCount = menu.Items.Count;
                Assert.AreEqual(7, itemCount, "Item count: " + itemCount.ToString());
                Assert.AreEqual("Copy", menu.Items[0].Value.Trim(), "");
                Assert.AreEqual("View Namespaces", menu.Items[1].Value.Trim(), "");
                Assert.AreEqual("View Containers", menu.Items[2].Value.Trim(), "");
                Assert.AreEqual("Sort Alphabetically", menu.Items[3].Value.Trim(), "");
                Assert.AreEqual("Sort By Object Type", menu.Items[4].Value.Trim(), "");
                Assert.AreEqual("Sort By Object Access", menu.Items[5].Value.Trim(), "");
                Assert.AreEqual("Group By Object Type", menu.Items[6].Value.Trim(), "");
                Keyboard.PressAndRelease(System.Windows.Input.Key.Escape);

                objectBrowser.TypeBrowserPane.Nodes[2].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                menu = new Menu(el);
                itemCount = menu.Items.Count;
                Assert.AreEqual(13, itemCount, "Item count: " + itemCount.ToString());
                Assert.AreEqual("Go To Definition", menu.Items[0].Value.Trim(), "");
                Assert.AreEqual("Go To Declaration", menu.Items[1].Value.Trim(), "");
                Assert.AreEqual("Go To Reference", menu.Items[2].Value.Trim(), "");
                Assert.AreEqual("Browse Definition", menu.Items[3].Value.Trim(), "");
                Assert.AreEqual("Find All References", menu.Items[4].Value.Trim(), "");
                Assert.AreEqual("Filter To Type", menu.Items[5].Value.Trim(), "");
                Assert.AreEqual("Copy", menu.Items[6].Value.Trim(), "");
                Assert.AreEqual("View Namespaces", menu.Items[7].Value.Trim(), "");
                Assert.AreEqual("View Containers", menu.Items[8].Value.Trim(), "");
                Assert.AreEqual("Sort Alphabetically", menu.Items[9].Value.Trim(), "");
                Assert.AreEqual("Sort By Object Type", menu.Items[10].Value.Trim(), "");
                Assert.AreEqual("Sort By Object Access", menu.Items[11].Value.Trim(), "");
                Assert.AreEqual("Group By Object Type", menu.Items[12].Value.Trim(), "");
                Keyboard.PressAndRelease(System.Windows.Input.Key.Escape);
            }
        }