public static AutomationTesterHarness ShowWindowAndExectueTests(SystemWindow initialSystemWindow, Action<AutomationTesterHarness> functionContainingTests, double secondsToTestFailure) { StackTrace st = new StackTrace(false); Console.WriteLine("\r\nRunning automation test: " + st.GetFrames().Skip(1).First().GetMethod().Name); AutomationTesterHarness testHarness = new AutomationTesterHarness(initialSystemWindow, functionContainingTests, secondsToTestFailure); return testHarness; }
public void ToolTipsShow() { SystemWindow buttonContainer = new SystemWindow(300, 200) { BackgroundColor = RGBA_Bytes.White, }; Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner("C:/TestImages"); testRunner.Wait(1); // Now do the actions specific to this test. (replace this for new tests) { testRunner.MoveToByName("ButtonWithToolTip"); testRunner.Wait(1.5); GuiWidget toolTipWidget = buttonContainer.FindNamedChildRecursive("ToolTipWidget"); resultsHarness.AddTestResult(toolTipWidget != null, "Tool tip is showing"); testRunner.MoveToByName("right"); toolTipWidget = buttonContainer.FindNamedChildRecursive("ToolTipWidget"); resultsHarness.AddTestResult(toolTipWidget == null, "Tool tip is not showing"); } testRunner.Wait(1); buttonContainer.CloseOnIdle(); }; Button leftButton = new Button("left", 10, 40); leftButton.Name = "ButtonWithToolTip"; leftButton.ToolTipText = "Left Tool Tip"; buttonContainer.AddChild(leftButton); Button rightButton = new Button("right", 110, 40); rightButton.Name = "right"; buttonContainer.AddChild(rightButton); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(buttonContainer, testToRun, 10000); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 2); // make sure we can all our tests }
public void SelectAllOnFocusCanStillClickAfterSelection() { TextEditWidget editField = null; SystemWindow systemWindow = new SystemWindow(300, 200) { BackgroundColor = RGBA_Bytes.Black, }; Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { editField.SelectAllOnFocus = true; AutomationRunner testRunner = new AutomationRunner(); testRunner.Wait(1); resultsHarness.AddTestResult(testRunner.ClickByName(editField.Name, 1)); editField.SelectAllOnFocus = true; testRunner.Type("123"); resultsHarness.AddTestResult(editField.Text == "123", "on enter we have selected all and replaced the text"); resultsHarness.AddTestResult(testRunner.ClickByName(editField.Name, 1)); testRunner.Type("123"); resultsHarness.AddTestResult(editField.Text == "123123", "we already have the contol selected so don't select all again."); systemWindow.CloseOnIdle(); }; editField = new TextEditWidget(pixelWidth: 200) { Name = "editField", Text = "Some Text", HAnchor = HAnchor.ParentCenter, VAnchor = VAnchor.ParentCenter, }; systemWindow.AddChild(editField); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(systemWindow, testToRun, 15); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 4); // make sure we can all our tests }
public void GetWidgetByNameTestRegionSingleWindow() { int leftClickCount = 0; Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(); testRunner.ClickByName("left"); testRunner.Wait(.5); resultsHarness.AddTestResult(leftClickCount == 1, "Got left button click"); SearchRegion rightButtonRegion = testRunner.GetRegionByName("right"); testRunner.ClickByName("left", searchRegion: rightButtonRegion); testRunner.Wait(.5); resultsHarness.AddTestResult(leftClickCount == 1, "Did not get left button click"); }; SystemWindow buttonContainer = new SystemWindow(300, 200); Button leftButton = new Button("left", 10, 40); leftButton.Name = "left"; leftButton.Click += (sender, e) => { leftClickCount++; }; buttonContainer.AddChild(leftButton); Button rightButton = new Button("right", 110, 40); rightButton.Name = "right"; buttonContainer.AddChild(rightButton); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(buttonContainer, testToRun, 10); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 2); // make sure we can all our tests }
public void VerifyFocusMakesTextWidgetEditable() { TextEditWidget editField = null; SystemWindow systemWindow = new SystemWindow(300, 200) { BackgroundColor = RGBA_Bytes.Black, }; bool firstDraw = true; Stopwatch testDiedTimer = Stopwatch.StartNew(); Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { UiThread.RunOnIdle(editField.Focus); AutomationRunner testRunner = new AutomationRunner(); testRunner.Wait(1); // Now do the actions specific to this test. (replace this for new tests) testRunner.Type("Test Text"); resultsHarness.AddTestResult(editField.Text == "Test Text", "validate text is typed"); systemWindow.CloseOnIdle(); }; editField = new TextEditWidget(pixelWidth: 200) { HAnchor = HAnchor.ParentCenter, VAnchor = VAnchor.ParentCenter, }; systemWindow.AddChild(editField); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(systemWindow, testToRun, 10); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 1); // make sure we can all our tests }
public static AutomationTesterHarness ShowWindowAndExectueTests(SystemWindow initialSystemWindow, Action<AutomationTesterHarness> functionContainingTests, double secondsToTestFailure) { AutomationTesterHarness testHarness = new AutomationTesterHarness(initialSystemWindow, functionContainingTests, secondsToTestFailure); return testHarness; }
private static void CheckAndUncheckSetting(AutomationTesterHarness resultsHarness, AutomationRunner testRunner, string settingToChange, string checkBoxName, bool expected) { // Assert that the checkbox is currently unchecked, and there is no user override resultsHarness.AddTestResult(ActiveSliceSettings.Instance.GetValue<bool>(settingToChange) == expected); resultsHarness.AddTestResult(ActiveSliceSettings.Instance.UserLayer.ContainsKey(settingToChange) == false); // Click the checkbox resultsHarness.AddTestResult(testRunner.ClickByName(checkBoxName, 1)); testRunner.Wait(2); // Assert the checkbox is checked and the user override is set resultsHarness.AddTestResult(ActiveSliceSettings.Instance.GetValue<bool>(settingToChange) != expected); resultsHarness.AddTestResult(ActiveSliceSettings.Instance.UserLayer.ContainsKey(settingToChange) == true); // Click the cancel user override button resultsHarness.AddTestResult(testRunner.ClickByName("Restore " + settingToChange, 1)); testRunner.Wait(2); // Assert the checkbox is unchecked and there is no user override resultsHarness.AddTestResult(ActiveSliceSettings.Instance.GetValue<bool>(settingToChange) == expected); resultsHarness.AddTestResult(ActiveSliceSettings.Instance.UserLayer.ContainsKey(settingToChange) == false); }
private static void WaitForLayerAndResume(AutomationTesterHarness resultsHarness, AutomationRunner testRunner, int indexToWaitFor) { testRunner.WaitForName("Resume Button", 30); SystemWindow containingWindow; GuiWidget layerNumber = testRunner.GetWidgetByName("Current GCode Layer Edit", out containingWindow, 20); layerNumber.Invalidate(); testRunner.WaitUntil(() => { return layerNumber.Text == indexToWaitFor.ToString(); }, 2); resultsHarness.AddTestResult(layerNumber.Text == indexToWaitFor.ToString()); resultsHarness.AddTestResult(testRunner.ClickByName("Resume Button", 1)); testRunner.Wait(.1); }
public static void SwitchToAdvancedSettings(AutomationRunner testRunner, AutomationTesterHarness resultsHarness) { if (testRunner.NameExists("SettingsAndControls")) { testRunner.ClickByName("SettingsAndControls", 1); testRunner.Wait(.5); } resultsHarness.AddTestResult(testRunner.ClickByName("User Level Dropdown", 1), "Click Settings Mode dropdown"); resultsHarness.AddTestResult(testRunner.ClickByName("Advanced Menu Item", 1), "Click 'Advanced' settings"); testRunner.Wait(.5); }
public static AutomationTesterHarness ShowWindowAndExectueTests(SystemWindow initialSystemWindow, Action <AutomationTesterHarness> functionContainingTests, double secondsToTestFailure) { AutomationTesterHarness testHarness = new AutomationTesterHarness(initialSystemWindow, functionContainingTests, secondsToTestFailure); return(testHarness); }