当前位置: 首页>>代码示例>>C#>>正文


C# PythonVisualStudioApp.OpenSolutionExplorer方法代码示例

本文整理汇总了C#中TestUtilities.UI.Python.PythonVisualStudioApp.OpenSolutionExplorer方法的典型用法代码示例。如果您正苦于以下问题:C# PythonVisualStudioApp.OpenSolutionExplorer方法的具体用法?C# PythonVisualStudioApp.OpenSolutionExplorer怎么用?C# PythonVisualStudioApp.OpenSolutionExplorer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestUtilities.UI.Python.PythonVisualStudioApp的用法示例。


在下文中一共展示了PythonVisualStudioApp.OpenSolutionExplorer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartupProjectSelected

        public void StartupProjectSelected() {
            using (var app = new PythonVisualStudioApp()) {
                app.OpenProject(TestData.GetPath(@"TestData\MultiProjectAnalysis\MultiProjectAnalysis.sln"));

                foreach (var project in app.Dte.Solution.Projects.Cast<EnvDTE.Project>()) {
                    var tree = app.OpenSolutionExplorer();
                    var item = tree.FindByName(project.Name);
                    item.Select();
                    app.Dte.ExecuteCommand("Project.SetasStartupProject");

                    using (var dialog = app.LaunchPythonProfiling()) {
                        Assert.AreEqual(project.Name, dialog.SelectedProject);
                    }
                    app.WaitForDialogDismissed();
                }
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:17,代码来源:ProfilingTests.cs

示例2: DefaultBaseInterpreterSelection

        public void DefaultBaseInterpreterSelection() {
            // The project that will be loaded references these environments.
            PythonPaths.Python27.AssertInstalled();
            PythonPaths.Python33.AssertInstalled();

            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var project = app.OpenProject(@"TestData\Environments.sln");

                app.OpenSolutionExplorer().SelectProject(project);
                app.Dte.ExecuteCommand("Python.ActivateEnvironment", "/env:\"Python 2.7\"");

                using (var createVenv = AutomationDialog.FromDte(app, "Python.AddVirtualEnvironment")) {
                    var baseInterp = new ComboBox(createVenv.FindByAutomationId("BaseInterpreter")).GetSelectedItemName();

                    Assert.AreEqual("Python 2.7", baseInterp);
                    createVenv.Cancel();
                }

                app.Dte.ExecuteCommand("Python.ActivateEnvironment", "/env:\"Python 3.3\"");

                using (var createVenv = AutomationDialog.FromDte(app, "Python.AddVirtualEnvironment")) {
                    var baseInterp = new ComboBox(createVenv.FindByAutomationId("BaseInterpreter")).GetSelectedItemName();

                    Assert.AreEqual("Python 3.3", baseInterp);
                    createVenv.Cancel();
                }
            }
        }
开发者ID:KaushikCh,项目名称:PTVS,代码行数:29,代码来源:VirtualEnvTests.cs

示例3: RemoveVirtualEnv

        public void RemoveVirtualEnv() {
            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var project = CreateTemporaryProject(app);

                string envName, envPath;
                var env = app.CreateVirtualEnvironment(project, out envName, out envPath);

                env.Select();

                using (var removeDeleteDlg = RemoveItemDialog.FromDte(app)) {
                    removeDeleteDlg.Remove();
                }

                app.OpenSolutionExplorer().WaitForChildOfProjectRemoved(
                    project,
                    SR.GetString(SR.Environments),
                    envName
                );

                var projectHome = (string)project.Properties.Item("ProjectHome").Value;
                envPath = Path.Combine(projectHome, envPath);
                Assert.IsTrue(Directory.Exists(envPath), envPath);
            }
        }
开发者ID:KaushikCh,项目名称:PTVS,代码行数:25,代码来源:VirtualEnvTests.cs

示例4: 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

示例5: TransferItem

        public void TransferItem() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                string filename, basename;
                int i = 0;
                do {
                    i++;
                    basename = "test" + i + " .py";
                    filename = Path.Combine(TestData.GetTempPath(), basename);
                } while (System.IO.File.Exists(filename));

                System.IO.File.WriteAllText(filename, "def f(): pass");

                var fileWindow = app.Dte.ItemOperations.OpenFile(filename);

                using (var dialog = ChooseLocationDialog.FromDte(app)) {
                    dialog.SelectProject("HelloWorld");
                    dialog.OK();
                }

                app.OpenSolutionExplorer().WaitForChildOfProject(project, basename);

                Assert.AreEqual(basename, fileWindow.Caption);

                System.IO.File.Delete(filename);
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:28,代码来源:UITests.cs

示例6: AddExistingItem

        public void AddExistingItem() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\AddExistingItem.sln");

                app.OpenSolutionExplorer().SelectProject(project);

                using (var addExistingDlg = AddExistingItemDialog.FromDte(app)) {
                    addExistingDlg.FileName = TestData.GetPath(@"TestData\AddExistingItem\Program2.py");
                    addExistingDlg.Add();
                }
                app.OpenSolutionExplorer().WaitForChildOfProject(project, "Program2.py");
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:13,代码来源:UITests.cs

示例7: DjangoIncludeInProject

        public void DjangoIncludeInProject() {
            using (var app = new PythonVisualStudioApp()) {
                app.OpenProject(@"TestData\DjangoApplication.sln");

                app.OpenSolutionExplorer();
                var window = app.SolutionExplorerTreeView;

                app.Dte.ExecuteCommand("Project.ShowAllFiles"); // start showing all

                var folderNode = window.WaitForItem("Solution 'DjangoApplication' (1 project)", "DjangoApplication", "Folder");
                Mouse.MoveTo(folderNode.GetClickablePoint());
                Mouse.Click(MouseButton.Right);

                Keyboard.Type("j"); // Exclude from Project
                app.Dte.ExecuteCommand("Project.ShowAllFiles"); // stop showing all

                Assert.IsNull(window.WaitForItemRemoved("Solution 'DjangoApplication' (1 project)", "DjangoApplication", "notinproject.py"));
                Assert.IsNotNull(window.WaitForItem("Solution 'DjangoApplication' (1 project)", "DjangoApplication", "Folder", "test.py"));
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:20,代码来源:UITests.cs

示例8: RenameProjectToExisting

        public void RenameProjectToExisting() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\RenameProjectTestUI.sln");

                app.OpenSolutionExplorer();
                var window = app.SolutionExplorerTreeView;

                // find Program.py, send copy & paste, verify copy of file is there
                var projectNode = window.FindItem("Solution 'RenameProjectTestUI' (1 project)", "HelloWorld");

                // rename once, cancel renaming to existing file....
                AutomationWrapper.Select(projectNode);
                Keyboard.PressAndRelease(Key.F2);
                System.Threading.Thread.Sleep(100);

                Keyboard.Type("HelloWorldExisting");
                System.Threading.Thread.Sleep(100);
                Keyboard.PressAndRelease(Key.Enter);

                IntPtr dialog = app.WaitForDialog();

                VisualStudioApp.CheckMessageBox("HelloWorldExisting.pyproj", "overwrite");

                // rename again, don't cancel...
                AutomationWrapper.Select(projectNode);
                Keyboard.PressAndRelease(Key.F2);
                System.Threading.Thread.Sleep(100);

                Keyboard.Type("HelloWorldExisting");
                System.Threading.Thread.Sleep(100);
                Keyboard.PressAndRelease(Key.Enter);

                dialog = app.WaitForDialog();

                VisualStudioApp.CheckMessageBox(MessageBoxButton.Yes, "HelloWorldExisting.pyproj", "overwrite");

                Assert.IsNotNull(window.WaitForItem("Solution 'RenameProjectTestUI' (1 project)", "HelloWorldExisting"));
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:39,代码来源:UITests.cs

示例9: AddNewFolderNested

        public void AddNewFolderNested() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                app.OpenSolutionExplorer().SelectProject(project);

                app.ExecuteCommand("Project.NewFolder");
                Keyboard.Type("FolderX");
                Keyboard.PressAndRelease(Key.Enter);

                var folderNode = app.OpenSolutionExplorer().WaitForChildOfProject(project, "FolderX");
                folderNode.Select();

                app.ExecuteCommand("Project.NewFolder");
                Keyboard.Type("FolderY");
                Keyboard.PressAndRelease(Key.Enter);

                var innerFolderNode = app.OpenSolutionExplorer().WaitForChildOfProject(project, "FolderX", "FolderY");
                innerFolderNode.Select();

                var newItem = project.ProjectItems.Item("FolderX").ProjectItems.Item("FolderY").ProjectItems.AddFromFile(
                    TestData.GetPath(@"TestData\DebuggerProject\BreakpointTest.py")
                );

                app.OpenSolutionExplorer().WaitForChildOfProject(project, "FolderX", "FolderY", "BreakpointTest.py");
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:27,代码来源:UITests.cs

示例10: LoadSearchPath

        public void LoadSearchPath() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\LoadSearchPaths.sln");

                // Ensure we complete analysis. VS may crash if the invalid
                // path is not handled correctly.
                project.GetPythonProject().GetAnalyzer().WaitForCompleteAnalysis(_ => true);

                var tree = app.OpenSolutionExplorer();

                const string sln = "Solution 'LoadSearchPaths' (1 project)";
                const string proj = "LoadSearchPaths";
                var sp = SR.GetString(SR.SearchPaths);

                // Entered in file as ..\AddSearchPaths\
                var path1 = tree.WaitForItem(sln, proj, sp, "..\\AddSearchPaths");
                Assert.IsNotNull(path1, "Could not find ..\\AddSearchPaths");

                // Entered in file as ..\HelloWorld
                var path2 = tree.WaitForItem(sln, proj, sp, "..\\HelloWorld");
                Assert.IsNotNull(path2, "Could not find ..\\HelloWorld");

                // Entered in file as ..\LoadSearchPaths\NotHere\..\ - resolves to .\
                var path3 = tree.WaitForItem(sln, proj, sp, ".");
                Assert.IsNotNull(path3, "Could not find .");

                // Entered in file as .\NotHere\
                var path4 = tree.WaitForItem(sln, proj, sp, "NotHere");
                Assert.IsNotNull(path4, "Could not find NotHere");
                Assert.AreEqual("NotHere", path4.Current.Name);

                AutomationWrapper.Select(path4);
                app.ExecuteCommand("Edit.Delete"); // should not prompt, https://pytools.codeplex.com/workitem/1233
                Assert.IsNull(tree.WaitForItemRemoved(sln, proj, sp, "NotHere"));

                // Entered in file as Invalid*Search?Path
                var path5 = tree.WaitForItem(sln, proj, sp, "Invalid*Search?Path");
                Assert.IsNotNull(path5, "Could not find Invalid*Search?Path");
                Assert.AreEqual(path5.Current.Name, "Invalid*Search?Path");

                AutomationWrapper.Select(path5);
                app.ExecuteCommand("Edit.Delete");
                Assert.IsNull(tree.WaitForItemRemoved(sln, proj, sp, "Invalid*Search?Path"));

                // Ensure NotHere hasn't come back
                path4 = tree.WaitForItem(sln, proj, sp, "NotHere");
                Assert.IsNull(path4, "NotHere came back");
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:49,代码来源:UITests.cs

示例11: AddSearchPathRelativePath

        public void AddSearchPathRelativePath() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\AddSearchPaths.sln");

                app.OpenSolutionExplorer().SelectProject(project);

                using (var dialog = SelectFolderDialog.AddFolderToSearchPath(app)) {
                    dialog.FolderName = TestData.GetPath(@"TestData\Outlining");
                    dialog.SelectFolder();
                }

                app.ExecuteCommand("File.SaveAll");

                var text = File.ReadAllText(TestData.GetPath(@"TestData\AddSearchPaths\AddSearchPaths.pyproj"));
                string actual = Regex.Match(text, @"<SearchPath>.*</SearchPath>", RegexOptions.Singleline).Value;
                Assert.AreEqual("<SearchPath>..\\Outlining\\</SearchPath>", actual);
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:18,代码来源:UITests.cs

示例12: AddNewFolder

        public void AddNewFolder() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                app.OpenSolutionExplorer().SelectProject(project);

                app.ExecuteCommand("Project.NewFolder");
                Keyboard.Type("MyNewFolder");
                Keyboard.PressAndRelease(Key.Enter);

                app.OpenSolutionExplorer().WaitForChildOfProject(project, "MyNewFolder");
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:13,代码来源:UITests.cs

示例13: CopyPasteFile

        public void CopyPasteFile() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                app.OpenSolutionExplorer();
                var window = app.SolutionExplorerTreeView;

                // find Program.py, send copy & paste, verify copy of file is there
                var programPy = window.FindItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "Program.py");

                AutomationWrapper.Select(programPy);

                Keyboard.ControlC();
                Keyboard.ControlV();

                Assert.IsNotNull(window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "Program - Copy.py"));

                AutomationWrapper.Select(programPy);
                Keyboard.ControlC();
                Keyboard.ControlV();

                Assert.IsNotNull(window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "Program - Copy (2).py"));
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:24,代码来源:UITests.cs

示例14: EnvironmentReplWorkingDirectoryTest

        private void EnvironmentReplWorkingDirectoryTest(
            PythonVisualStudioApp app,
            EnvDTE.Project project,
            TreeNode env
        ) {
            var path1 = Path.Combine(Path.GetDirectoryName(project.FullName), Guid.NewGuid().ToString("N"));
            var path2 = Path.Combine(Path.GetDirectoryName(project.FullName), Guid.NewGuid().ToString("N"));
            Directory.CreateDirectory(path1);
            Directory.CreateDirectory(path2);

            app.OpenSolutionExplorer().SelectProject(project);
            app.Dte.ExecuteCommand("Python.Interactive");

            using (var window = app.GetInteractiveWindow(string.Format("{0} Interactive", project.Name))) {
                Assert.IsNotNull(window, string.Format("Failed to find '{0} Interactive'", project.Name));
                app.ServiceProvider.GetUIThread().Invoke(() => project.GetPythonProject().SetProjectProperty("WorkingDirectory", path1));

                window.Reset();
                window.ExecuteText("import os; os.getcwd()").Wait();
                window.WaitForTextEnd(
                    string.Format("'{0}'", path1.Replace("\\", "\\\\")),
                    ">"
                );

                app.ServiceProvider.GetUIThread().Invoke(() => project.GetPythonProject().SetProjectProperty("WorkingDirectory", path2));

                window.Reset();
                window.ExecuteText("import os; os.getcwd()").Wait();
                window.WaitForTextEnd(
                    string.Format("'{0}'", path2.Replace("\\", "\\\\")),
                    ">"
                );
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:34,代码来源:VirtualEnvTests.cs

示例15: MultiSelectCopyAndPaste

        public void MultiSelectCopyAndPaste() {
            using (var app = new PythonVisualStudioApp()) {
                app.OpenProject(@"TestData\DebuggerProject.sln");

                app.OpenSolutionExplorer();
                var window = app.SolutionExplorerTreeView;

                var files = new[] { "BreakAllTest.py", "BreakpointTest.py", "BreakpointTest2.py" };
                bool anySelected = false;
                foreach (var f in files) {
                    var node = window.FindItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", f);
                    Assert.IsNotNull(node, f + " not found in DebuggerProject");
                    if (anySelected) {
                        ((SelectionItemPattern)node.GetCurrentPattern(SelectionItemPattern.Pattern)).AddToSelection();
                    } else {
                        node.Select();
                        anySelected = true;
                    }
                }
                Keyboard.ControlC();

                var projectNode = window.FindItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject");

                AutomationWrapper.Select(projectNode);
                Keyboard.ControlV();

                foreach (var f in files.Select(f => f.Remove(f.LastIndexOf('.')) + " - Copy" + f.Substring(f.LastIndexOf('.')))) {
                    Assert.IsNotNull(
                        window.WaitForItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", f),
                        f + " not found after copying");
                }
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:33,代码来源:UITests.cs


注:本文中的TestUtilities.UI.Python.PythonVisualStudioApp.OpenSolutionExplorer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。