Ejemplo n.º 1
0
        public void CrossProjectCutPaste()
        {
            using (var app = new VisualStudioApp())
            {
                app.OpenProject(@"TestData\NodejsProjectData\HelloWorld2.sln", expectedProjects: 2);

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    var folderNode = window.WaitForItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "TestFolder2");
                    AutomationWrapper.Select(folderNode);

                    Keyboard.ControlX();

                    var projectNode = window.FindItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld");

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

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld", "TestFolder2"));
                    Assert.AreEqual(null, window.WaitForItemRemoved("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "TestFolder2"));
                }
            }
        }
Ejemplo n.º 2
0
        public void SetAsStartupFile()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodeAppWithModule\NodeAppWithModule.sln");

                // wait for new solution to load...
                for (int i = 0; i < 40 && app.Dte.Solution.Projects.Count == 0; i++)
                {
                    System.Threading.Thread.Sleep(250);
                }

                var item = app.SolutionExplorerTreeView.WaitForItem(
                    "Solution '" + app.Dte.Solution.Projects.Item(1).Name + "' (1 project)",
                    app.Dte.Solution.Projects.Item(1).Name,
                    "mymod.js"
                    );

                AutomationWrapper.Select(item);
                app.Dte.ExecuteCommand("Project.SetasNode.jsStartupFile");

                string startupFile = null;
                for (int i = 0; i < 40; i++)
                {
                    startupFile = (string)project.Properties.Item("StartupFile").Value;
                    if (startupFile == "mymod.js")
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(250);
                }
                Assert.AreEqual(startupFile, Path.Combine(Environment.CurrentDirectory, @"TestData\NodeAppWithModule\NodeAppWithModule", "mymod.js"));
            }
        }
Ejemplo n.º 3
0
        public void AddNewFolderLongPathBoundary()
        {
            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("01234567891");
                    Keyboard.PressAndRelease(Key.Enter);

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN", "01234567891"));

                    var projectLoc  = Path.GetDirectoryName(project.FullName);
                    var checkedPath = Path.Combine(projectLoc, "LongFileNames", "01234567891");

                    Assert.IsTrue(Directory.Exists(checkedPath), checkedPath + " does not exist");
                }
            }
        }
Ejemplo n.º 4
0
        public void MoveLinkedNodeOpen()
        {
            foreach (var projectType in ProjectTypes)
            {
                using (var solution = LinkedFiles(projectType).Generate().ToVs()) {
                    var openWindow = solution.GetProject("LinkedFiles").ProjectItems.Item("MovedLinkedFileOpen" + projectType.CodeExtension).Open();
                    Assert.IsNotNull(openWindow, "openWindow");

                    var projectNode = solution.FindItem("LinkedFiles", "MovedLinkedFileOpen" + projectType.CodeExtension);

                    Assert.IsNotNull(projectNode, "projectNode");
                    AutomationWrapper.Select(projectNode);

                    solution.ExecuteCommand("Edit.Cut");

                    var folderNode = solution.FindItem("LinkedFiles", "MoveToFolder");
                    AutomationWrapper.Select(folderNode);

                    solution.ExecuteCommand("Edit.Paste");

                    var movedLinkedFileOpen = solution.WaitForItem("LinkedFiles", "MoveToFolder", "MovedLinkedFileOpen" + projectType.CodeExtension);
                    Assert.IsNotNull(movedLinkedFileOpen, "movedLinkedFileOpen");

                    Assert.IsTrue(File.Exists(Path.Combine(solution.SolutionDirectory, Path.Combine(solution.SolutionDirectory, "MovedLinkedFileOpen" + projectType.CodeExtension))));
                    Assert.IsFalse(File.Exists(Path.Combine(solution.SolutionDirectory, "MoveToFolder\\MovedLinkedFileOpen" + projectType.CodeExtension)));

                    // window sholudn't have changed.
                    Assert.AreEqual(VSTestContext.DTE.Windows.Item("MovedLinkedFileOpen" + projectType.CodeExtension), openWindow);
                }
            }
        }
Ejemplo n.º 5
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.");
                }
            }
        }
Ejemplo n.º 6
0
        public void MultiSelectCopyAndPaste()
        {
            using (var app = new VisualStudioApp())
            {
                app.OpenProject(@"TestData\NodejsProjectData\MultiSelectCopyAndPaste.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    var folderNode = window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server.js");
                    Mouse.MoveTo(folderNode.GetClickablePoint());
                    Mouse.Click();

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

                    var projectNode = window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste");

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

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server - Copy.js"));
                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server2 - Copy.js"));
                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server3 - Copy.js"));
                }
            }
        }
Ejemplo n.º 7
0
        public void MultiProjectMove()
        {
            foreach (var projectType in ProjectTypes)
            {
                using (var solution = MultiProjectLinkedFiles(projectType).ToVs()) {
                    var fileNode = solution.FindItem("LinkedFiles1", "FileNotInProject1" + projectType.CodeExtension);
                    Assert.IsNotNull(fileNode, "projectNode");
                    AutomationWrapper.Select(fileNode);

                    solution.ExecuteCommand("Edit.Copy");

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

                    solution.ExecuteCommand("Edit.Paste");

                    // item should have moved
                    var copiedFile = solution.WaitForItem("LinkedFiles2", "FileNotInProject1" + projectType.CodeExtension);
                    Assert.IsNotNull(copiedFile, "movedLinkedFile");

                    Assert.AreEqual(
                        true,
                        solution.GetProject("LinkedFiles2").ProjectItems.Item("FileNotInProject1" + projectType.CodeExtension).Properties.Item("IsLinkFile").Value
                        );
                }
            }
        }
        public void TestExcludedErrors()
        {
            var project = Project("TestExcludedErrors",
                                  Compile("server", "function f(a, b, c) { }\r\n\r\n"),
                                  Compile("excluded", "aa bb", isExcluded: true)
                                  );

            using (var solution = project.Generate().ToVs()) {
                List <IVsTaskItem> allItems = solution.WaitForErrorListItems(0);
                Assert.AreEqual(0, allItems.Count);

                var excluded = solution.WaitForItem("TestExcludedErrors", "excluded.js");
                AutomationWrapper.Select(excluded);
                solution.ExecuteCommand("Project.IncludeInProject");

                allItems = solution.WaitForErrorListItems(1);
                Assert.AreEqual(1, allItems.Count);

                excluded = solution.WaitForItem("TestExcludedErrors", "excluded.js");
                AutomationWrapper.Select(excluded);
                solution.ExecuteCommand("Project.ExcludeFromProject");

                allItems = solution.WaitForErrorListItems(0);
                Assert.AreEqual(0, allItems.Count);
            }
        }
Ejemplo n.º 9
0
        public void MoveStartupFile()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\NodejsProjectData\MoveStartupFile.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 server = window.WaitForItem("Solution 'MoveStartupFile' (1 project)", "HelloWorld", "server.js");
                    var folder = window.WaitForItem("Solution 'MoveStartupFile' (1 project)", "HelloWorld", "TestDir");

                    AutomationWrapper.Select(server);
                    Keyboard.ControlX();

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

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MoveStartupFile' (1 project)", "HelloWorld", "TestDir", "server.js"));

                    Assert.IsTrue(((string)project.Properties.Item("StartupFile").Value).EndsWith("TestDir\\server.js"));
                }
            }
        }
Ejemplo n.º 10
0
        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"));
            }
        }
Ejemplo n.º 11
0
        public void CutPasteRelocatedTest(VisualStudioApp app)
        {
            var sln    = app.CopyProjectForTest(@"TestData\CutPasteRelocatedTest.sln");
            var slnDir = PathUtils.GetParent(sln);

            FileUtils.CopyDirectory(TestData.GetPath("TestData", "CutPasteRelocatedTest"), Path.Combine(slnDir, "CutPasteRelocatedTest"));
            app.OpenProject(sln);

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

            var folder = window.FindItem("Solution 'CutPasteRelocatedTest' (1 project)", "CutPasteTest", "TestFolder", "SubItem.py");

            AutomationWrapper.Select(folder);
            app.ExecuteCommand("Edit.Cut");

            var projectItem = window.FindItem("Solution 'CutPasteRelocatedTest' (1 project)", "CutPasteTest");

            AutomationWrapper.Select(projectItem);
            app.ExecuteCommand("Edit.Paste");

            Assert.IsNotNull(window.WaitForItem("Solution 'CutPasteRelocatedTest' (1 project)", "CutPasteTest", "SubItem.py"));

            app.Dte.Solution.Close(true);
            // Ensure file was moved and the path was updated correctly.
            var project = app.OpenProject(sln);

            foreach (var item in project.ProjectItems.OfType <OAFileItem>())
            {
                Assert.IsTrue(File.Exists((string)item.Properties.Item("FullPath").Value), (string)item.Properties.Item("FullPath").Value);
            }
        }
Ejemplo n.º 12
0
        public void CopyPasteFile()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.sln");

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

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

                AutomationWrapper.Select(programPy);

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

                Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server - Copy.js"));

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

                Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server - Copy (2).js"));
            }
        }
Ejemplo n.º 13
0
        public void MoveLinkedNodeFileExistsButNotInProject()
        {
            foreach (var projectType in ProjectTypes)
            {
                using (var solution = LinkedFiles(projectType).Generate().ToVs()) {
                    var fileNode = solution.FindItem("LinkedFiles", "FileNotInProject" + projectType.CodeExtension);
                    Assert.IsNotNull(fileNode, "projectNode");
                    AutomationWrapper.Select(fileNode);

                    solution.ExecuteCommand("Edit.Cut");

                    var folderNode = solution.FindItem("LinkedFiles", "FolderWithAFile");
                    AutomationWrapper.Select(folderNode);

                    solution.ExecuteCommand("Edit.Paste");

                    // item should have moved
                    var fileNotInProject = solution.WaitForItem("LinkedFiles", "FolderWithAFile", "FileNotInProject" + projectType.CodeExtension);
                    Assert.IsNotNull(fileNotInProject, "fileNotInProject");

                    // but it should be the linked file on disk outside of our project, not the file that exists on disk at the same location.
                    var autoItem = solution.GetProject("LinkedFiles").ProjectItems.Item("FolderWithAFile").ProjectItems.Item("FileNotInProject" + projectType.CodeExtension);
                    Assert.AreEqual(Path.Combine(solution.SolutionDirectory, "FileNotInProject" + projectType.CodeExtension), autoItem.Properties.Item("FullPath").Value);
                }
            }
        }
Ejemplo n.º 14
0
        public void AddNewTypeScriptItem()
        {
            using (var solution = Project("AddNewTypeScriptItem", Compile("server")).Generate().ToVs())
            {
                var project = solution.WaitForItem("AddNewTypeScriptItem", "server.js");
                AutomationWrapper.Select(project);

                using (var newItem = solution.AddNewItem())
                {
                    newItem.FileName = "NewTSFile.ts";
                    newItem.OK();
                }

                using (AutoResetEvent buildDone = new AutoResetEvent(false))
                {
                    VSTestContext.DTE.Events.BuildEvents.OnBuildDone += (sender, args) =>
                    {
                        buildDone.Set();
                    };

                    solution.ExecuteCommand("Build.BuildSolution");
                    solution.WaitForOutputWindowText("Build", "tsc.exe");
                    Assert.IsTrue(buildDone.WaitOne(10000), "failed to wait for build)");
                }
            }
        }
Ejemplo n.º 15
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"));
                }
            }
        }
Ejemplo n.º 16
0
        public void AddNewFolder()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.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 'HelloWorld' (1 project)", "HelloWorld");
                    AutomationWrapper.Select(projectNode);

                    var startingDirs = new HashSet <string>(Directory.GetDirectories(@"TestData\NodejsProjectData\HelloWorld"), StringComparer.OrdinalIgnoreCase);
                    Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.PressAndRelease(Key.Right);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.Type("MyNewFolder");
                    var curDirs = new HashSet <string>(Directory.GetDirectories(@"TestData\NodejsProjectData\HelloWorld"), StringComparer.OrdinalIgnoreCase);
                    Assert.IsTrue(curDirs.IsSubsetOf(startingDirs) && startingDirs.IsSubsetOf(curDirs), "new directory created" + String.Join(", ", curDirs) + " vs. " + String.Join(", ", startingDirs));

                    Keyboard.PressAndRelease(Key.Enter);

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "MyNewFolder"));

                    Assert.IsTrue(Directory.Exists(@"TestData\NodejsProjectData\HelloWorld\MyNewFolder"));
                }
            }
        }
Ejemplo n.º 17
0
        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");
                }
            }
        }
Ejemplo n.º 18
0
        public void CopyPasteFile()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.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 'HelloWorld' (1 project)", "HelloWorld", "server.js");

                    AutomationWrapper.Select(programPy);

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

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server - Copy.js"));

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

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server - Copy (2).js"));
                }
            }
        }
Ejemplo n.º 19
0
        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"));
                }
            }
        }
Ejemplo n.º 20
0
        public void RenameLinkedNode()
        {
            foreach (var projectType in ProjectTypes)
            {
                using (var solution = LinkedFiles(projectType).Generate().ToVs())
                {
                    // implicitly linked node
                    var projectNode = solution.FindItem("LinkedFiles", "ImplicitLinkedFile" + projectType.CodeExtension);
                    Assert.IsNotNull(projectNode, "projectNode");
                    AutomationWrapper.Select(projectNode);

                    try
                    {
                        solution.ExecuteCommand("File.Rename");
                        Assert.Fail("Should have failed to rename");
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine(e.ToString());
                    }


                    // explicitly linked node
                    var explicitLinkedFile = solution.FindItem("LinkedFiles", "ExplicitDir", "ExplicitLinkedFile" + projectType.CodeExtension);
                    Assert.IsNotNull(explicitLinkedFile, "explicitLinkedFile");
                    AutomationWrapper.Select(explicitLinkedFile);

                    try
                    {
                        solution.ExecuteCommand("File.Rename");
                        Assert.Fail("Should have failed to rename");
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine(e.ToString());
                    }

                    var autoItem = solution.GetProject("LinkedFiles").ProjectItems.Item("ImplicitLinkedFile" + projectType.CodeExtension);
                    try
                    {
                        autoItem.Properties.Item("FileName").Value = "Fob";
                        Assert.Fail("Should have failed to rename");
                    }
                    catch (InvalidOperationException)
                    {
                    }

                    autoItem = solution.GetProject("LinkedFiles").ProjectItems.Item("ExplicitDir").ProjectItems.Item("ExplicitLinkedFile" + projectType.CodeExtension);
                    try
                    {
                        autoItem.Properties.Item("FileName").Value = "Fob";
                        Assert.Fail("Should have failed to rename");
                    }
                    catch (InvalidOperationException)
                    {
                    }
                }
            }
        }
Ejemplo n.º 21
0
        public void StartNewApp()
        {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.CreateProject(
                    PythonVisualStudioApp.TemplateLanguageName,
                    PythonVisualStudioApp.DjangoWebProjectTemplate,
                    TestData.GetTempPath(),
                    "StartNewApp"
                    );
                app.SolutionExplorerTreeView.SelectProject(project);

                using (var newAppDialog = NewAppDialog.FromDte(app)) {
                    newAppDialog.AppName = "Fob";
                    newAppDialog.OK();
                }

                app.SolutionExplorerTreeView.WaitForItem(
                    app.Dte.Solution.FullName,
                    app.Dte.Solution.Projects.Item(1).Name,
                    "Fob",
                    "models.py"
                    );

                var appFolder = project.ProjectItems.Item("Fob");
                Assert.IsNotNull(appFolder.Collection.Item("models.py"));
                Assert.IsNotNull(appFolder.Collection.Item("tests.py"));
                Assert.IsNotNull(appFolder.Collection.Item("views.py"));
                Assert.IsNotNull(appFolder.Collection.Item("__init__.py"));

                app.SolutionExplorerTreeView.SelectProject(project);
                app.Dte.ExecuteCommand("Project.ValidateDjangoApp");

                using (var console = app.GetInteractiveWindow("Django Management Console - " + project.Name)) {
                    Assert.IsNotNull(console);
                    console.WaitForTextEnd(
                        "Executing manage.py validate",
                        "0 errors found",
                        "The Python REPL process has exited",
                        ">"
                        );
                }

                app.SolutionExplorerTreeView.SelectProject(project);

                using (var newItem = NewItemDialog.FromDte(app)) {
                    AutomationWrapper.Select(newItem.ProjectTypes.FindItem("HTML Page"));
                    newItem.FileName = "NewPage.html";
                    newItem.OK();
                }

                System.Threading.Thread.Sleep(1000);

                Assert.IsNotNull(project.ProjectItems.Item("NewPage.html"));
            }
        }
Ejemplo n.º 22
0
        public void ProjectProperties()
        {
            var filename = Path.Combine(TestData.GetTempPath(), Path.GetRandomFileName());

            var project = Project("ProjectProperties",
                                  Compile("server"),
                                  Property(NodeProjectProperty.Environment, "fob=1\r\nbar=2;3\nbaz=4"),
                                  Property(NodeProjectProperty.DebuggerPort, "1234"),
                                  Property(CommonConstants.StartupFile, "server.js")
                                  );

            using (var solution = project.Generate().ToVs())
            {
                var projectNode = solution.WaitForItem("ProjectProperties");
                AutomationWrapper.Select(projectNode);

                solution.ExecuteCommand("ClassViewContextMenus.ClassViewMultiselectProjectReferencesItems.Properties");
                AutomationElement doc = null;
                for (int i = 0; i < 10; i++)
                {
                    doc = ((VisualStudioInstance)solution).App.GetDocumentTab("ProjectProperties");
                    if (doc != null)
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(1000);
                }
                Assert.IsNotNull(doc, "Failed to find project properties tab");

                var debuggerPort =
                    new TextBox(
                        new AutomationWrapper(doc).FindByAutomationId("_debuggerPort")
                        );
                var envVars = new TextBox(
                    new AutomationWrapper(doc).FindByAutomationId("_envVars")
                    );

                Assert.AreEqual(debuggerPort.Value, "1234");
                Assert.AreEqual(envVars.Value, "fob=1\r\nbar=2;3\r\nbaz=4");

                debuggerPort.Value = "2468";

                // Multi-line text box does not support setting value via automation.
                envVars.SetFocus();
                Keyboard.ControlA();
                Keyboard.Backspace();
                Keyboard.Type("fob=0\nbar=0;0\nbaz=0");

                solution.ExecuteCommand("File.SaveAll");

                var projFile = File.ReadAllText(solution.GetProject("ProjectProperties").FullName);
                Assert.AreNotEqual(-1, projFile.IndexOf("<DebuggerPort>2468</DebuggerPort>"));
                Assert.AreNotEqual(-1, projFile.IndexOf("<Environment>fob=0\r\nbar=0;0\r\nbaz=0</Environment>"));
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Selects the provided items with the mouse preparing for a drag and drop
        /// </summary>
        /// <param name="source"></param>
        private static void SelectItemsForDragAndDrop(AutomationElement[] source)
        {
            AutomationWrapper.Select(source.First());
            for (int i = 1; i < source.Length; i++)
            {
                AutomationWrapper.AddToSelection(source[i]);
            }

            Mouse.MoveTo(source.Last().GetClickablePoint());
            Mouse.Down(MouseButton.Left);
        }
Ejemplo n.º 24
0
        public void LoadSearchPath(PythonVisualStudioApp app)
        {
            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   = Strings.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");
        }
Ejemplo n.º 25
0
        public void SelectProject(EnvDTE.Project project)
        {
            var slnName = string.Format("Solution '{0}' ({1} of {1} project{2})",
                                        Path.GetFileNameWithoutExtension(project.DTE.Solution.FullName),
                                        project.DTE.Solution.Projects.Count,
                                        project.DTE.Solution.Projects.Count == 1 ? "" : "s"
                                        );
            AutomationWrapper item = WaitForItem(slnName, project.Name).AsWrapper();

            Assert.IsNotNull(item);
            item.Select();
        }
Ejemplo n.º 26
0
        public void MoveLinkedNode()
        {
            foreach (var projectType in ProjectTypes)
            {
                using (var solution = LinkedFiles(projectType).Generate().ToVs())
                {
                    var projectNode = solution.FindItem("LinkedFiles", "MovedLinkedFile" + projectType.CodeExtension);
                    Assert.IsNotNull(projectNode, "projectNode");
                    AutomationWrapper.Select(projectNode);

                    solution.ExecuteCommand("Edit.Cut");

                    var folderNode = solution.FindItem("LinkedFiles", "MoveToFolder");
                    AutomationWrapper.Select(folderNode);

                    solution.ExecuteCommand("Edit.Paste");

                    // item should have moved
                    var movedLinkedFile = solution.WaitForItem("LinkedFiles", "MoveToFolder", "MovedLinkedFile" + projectType.CodeExtension);
                    Assert.IsNotNull(movedLinkedFile, "movedLinkedFile");

                    // file should be at the same location
                    Assert.IsTrue(File.Exists(Path.Combine(solution.SolutionDirectory, "MovedLinkedFile" + projectType.CodeExtension)));
                    Assert.IsFalse(File.Exists(Path.Combine(solution.SolutionDirectory, "MoveToFolder\\MovedLinkedFile" + projectType.CodeExtension)));

                    // now move it back
                    AutomationWrapper.Select(movedLinkedFile);
                    solution.ExecuteCommand("Edit.Cut");

                    var originalFolder = solution.FindItem("LinkedFiles");
                    AutomationWrapper.Select(originalFolder);
                    solution.ExecuteCommand("Edit.Paste");

                    var movedLinkedFilePaste = solution.WaitForItem("LinkedFiles", "MovedLinkedFile" + projectType.CodeExtension);
                    Assert.IsNotNull(movedLinkedFilePaste, "movedLinkedFilePaste");

                    // and make sure we didn't mess up the path in the project file
                    MSBuild.Project buildProject = new MSBuild.Project(solution.GetProject("LinkedFiles").FullName);
                    bool            found        = false;
                    foreach (var item in buildProject.GetItems("Compile"))
                    {
                        if (item.UnevaluatedInclude == "..\\MovedLinkedFile" + projectType.CodeExtension)
                        {
                            found = true;
                            break;
                        }
                    }

                    Assert.IsTrue(found);
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Moves one or more items in solution explorer using the keyboard to cut and paste.
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="source"></param>
        private static void MoveByKeyboard(AutomationElement destination, params AutomationElement[] source)
        {
            AutomationWrapper.Select(source.First());
            for (int i = 1; i < source.Length; i++)
            {
                AutomationWrapper.AddToSelection(source[i]);
            }

            Keyboard.ControlX();

            AutomationWrapper.Select(destination);
            Keyboard.ControlV();
        }
Ejemplo n.º 28
0
        public void DirtyProperties()
        {
            using (var solution = Project("DirtyProperties").Generate().ToVs()) {
                var proj = solution.FindItem("DirtyProperties");
                AutomationWrapper.Select(proj);
                solution.App.Dte.ExecuteCommand("ClassViewContextMenus.ClassViewMultiselectProjectreferencesItems.Properties");
                var window = solution.App.Dte.Windows.Item("DirtyProperties");
                Assert.AreEqual(window.Caption, "DirtyProperties");

                solution.Project.Properties.Item("NodejsPort").Value = 3000;
                Assert.AreEqual(false, solution.Project.Saved);
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Moves one or more items in solution explorer using the keyboard to cut and paste.
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="source"></param>
        private static void MoveByKeyboard(IVisualStudioInstance vs, ITreeNode destination, params ITreeNode[] source)
        {
            AutomationWrapper.Select(source.First());
            for (int i = 1; i < source.Length; i++)
            {
                AutomationWrapper.AddToSelection(source[i]);
            }

            vs.ControlX();

            AutomationWrapper.Select(destination);
            vs.ControlV();
        }
Ejemplo n.º 30
0
        public void CopyPasteRenameFile()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\CopyPasteRenameProject\CopyPasteRenameProject.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    var jsFile = window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameJavaScript", "app.js");

                    AutomationWrapper.Select(jsFile);

                    Keyboard.ControlC();
                    Keyboard.ControlV();
                    var copiedJsFile = window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameJavaScript", "app - Copy.js");
                    Assert.AreNotEqual(null, copiedJsFile);

                    AutomationWrapper.Select(copiedJsFile);

                    Keyboard.PressAndRelease(Key.F2);
                    System.Threading.Thread.Sleep(100);

                    Keyboard.Type("renamed");
                    Keyboard.PressAndRelease(Key.Enter);

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameJavaScript", "renamed.js"));


                    var tsFile = window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameProjectTypeScript", "app.ts");

                    AutomationWrapper.Select(tsFile);

                    Keyboard.ControlC();
                    Keyboard.ControlV();
                    var copiedTsFile = window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameProjectTypeScript", "app - Copy.ts");
                    Assert.AreNotEqual(null, copiedTsFile);

                    AutomationWrapper.Select(copiedTsFile);

                    Keyboard.PressAndRelease(Key.F2);
                    System.Threading.Thread.Sleep(100);

                    Keyboard.Type("renamed");
                    Keyboard.PressAndRelease(Key.Enter);

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameProjectTypeScript", "renamed.ts"));
                }
            }
        }