Exemple #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);
                    }
                }
            }
        }
        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();
        }
Exemple #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");
        }
Exemple #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"));
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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:
        }
Exemple #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);
 }
Exemple #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");
        }
Exemple #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" });
 }
Exemple #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);
 }
Exemple #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();
        }
Exemple #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");
        }
Exemple #15
0
        public void CreateNewBranchTest()
        {
            TestClone(gtkSharpUrl);
            Ide.WaitForSolutionCheckedOut();

            OpenRepositoryConfiguration();
            CreateNewBranch("new-branch");
            CloseRepositoryConfiguration();
        }
Exemple #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();
        }
Exemple #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());
     }
 }
Exemple #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");
        }
Exemple #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);
 }
        public void RunASPTest(string templateName)
        {
            var templateOptions = new TemplateSelectionOptions {
                CategoryRoot     = OtherCategoryRoot,
                Category         = aspCategory,
                TemplateKindRoot = GeneralKindRoot,
                TemplateKind     = templateName
            };

            CreateBuildProject(templateOptions, () => Ide.WaitForIdeIdle(totalTimeoutInSecs: 50));
        }
Exemple #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));
        }
Exemple #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);
 }
Exemple #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);
        }
Exemple #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);
     }
 }
Exemple #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();
        }
 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");
 }
Exemple #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);
     }
 }
Exemple #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());
     }
 }