예제 #1
0
        public void AbsolutePaths()
        {
            var proj = File.ReadAllText(TestData.GetPath(@"TestData\AbsolutePath\AbsolutePath.pyproj"));
            proj = proj.Replace("[ABSPATH]", TestData.GetPath(@"TestData\AbsolutePath"));
            File.WriteAllText(TestData.GetPath(@"TestData\AbsolutePath\AbsolutePath.pyproj"), proj);

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

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

                // find Program.py, send copy & paste, verify copy of file is there
                var programPy = window.WaitForItem("Solution 'AbsolutePath' (1 project)", "AbsolutePath", "Program.py");
                Assert.IsNotNull(programPy);
            }
        }
예제 #2
0
        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();
                }
            }
        }
예제 #3
0
        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();
                }
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        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);
                }
            }
        }
예제 #6
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        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);
            }
        }
예제 #7
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        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");
            }
        }
예제 #8
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        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"));
            }
        }
예제 #9
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        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"));
            }
        }
예제 #10
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        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");
            }
        }
예제 #11
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        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");
            }
        }
예제 #12
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        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);
            }
        }
예제 #13
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        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");
            }
        }
예제 #14
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        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"));
            }
        }
예제 #15
0
        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("\\", "\\\\")),
                    ">"
                );
            }
        }
예제 #16
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        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");
                }
            }
        }
예제 #17
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        public void DjangoMultiSelectContextMenu() {
            using (var app = new PythonVisualStudioApp()) {
                app.OpenProject(@"TestData\DjangoApplication.sln");

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

                var manageNode = window.FindItem("Solution 'DjangoApplication' (1 project)", "DjangoApplication", "manage.py");
                Mouse.MoveTo(manageNode.GetClickablePoint());
                Mouse.Click(MouseButton.Left);

                Keyboard.Press(Key.LeftShift);
                Keyboard.PressAndRelease(Key.Down);
                Keyboard.Release(Key.LeftShift);

                Mouse.MoveTo(manageNode.GetClickablePoint());
                Mouse.Click(MouseButton.Right);

                Keyboard.Type("j"); // Exclude from Project
                Assert.IsNull(window.WaitForItemRemoved("Solution 'DjangoApplication' (1 project)", "DjangoApplication", "manage.py"));
            }
        }
예제 #18
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        public void RenameItemsTest() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\RenameItemsTestUI.sln");

                var window = app.OpenSolutionExplorer();

                // find Program.py, send copy & paste, verify copy of file is there
                var node = window.FindChildOfProject(project, "Program.py");

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

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

                IntPtr dialog = app.WaitForDialog();

                VisualStudioApp.CheckMessageBox(MessageBoxButton.Cancel, "file name extension");

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

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

                dialog = app.WaitForDialog();

                VisualStudioApp.CheckMessageBox(MessageBoxButton.Yes, "file name extension");

                Assert.IsNotNull(window.WaitForChildOfProject(project, "NewName.txt"));
            }
        }
예제 #19
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        public void AddItemPreviousSiblingNotVisible() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\AddItemPreviousSiblingNotVisible.sln");

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

                var projectNode = window.WaitForItem("Solution 'AddItemPreviousSiblingNotVisible' (1 project)", "HelloWorld");
                Assert.IsNotNull(projectNode);
                AutomationWrapper.Select(projectNode);

                var solutionService = app.GetService<IVsSolution>(typeof(SVsSolution));
                Assert.IsNotNull(solutionService);

                IVsHierarchy selectedHierarchy;
                ErrorHandler.ThrowOnFailure(solutionService.GetProjectOfUniqueName(project.UniqueName, out selectedHierarchy));
                Assert.IsNotNull(selectedHierarchy);
                HierarchyEvents events = new HierarchyEvents();
                uint cookie;
                selectedHierarchy.AdviseHierarchyEvents(events, out cookie);

                using (var newItem = NewItemDialog.FromDte(app)) {
                    AutomationWrapper.Select(newItem.ProjectTypes.FindItem("Empty Python File"));
                    newItem.FileName = "zmodule1.py";
                    newItem.OK();
                }

                var test2 = window.WaitForItem("Solution 'AddItemPreviousSiblingNotVisible' (1 project)", "HelloWorld", "zmodule1.py");
                Assert.IsNotNull(test2);

                selectedHierarchy.UnadviseHierarchyEvents(cookie);

                object caption;
                ErrorHandler.ThrowOnFailure(
                    selectedHierarchy.GetProperty(
                        events.SiblingPrev,
                        (int)__VSHPROPID.VSHPROPID_Caption,
                        out caption
                    )
                );

                Assert.AreEqual("Program.py", caption);
            }
        }
예제 #20
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        public void CutPaste() {
            using (var app = new PythonVisualStudioApp()) {
                app.OpenProject(@"TestData\HelloWorld2.sln", expectedProjects: 2);
                var proj = app.Dte.Solution.Projects.Cast<Project>().Single(p => p.Name == "HelloWorld2");

                var window = app.OpenSolutionExplorer();

                window.FindChildOfProject(proj, "TestFolder", "SubItem.py").Select();

                app.ExecuteCommand("Edit.Cut");

                window.SelectProject(proj);
                app.ExecuteCommand("Edit.Paste");

                Assert.IsNotNull(window.WaitForChildOfProject(proj, "SubItem.py"));
                Assert.IsNull(window.WaitForChildOfProjectRemoved(proj, "TestFolder", "SubItem.py"));
            }
        }
예제 #21
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        public void AddNewFileOverwritingExistingFileNotInProject() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\AddExistingItem.sln");

                app.OpenSolutionExplorer().SelectProject(project);

                const string filename = "Program2.py";

                using (var addItemDlg = NewItemDialog.FromDte(app)) {
                    AutomationWrapper.Select(addItemDlg.ProjectTypes.FindItem("Empty Python File"));
                    addItemDlg.FileName = filename;
                    addItemDlg.OK();
                }

                VisualStudioApp.CheckMessageBox(
                    MessageBoxButton.Yes,
                    "A file with the same name", filename, "already exists. Do you want to overwrite it?"
                );

                app.OpenSolutionExplorer().WaitForChildOfProject(project, "Program2.py");
            }
        }
예제 #22
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        public void CopyFolderOnToSelf() {
            using (var app = new PythonVisualStudioApp()) {
                app.OpenProject(@"TestData\HelloWorld2.sln", expectedProjects: 2);
                var proj = app.Dte.Solution.Projects.Cast<Project>().Single(p => p.Name == "HelloWorld2");

                var window = app.OpenSolutionExplorer();

                try {
                    // Remove the destination folder in case a previous test has
                    // created it.
                    Directory.Delete(TestData.GetPath(@"TestData\HelloWorld2\TestFolder - Copy"), true);
                } catch {
                }

                window.FindChildOfProject(proj, "TestFolder").Select();
                app.ExecuteCommand("Edit.Copy");

                window.FindChildOfProject(proj, "TestFolder").Select();
                app.ExecuteCommand("Edit.Paste");

                Assert.IsNotNull(window.WaitForChildOfProject(proj, "TestFolder - Copy"));
            }
        }
예제 #23
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        public void SaveAs() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\SaveAsUI.sln");

                var item = project.ProjectItems.Item("Program.py");
                var window = item.Open();
                window.Activate();

                var selection = ((TextSelection)window.Selection);
                selection.SelectAll();
                selection.Delete();

                // save under a new file name
                using (var saveDialog = SaveDialog.FromDte(app)) {
                    Assert.AreEqual(item.FileNames[0], saveDialog.FileName);
                    saveDialog.FileName = "Program2.py";
                    saveDialog.WaitForInputIdle();
                    saveDialog.Save();
                }

                Assert.IsNotNull(app.OpenSolutionExplorer().WaitForChildOfProject(project, "Program2.py"));
            }
        }
예제 #24
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        public void DragDropTest() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\DragDropTest.sln");

                var window = app.OpenSolutionExplorer();

                var folder = window.FindChildOfProject(project, "TestFolder", "SubItem.py");
                var point = folder.Element.GetClickablePoint();
                Mouse.MoveTo(point);
                Mouse.Down(MouseButton.Left);

                point = window.FindChildOfProject(project).Element.GetClickablePoint();
                Mouse.MoveTo(point);
                Mouse.Up(MouseButton.Left);

                window.WaitForChildOfProject(project, "SubItem.py");
            }
        }
예제 #25
0
        public void LoadVirtualEnv() {
            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var project = CreateTemporaryProject(app);
                var projectName = project.UniqueName;

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

                var solution = app.Dte.Solution.FullName;
                app.Dte.Solution.Close(true);

                app.Dte.Solution.Open(solution);
                project = app.Dte.Solution.Item(projectName);

                app.OpenSolutionExplorer().WaitForChildOfProject(
                    project,
                    SR.GetString(SR.Environments),
                    envName
                );
            }
        }
예제 #26
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        public void DragDropFileToContainingFolderTest() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\DragDropTest.sln");
                var window = app.OpenSolutionExplorer();

                Mouse.MoveTo(window.FindChildOfProject(project, "TestFolder", "SubItem2.py").Element.GetClickablePoint());
                Mouse.Down(MouseButton.Left);

                Mouse.MoveTo(window.FindChildOfProject(project, "TestFolder").Element.GetClickablePoint());
                Mouse.Up(MouseButton.Left);

                using (var dlg = AutomationDialog.WaitForDialog(app)) { }
                window.WaitForChildOfProject(project, "TestFolder", "SubItem2.py");
            }
        }
예제 #27
0
        public void DeleteVirtualEnv() {
            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var options = app.GetService<PythonToolsService>().GeneralOptions;
                var oldAutoAnalyze = options.AutoAnalyzeStandardLibrary;
                app.OnDispose(() => { options.AutoAnalyzeStandardLibrary = oldAutoAnalyze; options.Save(); });
                options.AutoAnalyzeStandardLibrary = false;
                options.Save();

                var project = CreateTemporaryProject(app);

                string envName, envPath;
                TreeNode env;
                using (var ps = new ProcessScope("Microsoft.PythonTools.Analyzer")) {
                    env = app.CreateVirtualEnvironment(project, out envName, out envPath);

                    Assert.IsFalse(ps.WaitForNewProcess(TimeSpan.FromSeconds(10)).Any(), "Unexpected analyzer processes");
                }

                // Need to wait some more for the database to be loaded.
                app.WaitForNoDialog(TimeSpan.FromSeconds(10.0));

                env.Select();
                using (var removeDeleteDlg = RemoveItemDialog.FromDte(app)) {
                    removeDeleteDlg.Delete();
                }

                app.WaitForNoDialog(TimeSpan.FromSeconds(5.0));

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

                var projectHome = (string)project.Properties.Item("ProjectHome").Value;
                envPath = Path.Combine(projectHome, envPath);
                for (int retries = 10;
                    Directory.Exists(envPath) && retries > 0;
                    --retries) {
                    Thread.Sleep(1000);
                }
                Assert.IsFalse(Directory.Exists(envPath), envPath);
            }
        }
예제 #28
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        public void DragLeaveFolderTest() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\DragDropTest.sln");
                var window = app.OpenSolutionExplorer();

                // click on SubItem.py
                var point = window.FindChildOfProject(project, "TestFolder2", "SubFolder").Element.GetClickablePoint();
                Mouse.MoveTo(point);
                Mouse.Down(MouseButton.Left);

                // move to project and hover
                Mouse.MoveTo(window.FindChildOfProject(project).Element.GetClickablePoint());
                System.Threading.Thread.Sleep(500);

                // move back and release
                Mouse.MoveTo(point);
                Mouse.Up(MouseButton.Left);

                window.WaitForChildOfProject(project, "TestFolder2", "SubFolder");
            }
        }
예제 #29
0
        public void EnvironmentReplWorkingDirectory() {
            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var project = CreateTemporaryProject(app);

                app.ServiceProvider.GetUIThread().Invoke(() => {
                    var pp = project.GetPythonProject();
                    pp.Interpreters.AddInterpreter(dis.CurrentDefault);
                });

                var envName = dis.CurrentDefault.Description;
                var sln = app.OpenSolutionExplorer();
                var env = sln.FindChildOfProject(project, SR.GetString(SR.Environments), envName);

                EnvironmentReplWorkingDirectoryTest(app, project, env, envName);
            }
        }
예제 #30
0
파일: UITests.cs 프로젝트: wenh123/PTVS
        public void CopyFolderInToSelf() {
            using (var app = new PythonVisualStudioApp()) {
                app.OpenProject(@"TestData\HelloWorld2.sln", expectedProjects: 2);

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

                var folder = window.FindItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "TestFolder");
                AutomationWrapper.Select(folder);
                Keyboard.ControlC();

                try {
                    // Remove the destination folder in case a previous test has
                    // created it.
                    Directory.Delete(TestData.GetPath(@"TestData\HelloWorld2\TestFolder - Copy"), true);
                } catch {
                }

                var subItem = window.FindItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "TestFolder", "SubItem.py");
                AutomationWrapper.Select(subItem);
                Keyboard.ControlV();

                var item = window.WaitForItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "TestFolder - Copy", "SubItem.py");
                if (item == null) {
                    AutomationWrapper.DumpElement(window.Element);
                    Assert.Fail("Did not find TestFolder - Copy");
                }
            }
        }