예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #4
0
        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);
                }
            }
        }