コード例 #1
0
        /// <summary>
        /// Opens the interactive window, clears the screen.
        /// </summary>
        internal void Test(Action<NodejsVisualStudioApp, InteractiveWindow> body) {
            using (var app = new NodejsVisualStudioApp()) {
                app.SuppressCloseAllOnDispose();

                const string interpreterDescription = "Node.js Interactive Window";
                app.Dte.ExecuteCommand("View.Node.jsInteractiveWindow");
                var interactive = app.GetInteractiveWindow(interpreterDescription);
                if (interactive == null) {
                    Assert.Inconclusive("Need " + interpreterDescription);
                }
                interactive.WaitForIdleState();
                app.Element.SetFocus();
                interactive.Element.SetFocus();

                interactive.ClearInput();

                bool isReady = false;
                for (int retries = 10; retries > 0; --retries) {
                    interactive.Reset();
                    try {
                        var task = interactive.ReplWindow.Evaluator.ExecuteText("console.log('READY')");
                        Assert.IsTrue(task.Wait(10000), "ReplWindow did not initialize in time");
                        if (!task.Result.IsSuccessful) {
                            continue;
                        }
                    } catch (TaskCanceledException) {
                        continue;
                    }

                    interactive.WaitForTextEnd("READY", "undefined", "> ");
                    isReady = true;
                    break;
                }
                Assert.IsTrue(isReady, "ReplWindow did not initialize");

                interactive.ClearScreen();
                interactive.ReplWindow.ClearHistory();

                body(app, interactive);

                interactive.ClearScreen();
                interactive.ReplWindow.ClearHistory();
            }
        }
コード例 #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
 public void TestStartAnalysisDebugMenuNoProject() {
     using (new JustMyCodeSetting(false))
     using (var app = new NodejsVisualStudioApp()) {
         bool ok = true;
         try {
             app.Dte.ExecuteCommand("Debug.StartNode.jsPerformanceAnalysis");
             ok = false;
         } catch {
         }
         Assert.IsTrue(ok, "Could start perf analysis w/o a project open");
     }
 }
コード例 #4
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);
                    }
                }
            }
        }
コード例 #5
0
ファイル: ProfilingTests.cs プロジェクト: lioaphy/nodejstools
        private NodejsVisualStudioApp OpenProfileTestProject(
            out EnvDTE.Project project,
            out INodeProfiling profiling,
            string projectFile = NodejsProfileTest
        ) {
            var app = new NodejsVisualStudioApp();
            try {
                profiling = (INodeProfiling)app.Dte.GetObject("NodejsProfiling");

                // 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();
                }
            }
        }
コード例 #6
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;
        }