コード例 #1
0
        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"));
                }
            }
        }
コード例 #2
0
        public void AddNewFolderLongPathTooLong()
        {
            using (var app = new VisualStudioApp())
            {
                var project = OpenLongFileNameProject(app, 24);

                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 'LongFileNames' (1 project)", "LFN");
                    AutomationWrapper.Select(projectNode);

                    Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.PressAndRelease(Key.Right);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.Type("012345678912");
                    Keyboard.PressAndRelease(Key.Enter);

                    VisualStudioApp.CheckMessageBox("The filename or extension is too long.");
                }
            }
        }
コード例 #3
0
ファイル: UITests.cs プロジェクト: ccwalkerjm/nodejstools
        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"));
                }
            }
        }
コード例 #4
0
ファイル: DebugProject.cs プロジェクト: zuokaihuang/PTVS
        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"));
                }
            }
        }
コード例 #5
0
        public void WebProjectLauncherNoStartupFile(VisualStudioApp app, DotNotWaitOnNormalExit optionSetter)
        {
            var project = app.CreateProject(
                PythonVisualStudioApp.TemplateLanguageName,
                PythonVisualStudioApp.EmptyWebProjectTemplate,
                TestData.GetTempPath(),
                "NewWebProject"
                );

            foreach (var cmd in new[] { "Debug.Start", "Debug.StartWithoutDebugging" })
            {
                app.Dte.ExecuteCommand(cmd);
                app.CheckMessageBox("The project cannot be launched because the startup file is not specified.");
            }
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        public void OpenInvalidUnicodeFile()
        {
            using (var app = new PythonVisualStudioApp()) {
                var project    = app.OpenProject(@"TestData\ErrorProjectUnicode.sln");
                var item       = project.ProjectItems.Item("Program.py");
                var windowTask = Task.Run(() => item.Open());

                VisualStudioApp.CheckMessageBox(TestUtilities.MessageBoxButton.Ok, "File Load", "Program.py", "ascii encoding");

                var window = windowTask.Result;
                window.Activate();
                var doc  = app.GetDocument(item.Document.FullName);
                var text = doc.TextView.TextBuffer.CurrentSnapshot.GetText();
                // Characters should not have been replaced
                Assert.AreEqual(-1, text.IndexOf("????"));
            }
        }
コード例 #8
0
ファイル: UITests.cs プロジェクト: ccwalkerjm/nodejstools
        public void AddNewItemLongPathTooLong()
        {
            using (var app = new VisualStudioApp()) {
                var project = OpenLongFileNameProject(app, 12);

                var window = app.OpenSolutionExplorer();

                // find server.js, send copy & paste, verify copy of file is there
                var projectNode = window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN");
                AutomationWrapper.Select(projectNode);

                using (var newItem = NewItemDialog.FromDte(app)) {
                    newItem.FileName = "NewJSFile.js";
                    newItem.OK();
                }

                VisualStudioApp.CheckMessageBox("The filename or extension is too long.");
            }
        }
コード例 #9
0
ファイル: LinkedFileTests.cs プロジェクト: shijiong/ntvsiot
        public void AddExistingItemAndFileByNameExistsInProjectButNotOnDisk()
        {
            foreach (var projectType in ProjectTypes)
            {
                using (var solution = LinkedFiles(projectType).Generate().ToVs()) {
                    var projectNode = solution.FindItem("LinkedFiles", "FolderWithAFile");
                    Assert.IsNotNull(projectNode, "projectNode");
                    AutomationWrapper.Select(projectNode);

                    using (var addExistingDlg = AddExistingItemDialog.FromDte(solution.App)) {
                        addExistingDlg.FileName = Path.Combine(solution.Directory, "ExistsInProjectButNotOnDisk" + projectType.CodeExtension);
                        addExistingDlg.AddLink();
                    }

                    solution.App.WaitForDialog();
                    VisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, "There is already a file of the same name in this folder.");
                }
            }
        }
コード例 #10
0
        public void RunWithoutStartupFile()
        {
            foreach (var projectType in ProjectTypes)
            {
                var testDef = new ProjectDefinition("RunWithoutStartupFile", projectType);

                using (var solution = testDef.Generate().ToVs()) {
                    solution.App.OpenDialogWithDteExecuteCommand("Debug.Start");
                    VisualStudioApp.CheckMessageBox(
                        "No startup file is defined for the startup project."
                        );

                    solution.App.OpenDialogWithDteExecuteCommand("Debug.StartWithoutDebugging");
                    VisualStudioApp.CheckMessageBox(
                        "No startup file is defined for the startup project."
                        );
                }
            }
        }
コード例 #11
0
        public void OpenInvalidUnicodeFile()
        {
            using (var app = new PythonVisualStudioApp()) {
                var project    = app.OpenProject(@"TestData\ErrorProjectUnicode.sln");
                var item       = project.ProjectItems.Item("Program.py");
                var windowTask = Task.Run(() => item.Open());

                VisualStudioApp.CheckMessageBox(TestUtilities.MessageBoxButton.Ok, "File Load", "Program.py", "Unicode (UTF-8) encoding");

                var window = windowTask.Result;
                window.Activate();
                var doc  = app.GetDocument(item.Document.FullName);
                var text = doc.TextView.TextBuffer.CurrentSnapshot.GetText();
                Console.WriteLine(string.Join(" ", text.Select(c => c < ' ' ? " .  " : string.Format(" {0}  ", c))));
                Console.WriteLine(string.Join(" ", text.Select(c => string.Format("{0:X04}", (int)c))));
                // Characters should have been replaced
                Assert.AreNotEqual(-1, text.IndexOf("\uFFFD\uFFFD\uFFFD\uFFFD", StringComparison.Ordinal));
            }
        }
コード例 #12
0
ファイル: LinkedFileTests.cs プロジェクト: shijiong/ntvsiot
        public void AddExistingItemAndLinkAlreadyExists()
        {
            foreach (var projectType in ProjectTypes)
            {
                using (var solution = LinkedFiles(projectType).Generate().ToVs()) {
                    var projectNode = solution.FindItem("LinkedFiles", "Oar");
                    Assert.IsNotNull(projectNode, "projectNode");
                    AutomationWrapper.Select(projectNode);

                    using (var addExistingDlg = AddExistingItemDialog.FromDte(solution.App)) {
                        addExistingDlg.FileName = Path.Combine(solution.Directory, "LinkedFilesDir\\SomeLinkedFile" + projectType.CodeExtension);
                        addExistingDlg.AddLink();
                    }

                    solution.App.WaitForDialog();
                    VisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, "There is already a link to", "SomeLinkedFile" + projectType.CodeExtension);
                }
            }
        }
コード例 #13
0
ファイル: UITests.cs プロジェクト: rsumner33/PTVS
        public void CopyFolderInToSelf()
        {
            DebugProject.OpenProject(@"Python.VS.TestData\HelloWorld2.sln", expectedProjects: 2);

            var app = new VisualStudioApp(VsIdeTestHostContext.Dte);

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

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

            folder.SetFocus();
            Keyboard.ControlC();

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

            subItem.SetFocus();
            Keyboard.ControlV();
            VisualStudioApp.CheckMessageBox("Cannot copy 'TestFolder'. The destination folder is a subfolder of the source folder.");
        }
コード例 #14
0
        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"));
                }
            }
        }
コード例 #15
0
ファイル: UITests.cs プロジェクト: zhangjinxing/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"));
            }
        }
コード例 #16
0
ファイル: UITests.cs プロジェクト: sarvex/nodejstools
        public void AddNewFolderLongPathTooLongCancelEdit()
        {
            using (var app = new VisualStudioApp()) {
                var project = OpenLongFileNameProject(app, 21);

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

                // find server.js, send copy & paste, verify copy of file is there
                var projectNode = window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN");
                AutomationWrapper.Select(projectNode);

                Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
                Keyboard.PressAndRelease(Key.D);
                Keyboard.PressAndRelease(Key.Right);
                Keyboard.PressAndRelease(Key.D);
                Keyboard.PressAndRelease(Key.Escape);

                VisualStudioApp.CheckMessageBox("The filename or extension is too long.");
            }
        }
コード例 #17
0
ファイル: UITests.cs プロジェクト: zhangjinxing/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"));
            }
        }
コード例 #18
0
        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)
                                             );
                    }
                }
            }
        }
コード例 #19
0
ファイル: UITests.cs プロジェクト: rsumner33/PTVS
        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"));
        }
コード例 #20
0
ファイル: UITests.cs プロジェクト: zhangjinxing/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");
            }
        }
コード例 #21
0
        public void MultiProjectMoveExists2()
        {
            foreach (var projectType in ProjectTypes)
            {
                using (var solution = MultiProjectLinkedFiles(projectType).ToVs()) {
                    var fileNode = solution.FindItem("LinkedFiles1", "FileNotInProject2" + projectType.CodeExtension);
                    Assert.IsNotNull(fileNode, "projectNode");
                    AutomationWrapper.Select(fileNode);

                    solution.ExecuteCommand("Edit.Copy");

                    var folderNode = solution.FindItem("LinkedFiles2");
                    AutomationWrapper.Select(folderNode);

                    ThreadPool.QueueUserWorkItem(x => solution.ExecuteCommand("Edit.Paste"));

                    string path = Path.Combine(solution.SolutionDirectory, "FileNotInProject2" + projectType.CodeExtension);
                    VisualStudioApp.CheckMessageBox(String.Format("There is already a link to '{0}'. You cannot have more than one link to the same file in a project.", path));

                    solution.WaitForDialogDismissed();
                }
            }
        }
コード例 #22
0
        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"));
                }
            }
        }
コード例 #23
0
        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"));
                }
            }
        }