本文整理汇总了C#中TestUtilities.UI.Python.PythonVisualStudioApp.OpenDialogWithDteExecuteCommand方法的典型用法代码示例。如果您正苦于以下问题:C# PythonVisualStudioApp.OpenDialogWithDteExecuteCommand方法的具体用法?C# PythonVisualStudioApp.OpenDialogWithDteExecuteCommand怎么用?C# PythonVisualStudioApp.OpenDialogWithDteExecuteCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestUtilities.UI.Python.PythonVisualStudioApp
的用法示例。
在下文中一共展示了PythonVisualStudioApp.OpenDialogWithDteExecuteCommand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtensionReference
public void ExtensionReference() {
using (var app = new PythonVisualStudioApp()) {
var project = app.OpenProject(@"TestData\ExtensionReference.sln");
app.OpenSolutionExplorer();
var solutionTree = app.SolutionExplorerTreeView;
var dbPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"Python Tools",
"ReferencesDB",
#if DEBUG
"Debug",
#endif
AssemblyVersionInfo.VSVersion
);
var existingFiles = Directory.GetFiles(dbPath, "spam*");
// open the solution, add a reference to our spam.pyd Python extension module
var folderNode = solutionTree.FindItem(
"Solution 'ExtensionReference' (1 project)",
"ExtensionReference",
SR.GetString(SR.ReferencesNodeName)
);
folderNode.Select();
var dialog = new AddReferenceDialog(AutomationElement.FromHandle(app.OpenDialogWithDteExecuteCommand("Project.AddReference")));
dialog.ActivateBrowseTab();
dialog.BrowseFilename = TestData.GetPath(@"TestData\spam.pyd");
dialog.ClickOK();
app.WaitForDialogDismissed();
// make sure the reference got added
var spamItem = solutionTree.WaitForItem(
"Solution 'ExtensionReference' (1 project)",
"ExtensionReference",
SR.GetString(SR.ReferencesNodeName),
"spam.pyd"
);
Assert.IsNotNull(spamItem);
// wait for scraping to complete
for (int retries = 10;
Directory.GetFiles(dbPath, "spam*").Length == existingFiles.Length && retries > 0;
--retries) {
System.Threading.Thread.Sleep(1000);
}
Assert.AreNotEqual(existingFiles.Length, Directory.GetFiles(dbPath, "spam*").Length, "File was not scraped");
// now open a file and make sure we get completions against the spam module
var item = project.ProjectItems.Item("Program.py");
var window = item.Open();
window.Activate();
var doc = app.GetDocument(item.Document.FullName);
doc.MoveCaret(doc.TextView.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(1).Start);
Keyboard.Type("spam.");
using (var sh = doc.WaitForSession<ICompletionSession>()) {
var completion = sh.Session.CompletionSets.First().Completions.Select(x => x.InsertionText).FirstOrDefault(x => x == "system");
Assert.IsNotNull(completion);
}
// now clear the text we just typed
for (int i = 0; i < 5; i++) {
Keyboard.Type(Key.Back);
}
// remove the extension
app.Dte.Solution.Projects.Item(1).ProjectItems.Item("References").ProjectItems.Item(@"spam.pyd").Remove();
// make sure it got removed
solutionTree.WaitForItemRemoved(
"Solution 'ExtensionReference' (1 project)",
"ExtensionReference",
SR.GetString(SR.ReferencesNodeName),
"spam.pyd"
);
window.Activate();
// and make sure we no longer offer completions on the spam module.
Keyboard.Type("spam.");
using (var sh = doc.WaitForSession<ICompletionSession>()) {
var completion = sh.Session.CompletionSets.First().Completions.Select(x => x.DisplayText).Single();
Assert.AreEqual(SR.GetString(SR.NoCompletionsCompletion), completion);
}
}
}
示例2: 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 *"));
}
}