コード例 #1
0
ファイル: ProfilingTests.cs プロジェクト: lioaphy/nodejstools
        public void NewProfilingSession() {
            using (new JustMyCodeSetting(false)) {
                using (var app = new NodejsVisualStudioApp()) {
                    app.Dte.Solution.Close(false);

                    app.OpenNodejsPerformance();
                    app.NodejsPerformanceExplorerToolBar.NewPerfSession();

                    var profiling = (INodeProfiling)app.Dte.GetObject("NodejsProfiling");

                    var perf = app.NodejsPerformanceExplorerTreeView.WaitForItem("Performance *");
                    Debug.Assert(perf != null);
                    var session = profiling.GetSession(1);
                    Assert.AreNotEqual(session, null);

                    NodejsPerfTarget perfTarget = null;
                    try {
                        Mouse.MoveTo(perf.GetClickablePoint());
                        Mouse.DoubleClick(System.Windows.Input.MouseButton.Left);

                        // wait for the dialog, set some settings, save them.
                        perfTarget = new NodejsPerfTarget(app.WaitForDialog());

                        perfTarget.SelectProfileScript();
                        perfTarget.InterpreterPath = NodeExePath;
                        perfTarget.ScriptName = TestData.GetPath(@"TestData\NodejsProfileTest\program.js");

                        try {
                            perfTarget.Ok();
                            perfTarget = null;
                        } catch (ElementNotEnabledException) {
                            Assert.Fail("Settings were invalid:\n  ScriptName = {0}\n",
                                perfTarget.ScriptName);
                        }
                        app.WaitForDialogDismissed();

                        Mouse.MoveTo(perf.GetClickablePoint());
                        Mouse.DoubleClick(System.Windows.Input.MouseButton.Left);

                        // re-open the dialog, verify the settings
                        perfTarget = new NodejsPerfTarget(app.WaitForDialog());

                        //Assert.AreEqual("Python 2.6", perfTarget.SelectedInterpreter);
                        Assert.AreEqual(TestData.GetPath(@"TestData\NodejsProfileTest\program.js"), perfTarget.ScriptName);

                    } finally {
                        if (perfTarget != null) {
                            perfTarget.Cancel();
                            app.WaitForDialogDismissed();
                        }
                        profiling.RemoveSession(session, true);
                    }
                }
            }
        }
コード例 #2
0
ファイル: ProfilingTests.cs プロジェクト: lioaphy/nodejstools
        private static void WaitForReport(INodeProfiling profiling, INodeProfileSession session, out INodePerformanceReport report, NodejsVisualStudioApp app, out AutomationElement child) {
            while (profiling.IsProfiling) {
                System.Threading.Thread.Sleep(500);
            }

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

            app.OpenNodejsPerformance();
            var pyPerf = app.NodejsPerformanceExplorerTreeView;
            Assert.AreNotEqual(null, pyPerf);

            var item = pyPerf.FindItem("NodejsProfileTest *", "Reports");
            child = item.FindFirst(System.Windows.Automation.TreeScope.Descendants, Condition.TrueCondition);
            var childName = child.GetCurrentPropertyValue(AutomationElement.NameProperty) as string;

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

            AutomationWrapper.EnsureExpanded(child);
        }
コード例 #3
0
ファイル: ProfilingTests.cs プロジェクト: lioaphy/nodejstools
        private static NodejsVisualStudioApp WaitForReport(INodeProfiling profiling, INodeProfileSession session, NodejsVisualStudioApp 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("NodejsProfileTest"));

            app.OpenNodejsPerformance();
            var pyPerf = app.NodejsPerformanceExplorerTreeView;
            Assert.AreNotEqual(null, pyPerf);

            var item = pyPerf.FindItem("NodejsProfileTest *", "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("NodejsProfileTest"));

            child.SetFocus();
            Keyboard.PressAndRelease(System.Windows.Input.Key.Delete);
            return app;
        }