Exemple #1
0
        public void Test_that_about_does_not_break_the_app()
        {
            Common.RunWithMainWindow((application, automation, mainWindow) =>
            {
                var helpMenuItem = mainWindow
                                   .FindFirstDescendant(
                    cf => cf.ByClassName("MenuItem").And(cf.ByName("Help")))
                                   .AsMenuItem();

                helpMenuItem.Click();

                var aboutMenuItem = helpMenuItem
                                    .FindFirstChild(cf => cf.ByName("About .."))
                                    .AsMenuItem();

                aboutMenuItem.Click();

                Retry.WhileNull(() =>
                                // ReSharper disable once AccessToDisposedClosure
                                application.GetAllTopLevelWindows(automation)
                                .FirstOrDefault((w) => w.Title == "About"),
                                throwOnTimeout: true, timeout: TimeSpan.FromSeconds(5),
                                timeoutMessage: "Could not find the about window"
                                );
            });
        }
Exemple #2
0
 public static Window RequireTopLevelWindow(Application application, UIA3Automation automation,
                                            Func <Window, bool> filter, string timeoutMessage, int timeoutSeconds = 5)
 {
     return(Retry.WhileNull(() =>
                            // ReSharper disable once AccessToDisposedClosure
                            application.GetAllTopLevelWindows(automation).FirstOrDefault(filter),
                            throwOnTimeout: true, timeout: TimeSpan.FromSeconds(timeoutSeconds), timeoutMessage: timeoutMessage
                            ).Result);
 }
Exemple #3
0
        public void Test_that_splash_screen_does_not_break_the_app()
        {
            Common.RunWithMainWindow((application, automation, mainWindow) =>
            {
                Retry.WhileNull(() =>
                                // ReSharper disable once AccessToDisposedClosure
                                application.GetAllTopLevelWindows(automation)
                                .FirstOrDefault((w) => w.AutomationId == "splashScreen"),
                                throwOnTimeout: true, timeout: TimeSpan.FromSeconds(5),
                                timeoutMessage: "Could not find the splash screen"
                                );

                Common.AssertNoErrors(application, mainWindow);
            }, new Run {
                Args = new[] { "-splash", "5000" }
            });
        }
Exemple #4
0
        public void Test_that_error_report_doesnt_break_the_app()
        {
            using var tmpDir = new TemporaryDirectory();
            var path = Path.Combine(tmpDir.Path, "invalid.aasx");

            File.WriteAllText(path, "totally invalid");

            Common.RunWithMainWindow((application, automation, mainWindow) =>
            {
                Common.AssertLoadAasx(application, mainWindow, path);

                var numberErrors = Retry.Find(
                    () => (application.HasExited)
                        ? null
                        : mainWindow.FindFirstChild(cf => cf.ByAutomationId("LabelNumberErrors")),
                    new RetrySettings {
                    ThrowOnTimeout = true, Timeout = TimeSpan.FromSeconds(5)
                });

                Assert.AreEqual("Errors: 1", numberErrors.AsLabel().Text);

                var buttonReport = Retry.Find(
                    () => mainWindow.FindFirstChild(cf => cf.ByAutomationId("ButtonReport")),
                    new RetrySettings
                {
                    ThrowOnTimeout = true,
                    Timeout        = TimeSpan.FromSeconds(5),
                    TimeoutMessage = "Could not find the report button"
                }).AsButton();

                buttonReport.Click();

                Retry.WhileNull(() =>
                                // ReSharper disable once AccessToDisposedClosure
                                application.GetAllTopLevelWindows(automation)
                                .FirstOrDefault((w) => w.Title == "Message Report"),
                                throwOnTimeout: true, timeout: TimeSpan.FromSeconds(5),
                                timeoutMessage: "Could not find the 'Message Report' window");
            });
        }