本文整理汇总了C#中TestUtilities.UI.Python.PythonVisualStudioApp.OpenPythonPerformance方法的典型用法代码示例。如果您正苦于以下问题:C# PythonVisualStudioApp.OpenPythonPerformance方法的具体用法?C# PythonVisualStudioApp.OpenPythonPerformance怎么用?C# PythonVisualStudioApp.OpenPythonPerformance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestUtilities.UI.Python.PythonVisualStudioApp
的用法示例。
在下文中一共展示了PythonVisualStudioApp.OpenPythonPerformance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WaitForReport
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);
}
示例2: NewProfilingSession
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);
}
}
}
示例3: DeleteMultipleSessions
public void DeleteMultipleSessions() {
using (var app = new PythonVisualStudioApp()) {
app.Dte.Solution.Close(false);
app.OpenPythonPerformance();
app.PythonPerformanceExplorerToolBar.NewPerfSession();
app.PythonPerformanceExplorerToolBar.NewPerfSession();
var profiling = (IPythonProfiling)app.Dte.GetObject("PythonProfiling");
app.OpenPythonPerformance();
var perf = app.PythonPerformanceExplorerTreeView.WaitForItem("Performance *");
Assert.IsNotNull(perf);
var perf2 = app.PythonPerformanceExplorerTreeView.WaitForItem("Performance1 *");
AutomationWrapper.Select(perf);
// Cannot use AddToSelection because the tree view declares that
// it does not support multi-select, even though it does.
// AutomationWrapper.AddToSelection(perf2);
Mouse.MoveTo(perf2.GetClickablePoint());
try {
Keyboard.Press(System.Windows.Input.Key.LeftCtrl);
Mouse.Click(System.Windows.Input.MouseButton.Left);
} finally {
Keyboard.Release(System.Windows.Input.Key.LeftCtrl);
}
var dialog = AutomationElement.FromHandle(app.OpenDialogWithDteExecuteCommand("Edit.Delete")).AsWrapper();
dialog.ClickButtonByName("Delete");
Assert.IsNull(app.PythonPerformanceExplorerTreeView.WaitForItemRemoved("Performance *"));
Assert.IsNull(app.PythonPerformanceExplorerTreeView.WaitForItemRemoved("Performance1 *"));
}
}
示例4: LaunchSession
private IPythonProfileSession LaunchSession(
PythonVisualStudioApp app,
Func<IPythonProfileSession> creator
) {
// Ensure the performance window has been opened, which will make
// the app clean up all sessions when it is disposed.
app.OpenPythonPerformance();
IPythonProfileSession session = null;
var task = Task.Factory.StartNew(() => {
session = creator();
// Must fault the task to abort the wait
throw new Exception();
});
var dialog = app.WaitForDialog(task);
if (dialog != IntPtr.Zero) {
using (var saveDialog = new SaveDialog(app, AutomationElement.FromHandle(dialog))) {
var originalDestName = Path.Combine(SaveDirectory, Path.GetFileName(saveDialog.FileName));
var destName = originalDestName;
while (File.Exists(destName)) {
destName = string.Format("{0} {1}{2}",
Path.GetFileNameWithoutExtension(originalDestName),
Guid.NewGuid(),
Path.GetExtension(originalDestName)
);
}
saveDialog.FileName = destName;
saveDialog.Save();
try {
task.Wait(TimeSpan.FromSeconds(5.0));
Assert.Fail("Task did not fault");
} catch (AggregateException) {
}
}
} else {
// Ensure the exception is observed
var ex = task.Exception;
}
Assert.IsNotNull(session, "Session was not correctly initialized");
return session;
}