private static void WaitForReport(IPythonProfiling profiling, IPythonProfileSession session, out IPythonPerformanceReport report, out PythonVisualStudioApp app, out AutomationElement child) { while (profiling.IsProfiling) { System.Threading.Thread.Sleep(100); } report = session.GetReport(1); var filename = report.Filename; Assert.IsTrue(filename.Contains("HelloWorld")); app = new PythonVisualStudioApp(VsIdeTestHostContext.Dte); app.OpenPythonPerformance(); var pyPerf = app.PythonPerformanceExplorerTreeView; Assert.AreNotEqual(null, pyPerf); var item = pyPerf.FindItem("HelloWorld *", "Reports"); child = item.FindFirst(System.Windows.Automation.TreeScope.Descendants, Condition.TrueCondition); var childName = child.GetCurrentPropertyValue(AutomationElement.NameProperty) as string; Assert.IsTrue(childName.StartsWith("HelloWorld")); AutomationWrapper.EnsureExpanded(child); }
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 static void EnsureExpanded(this AutomationElement node) { AutomationWrapper.EnsureExpanded(node); }