public void SaveAs() { var project = DebugProject.OpenProject(@"Python.VS.TestData\SaveAsUI.sln"); var app = new VisualStudioApp(VsIdeTestHostContext.Dte); app.OpenSolutionExplorer(); var solutionTree = app.SolutionExplorerTreeView; // open and edit the file var folderNode = solutionTree.FindItem("Solution 'SaveAsUI' (1 project)", "HelloWorld", "Program.py"); folderNode.SetFocus(); Keyboard.PressAndRelease(Key.Enter); var item = project.ProjectItems.Item("Program.py"); var window = item.Open(); var selection = ((TextSelection)window.Selection); selection.SelectAll(); selection.Delete(); // save under a new file name var saveDialog = app.SaveAs(); string oldName = saveDialog.FileName; saveDialog.FileName = "Program2.py"; saveDialog.Save(); Assert.AreNotEqual(null, solutionTree.WaitForItem("Solution 'SaveAsUI' (1 project)", "HelloWorld", "Program2.py")); }
public void MultiSelectCopyAndPaste() { DebugProject.OpenProject(@"Python.VS.TestData\DebuggerProject.sln"); var app = new VisualStudioApp(VsIdeTestHostContext.Dte); app.OpenSolutionExplorer(); var window = app.SolutionExplorerTreeView; var folderNode = window.FindItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", "BreakAllTest.py"); folderNode.SetFocus(); Keyboard.Press(Key.LeftShift); Keyboard.PressAndRelease(Key.Down); Keyboard.PressAndRelease(Key.Down); Keyboard.Release(Key.LeftShift); Keyboard.ControlC(); var projectNode = window.FindItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject"); projectNode.SetFocus(); Keyboard.ControlV(); Assert.AreNotEqual(null, window.WaitForItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", "BreakAllTest - Copy.py")); Assert.AreNotEqual(null, window.WaitForItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", "BreakpointTest - Copy.py")); Assert.AreNotEqual(null, window.WaitForItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", "BreakpointTest2 - Copy.py")); }
public void RenameProjectToExisting() { var project = DebugProject.OpenProject(@"Python.VS.TestData\RenameProjectTestUI.sln"); var app = new VisualStudioApp(VsIdeTestHostContext.Dte); 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.... projectNode.SetFocus(); 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... projectNode.SetFocus(); 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.AreNotEqual(null, window.WaitForItem("Solution 'RenameProjectTestUI' (1 project)", "HelloWorldExisting")); }
/// <summary> /// Selects the given source control provider. Name merely needs to be enough text to disambiguate from other source control providers. /// </summary> public void SelectSourceControlProvider(string providerName) { Element.SetFocus(); // bring up Tools->Options ThreadPool.QueueUserWorkItem(x => Dte.ExecuteCommand("Tools.Options")); // wait for it... IntPtr dialog = WaitForDialog(); // go to the tree view which lets us select a set of options... var treeView = new TreeView(AutomationElement.FromHandle(dialog).FindFirst(TreeScope.Descendants, new PropertyCondition( AutomationElement.ClassNameProperty, "SysTreeView32") )); treeView.FindItem("Source Control", "Plug-in Selection").SetFocus(); var currentSourceControl = new ComboBox( AutomationElement.FromHandle(dialog).FindFirst( TreeScope.Descendants, new AndCondition( new PropertyCondition( AutomationElement.NameProperty, "Current source control plug-in:" ), new PropertyCondition( AutomationElement.ClassNameProperty, "ComboBox" ) ) ) ); currentSourceControl.SelectItem(providerName); Keyboard.PressAndRelease(Key.Enter); WaitForDialogDismissed(); }
public void AddNewFolder() { var project = DebugProject.OpenProject(@"Python.VS.TestData\HelloWorld.sln"); var app = new VisualStudioApp(VsIdeTestHostContext.Dte); app.OpenSolutionExplorer(); var window = app.SolutionExplorerTreeView; // find Program.py, send copy & paste, verify copy of file is there var projectNode = window.FindItem("Solution 'HelloWorld' (1 project)", "HelloWorld"); projectNode.SetFocus(); Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift); Keyboard.PressAndRelease(Key.D); Keyboard.PressAndRelease(Key.Right); Keyboard.PressAndRelease(Key.D); Keyboard.Type("MyNewFolder"); Keyboard.PressAndRelease(Key.Enter); Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "MyNewFolder")); }
public void Save() { Keyboard.PressAndRelease(Key.S, Key.LeftAlt); }