public void DebugPythonCustomInterpreter() { // try once when the interpreter doesn't exist... using (var app = new VisualStudioApp()) { var project = app.OpenProject(TestData.GetPath(@"TestData\RelativeInterpreterPath.sln"), "Program.py"); app.Dte.ExecuteCommand("Debug.Start"); string expectedMissingInterpreterText = string.Format( "The project cannot be launched because no Python interpreter is available at \"{0}\". Please check the " + "Python Environments window and ensure the version of Python is installed and has all settings specified.", TestData.GetPath(@"TestData\Interpreter.exe")); var dialog = app.WaitForDialog(); VisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, expectedMissingInterpreterText); app.Dte.Solution.Close(false); // copy an interpreter over and try again File.Copy(PythonPaths.Python27.InterpreterPath, TestData.GetPath(@"TestData\Interpreter.exe")); try { OpenProjectAndBreak(app, TestData.GetPath(@"TestData\RelativeInterpreterPath.sln"), "Program.py", 1); app.Dte.Debugger.Go(WaitForBreakOrEnd: true); Assert.AreEqual(dbgDebugMode.dbgDesignMode, app.Dte.Debugger.CurrentMode); } finally { File.Delete(TestData.GetPath(@"TestData\Interpreter.exe")); } } }
public static OverwriteFileDialog Wait(VisualStudioApp app) { var hwnd = app.WaitForDialog(); Assert.AreNotEqual(IntPtr.Zero, hwnd, "Did not find OverwriteFileDialog"); var element = AutomationElement.FromHandle(hwnd); try { Assert.IsNotNull(element.FindFirst( TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "_allItems") ), "Not correct dialog - missing '_allItems'"); Assert.IsNotNull(element.FindFirst( TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "_yes") ), "Not correct dialog - missing '_yes'"); OverwriteFileDialog res = new OverwriteFileDialog(app, element); element = null; return(res); } finally { if (element != null) { AutomationWrapper.DumpElement(element); } } }
public void DeleteFile() { using (var app = new VisualStudioApp()) { var project = app.OpenProject(@"TestData\NodejsProjectData\DeleteFile.sln"); using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) { var window = app.OpenSolutionExplorer(); // find server.js, send copy & paste, verify copy of file is there var programPy = window.WaitForItem("Solution 'DeleteFile' (1 project)", "HelloWorld", "server.js"); Assert.IsTrue(File.Exists(@"TestData\NodejsProjectData\DeleteFile\server.js")); AutomationWrapper.Select(programPy); Keyboard.Type(Key.Delete); app.WaitForDialog(); VisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, "will be deleted permanently"); app.WaitForDialogDismissed(); window.WaitForItemRemoved("Solution 'DeleteFile' (1 project)", "HelloWorld", "server.js"); Assert.IsFalse(File.Exists(@"TestData\NodejsProjectData\DeleteFile\server.js")); } } }
public void DeleteLockedFolder() { using (var app = new VisualStudioApp()) { var project = app.OpenProject(@"TestData\NodejsProjectData\DeleteLockedFolder.sln"); using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) { var window = app.OpenSolutionExplorer(); var folderNode = window.WaitForItem("Solution 'DeleteLockedFolder' (1 project)", "DeleteLockedFolder", "Folder"); AutomationWrapper.Select(folderNode); var psi = new ProcessStartInfo( Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "system32", "cmd.exe")); psi.WorkingDirectory = Path.Combine(Environment.CurrentDirectory, @"TestData\NodejsProjectData\DeleteLockedFolder\Folder"); psi.CreateNoWindow = true; psi.UseShellExecute = false; using (var process = System.Diagnostics.Process.Start(psi)) { try { //Ensure the other process started and has time to lock the file System.Threading.Thread.Sleep(1000); Keyboard.Type(Key.Delete); app.WaitForDialog(); Keyboard.Type(Key.Enter); System.Threading.Thread.Sleep(500); VisualStudioApp.CheckMessageBox("The process cannot access the file 'Folder' because it is being used by another process."); } finally { process.Kill(); } } Assert.IsNotNull(window.FindItem("Solution 'DeleteLockedFolder' (1 project)", "DeleteLockedFolder", "Folder")); } } }
public AddVirtualEnvironmentDialogWrapper CreateVirtualEnv(VisualStudioApp app) { ClickHyperlinkByName(CreateVirtualEnvAutomationName); return(new AddVirtualEnvironmentDialogWrapper( app, AutomationElement.FromHandle(app.WaitForDialog()) )); }
public void RenameProjectToExisting() { using (var app = new VisualStudioApp()) { var project = app.OpenProject(@"TestData\NodejsProjectData\RenameProjectTestUI.sln"); using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) { var window = app.OpenSolutionExplorer(); // find server.js, send copy & paste, verify copy of file is there var projectNode = window.WaitForItem("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"); Keyboard.PressAndRelease(Key.Enter); IntPtr dialog = app.WaitForDialog(); VisualStudioApp.CheckMessageBox("HelloWorldExisting.njsproj", "overwrite"); // rename again, don't cancel... AutomationWrapper.Select(projectNode); Keyboard.PressAndRelease(Key.F2); System.Threading.Thread.Sleep(100); Keyboard.Type("HelloWorldExisting"); Keyboard.PressAndRelease(Key.Enter); dialog = app.WaitForDialog(); VisualStudioApp.CheckMessageBox(MessageBoxButton.Yes, "HelloWorldExisting.njsproj", "overwrite"); Assert.AreNotEqual(null, window.WaitForItem("Solution 'RenameProjectTestUI' (1 project)", "HelloWorldExisting")); } } }
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> /// Tests using a custom interpreter path that doesn't exist /// </summary> public void DebugPythonCustomInterpreterMissing(VisualStudioApp app, DotNotWaitOnNormalExit optionSetter) { var sln = app.CopyProjectForTest(@"TestData\RelativeInterpreterPath.sln"); var project = app.OpenProject(sln, "Program.py"); var interpreterPath = Path.Combine(PathUtils.GetParent(sln), "Interpreter.exe"); app.Dte.ExecuteCommand("Debug.Start"); string expectedMissingInterpreterText = string.Format( "The project cannot be launched because no Python interpreter is available at \"{0}\". Please check the " + "Python Environments window and ensure the version of Python is installed and has all settings specified.", interpreterPath); var dialog = app.WaitForDialog(); app.CheckMessageBox(expectedMissingInterpreterText); }
private static string SavePerfFile(string saveDirectory, VisualStudioApp app, IntPtr? dialog = null) { string destName; using (var saveDialog = new SaveDialog(app, AutomationElement.FromHandle(dialog ?? app.WaitForDialog()))) { var originalDestName = Path.Combine(saveDirectory, Path.GetFileName(saveDialog.FileName)); destName = originalDestName; while (File.Exists(destName)) { destName = string.Format("{0} {1}{2}", Path.GetFileNameWithoutExtension(originalDestName), Guid.NewGuid(), Path.GetExtension(originalDestName) ); } saveDialog.FileName = destName; saveDialog.Save(); } return destName; }
public void TestPublishFilesImpersonate() { var project = DebugProject.OpenProject(@"Python.VS.TestData\HelloWorld.sln"); try { string subDir = Guid.NewGuid().ToString(); project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir); string dir = Path.Combine(TestSharePrivate, subDir); 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 programPy = window.FindItem("Solution 'HelloWorld' (1 project)", "HelloWorld"); programPy.SetFocus(); ThreadPool.QueueUserWorkItem(x => VsIdeTestHostContext.Dte.ExecuteCommand("Build.PublishSelection")); var creds = new CredentialsDialog(app.WaitForDialog()); creds.UserName = PrivateShareUser; creds.Password = PrivateSharePassword; creds.Ok(); System.Threading.Thread.Sleep(2000); using (var impHelper = new ImpersonationHelper(new System.Net.NetworkCredential(PrivateShareUser.Split('\\')[1], PrivateSharePassword, PrivateShareUser.Split('\\')[0]))) { for (int i = 0; i < 10 && !Directory.Exists(dir); i++) { System.Threading.Thread.Sleep(1000); } var files = Directory.GetFiles(dir); Assert.AreEqual(files.Length, 1); Assert.AreEqual(Path.GetFileName(files[0]), "Program.py"); Directory.Delete(dir, true); } } finally { project.Properties.Item("PublishUrl").Value = ""; } }
public void RemoveItem() { using (var app = new VisualStudioApp()) { // close any projects before switching source control... app.Dte.Solution.Close(); app.SelectSourceControlProvider("Test Source Provider"); foreach (var projectType in ProjectTypes) { var testDef = SourceControlProject(projectType); using (var solution = testDef.Generate()) { TestSccProvider.DocumentEvents.Clear(); var project = app.OpenProject(solution.Filename); var window = app.OpenSolutionExplorer(); var fileName = "Program" + projectType.CodeExtension; var program = window.WaitForChildOfProject(project, fileName); program.Select(); Keyboard.Type(Key.Delete); app.WaitForDialog(); VisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, "will be deleted permanently"); app.WaitForDialogDismissed(); window.WaitForChildOfProjectRemoved(project, fileName); var projectDir = Path.GetDirectoryName(project.FullName); AssertDocumentEvents(projectDir, OnQueryRemoveFiles(fileName), OnAfterRemoveFiles(fileName) ); } } } }
public void DeferredSaveWithDot() { // http://pytools.codeplex.com/workitem/623 // enable deferred saving on projects using (var app = new VisualStudioApp()) { var props = app.Dte.get_Properties("Environment", "ProjectsAndSolution"); var prevValue = props.Item("SaveNewProjects").Value; props.Item("SaveNewProjects").Value = false; app.OnDispose(() => props.Item("SaveNewProjects").Value = prevValue); // now run the test var newProjDialog = app.FileNewProject(); newProjDialog.FocusLanguageNode("JavaScript"); var consoleApp = newProjDialog.ProjectTypes.FindItem("Blank Node.js Application"); consoleApp.Select(); newProjDialog.ProjectName = "Fob.Baz"; newProjDialog.ClickOK(); // wait for new solution to load... for (int i = 0; i < 100 && app.Dte.Solution.Projects.Count == 0; i++) { System.Threading.Thread.Sleep(1000); } TestUtils.DteExecuteCommandOnThreadPool("File.SaveAll"); var saveProjDialog = new SaveProjectDialog(app.WaitForDialog()); saveProjDialog.Save(); app.WaitForDialogDismissed(); var fullname = app.Dte.Solution.FullName; app.Dte.Solution.Close(false); Directory.Delete(Path.GetDirectoryName(fullname), true); } }
public void DeferredSaveWithDot() { // http://pytools.codeplex.com/workitem/623 // enable deferred saving on projects using (var app = new VisualStudioApp()) { var props = app.Dte.get_Properties("Environment", "ProjectsAndSolution"); var prevValue = props.Item("SaveNewProjects").Value; props.Item("SaveNewProjects").Value = false; app.OnDispose(() => props.Item("SaveNewProjects").Value = prevValue); // now run the test var newProjDialog = app.FileNewProject(); newProjDialog.FocusLanguageNode("JavaScript"); var consoleApp = newProjDialog.ProjectTypes.FindItem("Blank Node.js Application"); consoleApp.Select(); newProjDialog.ProjectName = "Fob.Baz"; newProjDialog.ClickOK(); // wait for new solution to load... for (int i = 0; i < 100 && app.Dte.Solution.Projects.Count == 0; i++) { System.Threading.Thread.Sleep(1000); } TestUtils.DteExecuteCommandOnThreadPool("File.SaveAll"); var saveProjDialog = new SaveProjectDialog(app.WaitForDialog()); saveProjDialog.Save(); app.WaitForDialogDismissed(); var fullname = app.Dte.Solution.FullName; app.Dte.Solution.Close(false); Directory.Delete(Path.GetDirectoryName(fullname), true); } }
private static INodeProfileSession LaunchSession( VisualStudioApp app, Func<INodeProfileSession> creator, string saveDirectory ) { INodeProfileSession session = null; var task = Task.Factory.StartNew(() => { session = creator(); // Must fault the task to abort the wait throw new Exception(); }); var dialog = app.WaitForDialog(task); if (dialog != IntPtr.Zero) { SavePerfFile(saveDirectory, app, dialog); try { task.Wait(TimeSpan.FromSeconds(5.0)); Assert.Fail("Task did not fault"); } catch (AggregateException) { } } Assert.IsNotNull(session, "Session was not correctly initialized"); return session; }
public void TestPublishFilesImpersonateCancelCredentials() { var project = DebugProject.OpenProject(@"Python.VS.TestData\HelloWorld.sln"); try { string subDir = Guid.NewGuid().ToString(); project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir); string dir = Path.Combine(TestSharePrivate, subDir); 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 programPy = window.FindItem("Solution 'HelloWorld' (1 project)", "HelloWorld"); programPy.SetFocus(); ThreadPool.QueueUserWorkItem(x => VsIdeTestHostContext.Dte.ExecuteCommand("Build.PublishSelection")); var creds = new CredentialsDialog(app.WaitForDialog()); creds.UserName = PrivateShareUser; creds.Password = PrivateSharePasswordIncorrect; creds.Cancel(); System.Threading.Thread.Sleep(2000); var statusBar = (IVsStatusbar)VsIdeTestHostContext.ServiceProvider.GetService(typeof(SVsStatusbar)); string text; ErrorHandler.ThrowOnFailure(statusBar.GetText(out text)); const string expected = "Publish failed: Access to the path '"; Assert.IsTrue(text.StartsWith(expected), "Expected '{0}', got '{1}'", expected, text); } finally { project.Properties.Item("PublishUrl").Value = ""; } }
public void DebugPythonCustomInterpreter() { // try once when the interpreter doesn't exist... using (var app = new VisualStudioApp()) { var project = app.OpenProject(TestData.GetPath(@"TestData\RelativeInterpreterPath.sln"), "Program.py"); app.Dte.ExecuteCommand("Debug.Start"); var dialog = app.WaitForDialog(); VisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, "Interpreter specified in the project does not exist:", "Interpreter.exe'"); app.Dte.Solution.Close(false); // copy an interpreter over and try again File.Copy(PythonPaths.Python27.InterpreterPath, TestData.GetPath(@"TestData\Interpreter.exe")); try { OpenProjectAndBreak(app, TestData.GetPath(@"TestData\RelativeInterpreterPath.sln"), "Program.py", 1); app.Dte.Debugger.Go(WaitForBreakOrEnd: true); Assert.AreEqual(dbgDebugMode.dbgDesignMode, app.Dte.Debugger.CurrentMode); } finally { File.Delete(TestData.GetPath(@"TestData\Interpreter.exe")); } } }
public static OverwriteFileDialog Wait(VisualStudioApp app) { var hwnd = app.WaitForDialog(); Assert.AreNotEqual(IntPtr.Zero, hwnd, "Did not find OverwriteFileDialog"); var element = AutomationElement.FromHandle(hwnd); try { Assert.IsNotNull(element.FindFirst( TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "_allItems") ), "Not correct dialog - missing '_allItems'"); Assert.IsNotNull(element.FindFirst( TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "_yes") ), "Not correct dialog - missing '_yes'"); var res = new OverwriteFileDialog(app, element); element = null; return res; } finally { if (element != null) { AutomationWrapper.DumpElement(element); } } }
public void RemoveItem() { using (var app = new VisualStudioApp()) { // close any projects before switching source control... app.Dte.Solution.Close(); app.SelectSourceControlProvider("Test Source Provider"); foreach (var projectType in ProjectTypes) { var testDef = SourceControlProject(projectType); using (var solution = testDef.Generate()) { TestSccProvider.DocumentEvents.Clear(); var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog); var window = app.SolutionExplorerTreeView; var fileName = "Program" + projectType.CodeExtension; var program = window.WaitForChildOfProject(project, fileName); program.Select(); Keyboard.Type(Key.Delete); app.WaitForDialog(); VisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, "will be deleted permanently"); app.WaitForDialogDismissed(); window.WaitForChildOfProjectRemoved(project, fileName); var projectDir = Path.GetDirectoryName(project.FullName); AssertDocumentEvents(projectDir, OnQueryRemoveFiles(fileName), OnAfterRemoveFiles(fileName) ); } } } }
public static AutomationDialog WaitForDialog(VisualStudioApp app) { return new AutomationDialog(app, AutomationElement.FromHandle(app.WaitForDialog())); }
public void DebugPythonCustomInterpreter() { // try once when the interpreter doesn't exist... using (var app = new VisualStudioApp()) { var project = app.OpenProject(TestData.GetPath(@"TestData\RelativeInterpreterPath.sln"), "Program.py"); app.Dte.ExecuteCommand("Debug.Start"); string expectedMissingInterpreterText = string.Format( "The project cannot be launched because no Python interpreter is available at \"{0}\". Please check the " + "Python Environments window and ensure the version of Python is installed and has all settings specified.", TestData.GetPath(@"TestData\Interpreter.exe")); var dialog = app.WaitForDialog(); VisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, expectedMissingInterpreterText); app.Dte.Solution.Close(false); // copy an interpreter over and try again File.Copy(PythonPaths.Python27.InterpreterPath, TestData.GetPath(@"TestData\Interpreter.exe")); try { OpenProjectAndBreak(app, TestData.GetPath(@"TestData\RelativeInterpreterPath.sln"), "Program.py", 1); app.Dte.Debugger.Go(WaitForBreakOrEnd: true); Assert.AreEqual(dbgDebugMode.dbgDesignMode, app.Dte.Debugger.CurrentMode); } finally { File.Delete(TestData.GetPath(@"TestData\Interpreter.exe")); } } }
public void RenameItemsTest() { using (var app = new VisualStudioApp()) { var project = app.OpenProject(@"TestData\NodejsProjectData\RenameItemsTestUI.sln"); using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) { var window = app.OpenSolutionExplorer(); // find server.js, send copy & paste, verify copy of file is there var projectNode = window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "server.js"); // rename once, cancel renaming to existing file.... AutomationWrapper.Select(projectNode); Keyboard.PressAndRelease(Key.F2); System.Threading.Thread.Sleep(100); Keyboard.Type("NewName.txt"); Keyboard.Type(Key.Delete); // delete extension left at end Keyboard.Type(Key.Delete); Keyboard.Type(Key.Delete); 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... AutomationWrapper.Select(projectNode); Keyboard.PressAndRelease(Key.F2); System.Threading.Thread.Sleep(100); Keyboard.Type("NewName.txt"); Keyboard.Type(Key.Delete); // delete extension left at end Keyboard.Type(Key.Delete); Keyboard.Type(Key.Delete); System.Threading.Thread.Sleep(100); Keyboard.PressAndRelease(Key.Enter); dialog = app.WaitForDialog(); VisualStudioApp.CheckMessageBox(MessageBoxButton.Yes, "file name extension"); Assert.AreNotEqual(null, window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "NewName.txt")); var subJs = window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "Sub1", "Sub2", "Foo.js"); Assert.IsNotNull(subJs); var sub1 = window.FindItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "Sub1"); AutomationWrapper.Select(sub1); Keyboard.PressAndRelease(Key.F2); System.Threading.Thread.Sleep(100); Keyboard.Type("FolderName"); Keyboard.PressAndRelease(Key.Enter); for (int i = 0; i < 20; i++) { try { if (project.GetIsFolderExpanded("FolderName")) { break; } } catch (ArgumentException) { } System.Threading.Thread.Sleep(100); } Assert.IsTrue(project.GetIsFolderExpanded("FolderName")); Assert.AreNotEqual(null, window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "FolderName", "Sub2", "Foo.js")); } } }
public void DeleteLockedFolder() { using (var app = new VisualStudioApp()) { var project = app.OpenProject(@"TestData\NodejsProjectData\DeleteLockedFolder.sln"); using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) { var window = app.OpenSolutionExplorer(); var folderNode = window.WaitForItem("Solution 'DeleteLockedFolder' (1 project)", "DeleteLockedFolder", "Folder"); AutomationWrapper.Select(folderNode); var psi = new ProcessStartInfo( Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "system32", "cmd.exe")); psi.WorkingDirectory = Path.Combine(Environment.CurrentDirectory, @"TestData\NodejsProjectData\DeleteLockedFolder\Folder"); psi.CreateNoWindow = true; psi.UseShellExecute = false; using (var process = System.Diagnostics.Process.Start(psi)) { try { //Ensure the other process started and has time to lock the file System.Threading.Thread.Sleep(1000); Keyboard.Type(Key.Delete); app.WaitForDialog(); Keyboard.Type(Key.Enter); System.Threading.Thread.Sleep(500); VisualStudioApp.CheckMessageBox("The process cannot access the file 'Folder' because it is being used by another process."); } finally { process.Kill(); } } Assert.IsNotNull(window.FindItem("Solution 'DeleteLockedFolder' (1 project)", "DeleteLockedFolder", "Folder")); } } }
public void DeleteFile() { using (var app = new VisualStudioApp()) { var project = app.OpenProject(@"TestData\NodejsProjectData\DeleteFile.sln"); using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) { var window = app.OpenSolutionExplorer(); // find server.js, send copy & paste, verify copy of file is there var programPy = window.WaitForItem("Solution 'DeleteFile' (1 project)", "HelloWorld", "server.js"); Assert.IsTrue(File.Exists(@"TestData\NodejsProjectData\DeleteFile\server.js")); AutomationWrapper.Select(programPy); Keyboard.Type(Key.Delete); app.WaitForDialog(); VisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, "will be deleted permanently"); app.WaitForDialogDismissed(); window.WaitForItemRemoved("Solution 'DeleteFile' (1 project)", "HelloWorld", "server.js"); Assert.IsFalse(File.Exists(@"TestData\NodejsProjectData\DeleteFile\server.js")); } } }
public static AutomationDialog WaitForDialog(VisualStudioApp app) { return(new AutomationDialog(app, AutomationElement.FromHandle(app.WaitForDialog()))); }
public void WebProjectCreateVirtualEnvOnNew() { using (var app = new VisualStudioApp()) { var t = Task.Run(() => app.CreateProject( PythonVisualStudioApp.TemplateLanguageName, PythonVisualStudioApp.FlaskWebProjectTemplate, TestData.GetTempPath(), "WebProjectCreateVirtualEnvOnNew", suppressUI: false )); using (var dlg = new AutomationDialog(app, AutomationElement.FromHandle(app.WaitForDialog(t)))) { // Create a virtual environment dlg.ClickButtonAndClose("CommandLink_1000", nameIsAutomationId: true); } using (var dlg = new AutomationDialog(app, AutomationElement.FromHandle(app.WaitForDialog(t)))) { dlg.ClickButtonByAutomationId("Create"); dlg.ClickButtonAndClose("Close", nameIsAutomationId: true); } var project = TaskExt.WaitAndUnwrapExceptions(t); var provider = project.Properties.Item("InterpreterFactoryProvider").Value as MSBuildProjectInterpreterFactoryProvider; for (int retries = 20; retries > 0; --retries) { if (provider.IsProjectSpecific(provider.ActiveInterpreter)) { break; } Thread.Sleep(1000); } Assert.IsTrue(provider.IsProjectSpecific(provider.ActiveInterpreter), "Did not have virtualenv"); for (int retries = 60; retries > 0; --retries) { if (InterpreterExt.FindModules(provider.ActiveInterpreter, "flask").Any()) { break; } Thread.Sleep(1000); } AssertUtil.ContainsExactly( InterpreterExt.FindModules(provider.ActiveInterpreter, "flask"), "flask" ); } }
public void RenameProjectToExisting() { using (var app = new VisualStudioApp()) { var project = app.OpenProject(@"TestData\NodejsProjectData\RenameProjectTestUI.sln"); using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) { var window = app.OpenSolutionExplorer(); // find server.js, send copy & paste, verify copy of file is there var projectNode = window.WaitForItem("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"); Keyboard.PressAndRelease(Key.Enter); IntPtr dialog = app.WaitForDialog(); VisualStudioApp.CheckMessageBox("HelloWorldExisting.njsproj", "overwrite"); // rename again, don't cancel... AutomationWrapper.Select(projectNode); Keyboard.PressAndRelease(Key.F2); System.Threading.Thread.Sleep(100); Keyboard.Type("HelloWorldExisting"); Keyboard.PressAndRelease(Key.Enter); dialog = app.WaitForDialog(); VisualStudioApp.CheckMessageBox(MessageBoxButton.Yes, "HelloWorldExisting.njsproj", "overwrite"); Assert.AreNotEqual(null, window.WaitForItem("Solution 'RenameProjectTestUI' (1 project)", "HelloWorldExisting")); } } }
public void RenameItemsTest() { using (var app = new VisualStudioApp()) { var project = app.OpenProject(@"TestData\NodejsProjectData\RenameItemsTestUI.sln"); using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) { var window = app.OpenSolutionExplorer(); // find server.js, send copy & paste, verify copy of file is there var projectNode = window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "server.js"); // rename once, cancel renaming to existing file.... AutomationWrapper.Select(projectNode); Keyboard.PressAndRelease(Key.F2); System.Threading.Thread.Sleep(100); Keyboard.Type("NewName.txt"); Keyboard.Type(Key.Delete); // delete extension left at end Keyboard.Type(Key.Delete); Keyboard.Type(Key.Delete); 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... AutomationWrapper.Select(projectNode); Keyboard.PressAndRelease(Key.F2); System.Threading.Thread.Sleep(100); Keyboard.Type("NewName.txt"); Keyboard.Type(Key.Delete); // delete extension left at end Keyboard.Type(Key.Delete); Keyboard.Type(Key.Delete); System.Threading.Thread.Sleep(100); Keyboard.PressAndRelease(Key.Enter); dialog = app.WaitForDialog(); VisualStudioApp.CheckMessageBox(MessageBoxButton.Yes, "file name extension"); Assert.AreNotEqual(null, window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "NewName.txt")); var subJs = window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "Sub1", "Sub2", "Foo.js"); Assert.IsNotNull(subJs); var sub1 = window.FindItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "Sub1"); AutomationWrapper.Select(sub1); Keyboard.PressAndRelease(Key.F2); System.Threading.Thread.Sleep(100); Keyboard.Type("FolderName"); Keyboard.PressAndRelease(Key.Enter); for (int i = 0; i < 20; i++) { try { if (project.GetIsFolderExpanded("FolderName")) { break; } } catch (ArgumentException) { } System.Threading.Thread.Sleep(100); } Assert.IsTrue(project.GetIsFolderExpanded("FolderName")); Assert.AreNotEqual(null, window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "FolderName", "Sub2", "Foo.js")); } } }