當前位置: 首頁>>代碼示例>>C#>>正文


C# PythonVisualStudioApp.OpenDialogWithDteExecuteCommand方法代碼示例

本文整理匯總了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);
                }
            }
        }
開發者ID:wenh123,項目名稱:PTVS,代碼行數:94,代碼來源:UITests.cs

示例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 *"));
            }
        }
開發者ID:wenh123,項目名稱:PTVS,代碼行數:35,代碼來源:ProfilingTests.cs


注:本文中的TestUtilities.UI.Python.PythonVisualStudioApp.OpenDialogWithDteExecuteCommand方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。