示例#1
0
        public virtual void Teardown()
        {
            try {
                ValidateIdeLogMessages();

                LoggingService.RemoveLogger(Logger.Name);
                Logger.Dispose();
            } finally {
                var testStatus = TestContext.CurrentContext.Result.Status;
                if (testStatus != TestStatus.Passed)
                {
                    try {
                        TakeScreenShot(string.Format("{0}-Test-Failed", TestContext.CurrentContext.Test.Name));
                    } catch (Exception e) {
                        Session.DebugObject.Debug("Final Screenshot failed");
                    }
                }

                File.WriteAllText(Path.Combine(currentTestResultFolder, "MemoryUsage.json"),
                                  JsonConvert.SerializeObject(Session.MemoryStats, Formatting.Indented));

                Ide.CloseAll();
                TestService.EndSession();

                OnCleanUp();
                if (testStatus == TestStatus.Passed)
                {
                    if (Directory.Exists(currentTestResultScreenshotFolder))
                    {
                        Directory.Delete(currentTestResultScreenshotFolder, true);
                    }
                }
            }
        }
示例#2
0
        public void OpenEditCompile()
        {
            var slnFile = Ide.OpenTestSolution("ConsoleApp-VS2010/ConsoleApplication.sln");
            var slnDir  = slnFile.ParentDirectory;

            var exe = slnDir.Combine("bin", "Debug", "ConsoleApplication.exe");

            Assert.IsFalse(File.Exists(exe));

            Ide.OpenFile(slnFile.ParentDirectory.Combine("Program.cs"));

            Ide.BuildSolution();
            AssertExeHasOutput(exe, "");

            //select text editor, move down 10 lines, and insert a statement
            Session.SelectActiveWidget();
            for (int n = 0; n < 10; n++)
            {
                Session.ExecuteCommand(TextEditorCommands.LineDown);
            }
            Session.ExecuteCommand(TextEditorCommands.LineEnd);
            Session.TypeText("\nConsole.WriteLine (\"Hello World!\");");

            Ide.BuildSolution();
            AssertExeHasOutput(exe, "Hello World!");

            Ide.CloseAll();
        }
示例#3
0
        protected void TestGitUnstash()
        {
            ReproStep("Click on Version Control > Pop Stash");
            Session.ExecuteCommand(MonoDevelop.VersionControl.Git.Commands.StashPop);

            WaitForElement(() => Ide.WaitForStatusMessage(new[] { "Stash successfully applied" }, 10), "Stash should apply successfully", "Stash failed to apply");
        }
示例#4
0
        public static string GetStatusMessage(int timeout = 20000, bool waitForNonEmpty = true)
        {
            if (Platform.IsMac)
            {
                const string macStatusTextField = "MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.text";
                if (waitForNonEmpty)
                {
                    Ide.WaitUntil(
                        () => Session.GetGlobalValue <string> (macStatusTextField) != string.Empty,
                        timeout
                        );
                }
                return((string)Session.GetGlobalValue(macStatusTextField));
            }

            if (waitForNonEmpty)
            {
                const string gtkStatusMessageCount = "MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.messageQueue.Count";
                Ide.WaitUntil(
                    () => Session.GetGlobalValue <int> (gtkStatusMessageCount) == 0,
                    timeout,
                    timeoutMessage: () => "MessageQueue.Count=" + Session.GetGlobalValue <int> (gtkStatusMessageCount)
                    );
            }
            return((string)Session.GetGlobalValue("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.renderArg.CurrentText"));
        }
示例#5
0
        public static bool IsBuildSuccessful(int timeoutInSecs)
        {
            bool isBuildSuccessful = false;

            Ide.WaitUntil(() => {
                var actualStatusMessage = Workbench.GetStatusMessage();
                if (actualStatusMessage == "Build successful.")
                {
                    isBuildSuccessful = true;
                    return(true);
                }
                if (actualStatusMessage == "Build failed.")
                {
                    isBuildSuccessful = false;
                    return(true);
                }
                var match = buildRegex.Match(actualStatusMessage);
                if (match != null && match.Success)
                {
                    isBuildSuccessful = string.Equals(match.Groups ["errors"].ToString(), "0");
                    return(true);
                }
                return(false);
            },
                          pollStep: 5 * 1000,
                          timeout: timeoutInSecs * 1000,
                          timeoutMessage: () => "GetStatusMessage=" + Workbench.GetStatusMessage());

            return(isBuildSuccessful);
        }
示例#6
0
        protected void TestCommit(string commitMsg)
        {
            ReproStep("Click on Version Control > Review Solution and Commit from Menu Bar");
            Session.ExecuteCommand(MonoDevelop.VersionControl.Commands.SolutionStatus);

            ReproStep("Wait for diff to be available");
            WaitForElement(c => c.Button().Marked("buttonCommit").Sensitivity(true), "Commit button should become enabled", "Commit button was not enabled");

            ReproStep("Click on Commit Button");
            Session.ClickElement(c => c.Button().Marked("buttonCommit"), false);

            WaitForElement(c => c.Window().Marked("MonoDevelop.VersionControl.Dialogs.CommitDialog"), "Commit Dialog should open", "Commit Dialog did not open");
            TakeScreenShot("Commit-Dialog-Opened");

            ReproStep("Enter commit message and click on Commit");
            Session.EnterText(c => c.Window().Marked("MonoDevelop.VersionControl.Dialogs.CommitDialog").Children().TextView().Marked("textview"), commitMsg);
            TakeScreenShot("Commit-Msg-Entered");
            Session.ClickElement(c => c.Window().Marked("MonoDevelop.VersionControl.Dialogs.CommitDialog").Children().Button().Marked("buttonCommit"), false);
            CheckIfNameEmailNeeded();
            CheckIfUserConflict();

            WaitForElement(() => Ide.WaitForStatusMessage(new [] { "Commit operation completed." }),
                           "Status bar should show 'Commit operation completed.'",
                           "Status bar did not show 'Commit operation completed.'");
            TakeScreenShot("Commit-Completed");

            ReproStep("Close currently commit tab");
            Session.ExecuteCommand(FileCommands.CloseFile);
            Session.WaitForElement(IdeQuery.TextArea);
        }
示例#7
0
        public static void WaitForStatusIcon(int timeout = 20000, string text = "", bool waitForExisting = true)
        {
            if (Platform.IsMac)
            {
                Ide.WaitUntil(
                    () => {
                    var icons  = Session.GetGlobalValue <string[]>("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.StatusIcons");
                    bool found = false;
                    foreach (string icon in icons)
                    {
                        if (icon == text)
                        {
                            found = true;
                            break;
                        }
                    }

                    return(found ^ waitForExisting);
                },
                    timeout
                    );
            }

            // TODO:
        }
示例#8
0
 static void PollStatusMessage(string[] statusMessage, int timeoutInSecs, int pollStepInSecs, bool waitForMessage = true)
 {
     Ide.WaitUntil(() => {
         var actualStatusMessage = Ide.GetStatusMessage();
         return(waitForMessage == (statusMessage.Contains(actualStatusMessage, StringComparer.OrdinalIgnoreCase)));
     }, pollStep: pollStepInSecs * 1000, timeout: timeoutInSecs * 1000);
 }
示例#9
0
        public static void WaitForStatusIcon(int timeout = 20000, string text = "", bool waitForExisting = true)
        {
            if (Platform.IsMac)
            {
                Ide.WaitUntil(
                    () => {
                    var icons  = Session.GetGlobalValue <string[]>("MonoDevelop.Ide.IdeApp.Workbench.statusBar.CurrentIcons");
                    bool found = false;
                    foreach (string icon in icons)
                    {
                        if (icon == text)
                        {
                            found = true;
                            break;
                        }
                    }

                    return(found ^ waitForExisting);
                },
                    timeout
                    );
            }

            throw new NotImplementedException("Gtk backend not implemented");
        }
示例#10
0
 protected void ComvertToBranch(int index, string branchName)
 {
     SelectStashEntry(index);
     TakeScreenShot("About-To-Click-Convert-To-Branch");
     Session.ClickElement(c => c.Window().Marked("Stash Manager").Children().Button().Text("Convert to Branch"), false);
     EnterBranchName(branchName);
     Ide.WaitForStatusMessage(new [] { "Stash successfully applied" });
 }
示例#11
0
 protected void DeleteBranch(string branchName)
 {
     Assert.IsTrue(Session.SelectElement(c => branchDisplayName(c).Contains(branchName)));
     Session.ClickElement(c => IdeQuery.GitConfigurationDialog(c).Children().Button().Text("Delete"), false);
     TakeScreenShot(string.Format("Delete-Branch-{0}", branchName));
     Ide.ClickButtonAlertDialog("Delete");
     Session.WaitForElement(IdeQuery.GitConfigurationDialog);
 }
示例#12
0
 protected void DeleteRemote(string remoteName)
 {
     Session.WaitForElement(c => remoteTreeName(c).Contains(remoteName));
     Session.ClickElement(c => IdeQuery.GitConfigurationDialog(c).Children().Button().Text("Remove"), false);
     TakeScreenShot(string.Format("Remove-Remote-{0}", remoteName));
     Ide.ClickButtonAlertDialog("Delete");
     Session.WaitForElement(IdeQuery.GitConfigurationDialog);
 }
        public void CreateNewBranchTest()
        {
            TestClone("[email protected]:mono/jurassic.git");
            Ide.WaitForSolutionCheckedOut();

            OpenRepositoryConfiguration();
            CreateNewBranch("new-branch");
            CloseRepositoryConfiguration();
        }
示例#14
0
        public static void OpenWorkspace(string solutionPath, UITestBase testContext = null)
        {
            testContext?.ReproStep(string.Format("Open solution path '{0}'", solutionPath));
            Action <string> takeScreenshot = GetScreenshotAction(testContext);

            Session.GlobalInvoke("MonoDevelop.Ide.IdeApp.Workspace.OpenWorkspaceItem", new FilePath(solutionPath), true);
            Ide.WaitForIdeIdle();
            takeScreenshot("Solution-Opened");
        }
示例#15
0
        public void CreateNewBranchTest()
        {
            TestClone(gtkSharpUrl);
            Ide.WaitForSolutionCheckedOut();

            OpenRepositoryConfiguration();
            CreateNewBranch("new-branch");
            CloseRepositoryConfiguration();
        }
示例#16
0
        public void DeleteTag()
        {
            TestClone(gtkSharpUrl);
            Ide.WaitForSolutionCheckedOut();

            OpenRepositoryConfiguration("Tags");
            DeleteTag("1.0.10");
            CloseRepositoryConfiguration();
        }
        public void SelectRemoteTest()
        {
            TestClone("[email protected]:mono/jurassic.git");
            Ide.WaitForSolutionCheckedOut();

            OpenRepositoryConfiguration("Remote Sources");
            SelectRemote("origin");
            CloseRepositoryConfiguration();
        }
示例#18
0
        public void SelectRemoteTest()
        {
            TestClone(gtkSharpUrl);
            Ide.WaitForSolutionCheckedOut();

            OpenRepositoryConfiguration("Remote Sources");
            SelectRemote("origin");
            CloseRepositoryConfiguration();
        }
 protected virtual void OnBuildTemplate(int buildTimeoutInSecs = 180)
 {
     try {
         Assert.IsTrue(Ide.BuildSolution(timeoutInSecs: buildTimeoutInSecs), "Build Failed");
         TakeScreenShot("AfterBuildFinishedSuccessfully");
     } catch (TimeoutException e) {
         TakeScreenShot("AfterBuildFailed");
         Assert.Fail(e.ToString());
     }
 }
示例#20
0
        public static bool ClickButtonAlertDialog(string buttonText)
        {
            if (Platform.IsMac)
            {
                Ide.WaitUntil(() => Session.Query(c => c.Marked("Xamarin Studio").Marked("AppKit.NSPanel")).Any());
                return(Session.ClickElement(c => c.Marked("AppKit.NSButton").Text(buttonText)));
            }

            throw new PlatformNotSupportedException("ClickButtonAlertDialog is only supported on Mac");
        }
示例#21
0
 protected void DeleteBranch(string branchName)
 {
     SelectBranch(branchName);
     ReproStep("Press Delete");
     Session.ClickElement(c => IdeQuery.GitConfigurationDialog(c).Children().Button().Text("Delete"), false);
     TakeScreenShot(string.Format("Delete-Branch-{0}", branchName));
     ReproStep("If prompted for confirmation, press Delete");
     Ide.ClickButtonAlertDialog("Delete");
     Session.WaitForElement(IdeQuery.GitConfigurationDialog);
 }
示例#22
0
        public void RunASPTest(string templateName)
        {
            var templateOptions = new TemplateSelectionOptions {
                CategoryRoot     = OtherCategoryRoot,
                Category         = aspCategory,
                TemplateKindRoot = GeneralKindRoot,
                TemplateKind     = templateName
            };

            CreateBuildProject(templateOptions, () => Ide.WaitForIdeIdle(totalTimeoutInSecs: 50));
        }
示例#23
0
        public void RunDotNetTests(string templateName, int totalTimeoutInSecs)
        {
            var templateOptions = new TemplateSelectionOptions {
                CategoryRoot     = OtherCategoryRoot,
                Category         = dotNetCategory,
                TemplateKindRoot = GeneralKindRoot,
                TemplateKind     = templateName
            };

            CreateBuildProject(templateOptions, () => Ide.WaitForIdeIdle((uint)totalTimeoutInSecs));
        }
示例#24
0
 protected void TestGitStash(string stashMsg, int timeoutStashSecs = 10)
 {
     Session.ExecuteCommand(MonoDevelop.VersionControl.Git.Commands.Stash);
     Session.WaitForElement(c => c.Window().Marked("MonoDevelop.VersionControl.Git.NewStashDialog"));
     TakeScreenShot("Stash-Dialog-Opened");
     Session.EnterText(c => c.Window().Marked("MonoDevelop.VersionControl.Git.NewStashDialog").Children().Textfield().Marked("entryComment"), stashMsg);
     Session.WaitForElement(c => c.Window().Marked("MonoDevelop.VersionControl.Git.NewStashDialog").Children().Textfield().Marked("entryComment").Text(stashMsg));
     TakeScreenShot("Stash-Message-Entered");
     Session.ClickElement(c => c.Window().Marked("MonoDevelop.VersionControl.Git.NewStashDialog").Children().Button().Marked("buttonOk"));
     Ide.WaitForStatusMessage(new [] { "Changes successfully stashed" }, timeoutStashSecs);
 }
示例#25
0
        public void RunMiscTemplatesTest(string templateName, string templateKind)
        {
            var templateOptions = new TemplateSelectionOptions {
                CategoryRoot     = OtherCategoryRoot,
                Category         = miscCategory,
                TemplateKindRoot = templateKind,
                TemplateKind     = templateName
            };

            CreateBuildProject(templateOptions, () => Ide.WaitForIdeIdle());
            IsTemplateSelected(templateOptions);
        }
示例#26
0
 public static bool Debug(int timeoutSeconds = 20, int pollStepSecs = 1)
 {
     Session.ExecuteCommand("MonoDevelop.Debugger.DebugCommands.Debug");
     try {
         Ide.WaitUntil(
             () => !Session.Query(c => IdeQuery.RunButton(c).Property("Icon", "Stop")).Any(),
             timeout: timeoutSeconds * 1000, pollStep: pollStepSecs * 1000);
         return(false);
     } catch (TimeoutException) {
         return(true);
     }
 }
示例#27
0
        public void GitEditBranchTest()
        {
            TestClone(gtkSharpUrl);
            Ide.WaitForSolutionCheckedOut();

            OpenRepositoryConfiguration();
            CreateNewBranch("new-branch");
            SelectBranch("new-branch");
            EditBranch("new-branch", "new-new-branch");
            SwitchToBranch("new-new-branch");
            CloseRepositoryConfiguration();
        }
示例#28
0
 public static void UpdateAllNuGetPackages(Action <string> takeScreenshot = null)
 {
     Session.ExecuteCommand("MonoDevelop.PackageManagement.Commands.UpdateAllPackagesInSolution");
     Ide.WaitForStatusMessage(new [] {
         "Packages are up to date.",
         "No updates found but warnings were reported.",
         "Packages successfully updated.",
         "Packages updated with warnings."
     },
                              timeoutInSecs: 120, pollStepInSecs: 5);
     takeScreenshot("All-NuGet-Packages-Updated");
 }
示例#29
0
 public static bool Run(int timeoutSeconds = 20, int pollStepSecs = 5)
 {
     Session.ExecuteCommand(ProjectCommands.Run);
     try {
         Ide.WaitUntil(
             () => !Session.Query(c => IdeQuery.RunButton(c).Property("Icon", "Stop")).Any(),
             timeout: timeoutSeconds * 1000, pollStep: pollStepSecs * 1000);
         return(false);
     } catch (TimeoutException) {
         return(true);
     }
 }
示例#30
0
 protected virtual void OnBuildTemplate(int buildTimeoutInSecs = 180)
 {
     ReproStep("Build solution");
     try {
         Assert.IsTrue(Ide.BuildSolution(timeoutInSecs: buildTimeoutInSecs), "Build Failed");
         TakeScreenShot("AfterBuildFinishedSuccessfully");
     } catch (TimeoutException e) {
         Session.DebugObject.Debug("Build Failed");
         ReproStep(string.Format("Expected: Build should finish within '{0}' seconds\nActual: Build timed out", buildTimeoutInSecs));
         TakeScreenShot("AfterBuildFailed");
         Assert.Fail(e.ToString());
     }
 }