Example #1
0
        private static void WaitForReport(IPythonProfiling profiling, IPythonProfileSession session, out PythonVisualStudioApp app, out string reportFilename)
        {
            while (profiling.IsProfiling)
            {
                System.Threading.Thread.Sleep(100);
            }

            var 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");
            var child     = item.FindFirst(System.Windows.Automation.TreeScope.Descendants, Condition.TrueCondition);
            var childName = child.GetCurrentPropertyValue(AutomationElement.NameProperty) as string;

            reportFilename = report.Filename;
            Assert.IsTrue(childName.StartsWith("HelloWorld"));

            child.SetFocus();
            Keyboard.PressAndRelease(System.Windows.Input.Key.Delete);
        }
Example #2
0
        private static void WaitForReport(IPythonProfiling profiling, IPythonProfileSession session, PythonVisualStudioApp app, out string reportFilename) {
            while (profiling.IsProfiling) {
                Thread.Sleep(100);
            }

            var report = session.GetReport(1);
            var filename = report.Filename;
            Assert.IsTrue(filename.Contains("HelloWorld"));

            app.OpenPythonPerformance();
            var pyPerf = app.PythonPerformanceExplorerTreeView;
            Assert.IsNotNull(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;

            reportFilename = report.Filename;
            Assert.IsTrue(childName.StartsWith("HelloWorld"));

            child.SetFocus();
            Keyboard.PressAndRelease(System.Windows.Input.Key.Delete);
        }
Example #3
0
        private static void WaitForReport(IPythonProfiling profiling, IPythonProfileSession session, out IPythonPerformanceReport report, PythonVisualStudioApp app, out AutomationElement child) {
            while (profiling.IsProfiling) {
                Thread.Sleep(100);
            }

            report = session.GetReport(1);
            var filename = report.Filename;
            Assert.IsTrue(filename.Contains("HelloWorld"));

            app.OpenPythonPerformance();
            var pyPerf = app.PythonPerformanceExplorerTreeView;
            Assert.IsNotNull(pyPerf);

            var item = pyPerf.WaitForItem("HelloWorld *", "Reports");
            child = item.FindFirst(TreeScope.Descendants, Condition.TrueCondition);
            var childName = (string)child.GetCurrentPropertyValue(AutomationElement.NameProperty);

            Assert.IsTrue(childName.StartsWith("HelloWorld"));

            AutomationWrapper.EnsureExpanded(child);
        }
Example #4
0
        private PythonVisualStudioApp OpenProfileTestProject(
            out EnvDTE.Project project,
            out IPythonProfiling profiling,
            string projectFile = @"TestData\ProfileTest.sln"
        ) {
            var app = new PythonVisualStudioApp();
            try {
                profiling = (IPythonProfiling)app.Dte.GetObject("PythonProfiling");

                // no sessions yet
                Assert.IsNull(profiling.GetSession(1));

                if (string.IsNullOrEmpty(projectFile)) {
                    project = null;
                } else {
                    project = app.OpenProject(projectFile);
                } 

                var res = app;
                app = null;
                return res;
            } finally {
                if (app != null) {
                    app.Dispose();
                }
            }
        }
Example #5
0
 private IPythonProfileSession LaunchProject(
     PythonVisualStudioApp app,
     IPythonProfiling profiling,
     EnvDTE.Project project,
     string directory,
     bool openReport
 ) {
     return LaunchSession(app, () => profiling.LaunchProject(project, openReport));
 }
Example #6
0
 private IPythonProfileSession LaunchProcess(
     PythonVisualStudioApp app,
     IPythonProfiling profiling,
     string interpreterPath,
     string filename,
     string directory,
     string arguments,
     bool openReport
 ) {
     return LaunchSession(app,
         () => profiling.LaunchProcess(
             interpreterPath,
             filename,
             directory,
             "",
             openReport
         )
     );
 }