/// <summary> /// Opens and activates the solution explorer window. /// </summary> public void OpenPythonPerformance() { try { _deletePerformanceSessions = true; Dte.ExecuteCommand("Python.PerformanceExplorer"); } catch { // If the package is not loaded yet then the command may not // work. Force load the package by opening the Launch dialog. using (var dialog = new PythonPerfTarget(OpenDialogWithDteExecuteCommand("Analyze.LaunchProfiling"))) { } Dte.ExecuteCommand("Python.PerformanceExplorer"); } }
public void TestTargetPropertiesForExecutable() { var interp = PythonPaths.Python27; interp.AssertInstalled(); EnvDTE.Project project; IPythonProfiling profiling; using (var app = OpenProfileTestProject(out project, out profiling, null)) { var session = LaunchProcess(app, profiling, interp.InterpreterPath, TestData.GetPath(@"TestData\ProfileTest\Program.py"), TestData.GetPath(@"TestData\ProfileTest"), "", false ); while (profiling.IsProfiling) { Thread.Sleep(100); } app.OpenPythonPerformance(); var pyPerf = app.PythonPerformanceExplorerTreeView; var item = pyPerf.FindItem("Program *"); Mouse.MoveTo(item.GetClickablePoint()); Mouse.DoubleClick(System.Windows.Input.MouseButton.Left); using (var perfTarget = new PythonPerfTarget(app.WaitForDialog())) { Assert.AreEqual(interp.InterpreterPath, perfTarget.InterpreterPath); Assert.AreEqual("", perfTarget.Arguments); Assert.IsTrue(perfTarget.ScriptName.EndsWith("Program.py")); Assert.IsTrue(perfTarget.ScriptName.StartsWith(perfTarget.WorkingDir)); } } }
public void TestTargetPropertiesForInterpreter() { PythonPaths.Python27.AssertInstalled(); EnvDTE.Project project; IPythonProfiling profiling; using (var app = OpenProfileTestProject(out project, out profiling, null)) { var session = LaunchProcess(app, profiling, "{2AF0F10D-7135-4994-9156-5D01C9C11B7E};2.7", TestData.GetPath(@"TestData\ProfileTest\Program.py"), TestData.GetPath(@"TestData\ProfileTest"), "", false ); try { while (profiling.IsProfiling) { Thread.Sleep(100); } app.OpenPythonPerformance(); var pyPerf = app.PythonPerformanceExplorerTreeView; var item = pyPerf.FindItem("Program *"); Mouse.MoveTo(item.GetClickablePoint()); Mouse.DoubleClick(System.Windows.Input.MouseButton.Left); using (var perfTarget = new PythonPerfTarget(app.WaitForDialog())) { Assert.AreEqual("Python 2.7", perfTarget.SelectedInterpreter); Assert.AreEqual("", perfTarget.Arguments); Assert.IsTrue(perfTarget.ScriptName.EndsWith("Program.py")); Assert.IsTrue(perfTarget.ScriptName.StartsWith(perfTarget.WorkingDir)); } app.WaitForDialogDismissed(); } finally { profiling.RemoveSession(session, true); } } }
public void TestTargetPropertiesForProject() { EnvDTE.Project project; IPythonProfiling profiling; using (var app = OpenProfileTestProject(out project, out profiling)) { var session = LaunchProject(app, profiling, project, TestData.GetPath(@"TestData\ProfileTest"), false); while (profiling.IsProfiling) { Thread.Sleep(100); } app.OpenPythonPerformance(); var pyPerf = app.PythonPerformanceExplorerTreeView; var item = pyPerf.FindItem("HelloWorld *"); Mouse.MoveTo(item.GetClickablePoint()); Mouse.DoubleClick(System.Windows.Input.MouseButton.Left); using (var perfTarget = new PythonPerfTarget(app.WaitForDialog())) { Assert.AreEqual("HelloWorld", perfTarget.SelectedProject); } } }
public void NewProfilingSessionOpenSolution() { EnvDTE.Project project; IPythonProfiling profiling; using (var app = OpenProfileTestProject(out project, out profiling)) { app.OpenPythonPerformance(); app.PythonPerformanceExplorerToolBar.NewPerfSession(); var perf = app.PythonPerformanceExplorerTreeView.WaitForItem("Performance"); var session = profiling.GetSession(1); Assert.IsNotNull(session); Mouse.MoveTo(perf.GetClickablePoint()); Mouse.DoubleClick(System.Windows.Input.MouseButton.Left); // wait for the dialog, set some settings, save them. using (var perfTarget = new PythonPerfTarget(app.WaitForDialog())) { perfTarget.SelectProfileProject(); perfTarget.SelectedProjectComboBox.SelectItem("HelloWorld"); try { perfTarget.Ok(); } catch (ElementNotEnabledException) { Assert.Fail("Settings were invalid:\n SelectedProject = {0}", perfTarget.SelectedProjectComboBox.GetSelectedItemName()); } } Mouse.MoveTo(perf.GetClickablePoint()); Mouse.DoubleClick(System.Windows.Input.MouseButton.Left); // re-open the dialog, verify the settings using (var perfTarget = new PythonPerfTarget(app.WaitForDialog())) { Assert.AreEqual("HelloWorld", perfTarget.SelectedProject); } } }
public void NewProfilingSession() { PythonPaths.Python27.AssertInstalled(); var testFile = TestData.GetPath(@"TestData\ProfileTest\Program.py"); Assert.IsTrue(File.Exists(testFile), "ProfileTest\\Program.py does not exist"); using (var app = new PythonVisualStudioApp()) { app.OpenPythonPerformance(); app.PythonPerformanceExplorerToolBar.NewPerfSession(); var profiling = (IPythonProfiling)app.Dte.GetObject("PythonProfiling"); app.OpenPythonPerformance(); var perf = app.PythonPerformanceExplorerTreeView.WaitForItem("Performance *"); Assert.IsNotNull(perf); var session = profiling.GetSession(1); Assert.IsNotNull(session); Mouse.MoveTo(perf.GetClickablePoint()); Mouse.DoubleClick(System.Windows.Input.MouseButton.Left); // wait for the dialog, set some settings, save them. using (var perfTarget = new PythonPerfTarget(app.WaitForDialog())) { perfTarget.SelectProfileScript(); perfTarget.InterpreterComboBox.SelectItem("Python 2.7"); perfTarget.ScriptName = testFile; perfTarget.WorkingDir = Path.GetDirectoryName(testFile); try { perfTarget.Ok(); } catch (ElementNotEnabledException) { Assert.Fail("Settings were invalid:\n ScriptName = {0}\n Interpreter = {1}", perfTarget.ScriptName, perfTarget.SelectedInterpreter); } } app.WaitForDialogDismissed(); Mouse.MoveTo(perf.GetClickablePoint()); Mouse.DoubleClick(System.Windows.Input.MouseButton.Left); // re-open the dialog, verify the settings using (var perfTarget = new PythonPerfTarget(app.WaitForDialog())) { Assert.AreEqual("Python 2.7", perfTarget.SelectedInterpreter); Assert.AreEqual(TestData.GetPath(@"TestData\ProfileTest\Program.py"), perfTarget.ScriptName); } } }
/// <summary> /// Opens and activates the solution explorer window. /// </summary> public void OpenPythonPerformance() { try { _deletePerformanceSessions = true; Dte.ExecuteCommand("Python.PerformanceExplorer"); } catch { // If the package is not loaded yet then the command may not // work. Force load the package by opening the Launch dialog. using (var dialog = new PythonPerfTarget(OpenDialogWithDteExecuteCommand("Python.LaunchProfiling"))) { } Dte.ExecuteCommand("Python.PerformanceExplorer"); } }