Esempio n. 1
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);
        }
Esempio n. 2
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
                    );
            }

            // TODO:
        }
Esempio n. 3
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);
     }
 }
Esempio n. 4
0
        public static void OpenWorkspace(string solutionPath, UITestBase testContext = null)
        {
            if (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");
        }
Esempio n. 5
0
 public static string GetStatusMessage(int timeout = 20000, bool waitForNonEmpty = true)
 {
     if (waitForNonEmpty)
     {
         string text = null;
         Ide.WaitUntil(
             () => (text = Session.GetGlobalValue <string> ("MonoDevelop.Ide.IdeApp.Workbench.statusBar.CurrentText")) != string.Empty,
             timeout
             );
         return(text);
     }
     return((string)Session.GetGlobalValue("MonoDevelop.Ide.IdeApp.Workbench.statusBar.CurrentText"));
 }
Esempio n. 6
0
 public static bool ClickButtonAlertDialog(string buttonText)
 {
     if (Platform.IsMac)
     {
         Ide.WaitUntil(() => Session.Query(c => c.Marked("Visual Studio").Marked("AppKit.NSPanel")).Any());
         return(Session.ClickElement(c => c.Marked("AppKit.NSButton").Text(buttonText)));
     }
     else
     {
         Ide.WaitUntil(() => Session.Query(c => c.Window().Marked("MonoDevelop.Ide.Gui.Dialogs.GtkAlertDialog")).Any());
         return(Session.ClickElement(c => c.Window().Marked("MonoDevelop.Ide.Gui.Dialogs.GtkAlertDialog").Children().Button().Text(buttonText)));
     }
 }
 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());
     }
 }
Esempio n. 8
0
 static void PollStatusMessage(string[] statusMessage, int timeoutInSecs, int pollStepInSecs, bool waitForMessage = true)
 {
     Ide.WaitUntil(() => {
         string actualStatusMessage = string.Empty;
         try {
             actualStatusMessage = Workbench.GetStatusMessage();
             return(waitForMessage == (statusMessage.Contains(actualStatusMessage, StringComparer.OrdinalIgnoreCase)));
         } catch (TimeoutException e) {
             throw new TimeoutException(
                 string.Format("Timed out. Found status message '{0}'\nand expected one of these:\n\t {1}",
                               actualStatusMessage, string.Join("\n\t", statusMessage)), e);
         }
     },
                   pollStep: pollStepInSecs * 1000,
                   timeout: timeoutInSecs * 1000,
                   timeoutMessage: () => "GetStatusMessage=" + Workbench.GetStatusMessage());
 }
Esempio n. 9
0
        public virtual void Teardown()
        {
            try {
                bool isInconclusive = false;
                var  testStatus     = TestContext.CurrentContext.Result.Status;
                if (testStatus != TestStatus.Passed)
                {
                    try {
                        var updateOpened = Session.Query(IdeQuery.XamarinUpdate);
                        if (updateOpened != null && updateOpened.Any())
                        {
                            isInconclusive = true;
                        }
                        TakeScreenShot(string.Format("{0}-Test-Failed", TestContext.CurrentContext.Test.Name));
                    } catch (Exception e) {
                        Session.DebugObject.Debug("Final Screenshot failed");
                        Session.DebugObject.Debug(e.ToString());
                    }
                }

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

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

                ValidateIdeLogMessages();

                OnCleanUp();
                if (testStatus == TestStatus.Passed)
                {
                    if (Directory.Exists(currentTestResultScreenshotFolder))
                    {
                        Directory.Delete(currentTestResultScreenshotFolder, true);
                    }
                }

                if (isInconclusive)
                {
                    Assert.Inconclusive("Xamarin Update is blocking the application focus");
                }
            } finally {
                LoggingService.RemoveLogger(Logger.Name);
                Logger.Dispose();
            }
        }
Esempio n. 10
0
        public static string GetStatusMessage(int timeout = 20000, bool waitForNonEmpty = true)
        {
            if (Platform.IsMac)
            {
                if (waitForNonEmpty)
                {
                    Ide.WaitUntil(
                        () => Session.GetGlobalValue <string> ("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.text") != string.Empty,
                        timeout
                        );
                }
                return((string)Session.GetGlobalValue("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.text"));
            }

            if (waitForNonEmpty)
            {
                Ide.WaitUntil(
                    () => Session.GetGlobalValue <int> ("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.messageQueue.Count") == 0,
                    timeout,
                    timeoutMessage: () => "MessageQueue.Count=" + Session.GetGlobalValue <int> ("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.messageQueue.Count")
                    );
            }
            return((string)Session.GetGlobalValue("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.renderArg.CurrentText"));
        }