示例#1
0
        /// <summary>
        /// Verify we don't get called for a project which doesn't have source control enabled.
        /// </summary>
        public void SourceControlNoControl(VisualStudioApp app, ProjectGenerator pg)
        {
            // close any projects before switching source control...
            app.Dte.Solution.Close();

            app.SelectSourceControlProvider("Test Source Provider");
            DontExpectSourceControl();

            foreach (var projectType in pg.ProjectTypes)
            {
                var testDef = NoSourceControlProject(projectType);
                using (var solution = testDef.Generate()) {
                    var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                    Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);

                    app.Dte.Solution.Close();

                    Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
                    if (TestSccProvider.Failures.Count != 0)
                    {
                        Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
                    }

                    app.SelectSourceControlProvider("None");
                }
            }
        }
示例#2
0
        public void SourceControlExcludedFilesNotPresent()
        {
            using (var app = new VisualStudioApp()) {
                foreach (var projectType in ProjectTypes)
                {
                    using (var solution = SourceControlProject(projectType).Generate()) {
                        // close any projects before switching source control...
                        app.Dte.Solution.Close();

                        app.SelectSourceControlProvider("Test Source Provider");

                        var project = app.OpenProject(solution.Filename);

                        Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);
                        var sccProject = TestSccProvider.LoadedProjects.First();
                        foreach (var curFile in sccProject.Files)
                        {
                            Assert.IsFalse(curFile.Key.EndsWith("ExcludedFile" + projectType.CodeExtension), "found excluded file");
                        }
                    }
                }

                app.Dte.Solution.Close();
                app.SelectSourceControlProvider("None");
            }
        }
示例#3
0
        public void AddExistingItem(VisualStudioApp app, ProjectGenerator pg)
        {
            // close any projects before switching source control...
            app.Dte.Solution.Close();

            app.SelectSourceControlProvider("Test Source Provider");
            foreach (var projectType in pg.ProjectTypes)
            {
                var testDef = SourceControlProject(projectType);

                using (var solution = testDef.Generate()) {
                    TestSccProvider.DocumentEvents.Clear();

                    var project  = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);
                    var fileName = projectType.Code(@"ExcludedFile");

                    using (var newItem = AddExistingItemDialog.FromDte(app)) {
                        newItem.FileName = fileName;
                        newItem.OK();
                    }

                    System.Threading.Thread.Sleep(250);

                    Assert.IsNotNull(project.ProjectItems.Item(fileName));
                    AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                                         OnQueryAddFiles(fileName),
#if DEV16_OR_LATER      // We get queried twice now, it seems
                                         OnQueryAddFiles(fileName),
#endif
                                         OnAfterAddFilesEx(fileName)
                                         );
                }
            }
        }
示例#4
0
        public void NavigateTo()
        {
            using (var app = new VisualStudioApp()) {
                app.OpenProject(@"TestData\Navigation.sln");

                using (var dialog = app.OpenNavigateTo()) {
                    dialog.SearchTerm = "Class";
                    Assert.AreEqual(4, dialog.WaitForNumberOfResults(4));
                }

                using (var dialog = app.OpenNavigateTo()) {
                    dialog.SearchTerm = "cls";
                    Assert.AreEqual(4, dialog.WaitForNumberOfResults(4));
                }

                using (var dialog = app.OpenNavigateTo()) {
                    dialog.SearchTerm = "func";
                    Assert.AreEqual(8, dialog.WaitForNumberOfResults(8));
                }

                using (var dialog = app.OpenNavigateTo()) {
                    dialog.SearchTerm = "fn";
                    Assert.AreEqual(8, dialog.WaitForNumberOfResults(8));
                }
            }
        }
示例#5
0
        public void AddNewItem()
        {
            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 fileName = "NewFile" + projectType.CodeExtension;

                        using (var newItem = NewItemDialog.FromDte(app)) {
                            newItem.FileName = fileName;
                            newItem.OK();
                        }

                        System.Threading.Thread.Sleep(250);

                        Assert.IsNotNull(project.ProjectItems.Item(fileName));
                        AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                                             OnQueryAddFiles(fileName),
                                             OnAfterAddFilesEx(fileName)
                                             );
                    }
                }
            }
        }
        public void TestPublishFilesControlled()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\PublishTest.sln");
                try {
                    string subDir = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePublic, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                    string dir = Path.Combine(TestSharePublic, subDir);

                    app.OpenSolutionExplorer().SelectProject(project);

                    var files = PublishAndWaitForFiles(app, "Build.PublishSelection", dir);

                    Assert.IsNotNull(files, "Timed out waiting for files to publish");
                    Assert.AreEqual(2, files.Length);
                    AssertUtil.ContainsExactly(
                        files.Select(Path.GetFileName),
                        "Program.py",
                        "TextFile.txt"
                        );

                    Directory.Delete(dir, true);
                } finally {
                    WNetCancelConnection2(TestSharePrivate, 0, true);
                }
            }
        }
        public void TestPublishFtp()
        {
            using (var app = new VisualStudioApp()) {
                var    project = app.OpenProject(@"TestData\HelloWorld.sln");
                string subDir  = Guid.NewGuid().ToString();
                string url     = TestFtpUrl + "/" + subDir;
                project.Properties.Item("PublishUrl").Value = url;
                app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                string dir = Path.Combine(FtpValidateDir, subDir);
                Debug.WriteLine(dir);

                app.OpenSolutionExplorer().SelectProject(project);

                app.ExecuteCommand("Build.PublishSelection");
                System.Threading.Thread.Sleep(2000);
                var files = WaitForFiles(dir);
                Assert.AreEqual(1, files.Length);
                Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                // do it again w/ the directories already existing
                File.Delete(files[0]);

                app.OpenSolutionExplorer().SelectProject(project);
                app.ExecuteCommand("Build.PublishSelection");
                files = WaitForFiles(dir);
                Assert.AreEqual(1, files.Length);
                Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                Directory.Delete(dir, true);
            }
        }
示例#8
0
        private void OutlineTest(string filename, params ExpectedTag[] expected)
        {
            using (var app = new VisualStudioApp()) {
                var prevOption = NodejsPackage.Instance.AdvancedEditorOptionsPage.EnterOutliningOnOpen;
                try {
                    NodejsPackage.Instance.AdvancedEditorOptionsPage.EnterOutliningOnOpen = true;

                    var project = app.OpenProject(@"TestData\Outlining\Outlining.sln");

                    var item   = project.ProjectItems.Item(filename);
                    var window = item.Open();
                    window.Activate();

                    System.Threading.Thread.Sleep(2000);

                    var doc      = app.GetDocument(item.Document.FullName);
                    var snapshot = doc.TextView.TextBuffer.CurrentSnapshot;
                    var tags     = doc.GetTaggerAggregator <IOutliningRegionTag>(doc.TextView.TextBuffer).GetTags(new SnapshotSpan(snapshot, 0, snapshot.Length));

                    VerifyTags(doc.TextView.TextBuffer, tags, expected);
                }
                finally {
                    NodejsPackage.Instance.AdvancedEditorOptionsPage.EnterOutliningOnOpen = prevOption;
                }
            }
        }
示例#9
0
        public void DebugPythonProjectWithAndWithoutClearingPythonPath()
        {
            var    origPythonPath = Environment.GetEnvironmentVariable("PYTHONPATH");
            string testDataPath   = TestData.GetPath("TestData\\HelloWorld").Replace("\\", "\\\\");

            Environment.SetEnvironmentVariable("PYTHONPATH", testDataPath);
            try {
                using (var app = new VisualStudioApp()) {
                    app.OpenProject(TestData.GetPath(@"TestData\SysPath.sln"));

                    app.ServiceProvider.GetPythonToolsService().GeneralOptions.ClearGlobalPythonPath = false;
                    try {
                        ClearOutputWindowDebugPaneText();
                        app.Dte.ExecuteCommand("Debug.Start");
                        WaitForMode(app, dbgDebugMode.dbgDesignMode);

                        WaitForDebugOutput(text => text.Contains(testDataPath));
                    } finally {
                        app.ServiceProvider.GetPythonToolsService().GeneralOptions.ClearGlobalPythonPath = true;
                    }

                    ClearOutputWindowDebugPaneText();
                    app.Dte.ExecuteCommand("Debug.Start");
                    WaitForMode(app, dbgDebugMode.dbgDesignMode);

                    WaitForDebugOutput(text => text.Contains("DONE"));
                    var outputWindowText = GetOutputWindowDebugPaneText();
                    Assert.IsFalse(outputWindowText.Contains(testDataPath), outputWindowText);
                }
            } finally {
                Environment.SetEnvironmentVariable("PYTHONPATH", origPythonPath);
            }
        }
示例#10
0
        public void TestPendingBreakPointLocation()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\DebuggerProject.sln", "BreakpointInfo.py");
                var bpInfo  = project.ProjectItems.Item("BreakpointInfo.py");

                project.GetPythonProject().GetAnalyzer().WaitForCompleteAnalysis(x => true);

                var bp = app.Dte.Debugger.Breakpoints.Add(File: "BreakpointInfo.py", Line: 2);
                Assert.AreEqual("Python", bp.Item(1).Language);
                // FunctionName doesn't get queried for when adding the BP via EnvDTE, so we can't assert here :(
                //Assert.AreEqual("BreakpointInfo.C", bp.Item(1).FunctionName);
                bp = app.Dte.Debugger.Breakpoints.Add(File: "BreakpointInfo.py", Line: 3);
                Assert.AreEqual("Python", bp.Item(1).Language);
                //Assert.AreEqual("BreakpointInfo.C.f", bp.Item(1).FunctionName);
                bp = app.Dte.Debugger.Breakpoints.Add(File: "BreakpointInfo.py", Line: 6);
                Assert.AreEqual("Python", bp.Item(1).Language);
                //Assert.AreEqual("BreakpointInfo", bp.Item(1).FunctionName);
                bp = app.Dte.Debugger.Breakpoints.Add(File: "BreakpointInfo.py", Line: 7);
                Assert.AreEqual("Python", bp.Item(1).Language);
                //Assert.AreEqual("BreakpointInfo.f", bp.Item(1).FunctionName);

                // https://github.com/Microsoft/PTVS/pull/630
                // Make sure
            }
        }
示例#11
0
        public void TestPublishFilesImpersonate(VisualStudioApp app)
        {
            WNetCancelConnection2(TestSharePrivate, 0, true);
            try {
                var    project = app.OpenProject(@"TestData\HelloWorld.sln");
                string subDir  = Guid.NewGuid().ToString();
                project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir);
                app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");

                app.OpenSolutionExplorer().SelectProject(project);

                using (var creds = CredentialsDialog.PublishSelection(app)) {
                    creds.UserName = PrivateShareUserWithoutMachine;
                    creds.Password = PrivateSharePassword;
                    creds.OK();
                }

                string dir = Path.Combine(TestSharePrivate, subDir);

                var files = WaitForFiles(dir);

                Assert.IsNotNull(files, "Timed out waiting for files to publish");
                Assert.AreEqual(1, files.Length);
                Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                Directory.Delete(dir, true);
            } finally {
                WNetCancelConnection2(TestSharePrivate, 0, true);
            }
        }
示例#12
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");

                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"));
                }
            }
        }
示例#13
0
        public void ObjectBrowserSearchTextTest()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\ObjectBrowser.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                objectBrowser.EnsureLoaded();

                // Initially, we should have only the top-level collapsed node for the project

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                // Now that it is expanded, we should also get a node for Program.py

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(2, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                // Sanity-check the starting view with all nodes expanded.

                var expectedNodesBeforeSearch = new[] {
                    new NodeInfo("ObjectBrowser", "ObjectBrowser"),
                    new NodeInfo("Program.py", "Program.py", new[] { "frob()" }),
                    new NodeInfo("Oar", "class Oar", new[] { "oar(self)" }),
                    new NodeInfo("Fob", "class Fob"),
                    new NodeInfo("FobOarBaz", "class FobOarBaz", new[] { "frob(self)" }),
                };
                AssertNodes(objectBrowser, expectedNodesBeforeSearch);

                // Do the search and check results

                objectBrowser.SearchText.SetValue("oar");
                System.Threading.Thread.Sleep(1000);

                objectBrowser.SearchButton.Click();
                System.Threading.Thread.Sleep(1000);

                var expectedNodesAfterSearch = new[] {
                    new NodeInfo("oar", "def oar(self)"),
                    new NodeInfo("Oar", "class Oar", new[] { "oar(self)" }),
                    new NodeInfo("FobOarBaz", "class FobOarBaz", new[] { "frob(self)" }),
                };
                AssertNodes(objectBrowser, expectedNodesAfterSearch);

                // Clear the search and check that we get back to the starting view.

                objectBrowser.ClearSearchButton.Click();
                System.Threading.Thread.Sleep(1000);

                AssertNodes(objectBrowser, expectedNodesBeforeSearch);
            }
        }
示例#14
0
        public void SetAsStartupFile()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                // wait for 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,
                    "JavaScript1.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 == "JavaScript1.js")
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(250);
                }
                Assert.AreEqual(startupFile, Path.Combine(Environment.CurrentDirectory, @"TestData\HelloWorld", "JavaScript1.js"));
            }
        }
示例#15
0
        /// <summary>
        /// Verify we get called w/ a project which does have source control enabled.
        /// </summary>
        public void SourceControlRenameFolder(VisualStudioApp app, ProjectGenerator pg)
        {
            foreach (var projectType in pg.ProjectTypes)
            {
                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");

                TestSccProvider.DocumentEvents.Clear();

                using (var solution = SourceControlProject(projectType).Generate()) {
                    try {
                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                        project.ProjectItems.Item("TestFolder").Name = "Renamed";

                        AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                                             OnQueryRenameFiles("TestFolder\\", "Renamed\\", VSQUERYRENAMEFILEFLAGS_Directory),
                                             OnAfterRenameFiles("TestFolder\\", "Renamed\\", VSRENAMEFILEFLAGS_Directory)
                                             );
                        app.Dte.Solution.Close();
                    } finally {
                        app.SelectSourceControlProvider("None");
                    }
                }
            }
        }
示例#16
0
        public void AddDeleteItem2()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\ProjectHomeSingleProject.sln");

                var folder = project.ProjectItems.Item("Subfolder");

                Assert.AreEqual("ProjectSingle.pyproj", Path.GetFileName(project.FileName));

                folder.ProjectItems.AddFromTemplate(((Solution2)app.Dte.Solution).GetProjectItemTemplate("PyClass.zip", "pyproj"), "TemplateItem.py");

                var newItem = folder.ProjectItems.Item("TemplateItem.py");
                Assert.IsNotNull(newItem);
                Assert.AreEqual(false, project.Saved);
                project.Save();
                Assert.AreEqual(true, project.Saved);
                Assert.IsTrue(File.Exists(TestData.GetPath(@"TestData\ProjectHomeProjects\Subfolder\TemplateItem.py")));

                newItem.Delete();
                Assert.AreEqual(false, project.Saved);
                project.Save();
                Assert.AreEqual(true, project.Saved);
                Assert.IsFalse(File.Exists(TestData.GetPath(@"TestData\ProjectHomeProjects\Subfolder\TemplateItem.py")));
            }
        }
        public void TestPublishReadOnlyFiles()
        {
            var sourceFile = TestData.GetPath(@"TestData\HelloWorld\Program.py");

            Assert.IsTrue(File.Exists(sourceFile), sourceFile + " not found");
            var attributes = File.GetAttributes(sourceFile);

            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");
                try {
                    string subDir = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePublic, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                    string dir = Path.Combine(TestSharePublic, subDir);

                    File.SetAttributes(sourceFile, attributes | FileAttributes.ReadOnly);

                    app.OpenSolutionExplorer().SelectProject(project);

                    var files = PublishAndWaitForFiles(app, "Build.PublishSelection", dir);

                    Assert.IsNotNull(files, "Timed out waiting for files to publish");
                    Assert.AreEqual(1, files.Length);
                    Assert.AreEqual("Program.py", Path.GetFileName(files[0]));
                    Assert.IsTrue(File.GetAttributes(sourceFile).HasFlag(FileAttributes.ReadOnly), "Source file should be read-only");
                    Assert.IsFalse(File.GetAttributes(files[0]).HasFlag(FileAttributes.ReadOnly), "Published file should not be read-only");

                    Directory.Delete(dir, true);
                } finally {
                    WNetCancelConnection2(TestSharePublic, 0, true);
                    File.SetAttributes(sourceFile, attributes);
                }
            }
        }
示例#18
0
        public void DjangoProjectWithSubdirectory(VisualStudioApp app)
        {
            var sln     = app.CopyProjectForTest(@"TestData\DjangoProjectWithSubDirectory.sln");
            var slnDir  = PathUtils.GetParent(sln);
            var project = app.OpenProject(sln);

            var pyProj = project.GetPythonProject();
            var dsm    = pyProj.Site.GetUIThread().Invoke(() => pyProj.GetProperty("DjangoSettingsModule"));

            Assert.AreEqual("config.settings", dsm);
            var workDir = pyProj.Site.GetUIThread().Invoke(() => pyProj.GetWorkingDirectory()).TrimEnd('\\');

            Assert.AreEqual(Path.Combine(slnDir, "DjangoProjectWithSubDirectory", "project"), workDir, true);

            var cmd = pyProj.FindCommand("DjangoCollectStaticCommand");

            pyProj.Site.GetUIThread().Invoke(() => {
                Assert.IsTrue(cmd.CanExecute(pyProj), "Cannot execute DjangoCollectStaticCommand");
                cmd.Execute(pyProj);
            });

            // The static dir is 'test_static', check that the admin files
            // are copied into there.
            Assert.IsTrue(Directory.Exists(Path.Combine(workDir, "test_static", "admin")), "admin static directory was not created");
            Assert.IsTrue(File.Exists(Path.Combine(workDir, "test_static", "admin", "css", "base.css")), "admin static files were not copied");
        }
        public void TestPublishFilesImpersonateNoMachineName()
        {
            WNetCancelConnection2(TestSharePrivate, 0, true);
            using (var app = new VisualStudioApp()) {
                try {
                    var    project = app.OpenProject(@"TestData\HelloWorld.sln");
                    string subDir  = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");

                    app.OpenSolutionExplorer().SelectProject(project);

                    using (var creds = CredentialsDialog.PublishSelection(app)) {
                        creds.UserName = PrivateShareUserWithoutMachine;
                        creds.Password = PrivateSharePassword;
                        creds.OK();
                    }

                    System.Threading.Thread.Sleep(2000);

                    using (var helper = new NetUseHelper()) {
                        string dir   = Path.Combine(helper.Drive + "\\", subDir);
                        var    files = WaitForFiles(dir);
                        Assert.AreEqual(1, files.Length);
                        Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                        Directory.Delete(dir, true);
                    }
                } finally {
                    WNetCancelConnection2(TestSharePrivate, 0, true);
                }
            }
        }
示例#20
0
        ////[TestMethod, Priority(UITestPriority.P0)]
        //[HostType("VSTestHost"), TestCategory("Installed")]
        public void ObjectBrowserBasicTest(VisualStudioApp app)
        {
            var project = app.OpenProject(@"TestData\Outlining.sln");

            System.Threading.Thread.Sleep(1000);

            app.OpenObjectBrowser();
            var objectBrowser = app.ObjectBrowser;

            System.Threading.Thread.Sleep(1000);

            int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;

            Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

            AssertNodes(objectBrowser,
                        new NodeInfo("Outlining", "Outlining"),
                        new NodeInfo("BadForStatement.py", "BadForStatement.py"),
                        new NodeInfo("NestedFuncDef.py", "NestedFuncDef.py", new[] { "def f()" }),
                        new NodeInfo("Program.py", "Program.py", new[] { "def f()", "i" }));

            app.Dte.Solution.Close(false);

            System.Threading.Thread.Sleep(1000);
            nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
            Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());
        }
示例#21
0
        private static void RemoveSmartTagTest(string filename, int line, int column, bool allScopes, string expectedText)
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\RemoveImport.sln");
                var item    = project.ProjectItems.Item(filename);
                var window  = item.Open();
                window.Activate();

                var doc = app.GetDocument(item.Document.FullName);

                doc.Invoke(() => {
                    var point = doc.TextView.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(line - 1).Start.Add(column - 1);
                    doc.TextView.Caret.MoveTo(point);
                    doc.WaitForAnalyzerAtCaret();
                });

                if (allScopes)
                {
                    app.ExecuteCommand("EditorContextMenus.CodeWindow.RemoveImports.AllScopes");
                }
                else
                {
                    app.ExecuteCommand("EditorContextMenus.CodeWindow.RemoveImports.CurrentScope");
                }

                doc.WaitForText(expectedText);
            }
        }
示例#22
0
        public void AddDeleteItem2(VisualStudioApp app)
        {
            var sln     = app.CopyProjectForTest(@"TestData\ProjectHomeSingleProject.sln");
            var slnDir  = PathUtils.GetParent(sln);
            var project = app.OpenProject(sln);

            var folder = project.ProjectItems.Item("Subfolder");

            Assert.AreEqual("ProjectSingle.pyproj", Path.GetFileName(project.FileName));

            folder.ProjectItems.AddFromTemplate(((Solution2)app.Dte.Solution).GetProjectItemTemplate("PyClass.zip", "pyproj"), "TemplateItem.py");

            var newItem = folder.ProjectItems.Item("TemplateItem.py");

            Assert.IsNotNull(newItem);
            Assert.AreEqual(false, project.Saved);
            project.Save();
            Assert.AreEqual(true, project.Saved);
            Assert.IsTrue(File.Exists(Path.Combine(slnDir, "ProjectHomeProjects", "Subfolder", "TemplateItem.py")));

            newItem.Delete();
            Assert.AreEqual(false, project.Saved);
            project.Save();
            Assert.AreEqual(true, project.Saved);
            Assert.IsFalse(File.Exists(Path.Combine(slnDir, "ProjectHomeProjects", "Subfolder", "TemplateItem.py")));
        }
示例#23
0
        public void NavigateTo()
        {
            using (var app = new VisualStudioApp()) {
                app.OpenProject(@"TestData\Navigation.sln");

                using (var dialog = app.OpenNavigateTo()) {
                    dialog.SearchTerm = "Class";
                    Assert.AreEqual(4, dialog.WaitForNumberOfResults(4));
                }

                using (var dialog = app.OpenNavigateTo()) {
                    dialog.SearchTerm = "cls";
                    Assert.AreEqual(4, dialog.WaitForNumberOfResults(4));
                }

                using (var dialog = app.OpenNavigateTo()) {
                    dialog.SearchTerm = "func";
                    Assert.AreEqual(8, dialog.WaitForNumberOfResults(8));
                }

                using (var dialog = app.OpenNavigateTo()) {
                    dialog.SearchTerm = "fn";
                    Assert.AreEqual(8, dialog.WaitForNumberOfResults(8));
                }
            }
        }
示例#24
0
        ////[TestMethod, Priority(UITestPriority.P0)]
        //[HostType("VSTestHost"), TestCategory("Installed")]
        public void ObjectBrowserTypeBrowserViewTest(VisualStudioApp app)
        {
            var project = app.OpenProject(@"TestData\MultiModule.sln");

            System.Threading.Thread.Sleep(1000);

            app.OpenObjectBrowser();
            var objectBrowser = app.ObjectBrowser;

            System.Threading.Thread.Sleep(1000);

            int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;

            Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

            objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
            System.Threading.Thread.Sleep(1000);

            nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
            Assert.AreEqual(3, nodeCount, "Node count: " + nodeCount.ToString());

            string str = objectBrowser.TypeBrowserPane.Nodes[1].Value;

            Assert.AreEqual("MyModule.py", str, "");
            str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
            Assert.AreEqual("Program.py", str, "");

            objectBrowser.TypeBrowserPane.Nodes[1].ShowContextMenu();
            System.Threading.Thread.Sleep(1000);
            Condition con = new PropertyCondition(
                AutomationElement.ClassNameProperty,
                "ContextMenu"
                );
            AutomationElement el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);

            Assert.IsNotNull(el);
            Menu menu      = new Menu(el);
            int  itemCount = menu.Items.Count;

            Assert.AreEqual(7, itemCount, "Item count: " + itemCount.ToString());
            menu.Items[1].Check();
            System.Threading.Thread.Sleep(1000);

            nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
            Assert.AreEqual(2, nodeCount, "Node count: " + nodeCount.ToString());

            objectBrowser.TypeBrowserPane.Nodes[0].ShowContextMenu();
            System.Threading.Thread.Sleep(1000);
            el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
            Assert.IsNotNull(el);
            menu      = new Menu(el);
            itemCount = menu.Items.Count;
            Assert.AreEqual(7, itemCount, "Item count: " + itemCount.ToString());
            Assert.IsTrue(menu.Items[1].ToggleStatus);
            menu.Items[2].Check();
            System.Threading.Thread.Sleep(1000);

            nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
            Assert.AreEqual(3, nodeCount, "Node count: " + nodeCount.ToString());
        }
示例#25
0
        public void TransferItem()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    string filename, basename;
                    int    i = 0;
                    do
                    {
                        i++;
                        basename = "test" + i + " .js";
                        filename = Path.Combine(Path.GetTempPath(), basename);
                    } while (System.IO.File.Exists(filename));

                    System.IO.File.WriteAllText(filename, "function f() { }");

                    var fileWindow = app.Dte.ItemOperations.OpenFile(filename);

                    using (var dlg = ChooseLocationDialog.FromDte(app)) {
                        dlg.SelectProject("HelloWorld");
                        dlg.OK();
                    }

                    var window = app.OpenSolutionExplorer();
                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", basename));

                    Assert.AreEqual(fileWindow.Caption, basename);

                    System.IO.File.Delete(filename);
                }
            }
        }
示例#26
0
        public void SaveAs()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\SaveAsUI.sln");

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

                    // open and edit the file
                    var folderNode = solutionTree.WaitForItem("Solution 'SaveAsUI' (1 project)", "HelloWorld", "server.js");
                    folderNode.SetFocus();
                    Keyboard.PressAndRelease(Key.Enter);

                    var item   = project.ProjectItems.Item("server.js");
                    var window = item.Open();
                    window.Activate();

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

                    // save under a new file name
                    var    saveDialog = app.SaveAs();
                    string oldName    = saveDialog.FileName;
                    saveDialog.FileName = "Program2.js";
                    saveDialog.Save();

                    Assert.AreNotEqual(null, solutionTree.WaitForItem("Solution 'SaveAsUI' (1 project)", "HelloWorld", "Program2.js"));
                }
            }
        }
示例#27
0
        public void DragLeaveFolderTest()
        {
            using (var app = new VisualStudioApp()) {
                app.OpenProject(@"TestData\NodejsProjectData\DragDropTest.sln");

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

                    var folder  = window.WaitForItem("Solution 'DragDropTest' (1 project)", "DragDropTest", "TestFolder2", "SubFolder");
                    var project = window.WaitForItem("Solution 'DragDropTest' (1 project)", "DragDropTest");

                    // click on SubItem.js
                    var point = folder.GetClickablePoint();
                    Mouse.MoveTo(point);
                    Mouse.Down(MouseButton.Left);

                    // move to project and hover
                    var projectPoint = project.GetClickablePoint();
                    Mouse.MoveTo(projectPoint);

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

                    Assert.AreNotEqual(null, window.FindItem("Solution 'DragDropTest' (1 project)", "DragDropTest", "TestFolder2", "SubFolder"));
                }
            }
        }
示例#28
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"));
                }
            }
        }
示例#29
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"));
                }
            }
        }
示例#30
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"));
                }
            }
        }
示例#31
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"));
                }
            }
        }
示例#32
0
        public void ObjectBrowserBasicTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\Outlining.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                System.Threading.Thread.Sleep(1000);

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(4, nodeCount, "Node count: " + nodeCount.ToString());

                AssertNodes(objectBrowser,
                    new NodeInfo("Outlining", "Outlining"),
                    new NodeInfo("BadForStatement.py", "BadForStatement.py"),
                    new NodeInfo("NestedFuncDef.py", "NestedFuncDef.py", new[] { "f()" }),
                    new NodeInfo("Program.py", "Program.py", new[] { "f()" }));

                app.Dte.Solution.Close(false);

                System.Threading.Thread.Sleep(1000);
                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());
            }
        }
        public VisualStudioInstance(SolutionFile solution) {
            _solution = solution;
            _app = new VisualStudioApp();
            Project = _app.OpenProject(solution.Filename);

            ThreadHelper.Generic.Invoke(Keyboard.Reset);
            _solutionExplorer = _app.OpenSolutionExplorer();
            SelectSolutionNode();
        }
示例#34
0
        // Currently Fails: https://pytools.codeplex.com/workitem/2609
        public void MoveFolderWithItem() {
            using (var app = new VisualStudioApp()) {

                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");

                ExpectSourceControl();

                foreach (var projectType in ProjectTypes) {
                    var testDef = new ProjectDefinition("SourceControl", projectType,
                        PropertyGroup(
                            Property("SccProjectName", "HelloWorld"),
                            Property("SccLocalPath", "LocalPath"),
                            Property("SccAuxPath", "AuxPath"),
                            Property("SccProvider", "TestProvider")
                        ),
                        ItemGroup(
                            Folder("Fob"),
                            Folder("Fob\\Oar"),
                            Compile("Program"),
                            Compile("Fob\\Oar\\Quox")
                        )
                    );

                    using (var solution = testDef.Generate()) {
                        TestSccProvider.DocumentEvents.Clear();

                        var project = app.OpenProject(solution.Filename);
                        var window = app.OpenSolutionExplorer();
                        
                        var folder = window.WaitForItem("Solution 'SourceControl' (1 project)", "SourceControl", "Fob", "Oar");
                        var point = folder.GetClickablePoint();
                        Mouse.MoveTo(point);
                        Mouse.Down(MouseButton.Left);

                        var destFolder = window.WaitForItem("Solution 'SourceControl' (1 project)", "SourceControl");
                        Mouse.MoveTo(destFolder.GetClickablePoint());
                        Mouse.Up(MouseButton.Left);

                        window.AssertFileExists(Path.GetDirectoryName(solution.Filename), "Solution 'SourceControl' (1 project)", "SourceControl", "Oar", "Quox" + projectType.CodeExtension);
                        var projectDir = Path.GetDirectoryName(project.FullName);
                        AssertDocumentEvents(projectDir,
                            OnQueryRenameFiles(projectType.Code("Fob\\Oar\\Quox"), projectType.Code("Oar\\Quox"), VSQUERYRENAMEFILEFLAGS_NoFlags),
                            OnQueryRenameFiles("Fob\\Oar\\", "Oar", VSQUERYRENAMEFILEFLAGS_Directory),
                            OnAfterRenameFiles(projectType.Code("Fob\\Oar\\Quox"), projectType.Code("Oar\\Quox"), VSRENAMEFILEFLAGS_NoFlags),
                            OnAfterRenameFiles("Fob\\Oar\\", "Oar", VSRENAMEFILEFLAGS_Directory)
                        );
                    }
                }
            }
        }
示例#35
0
        public void AddDifferentFileType() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");
                string fullPath = TestData.GetPath(@"TestData\HelloWorld.sln");

                // "Python Environments", "References", "Search Paths", "Program.py"
                Assert.AreEqual(4, project.ProjectItems.Count);

                var item = project.ProjectItems.AddFromFileCopy(TestData.GetPath(@"TestData\Xaml\EmptyXName.xaml"));
                Assert.AreEqual("EmptyXName.xaml", item.Properties.Item("FileName").Value);
            }
        }
示例#36
0
        public void LoadNodejsProject() {
            using (var app = new VisualStudioApp()) {
                app.OpenProject(@"TestData\HelloWorld.sln");

                Assert.IsTrue(app.Dte.Solution.IsOpen, "The solution is not open");
                Assert.IsTrue(app.Dte.Solution.Projects.Count == 1, String.Format("Loading project resulted in wrong number of loaded projects, expected 1, received {0}", app.Dte.Solution.Projects.Count));

                var iter = app.Dte.Solution.Projects.GetEnumerator();
                iter.MoveNext();
                Project project = (Project)iter.Current;
                Assert.AreEqual("HelloWorld.njsproj", Path.GetFileName(project.FileName), "Wrong project file name");
            }
        }
示例#37
0
        public void DebugPythonProjectSubFolderStartupFileSysPath() {
            using (var app = new VisualStudioApp()) {
                app.OpenProject(TestData.GetPath(@"TestData\SysPath.sln"));

                ClearOutputWindowDebugPaneText();
                app.Dte.ExecuteCommand("Debug.Start");
                WaitForMode(app, dbgDebugMode.dbgDesignMode);

                // sys.path should point to the startup file directory, not the project directory.
                // this matches the behavior of start without debugging.
                // Note: backslashes are escaped in the output
                string testDataPath = TestData.GetPath("TestData\\SysPath\\Sub'").Replace("\\", "\\\\");
                WaitForDebugOutput(text => text.Contains(testDataPath));
            }
        }
示例#38
0
        public void LoadRelativeProjects() {
            using (var app = new VisualStudioApp()) {
            string fullPath = TestData.GetPath(@"TestData\ProjectHomeProjects.sln");
                app.OpenProject(@"TestData\ProjectHomeProjects.sln", expectedProjects: 9);

                foreach (var project in app.Dte.Solution.Projects.OfType<Project>()) {
                    var name = Path.GetFileName(project.FileName);
                    if (name.StartsWith("ProjectA")) {
                        // Should have ProgramA.py, Subfolder\ProgramB.py and Subfolder\Subsubfolder\ProgramC.py
                        var programA = project.ProjectItems.Item("ProgramA.py");
                        Assert.IsNotNull(programA);

                        var subfolder = project.ProjectItems.Item("Subfolder");
                        var programB = subfolder.ProjectItems.Item("ProgramB.py");
                        Assert.IsNotNull(programB);

                        var subsubfolder = subfolder.ProjectItems.Item("Subsubfolder");
                        var programC = subsubfolder.ProjectItems.Item("ProgramC.py");
                        Assert.IsNotNull(programC);
                    } else if (name.StartsWith("ProjectB")) {
                        // Should have ProgramB.py and Subsubfolder\ProgramC.py
                        var programB = project.ProjectItems.Item("ProgramB.py");
                        Assert.IsNotNull(programB);

                        var subsubfolder = project.ProjectItems.Item("Subsubfolder");
                        var programC = subsubfolder.ProjectItems.Item("ProgramC.py");
                        Assert.IsNotNull(programC);
                    } else if (name.StartsWith("ProjectSln")) {
                        // Should have ProjectHomeProjects\ProgramA.py, 
                        // ProjectHomeProjects\Subfolder\ProgramB.py and
                        // ProjectHomeProjects\Subfolder\Subsubfolder\ProgramC.py
                        var projectHome = project.ProjectItems.Item("ProjectHomeProjects");
                        var programA = projectHome.ProjectItems.Item("ProgramA.py");
                        Assert.IsNotNull(programA);

                        var subfolder = projectHome.ProjectItems.Item("Subfolder");
                        var programB = subfolder.ProjectItems.Item("ProgramB.py");
                        Assert.IsNotNull(programB);

                        var subsubfolder = subfolder.ProjectItems.Item("Subsubfolder");
                        var programC = subsubfolder.ProjectItems.Item("ProgramC.py");
                        Assert.IsNotNull(programC);
                    } else {
                        Assert.Fail("Wrong project file name", name);
                    }
                }
            }
        }
示例#39
0
        public void FileNamesResolve() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                var ps = System.Management.Automation.PowerShell.Create();
                ps.AddScript(@"
                        param($project)
                        $folderProjectItem = $project.ProjectItems.Item(""Program.py"")
                        $result =  $folderProjectItem.FileNames(1)
                ");
                ps.AddParameter("project", project);
                ps.Invoke();
                var result = ps.Runspace.SessionStateProxy.GetVariable("result");

                var folder = project.ProjectItems.Item("Program.py");
                string path = folder.get_FileNames(1);
                
                Assert.AreEqual(path, result);
            }
        }
示例#40
0
        public void ProjectBuild() {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                app.Dte.Solution.SolutionBuild.Build(true);

                string[] expectedOutputFiles = { "AppxManifest.xml", "HelloWorld.build.appxrecipe", "resources.pri", "startupinfo.xml" };

                string currentDir = Directory.GetCurrentDirectory();

                foreach (string s in expectedOutputFiles)
                {
                    Assert.AreEqual(true, File.Exists(string.Format("{0}\\TestData\\HelloWorld\\bin\\{1}", currentDir, s)),
                        string.Format("{0} is missing from bin output folder", s));
                }

                // TODO: 
                // Add test for rebuild
                // Add test to build all configs and platforms
            }
        }
示例#41
0
        public void ObjectBrowserTypeBrowserSortTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\MultiModule.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                System.Threading.Thread.Sleep(1000);

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(3, nodeCount, "Node count: " + nodeCount.ToString());

                string str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("MyModule.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
                Assert.AreEqual("Program.py", str, "");

                objectBrowser.TypeBrowserPane.Nodes[1].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                Condition con = new PropertyCondition(
                                        AutomationElement.ClassNameProperty,
                                        "ContextMenu"
                                    );
                AutomationElement el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                Menu menu = new Menu(el);
                int itemCount = menu.Items.Count;
                Assert.AreEqual(7, itemCount, "Item count: " + itemCount.ToString());
                menu.Items[6].Check();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(4, nodeCount, "Node count: " + nodeCount.ToString());
                objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(5, nodeCount, "Node count: " + nodeCount.ToString());
                Assert.AreEqual("Namespaces", objectBrowser.TypeBrowserPane.Nodes[3].Value, "");
                Assert.AreEqual("Namespaces", objectBrowser.TypeBrowserPane.Nodes[1].Value, "");
                objectBrowser.TypeBrowserPane.Nodes[3].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(6, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[3].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                objectBrowser.TypeBrowserPane.Nodes[0].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                menu = new Menu(el);
                itemCount = menu.Items.Count;
                Assert.AreEqual(7, itemCount, "Item count: " + itemCount.ToString());
                Assert.IsTrue(menu.Items[6].ToggleStatus);
                menu.Items[3].Check();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(4, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[3].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(6, nodeCount, "Node count: " + nodeCount.ToString());

                str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("MyModule.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
                Assert.AreEqual("SchoolMember", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[3].Value;
                Assert.AreEqual("Program.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[4].Value;
                Assert.AreEqual("Student", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[5].Value;
                Assert.AreEqual("Teacher", str, "");
            }
        }
示例#42
0
        public void ObjectBrowserContextMenuBasicTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\MultiModule.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                System.Threading.Thread.Sleep(1000);

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(3, nodeCount, "Node count: " + nodeCount.ToString());

                string str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("MyModule.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
                Assert.AreEqual("Program.py", str, "");

                objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(6, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[1].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                Condition con = new PropertyCondition(
                                        AutomationElement.ClassNameProperty,
                                        "ContextMenu"
                                    );
                AutomationElement el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                Menu menu = new Menu(el);
                int itemCount = menu.Items.Count;
                Assert.AreEqual(7, itemCount, "Item count: " + itemCount.ToString());
                Assert.AreEqual("Copy", menu.Items[0].Value.Trim(), "");
                Assert.AreEqual("View Namespaces", menu.Items[1].Value.Trim(), "");
                Assert.AreEqual("View Containers", menu.Items[2].Value.Trim(), "");
                Assert.AreEqual("Sort Alphabetically", menu.Items[3].Value.Trim(), "");
                Assert.AreEqual("Sort By Object Type", menu.Items[4].Value.Trim(), "");
                Assert.AreEqual("Sort By Object Access", menu.Items[5].Value.Trim(), "");
                Assert.AreEqual("Group By Object Type", menu.Items[6].Value.Trim(), "");
                Keyboard.PressAndRelease(System.Windows.Input.Key.Escape);

                objectBrowser.TypeBrowserPane.Nodes[2].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                menu = new Menu(el);
                itemCount = menu.Items.Count;
                Assert.AreEqual(13, itemCount, "Item count: " + itemCount.ToString());
                Assert.AreEqual("Go To Definition", menu.Items[0].Value.Trim(), "");
                Assert.AreEqual("Go To Declaration", menu.Items[1].Value.Trim(), "");
                Assert.AreEqual("Go To Reference", menu.Items[2].Value.Trim(), "");
                Assert.AreEqual("Browse Definition", menu.Items[3].Value.Trim(), "");
                Assert.AreEqual("Find All References", menu.Items[4].Value.Trim(), "");
                Assert.AreEqual("Filter To Type", menu.Items[5].Value.Trim(), "");
                Assert.AreEqual("Copy", menu.Items[6].Value.Trim(), "");
                Assert.AreEqual("View Namespaces", menu.Items[7].Value.Trim(), "");
                Assert.AreEqual("View Containers", menu.Items[8].Value.Trim(), "");
                Assert.AreEqual("Sort Alphabetically", menu.Items[9].Value.Trim(), "");
                Assert.AreEqual("Sort By Object Type", menu.Items[10].Value.Trim(), "");
                Assert.AreEqual("Sort By Object Access", menu.Items[11].Value.Trim(), "");
                Assert.AreEqual("Group By Object Type", menu.Items[12].Value.Trim(), "");
                Keyboard.PressAndRelease(System.Windows.Input.Key.Escape);
            }
        }
示例#43
0
        public void ObjectBrowserNavigationTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\MultiModule.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                objectBrowser.EnsureLoaded();

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(3, nodeCount, "Node count: " + nodeCount.ToString());

                string str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("MyModule.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
                Assert.AreEqual("Program.py", str, "");

                objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(6, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[4].Select();
                System.Threading.Thread.Sleep(1000);
                objectBrowser.TypeBrowserPane.Nodes[4].DoubleClick();
                System.Threading.Thread.Sleep(1000);

                str = app.Dte.ActiveDocument.Name;
                Assert.AreEqual("Program.py", str, "");

                int lineNo = ((TextSelection)app.Dte.ActiveDocument.Selection).ActivePoint.Line;
                Assert.AreEqual(14, lineNo, "Line number: " + lineNo.ToString());

                app.OpenObjectBrowser();
                objectBrowser.TypeBrowserPane.Nodes[2].Select();
                System.Threading.Thread.Sleep(1000);
                objectBrowser.TypeBrowserPane.Nodes[2].DoubleClick();
                System.Threading.Thread.Sleep(1000);

                str = app.Dte.ActiveDocument.Name;
                Assert.AreEqual("MyModule.py", str, "");

                lineNo = ((TextSelection)app.Dte.ActiveDocument.Selection).ActivePoint.Line;
                Assert.AreEqual(1, lineNo, "Line number: " + lineNo.ToString());

                objectBrowser.TypeBrowserPane.Nodes[3].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
            }
        }
示例#44
0
        public void ObjectBrowserInheritanceRelationshipTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\Inheritance.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                System.Threading.Thread.Sleep(1000);

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(2, nodeCount, "Node count: " + nodeCount.ToString());

                string str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("Program.py", str, "");

                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(5, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[3].Select();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeNavigatorPane.Nodes.Count;
                Assert.AreEqual(2, nodeCount, "Node Count: " + nodeCount.ToString());
                str = objectBrowser.TypeNavigatorPane.Nodes[0].Value;
                Assert.IsTrue(str.Trim().StartsWith("__init__(self"), str);
                str = objectBrowser.TypeNavigatorPane.Nodes[1].Value;
                Assert.AreEqual("tell(self)", str.Trim(), "");

                str = objectBrowser.DetailPane.Value;
                Assert.IsTrue(str.Trim().Contains("Student(SchoolMember)"), str);
                Assert.IsTrue(str.Trim().Contains("Represents a student."), str);

                objectBrowser.TypeNavigatorPane.Nodes[1].Select();
                System.Threading.Thread.Sleep(1000);

                str = objectBrowser.DetailPane.Value;
                Assert.IsTrue(str.Trim().Contains("def tell(self)"), str);

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
            }
        }
示例#45
0
        public void ObjectBrowserExpandTypeBrowserTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\Inheritance.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                objectBrowser.EnsureLoaded();

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                string str = objectBrowser.TypeBrowserPane.Nodes[0].Value;
                Assert.AreEqual("Inheritance", str, "");
                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(2, nodeCount, "Node count: " + nodeCount.ToString());

                str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("Program.py", str, "");

                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(5, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());
            }
        }
示例#46
0
        public void ProjectConfiguration()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                string[] expectedPlatforms = { "x86", "x64", "ARM" };
                string[] expectedConfigs = { "Debug", "Release" };

                var debug = project.ConfigurationManager.Item("Debug", "x86");
                Assert.AreEqual(debug.IsBuildable, true);

                // Check platforms
                for (int i = 0; i < expectedPlatforms.Length; i++)
                {
                    Assert.AreEqual(expectedPlatforms[i], ((object[])project.ConfigurationManager.PlatformNames)[i]);
                }

                // Check configurations
                for (int i = 0; i < expectedConfigs.Length; i++)
                {
                    Assert.AreEqual(expectedConfigs[i], ((object[])project.ConfigurationManager.ConfigurationRowNames)[i]);
                }
            }
        }
示例#47
0
        public void ResourceViewIsDisabledTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\Outlining.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenResourceView();
                var resourceView = app.ResourceView;
                Assert.IsNotNull(resourceView);
                System.Threading.Thread.Sleep(1000);

                Assert.IsNull(resourceView.TypeBrowserPane);
            }
        }
示例#48
0
        public void SourceControlExcludedFilesNotPresent() {
            using (var app = new VisualStudioApp()) {
                foreach (var projectType in ProjectTypes) {
                    using (var solution = SourceControlProject(projectType).Generate()) {
                        // close any projects before switching source control...
                        app.Dte.Solution.Close();

                        app.SelectSourceControlProvider("Test Source Provider");

                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                        Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);
                        var sccProject = TestSccProvider.LoadedProjects.First();
                        foreach (var curFile in sccProject.Files) {
                            Assert.IsFalse(curFile.Key.EndsWith("ExcludedFile" + projectType.CodeExtension), "found excluded file");
                        }
                    }
                }

                app.Dte.Solution.Close();
                app.SelectSourceControlProvider("None");
            }
        }
示例#49
0
        public void SourceControlNoControl() {
            using (var app = new VisualStudioApp()) {

                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");
                DontExpectSourceControl();

                foreach (var projectType in ProjectTypes) {
                    var testDef = NoSourceControlProject(projectType);
                    using (var solution = testDef.Generate()) {
                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);

                        app.Dte.Solution.Close();

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
                        if (TestSccProvider.Failures.Count != 0) {
                            Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
                        }

                        app.SelectSourceControlProvider("None");
                    }
                }
            }
        }
示例#50
0
        public void SourceControlGlyphChanged() {
            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()) {
                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                        Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);
                        var sccProject = TestSccProvider.LoadedProjects.First();
                        Microsoft.TestSccPackage.FileInfo fileInfo = null;
                        foreach (var curFile in sccProject.Files) {
                            if (curFile.Key.EndsWith("Program" + projectType.CodeExtension)) {
                                fileInfo = curFile.Value;
                                break;
                            }
                        }
                        Assert.IsNotNull(fileInfo);

                        fileInfo.GlyphChanged(VsStateIcon.STATEICON_CHECKEDOUTEXCLUSIVEOTHER);

                        var programPy = project.ProjectItems.Item("Program" + projectType.CodeExtension);
                        Assert.AreEqual(programPy.Properties.Item("SourceControlStatus").Value, "CHECKEDOUTEXCLUSIVEOTHER");

                        fileInfo.StateIcon = VsStateIcon.STATEICON_READONLY;
                        sccProject.AllGlyphsChanged();

                        Assert.AreEqual(programPy.Properties.Item("SourceControlStatus").Value, "READONLY");

                        app.Dte.Solution.Close();

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
                        if (TestSccProvider.Failures.Count != 0) {
                            Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
                        }

                        app.SelectSourceControlProvider("None");
                    }
                }
            }
        }
示例#51
0
        public void BasicSourceControl() {
            using (var app = new VisualStudioApp()) {

                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");

                ExpectSourceControl();

                foreach (var projectType in ProjectTypes) {
                    var testDef = SourceControlProject(projectType);

                    using (var solution = testDef.Generate()) {
                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                        Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);

                        TestSccProvider.ExpectedAuxPath = null;
                        TestSccProvider.ExpectedLocalPath = null;
                        TestSccProvider.ExpectedProvider = null;
                        TestSccProvider.ExpectedProjectName = null;

                        TestSccProvider.LoadedProjects.First().SccProject.SetSccLocation(
                            "NewProjectName",
                            "NewAuxPath",
                            "NewLocalPath",
                            "NewProvider"
                        );

                        app.Dte.Solution.Close();

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
                        if (TestSccProvider.Failures.Count != 0) {
                            Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
                        }

                        app.SelectSourceControlProvider("None");
                    }
                }
            }
        }
示例#52
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, 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)
                        );
                    }
                }
            }
        }
示例#53
0
        public void IncludeInProject() {
            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().ToVs()) {
                        TestSccProvider.DocumentEvents.Clear();
                        var project = app.OpenProject(solution.SolutionFilename, onDialog: OnNoSccDialog);
                        var window = app.SolutionExplorerTreeView;
                        var fileName = projectType.Code(@"ExcludedFile");

                        // Try to select the file.  If it throws, it is likely the issue was that we weren't showing all files.
                        try {
                            window.WaitForChildOfProject(project, fileName).Select();
                        } catch (Exception) {
                            // Show all files so we can see the excluded item if we previously couldn't
                            solution.ExecuteCommand("Project.ShowAllFiles");
                            window.WaitForChildOfProject(project, fileName).Select();
                        }

                        solution.ExecuteCommand("Project.IncludeInProject");

                        System.Threading.Thread.Sleep(250);

                        AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                            OnQueryAddFiles(fileName),
                            OnAfterAddFilesEx(fileName)
                        );
                    }
                }
            }
        }
示例#54
0
        public void ObjectBrowserNavigateVarContextMenuTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\MultiModule.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                objectBrowser.EnsureLoaded();

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(3, nodeCount, "Node count: " + nodeCount.ToString());

                string str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("MyModule.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
                Assert.AreEqual("Program.py", str, "");

                objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(6, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[4].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                Condition con = new PropertyCondition(
                                        AutomationElement.ClassNameProperty,
                                        "ContextMenu"
                                    );
                AutomationElement el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                Menu menu = new Menu(el);
                int itemCount = menu.Items.Count;
                Assert.AreEqual(13, itemCount, "Item count: " + itemCount.ToString());
                menu.Items[0].Check();
                System.Threading.Thread.Sleep(1000);

                str = app.Dte.ActiveDocument.Name;
                Assert.AreEqual("Program.py", str, "");

                int lineNo = ((TextSelection)app.Dte.ActiveDocument.Selection).ActivePoint.Line;
                Assert.AreEqual(14, lineNo, "Line number: " + lineNo.ToString());

                app.OpenObjectBrowser();
                objectBrowser.TypeBrowserPane.Nodes[5].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                menu = new Menu(el);
                menu.Items[0].Check();
                System.Threading.Thread.Sleep(1000);

                lineNo = ((TextSelection)app.Dte.ActiveDocument.Selection).ActivePoint.Line;
                Assert.AreEqual(3, lineNo, "Line number: " + lineNo.ToString());
            }
        }
示例#55
0
        public void ObjectBrowserFindAllReferencesTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\MultiModule.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                System.Threading.Thread.Sleep(1000);

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(3, nodeCount, "Node count: " + nodeCount.ToString());

                string str = objectBrowser.TypeBrowserPane.Nodes[1].Value;
                Assert.AreEqual("MyModule.py", str, "");
                str = objectBrowser.TypeBrowserPane.Nodes[2].Value;
                Assert.AreEqual("Program.py", str, "");

                objectBrowser.TypeBrowserPane.Nodes[2].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);
                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(6, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[4].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                Condition con = new PropertyCondition(
                                        AutomationElement.ClassNameProperty,
                                        "ContextMenu"
                                    );
                AutomationElement el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                Menu menu = new Menu(el);
                int itemCount = menu.Items.Count;
                Assert.AreEqual(13, itemCount, "Item count: " + itemCount.ToString());
                menu.Items[4].Check();
                System.Threading.Thread.Sleep(1000);

                //this needs to be updated for bug #4840
                str = app.Dte.ActiveWindow.Caption;
                Assert.IsTrue(str.Contains("2 matches found"), str);

                objectBrowser.TypeBrowserPane.Nodes[2].ShowContextMenu();
                System.Threading.Thread.Sleep(1000);
                el = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, con);
                Assert.IsNotNull(el);
                menu = new Menu(el);
                menu.Items[4].Check();
                System.Threading.Thread.Sleep(1000);

                str = app.Dte.ActiveWindow.Caption;
                Assert.IsTrue(str.Contains("2 matches found"), str);
            }
        }
示例#56
0
        public void SourceControlRenameFolder() {
            using (var app = new VisualStudioApp()) {
                foreach (var projectType in ProjectTypes) {
                    // close any projects before switching source control...
                    app.Dte.Solution.Close();

                    app.SelectSourceControlProvider("Test Source Provider");

                    TestSccProvider.DocumentEvents.Clear();

                    using (var solution = SourceControlProject(projectType).Generate()) {
                        try {
                            var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                            project.ProjectItems.Item("TestFolder").Name = "Renamed";

                            AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                                OnQueryRenameFiles("TestFolder\\", "Renamed\\", VSQUERYRENAMEFILEFLAGS_Directory),
                                OnAfterRenameFiles("TestFolder\\", "Renamed", VSRENAMEFILEFLAGS_Directory)
                            );
                            app.Dte.Solution.Close();
                        } finally {
                            app.SelectSourceControlProvider("None");
                        }
                    }
                }
            }
        }
示例#57
0
        internal static Project OpenProjectAndBreak(VisualStudioApp app, string projName, string filename, int lineNo, bool setStartupItem = true) {
            var project = app.OpenProject(projName, filename, setStartupItem: setStartupItem);

            app.Dte.Debugger.Breakpoints.Add(File: filename, Line: lineNo);
            app.Dte.ExecuteCommand("Debug.Start");

            WaitForMode(app, dbgDebugMode.dbgBreakMode);

            Assert.IsNotNull(app.Dte.Debugger.BreakpointLastHit);
            Assert.AreEqual(lineNo, app.Dte.Debugger.BreakpointLastHit.FileLine);
            return project;
        }
示例#58
0
        public void ObjectBrowserSearchTextTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\ObjectBrowser.sln");
                System.Threading.Thread.Sleep(1000);

                app.OpenObjectBrowser();
                var objectBrowser = app.ObjectBrowser;
                objectBrowser.EnsureLoaded();

                // Initially, we should have only the top-level collapsed node for the project

                int nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(1, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[0].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                // Now that it is expanded, we should also get a node for Program.py

                nodeCount = objectBrowser.TypeBrowserPane.Nodes.Count;
                Assert.AreEqual(2, nodeCount, "Node count: " + nodeCount.ToString());

                objectBrowser.TypeBrowserPane.Nodes[1].ExpandCollapse();
                System.Threading.Thread.Sleep(1000);

                // Sanity-check the starting view with all nodes expanded.

                var expectedNodesBeforeSearch = new[] {
                new NodeInfo("ObjectBrowser", "ObjectBrowser"),
                new NodeInfo("Program.py", "Program.py", new[] { "frob()" }),
                new NodeInfo("Oar", "class Oar", new[] { "oar(self)" }),
                new NodeInfo("Fob", "class Fob"),
                new NodeInfo("FobOarBaz", "class FobOarBaz", new[] { "frob(self)" }),
            };
                AssertNodes(objectBrowser, expectedNodesBeforeSearch);

                // Do the search and check results

                objectBrowser.SearchText.SetValue("oar");
                System.Threading.Thread.Sleep(1000);

                objectBrowser.SearchButton.Click();
                System.Threading.Thread.Sleep(1000);

                var expectedNodesAfterSearch = new[] {
                new NodeInfo("oar", "def oar(self)"),
                new NodeInfo("Oar", "class Oar", new[] { "oar(self)" }),
                new NodeInfo("FobOarBaz", "class FobOarBaz", new[] { "frob(self)" }),
            };
                AssertNodes(objectBrowser, expectedNodesAfterSearch);

                // Clear the search and check that we get back to the starting view.

                objectBrowser.ClearSearchButton.Click();
                System.Threading.Thread.Sleep(1000);

                AssertNodes(objectBrowser, expectedNodesBeforeSearch);
            }
        }
示例#59
0
        public void ProjectBuild()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                TargetInfo ti = TargetInfo.GetTargetInfo();

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

                Assert.IsFalse(0 == app.Dte.Solution.Projects.Count);

                // Set platform
                foreach (SolutionConfiguration2 solConfiguration2 in app.Dte.Solution.SolutionBuild.SolutionConfigurations) {
                    if (String.Equals(solConfiguration2.PlatformName, ti.Plat, StringComparison.Ordinal)) {
                        solConfiguration2.Activate();
                        break;
                    }
                }

                app.Dte.Solution.SolutionBuild.Build(true);

                string[] expectedOutputFiles = { "AppxManifest.xml", "HelloWorld.build.appxrecipe" };

                string currentDir = Directory.GetCurrentDirectory();

                foreach (string s in expectedOutputFiles) {
                    Assert.AreEqual(true, File.Exists(string.Format("{0}\\TestData\\HelloWorld\\bin\\{1}\\Debug\\{2}", currentDir, ti.Plat, s)),
                        string.Format("{0} is missing from bin output folder", s));
                }

                // TODO:
                // Add test for rebuild
                // Add test to build all configs and platforms
            }
        }
示例#60
0
        public void AddExistingItem() {
            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 fileName = projectType.Code(@"ExcludedFile");

                        using (var newItem = AddExistingItemDialog.FromDte(app)) {
                            newItem.FileName = fileName;
                            newItem.OK();
                        }

                        System.Threading.Thread.Sleep(250);

                        Assert.IsNotNull(project.ProjectItems.Item(fileName));
                        AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                            OnQueryAddFiles(fileName),
                            OnAfterAddFilesEx(fileName)
                        );
                    }
                }
            }
        }