public void ObjectBrowserBasicTest() { var app = new VisualStudioApp(VsIdeTestHostContext.Dte); var project = DebugProject.OpenProject(@"Python.VS.TestData\Outlining.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()); string str = objectBrowser.TypeBrowserPane.Nodes[0].Value; Assert.AreEqual("Program.py", str, ""); objectBrowser.TypeBrowserPane.Nodes[0].Select(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeNavigatorPane.Nodes.Count; Assert.AreEqual(1, nodeCount, "Node Count: " + nodeCount.ToString()); str = objectBrowser.TypeNavigatorPane.Nodes[0].Value; Assert.AreEqual("f()", str.Trim(), ""); str = objectBrowser.DetailPane.Value; Assert.AreEqual("Program.py", str.Trim(), ""); }
public void TestPublishFilesControlled() { var project = DebugProject.OpenProject(@"Python.VS.TestData\PublishTest.sln"); try { string subDir = Guid.NewGuid().ToString(); project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePublic, subDir); string dir = Path.Combine(TestSharePublic, subDir); var app = new VisualStudioApp(VsIdeTestHostContext.Dte); app.OpenSolutionExplorer(); var window = app.SolutionExplorerTreeView; // find Program.py, send copy & paste, verify copy of file is there var programPy = window.FindItem("Solution 'PublishTest' (1 project)", "HelloWorld"); programPy.SetFocus(); ThreadPool.QueueUserWorkItem(x => VsIdeTestHostContext.Dte.ExecuteCommand("Build.PublishSelection")); System.Threading.Thread.Sleep(2000); var files = Directory.GetFiles(dir); Assert.AreEqual(files.Length, 2); files = files.Select(x => Path.GetFileName(x)).ToArray(); Assert.IsTrue(files.Contains("Program.py")); Assert.IsTrue(files.Contains("TextFile.txt")); Directory.Delete(dir, true); } finally { project.Properties.Item("PublishUrl").Value = ""; } }
public void LaunchProject() { var profiling = (IPythonProfiling)VsIdeTestHostContext.Dte.GetObject("PythonProfiling"); // no sessions yet Assert.AreEqual(profiling.GetSession(1), null); var project = DebugProject.OpenProject(@"Python.VS.TestData\ProfileTest.sln"); var session = profiling.LaunchProject(project, false); try { while (profiling.IsProfiling) { System.Threading.Thread.Sleep(100); } var report = session.GetReport(1); var filename = report.Filename; Assert.IsTrue(filename.Contains("HelloWorld")); Assert.AreEqual(session.GetReport(2), null); Assert.AreNotEqual(session.GetReport(report.Filename), null); VerifyReport(report, "Program.f", "time.sleep"); } finally { profiling.RemoveSession(session, true); } }
public void TestRemoveReport() { var profiling = (IPythonProfiling)VsIdeTestHostContext.Dte.GetObject("PythonProfiling"); // no sessions yet Assert.AreEqual(profiling.GetSession(1), null); var project = DebugProject.OpenProject(@"Python.VS.TestData\ProfileTest.sln"); var session = profiling.LaunchProject(project, false); try { PythonVisualStudioApp app; string reportFilename; WaitForReport(profiling, session, out app, out reportFilename); new RemoveItemDialog(app.WaitForDialog()).Remove(); app.WaitForDialogDismissed(); Assert.IsTrue(File.Exists(reportFilename)); } finally { profiling.RemoveSession(session, true); } }
public void TestOpenReport() { var profiling = (IPythonProfiling)VsIdeTestHostContext.Dte.GetObject("PythonProfiling"); // no sessions yet Assert.AreEqual(profiling.GetSession(1), null); var project = DebugProject.OpenProject(@"Python.VS.TestData\ProfileTest.sln"); var session = profiling.LaunchProject(project, false); try { IPythonPerformanceReport report; PythonVisualStudioApp app; AutomationElement child; WaitForReport(profiling, session, out report, out app, out child); var clickPoint = child.GetClickablePoint(); Mouse.MoveTo(clickPoint); Mouse.DoubleClick(System.Windows.Input.MouseButton.Left); Assert.AreNotEqual(null, app.WaitForDocument(report.Filename)); app.Dte.Documents.CloseAll(EnvDTE.vsSaveChanges.vsSaveChangesNo); } finally { profiling.RemoveSession(session, true); } }
public void LaunchPythonProfilingWizard() { var app = new PythonVisualStudioApp(VsIdeTestHostContext.Dte); var project = DebugProject.OpenProject(@"Python.VS.TestData\ProfileTest.sln"); app.LaunchPythonProfiling(); // wait for the dialog, set some settings, save them. var perfTarget = new PythonPerfTarget(app.WaitForDialog()); perfTarget.SelectProfileProject(); perfTarget.SelectedProjectComboBox.SelectItem("HelloWorld"); perfTarget.Ok(); app.WaitForDialogDismissed(); var profiling = (IPythonProfiling)VsIdeTestHostContext.Dte.GetObject("PythonProfiling"); var session = profiling.GetSession(1); try { Assert.AreNotEqual(null, app.PythonPerformanceExplorerTreeView.WaitForItem("HelloWorld *")); while (profiling.IsProfiling) { // wait for profiling to finish... System.Threading.Thread.Sleep(100); } } finally { profiling.RemoveSession(session, true); } }
public void ObjectBrowserExpandTypeBrowserTest() { var app = new VisualStudioApp(VsIdeTestHostContext.Dte); var project = DebugProject.OpenProject(@"Python.VS.TestData\Inheritance.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()); string str = objectBrowser.TypeBrowserPane.Nodes[0].Value; Assert.AreEqual("Program.py", str, ""); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count; Assert.AreEqual(4, nodeCount, "Node count: " + nodeCount.ToString()); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count; Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString()); }
public void ObjectBrowserSearchTextTest() { var app = new VisualStudioApp(VsIdeTestHostContext.Dte); var project = DebugProject.OpenProject(@"Python.VS.TestData\Outlining.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()); string str = objectBrowser.TypeBrowserPane.Nodes[0].Value; Assert.AreEqual("Program.py", str, ""); nodeCount = objectBrowser.TypeNavigatorPane.Nodes.Count; Assert.AreEqual(1, nodeCount, "Node Count: " + nodeCount.ToString()); objectBrowser.SearchText.SetValue("f"); System.Threading.Thread.Sleep(1000); objectBrowser.SearchButton.Click(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count; Assert.IsTrue(nodeCount >= 1, "Node count: " + nodeCount.ToString()); if (objectBrowser.TypeBrowserPane.Nodes[0].Value.ToLower().Contains("namespace")) { objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); Assert.AreEqual("f", objectBrowser.TypeBrowserPane.Nodes[1].Value.Trim(), ""); objectBrowser.TypeBrowserPane.Nodes[1].Select(); System.Threading.Thread.Sleep(1000); } else { Assert.AreEqual("f", objectBrowser.TypeBrowserPane.Nodes[0].Value.Trim(), ""); } str = objectBrowser.DetailPane.Value; Assert.AreEqual("def f()", str.Trim(), ""); objectBrowser.ClearSearchButton.Click(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count; Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString()); str = objectBrowser.TypeBrowserPane.Nodes[0].Value; Assert.AreEqual("Program.py", str, ""); nodeCount = objectBrowser.TypeNavigatorPane.Nodes.Count; Assert.AreEqual(1, nodeCount, "Node Count: " + nodeCount.ToString()); }
public void ObjectBrowserCommentsTest() { var app = new VisualStudioApp(VsIdeTestHostContext.Dte); var project = DebugProject.OpenProject(@"Python.VS.TestData\Inheritance.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()); string str = objectBrowser.TypeBrowserPane.Nodes[0].Value; Assert.AreEqual("Program.py", str, ""); nodeCount = objectBrowser.TypeNavigatorPane.Nodes.Count; Assert.AreEqual(3, nodeCount, "Node Count: " + nodeCount.ToString()); str = objectBrowser.TypeNavigatorPane.Nodes[0].Value; Assert.AreEqual("members", str.Trim(), ""); str = objectBrowser.TypeNavigatorPane.Nodes[1].Value; Assert.AreEqual("s", str.Trim(), ""); str = objectBrowser.TypeNavigatorPane.Nodes[2].Value; Assert.AreEqual("t", str.Trim(), ""); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count; Assert.AreEqual(4, nodeCount, "Node count: " + nodeCount.ToString()); objectBrowser.TypeBrowserPane.Nodes[1].Select(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeNavigatorPane.Nodes.Count; Assert.AreEqual(2, nodeCount, "Node Count: " + nodeCount.ToString()); str = objectBrowser.TypeNavigatorPane.Nodes[0].Value; Assert.IsTrue(str.Trim().StartsWith("__init__(self"), str); str = objectBrowser.TypeNavigatorPane.Nodes[1].Value; Assert.AreEqual("tell(self)", str.Trim(), ""); str = objectBrowser.DetailPane.Value; Assert.IsTrue(str.Trim().Contains("SchoolMember"), str); Assert.IsTrue(str.Trim().Contains("Represents any school member."), str); objectBrowser.TypeNavigatorPane.Nodes[1].Select(); System.Threading.Thread.Sleep(1000); str = objectBrowser.DetailPane.Value; Assert.IsTrue(str.Trim().Contains("def tell(self)"), str); Assert.IsTrue(str.Trim().Contains("Tell my detail."), str); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); }
public void ObjectBrowserNavigationTest() { var app = new VisualStudioApp(VsIdeTestHostContext.Dte); var project = DebugProject.OpenProject(@"Python.VS.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(2, nodeCount, "Node count: " + nodeCount.ToString()); string str = objectBrowser.TypeBrowserPane.Nodes[0].Value; Assert.AreEqual("MyModule.py", str, ""); str = objectBrowser.TypeBrowserPane.Nodes[1].Value; Assert.AreEqual("Program.py", str, ""); objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse(); System.Threading.Thread.Sleep(1000); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count; Assert.AreEqual(5, nodeCount, "Node count: " + nodeCount.ToString()); objectBrowser.TypeBrowserPane.Nodes[3].Select(); System.Threading.Thread.Sleep(1000); objectBrowser.TypeBrowserPane.Nodes[3].DoubleClick(); 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()); objectBrowser.TypeBrowserPane.Nodes[1].Select(); System.Threading.Thread.Sleep(1000); objectBrowser.TypeBrowserPane.Nodes[1].DoubleClick(); System.Threading.Thread.Sleep(1000); str = app.Dte.ActiveDocument.Name; Assert.AreEqual("MyModule.py", str, ""); lineNo = ((TextSelection)app.Dte.ActiveDocument.Selection).ActivePoint.Line; Assert.AreEqual(1, lineNo, "Line number: " + lineNo.ToString()); objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse(); System.Threading.Thread.Sleep(1000); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); }
public void ObjectBrowserTypeBrowserViewTest() { var app = new VisualStudioApp(VsIdeTestHostContext.Dte); var project = DebugProject.OpenProject(@"Python.VS.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(2, nodeCount, "Node count: " + nodeCount.ToString()); string str = objectBrowser.TypeBrowserPane.Nodes[0].Value; Assert.AreEqual("MyModule.py", str, ""); str = objectBrowser.TypeBrowserPane.Nodes[1].Value; Assert.AreEqual("Program.py", str, ""); objectBrowser.TypeBrowserPane.Nodes[0].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[1].Check(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count; Assert.AreEqual(8, nodeCount, "Node count: " + nodeCount.ToString()); 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(11, itemCount, "Item count: " + itemCount.ToString()); Assert.IsTrue(menu.Items[5].ToggleStatus); menu.Items[6].Check(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count; Assert.AreEqual(2, nodeCount, "Node count: " + nodeCount.ToString()); }
public void TestPublishFilesImpersonate() { var project = DebugProject.OpenProject(@"Python.VS.TestData\HelloWorld.sln"); try { string subDir = Guid.NewGuid().ToString(); project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir); string dir = Path.Combine(TestSharePrivate, subDir); var app = new VisualStudioApp(VsIdeTestHostContext.Dte); app.OpenSolutionExplorer(); var window = app.SolutionExplorerTreeView; // find Program.py, send copy & paste, verify copy of file is there var programPy = window.FindItem("Solution 'HelloWorld' (1 project)", "HelloWorld"); programPy.SetFocus(); ThreadPool.QueueUserWorkItem(x => VsIdeTestHostContext.Dte.ExecuteCommand("Build.PublishSelection")); var creds = new CredentialsDialog(app.WaitForDialog()); creds.UserName = PrivateShareUser; creds.Password = PrivateSharePassword; creds.Ok(); System.Threading.Thread.Sleep(2000); using (var impHelper = new ImpersonationHelper(new System.Net.NetworkCredential(PrivateShareUser.Split('\\')[1], PrivateSharePassword, PrivateShareUser.Split('\\')[0]))) { for (int i = 0; i < 10 && !Directory.Exists(dir); i++) { System.Threading.Thread.Sleep(1000); } var files = Directory.GetFiles(dir); Assert.AreEqual(files.Length, 1); Assert.AreEqual(Path.GetFileName(files[0]), "Program.py"); Directory.Delete(dir, true); } } finally { project.Properties.Item("PublishUrl").Value = ""; } }
public void TestSaveDirtySession() { var profiling = (IPythonProfiling)VsIdeTestHostContext.Dte.GetObject("PythonProfiling"); // no sessions yet Assert.AreEqual(profiling.GetSession(1), null); var project = DebugProject.OpenProject(@"Python.VS.TestData\ProfileTest.sln"); var session = profiling.LaunchProject(project, false); try { while (profiling.IsProfiling) { System.Threading.Thread.Sleep(100); } var report = session.GetReport(1); var filename = report.Filename; Assert.IsTrue(filename.Contains("HelloWorld")); var app = new PythonVisualStudioApp(VsIdeTestHostContext.Dte); app.OpenPythonPerformance(); var pyPerf = app.PythonPerformanceExplorerTreeView; Assert.AreNotEqual(null, pyPerf); var item = pyPerf.FindItem("HelloWorld *", "Reports"); var child = item.FindFirst(System.Windows.Automation.TreeScope.Descendants, Condition.TrueCondition); var childName = child.GetCurrentPropertyValue(AutomationElement.NameProperty) as string; Assert.IsTrue(childName.StartsWith("HelloWorld")); // select the dirty session node and save it var perfSessionItem = pyPerf.FindItem("HelloWorld *"); perfSessionItem.SetFocus(); app.SaveSelection(); // now it should no longer be dirty perfSessionItem = pyPerf.WaitForItem("HelloWorld"); } finally { profiling.RemoveSession(session, true); } }
public void NewProfilingSessionOpenSolution() { var app = new PythonVisualStudioApp(VsIdeTestHostContext.Dte); var project = DebugProject.OpenProject(@"Python.VS.TestData\ProfileTest.sln"); app.PythonPerformanceExplorerToolBar.NewPerfSession(); var profiling = (IPythonProfiling)VsIdeTestHostContext.Dte.GetObject("PythonProfiling"); var perf = app.PythonPerformanceExplorerTreeView.WaitForItem("Performance"); var session = profiling.GetSession(1); Assert.AreNotEqual(session, null); try { Mouse.MoveTo(perf.GetClickablePoint()); Mouse.DoubleClick(System.Windows.Input.MouseButton.Left); // wait for the dialog, set some settings, save them. var perfTarget = new PythonPerfTarget(app.WaitForDialog()); perfTarget.SelectProfileProject(); perfTarget.SelectedProjectComboBox.SelectItem("HelloWorld"); perfTarget.Ok(); app.WaitForDialogDismissed(); Mouse.MoveTo(perf.GetClickablePoint()); Mouse.DoubleClick(System.Windows.Input.MouseButton.Left); // re-open the dialog, verify the settings perfTarget = new PythonPerfTarget(app.WaitForDialog()); Assert.AreEqual("HelloWorld", perfTarget.SelectedProject); perfTarget.Ok(); } finally { profiling.RemoveSession(session, true); } }
public void TestPublishFtp() { var project = DebugProject.OpenProject(@"Python.VS.TestData\HelloWorld.sln"); try { string subDir = Guid.NewGuid().ToString(); string url = TestFtpUrl + "/" + subDir; project.Properties.Item("PublishUrl").Value = url; string dir = Path.Combine(FtpValidateDir, subDir); var app = new VisualStudioApp(VsIdeTestHostContext.Dte); app.OpenSolutionExplorer(); var window = app.SolutionExplorerTreeView; // find Program.py, send copy & paste, verify copy of file is there var programPy = window.FindItem("Solution 'HelloWorld' (1 project)", "HelloWorld"); programPy.SetFocus(); ThreadPool.QueueUserWorkItem(x => VsIdeTestHostContext.Dte.ExecuteCommand("Build.PublishSelection")); System.Threading.Thread.Sleep(2000); var files = Directory.GetFiles(dir); Assert.AreEqual(files.Length, 1); Assert.AreEqual(Path.GetFileName(files[0]), "Program.py"); // do it again w/ the directories already existing File.Delete(files[0]); programPy.SetFocus(); ThreadPool.QueueUserWorkItem(x => VsIdeTestHostContext.Dte.ExecuteCommand("Build.PublishSelection")); System.Threading.Thread.Sleep(2000); files = Directory.GetFiles(dir); Assert.AreEqual(files.Length, 1); Assert.AreEqual(Path.GetFileName(files[0]), "Program.py"); Directory.Delete(dir, true); } finally { project.Properties.Item("PublishUrl").Value = ""; } }
public void TestPublishFilesImpersonateCancelCredentials() { var project = DebugProject.OpenProject(@"Python.VS.TestData\HelloWorld.sln"); try { string subDir = Guid.NewGuid().ToString(); project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir); string dir = Path.Combine(TestSharePrivate, subDir); var app = new VisualStudioApp(VsIdeTestHostContext.Dte); app.OpenSolutionExplorer(); var window = app.SolutionExplorerTreeView; // find Program.py, send copy & paste, verify copy of file is there var programPy = window.FindItem("Solution 'HelloWorld' (1 project)", "HelloWorld"); programPy.SetFocus(); ThreadPool.QueueUserWorkItem(x => VsIdeTestHostContext.Dte.ExecuteCommand("Build.PublishSelection")); var creds = new CredentialsDialog(app.WaitForDialog()); creds.UserName = PrivateShareUser; creds.Password = PrivateSharePasswordIncorrect; creds.Cancel(); System.Threading.Thread.Sleep(2000); var statusBar = (IVsStatusbar)VsIdeTestHostContext.ServiceProvider.GetService(typeof(SVsStatusbar)); string text; ErrorHandler.ThrowOnFailure(statusBar.GetText(out text)); const string expected = "Publish failed: Access to the path '"; Assert.IsTrue(text.StartsWith(expected), "Expected '{0}', got '{1}'", expected, text); } finally { project.Properties.Item("PublishUrl").Value = ""; } }
public void TestTargetPropertiesForProject() { var profiling = (IPythonProfiling)VsIdeTestHostContext.Dte.GetObject("PythonProfiling"); // no sessions yet Assert.AreEqual(profiling.GetSession(1), null); var project = DebugProject.OpenProject(@"Python.VS.TestData\ProfileTest.sln"); var session = profiling.LaunchProject(project, false); try { while (profiling.IsProfiling) { System.Threading.Thread.Sleep(100); } var app = new PythonVisualStudioApp(VsIdeTestHostContext.Dte); app.OpenPythonPerformance(); var pyPerf = app.PythonPerformanceExplorerTreeView; var item = pyPerf.FindItem("HelloWorld *"); Mouse.MoveTo(item.GetClickablePoint()); Mouse.DoubleClick(System.Windows.Input.MouseButton.Left); var perfTarget = new PythonPerfTarget(app.WaitForDialog()); Assert.AreEqual("HelloWorld", perfTarget.SelectedProject); perfTarget.Cancel(); app.WaitForDialogDismissed(); } finally { profiling.RemoveSession(session, true); } }
public void MultipleTargets() { var profiling = (IPythonProfiling)VsIdeTestHostContext.Dte.GetObject("PythonProfiling"); // no sessions yet Assert.AreEqual(profiling.GetSession(1), null); var project = DebugProject.OpenProject(@"Python.VS.TestData\ProfileTest.sln"); var session = profiling.LaunchProject(project, false); IPythonProfileSession session2 = null; try { { while (profiling.IsProfiling) { System.Threading.Thread.Sleep(100); } var report = session.GetReport(1); var filename = report.Filename; Assert.IsTrue(filename.Contains("HelloWorld")); Assert.AreEqual(session.GetReport(2), null); Assert.AreNotEqual(session.GetReport(report.Filename), null); VerifyReport(report, "Program.f", "time.sleep"); } { session2 = profiling.LaunchProcess("C:\\Python26\\python.exe", Path.GetFullPath(@"Python.VS.TestData\ProfileTest\Program.py"), Path.GetFullPath(@"Python.VS.TestData\ProfileTest"), "", false ); while (profiling.IsProfiling) { System.Threading.Thread.Sleep(100); } var report = session2.GetReport(1); var filename = report.Filename; Assert.IsTrue(filename.Contains("Program")); Assert.AreEqual(session2.GetReport(2), null); Assert.AreNotEqual(session2.GetReport(report.Filename), null); VerifyReport(report, "Program.f", "time.sleep"); } } finally { profiling.RemoveSession(session, true); if (session2 != null) { profiling.RemoveSession(session2, true); } } }
public void ObjectBrowserContextMenuBasicTest() { var app = new VisualStudioApp(VsIdeTestHostContext.Dte); var project = DebugProject.OpenProject(@"Python.VS.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(2, nodeCount, "Node count: " + nodeCount.ToString()); string str = objectBrowser.TypeBrowserPane.Nodes[0].Value; Assert.AreEqual("MyModule.py", str, ""); str = objectBrowser.TypeBrowserPane.Nodes[1].Value; Assert.AreEqual("Program.py", str, ""); objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse(); System.Threading.Thread.Sleep(1000); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count; Assert.AreEqual(5, nodeCount, "Node count: " + nodeCount.ToString()); objectBrowser.TypeBrowserPane.Nodes[0].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[1].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(11, 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("Find All References", menu.Items[3].Value.Trim(), ""); Assert.AreEqual("Copy", menu.Items[4].Value.Trim(), ""); Assert.AreEqual("View Namespaces", menu.Items[5].Value.Trim(), ""); Assert.AreEqual("View Containers", menu.Items[6].Value.Trim(), ""); Assert.AreEqual("Sort Alphabetically", menu.Items[7].Value.Trim(), ""); Assert.AreEqual("Sort By Object Type", menu.Items[8].Value.Trim(), ""); Assert.AreEqual("Sort By Object Access", menu.Items[9].Value.Trim(), ""); Assert.AreEqual("Group By Object Type", menu.Items[10].Value.Trim(), ""); Keyboard.PressAndRelease(System.Windows.Input.Key.Escape); objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse(); System.Threading.Thread.Sleep(1000); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); }
public void ObjectBrowserNavigateVarContextMenuTest() { var app = new VisualStudioApp(VsIdeTestHostContext.Dte); var project = DebugProject.OpenProject(@"Python.VS.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(2, nodeCount, "Node count: " + nodeCount.ToString()); string str = objectBrowser.TypeBrowserPane.Nodes[0].Value; Assert.AreEqual("MyModule.py", str, ""); str = objectBrowser.TypeBrowserPane.Nodes[1].Value; Assert.AreEqual("Program.py", str, ""); objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse(); System.Threading.Thread.Sleep(1000); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count; Assert.AreEqual(5, nodeCount, "Node count: " + nodeCount.ToString()); objectBrowser.TypeBrowserPane.Nodes[3].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(11, 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()); objectBrowser.TypeBrowserPane.Nodes[4].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()); objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse(); System.Threading.Thread.Sleep(1000); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); }
public void TestCompareReports() { var profiling = (IPythonProfiling)VsIdeTestHostContext.Dte.GetObject("PythonProfiling"); // no sessions yet Assert.AreEqual(profiling.GetSession(1), null); var project = DebugProject.OpenProject(@"Python.VS.TestData\ProfileTest.sln"); var session = profiling.LaunchProject(project, false); try { while (profiling.IsProfiling) { System.Threading.Thread.Sleep(100); } session.Launch(false); while (profiling.IsProfiling) { System.Threading.Thread.Sleep(100); } var app = new PythonVisualStudioApp(VsIdeTestHostContext.Dte); var pyPerf = app.PythonPerformanceExplorerTreeView; var item = pyPerf.FindItem("HelloWorld *", "Reports"); var child = item.FindFirst(System.Windows.Automation.TreeScope.Descendants, Condition.TrueCondition); AutomationWrapper.EnsureExpanded(child); child.SetFocus(); Mouse.MoveTo(child.GetClickablePoint()); Mouse.Click(System.Windows.Input.MouseButton.Right); Keyboard.PressAndRelease(System.Windows.Input.Key.C); var cmpReports = new ComparePerfReports(app.WaitForDialog()); cmpReports.ComparisonFile = session.GetReport(2).Filename; cmpReports.Ok(); app.WaitForDialogDismissed(); // verify the difference file opens.... bool foundDiff = false; for (int j = 0; j < 100 && !foundDiff; j++) { for (int i = 0; i < app.Dte.Documents.Count; i++) { var doc = app.Dte.Documents.Item(i + 1); string name = doc.FullName; if (name.StartsWith("vsp://diff/?baseline=")) { foundDiff = true; doc.Close(EnvDTE.vsSaveChanges.vsSaveChangesNo); break; } } if (!foundDiff) { System.Threading.Thread.Sleep(300); } } Assert.IsTrue(foundDiff); } finally { profiling.RemoveSession(session, true); } }
public void ObjectBrowserFindAllReferencesTest() { var app = new VisualStudioApp(VsIdeTestHostContext.Dte); var project = DebugProject.OpenProject(@"Python.VS.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(2, nodeCount, "Node count: " + nodeCount.ToString()); string str = objectBrowser.TypeBrowserPane.Nodes[0].Value; Assert.AreEqual("MyModule.py", str, ""); str = objectBrowser.TypeBrowserPane.Nodes[1].Value; Assert.AreEqual("Program.py", str, ""); objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse(); System.Threading.Thread.Sleep(1000); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count; Assert.AreEqual(5, nodeCount, "Node count: " + nodeCount.ToString()); objectBrowser.TypeBrowserPane.Nodes[3].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(11, itemCount, "Item count: " + itemCount.ToString()); menu.Items[3].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[1].ShowContextMenu(); System.Threading.Thread.Sleep(1000); el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con); Assert.IsNotNull(el); menu = new Menu(el); menu.Items[3].Check(); System.Threading.Thread.Sleep(1000); str = app.Dte.ActiveWindow.Caption; Assert.IsTrue(str.Contains("2 matches found"), str); objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse(); System.Threading.Thread.Sleep(1000); objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse(); System.Threading.Thread.Sleep(1000); }