public static void CreateAndRenameLocalLibraryFolder(GuiWidget container, double secondsBetweenClicks = .1) { AutomationRunner testRunner; EventHandler <DrawEventArgs> beforeDraw = null; beforeDraw = (sender, e) => { testRunner = new AutomationRunner(); Task.Run(() => { testRunner.ClickByName("Library Tab"); testRunner.NavigateToFolder("Local Library Row Item Collection"); testRunner.ClickByName("Create Folder From Library Button"); testRunner.Delay(2); testRunner.Type("New Folder"); testRunner.ClickByName("Create Folder Button"); testRunner.ClickByName("Library Edit Button"); testRunner.ClickByName("Row Item New Folder"); MatterControlUtilities.LibraryRenameSelectedItem(testRunner); testRunner.Delay(.5); testRunner.Type("Renamed Folder"); testRunner.ClickByName("Rename Button"); }); container.BeforeDraw -= beforeDraw; }; container.BeforeDraw += beforeDraw; }
public static void NavigateToFolder(this AutomationRunner testRunner, string libraryRowItemName) { SearchRegion libraryRowItemRegion = testRunner.GetRegionByName(libraryRowItemName, 3); testRunner.ClickByName(libraryRowItemName); testRunner.Delay(.5); testRunner.ClickByName("Open Collection", searchRegion: libraryRowItemRegion); testRunner.Delay(.5); }
public static void NavigateToLibraryHome(this AutomationRunner testRunner) { while (!testRunner.NameExists("Local Library Row Item Collection", .5)) { testRunner.ClickByName("Library Up Button"); testRunner.Delay(1); } testRunner.Delay(.5); }
public static void DeleteSelectedPrinter(AutomationRunner testRunner) { // delete printer testRunner.ClickByName("Edit Printer Button", 5); testRunner.Delay(.5); testRunner.ClickByName("Delete Printer Button", 5); testRunner.Delay(.5); testRunner.WaitForReloadAll(() => testRunner.ClickByName("Yes Button", 5)); }
public static void SwitchToAdvancedSettings(AutomationRunner testRunner) { if (testRunner.WaitForName("SettingsAndControls", .2)) { testRunner.ClickByName("SettingsAndControls"); testRunner.Delay(.5); } testRunner.ClickByName("User Level Dropdown"); testRunner.ClickByName("Advanced Menu Item"); testRunner.Delay(.5); }
private static void WaitForLayerAndResume(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.Delay(() => layerNumber.Text == indexToWaitFor.ToString(), 2); Assert.IsTrue(layerNumber.Text == indexToWaitFor.ToString()); testRunner.ClickByName("Resume Button", 1); testRunner.Delay(.1); }
public static void SaveBedplateToFolder(this AutomationRunner testRunner, string newFileName, string folderName) { testRunner.ClickByName("Bed Options Menu"); testRunner.ClickByName("Save As Menu Item"); testRunner.Delay(1); testRunner.Type(newFileName); testRunner.NavigateToFolder(folderName); testRunner.ClickByName("Accept Button"); // Give the SaveAs window time to close before returning to the caller testRunner.Delay(2); }
public static IDisposable LaunchAndConnectToPrinterEmulator(this AutomationRunner testRunner, string make = "Airwolf 3D", string model = "HD", bool runSlow = false) { // Load the TestEnv config var config = TestAutomationConfig.Load(); // Create the printer MatterControlUtilities.AddAndSelectPrinter(testRunner, make, model); Emulator emulator = new Emulator(); emulator.PortName = config.Printer; emulator.RunSlow = runSlow; emulator.Startup(); // edit the com port SystemWindow containingWindow; var editButton = testRunner.GetWidgetByName("Edit Printer Button", out containingWindow); testRunner.Delay(() => editButton.Enabled, 5); // Wait until the edit button is ready to click it. Ensures the printer is loaded. testRunner.ClickByName("Edit Printer Button", 3); testRunner.ClickByName("Serial Port Dropdown", 3); testRunner.ClickByName(config.MCPort + " Menu Item", 5); testRunner.ClickByName("Cancel Wizard Button"); // connect to the created printer testRunner.ClickByName("Connect to printer button", 2); testRunner.WaitForName("Disconnect from printer button", 5); return(emulator); }
public static void NavigateToFolder(this AutomationRunner testRunner, string libraryRowItemName) { testRunner.EnsureContentMenuOpen(); testRunner.EnsureFoldersVisible(); switch (libraryRowItemName) { case "Calibration Parts Row Item Collection": case "Cloud Library Row Item Collection": case "Print Queue Row Item Collection": case "Local Library Row Item Collection": if (!testRunner.NameExists("Library Row Item Collection")) { testRunner.ClickByName("Bread Crumb Button Home"); testRunner.Delay(); } // If visible, navigate into Libraries container before opening target if (testRunner.NameExists("Library Row Item Collection")) { testRunner.DoubleClickByName("Library Row Item Collection"); } break; } testRunner.DoubleClickByName(libraryRowItemName); }
public static SliceSettingData NavigateToSliceSettingsField(this AutomationRunner testRunner, string userLevel, string slicerConfigName) { var rootLevel = SettingsOrganizer.Instance.UserLevels[userLevel]; var settingData = SettingsOrganizer.Instance.GetSettingsData(slicerConfigName); var subGroup = rootLevel.GetContainerForSetting(slicerConfigName); var category = subGroup.Group.Category; // Click tab testRunner.ClickByName(category.Name + " Tab"); // Open the subGroup if required var foundWidget = testRunner.GetWidgetByName(subGroup.Name + " Panel", out _); if (foundWidget != null) { var containerCheckBox = foundWidget.Descendants <ExpandCheckboxButton>().First(); if (!containerCheckBox.Checked) { containerCheckBox.Checked = true; testRunner.Delay(); } } return(settingData); }
public static void SwitchToSettingsAndControls(this AutomationRunner testRunner) { if (testRunner.WaitForName("SettingsAndControls", .2)) { testRunner.ClickByName("SettingsAndControls"); testRunner.Delay(.5); } }
public static void SignOut(AutomationRunner testRunner) { testRunner.ClickByName("User Options Menu"); testRunner.ClickByName("Sign Out Menu Item"); testRunner.Delay(.5); // Rather than waiting a fixed amount of time, we wait for the ReloadAll to complete before returning testRunner.WaitForReloadAll(() => testRunner.ClickByName("Yes Button")); }
// TODO: Promote to extension method private static void WaitForLayerAndResume(AutomationRunner testRunner, PrinterConfig printer, int indexToWaitFor) { testRunner.WaitForName("Yes Button", 15); // Wait for layer testRunner.WaitFor(() => printer.Bed.ActiveLayerIndex + 1 == indexToWaitFor, 10, 500); Assert.AreEqual(indexToWaitFor, printer.Bed.ActiveLayerIndex + 1, "Active layer index does not match expected"); testRunner.ClickByName("Yes Button"); testRunner.Delay(); }
public static void Select3DPart(this AutomationRunner testRunner, string partNameToSelect) { if (testRunner.NameExists("3D View Edit", .2)) { testRunner.ClickByName("3D View Edit"); } testRunner.DragDropByName("InteractionLayer", "InteractionLayer", offsetDrop: new Agg.Point2D(10, 15), mouseButtons: MouseButtons.Right); testRunner.Delay(1); testRunner.ClickByName(partNameToSelect); }
private static void CloseMatterControlViaMenu(AutomationRunner testRunner) { SystemWindow mcWindowLocal = MatterControlApplication.Instance; testRunner.ClickByName("File Menu", 5); testRunner.ClickByName("Exit Menu Item", 5); testRunner.Delay(.2); if (mcWindowLocal.Parent != null) { mcWindowLocal.CloseOnIdle(); } }
private static void CheckAndUncheckSetting(AutomationRunner testRunner, string settingToChange, string checkBoxName, bool expected) { // Assert that the checkbox is currently unchecked, and there is no user override Assert.IsTrue(ActiveSliceSettings.Instance.GetValue <bool>(settingToChange) == expected); Assert.IsTrue(ActiveSliceSettings.Instance.UserLayer.ContainsKey(settingToChange) == false); // Click the checkbox testRunner.ClickByName(checkBoxName, 1); testRunner.Delay(2); // Assert the checkbox is checked and the user override is set Assert.IsTrue(ActiveSliceSettings.Instance.GetValue <bool>(settingToChange) != expected); Assert.IsTrue(ActiveSliceSettings.Instance.UserLayer.ContainsKey(settingToChange) == true); // Click the cancel user override button testRunner.ClickByName("Restore " + settingToChange, 1); testRunner.Delay(2); // Assert the checkbox is unchecked and there is no user override Assert.IsTrue(ActiveSliceSettings.Instance.GetValue <bool>(settingToChange) == expected); Assert.IsTrue(ActiveSliceSettings.Instance.UserLayer.ContainsKey(settingToChange) == false); }
private static void SetCheckBoxSetting(AutomationRunner testRunner, PrinterConfig printer, string settingToChange, bool valueToSet) { var settingsData = PrinterSettings.SettingsData[settingToChange]; string checkBoxName = $"{settingsData.PresentationName} Field"; Assert.IsTrue(printer.Settings.GetValue <bool>(settingToChange) != valueToSet); //testRunner.ScrollIntoView(checkBoxName); //testRunner.ClickByName(checkBoxName); testRunner.SelectSliceSettingsField(PrinterSettings.Layout.Printer, settingToChange); // give some time for the ui to update if necessary testRunner.Delay(2); Assert.IsTrue(printer.Settings.GetValue <bool>(settingToChange) == valueToSet); }
private static void SetCheckBoxSetting(AutomationRunner testRunner, string settingToChange, bool printer, bool valueToSet) { var settingsData = SettingsOrganizer.Instance.GetSettingsData(settingToChange); string checkBoxName = $"{settingsData.PresentationName} Field"; Assert.IsTrue(ActiveSliceSettings.Instance.GetValue <bool>(settingToChange) != valueToSet); //testRunner.ScrollIntoView(checkBoxName); //testRunner.ClickByName(checkBoxName); testRunner.SelectSliceSettingsField(printer ? "Printer" : "Advanced", settingToChange); // give some time for the ui to update if necessary testRunner.Delay(2); Assert.IsTrue(ActiveSliceSettings.Instance.GetValue <bool>(settingToChange) == valueToSet); }
private static void ConfirmExpectedSpeeds(AutomationRunner testRunner, double targetExtrusionRate, double targetFeedRate) { SystemWindow systemWindow; SolidSlider slider; // Assert the UI has the expected values slider = testRunner.GetWidgetByName("Extrusion Multiplier Slider", out systemWindow, 5) as SolidSlider; Assert.AreEqual(targetExtrusionRate, slider.Value); slider = testRunner.GetWidgetByName("Feed Rate Slider", out systemWindow, 5) as SolidSlider; Assert.AreEqual(targetFeedRate, slider.Value); testRunner.Delay(.2); // Assert the changes took effect on the model Assert.AreEqual(targetExtrusionRate, ExtrusionMultiplyerStream.ExtrusionRatio); Assert.AreEqual(targetFeedRate, FeedRateMultiplyerStream.FeedRateRatio); }
private static void ConfirmExpectedSpeeds(AutomationRunner testRunner, double targetExtrusionRate, double targetFeedRate) { SystemWindow systemWindow; SolidSlider slider; // Assert the UI has the expected values slider = testRunner.GetWidgetByName("Extrusion Multiplier Slider", out systemWindow, 5) as SolidSlider; Assert.AreEqual(targetExtrusionRate, slider.Value); slider = testRunner.GetWidgetByName("Feed Rate Slider", out systemWindow, 5) as SolidSlider; Assert.AreEqual(targetFeedRate, slider.Value); testRunner.Delay(.2); // Assert the changes took effect on the model Assert.AreEqual(targetExtrusionRate, ActiveSliceSettings.Instance.GetValue <double>(SettingsKey.extrusion_ratio)); Assert.AreEqual(targetFeedRate, ActiveSliceSettings.Instance.GetValue <double>(SettingsKey.feedrate_ratio)); }
/// <summary> /// Types the specified text into the dialog and sends {Enter} to complete the interaction /// </summary> /// <param name="testRunner">The TestRunner to interact with</param> /// <param name="textValue">The text to type</param> public static void CompleteDialog(this AutomationRunner testRunner, string textValue, double secondsToWait = 2) { // AutomationDialog requires no delay if (AggContext.FileDialogs is AutomationDialogProvider) { // Wait for text widget to have focus var widget = testRunner.GetWidgetByName("Automation Dialog TextEdit", out _, 5); testRunner.WaitFor(() => widget.ContainsFocus); } else { testRunner.Delay(secondsToWait); } testRunner.Type(textValue); testRunner.Type("{Enter}"); testRunner.WaitForWidgetDisappear("Automation Dialog TextEdit", 5); }
public static void WaitForReloadAll(this AutomationRunner testRunner, Action reloadAllAction) { // Wire up a block and release mechanism to wait until the sign in process has completed AutoResetEvent resetEvent = new AutoResetEvent(false); ApplicationController.Instance.DoneReloadingAll.RegisterEvent((s, e) => resetEvent.Set(), ref unregisterEvents); // Start the procedure that begins a ReloadAll event in MatterControl reloadAllAction(); // Wait up to 10 seconds for the DoneReloadingAll event resetEvent.WaitOne(10 * 1000); // Remove our DoneReloadingAll listener unregisterEvents(null, null); // Wait for any post DoneReloadingAll code to finish up and return testRunner.Delay(.2); }
private static void CheckAndUncheckSetting(AutomationRunner testRunner, string settingToChange, bool printer, bool expected) { // Assert that the checkbox is currently unchecked, and there is no user override Assert.IsTrue(ActiveSliceSettings.Instance.UserLayer.ContainsKey(settingToChange) == false); // Click the checkbox SetCheckBoxSetting(testRunner, settingToChange, printer, !expected); // Assert the checkbox is checked and the user override is set Assert.IsTrue(ActiveSliceSettings.Instance.UserLayer.ContainsKey(settingToChange) == true); // make sure the setting is still open in case of a reload all testRunner.NavigateToSliceSettingsField("Printer", settingToChange); // Click the cancel user override button testRunner.ClickByName("Restore " + settingToChange); testRunner.Delay(2); // Assert the checkbox is unchecked and there is no user override Assert.IsTrue(ActiveSliceSettings.Instance.GetValue <bool>(settingToChange) == expected); Assert.IsTrue(ActiveSliceSettings.Instance.UserLayer.ContainsKey(settingToChange) == false); }
public static void AddAndSelectPrinter(AutomationRunner testRunner, string make, string model) { if (!testRunner.NameExists("Select Make")) { testRunner.ClickByName("Printers... Menu", 2, delayBeforeReturn: .5); testRunner.ClickByName("Add New Printer... Menu Item", 5, delayBeforeReturn: .5); } testRunner.ClickByName("Select Make", 5); testRunner.Type(make); testRunner.Type("{Enter}"); testRunner.ClickByName("Select Model", 5); testRunner.Type(model); testRunner.Type("{Enter}"); // An unpredictable period of time will pass between Clicking Save, everything reloading and us returning to the caller. // Block until ReloadAll has completed then close and return to the caller, at which point hopefully everything is reloaded. WaitForReloadAll(testRunner, () => testRunner.ClickByName("Save & Continue Button", 2)); testRunner.ClickByName("Cancel Wizard Button", 5); testRunner.Delay(1); }
public static void AddLocalLibraryItemToQueue(GuiWidget container, double secondsBetweenClicks = .1) { AutomationRunner testRunner; EventHandler <DrawEventArgs> beforeDraw = null; beforeDraw = (sender, e) => { testRunner = new AutomationRunner(); Task.Run(() => { testRunner.ClickByName("Library Tab"); testRunner.NavigateToFolder("Local Library Row Item Collection"); testRunner.ClickByName("Library Edit Button"); testRunner.ClickByName("Row Item Calibration - Box"); testRunner.Delay(2); MatterControlUtilities.LibraryAddSelectionToQueue(testRunner); testRunner.ClickByName("Queue Tab"); }); container.BeforeDraw -= beforeDraw; }; container.BeforeDraw += beforeDraw; }
public static void RemoveAllFromQueue(this AutomationRunner testRunner) { testRunner.ClickByName("Queue... Menu"); testRunner.Delay(1); testRunner.ClickByName(" Remove All Menu Item"); }
public static void NavigateToLibraryHome(this AutomationRunner testRunner) { testRunner.EnsureContentMenuOpen(); testRunner.ClickByName("Bread Crumb Button Home"); testRunner.Delay(.5); }
public static void ClickSignOut(this AutomationRunner testRunner) { testRunner.ClickByName("User Options Menu"); testRunner.ClickByName("Sign Out Menu Item"); testRunner.Delay(.5); }
public static void LibraryEditSelectedItem(AutomationRunner testRunner) { testRunner.ClickByName("Edit Menu Item"); testRunner.Delay(1); // wait for the new window to open }
public static void Complete9StepLeveling(this AutomationRunner testRunner, int numUpClicks = 1) { // Helper methods bool headerExists(string headerText) { var header = testRunner.GetWidgetByName("HeaderRow", out _); var textWidget = header.Children <TextWidget>().FirstOrDefault(); return(textWidget?.Text.StartsWith(headerText) ?? false); } void waitForPage(string headerText) { testRunner.WaitFor(() => headerExists(headerText)); Assert.IsTrue(headerExists(headerText), "Expected page not found: " + headerText); } void waitForPageAndAdvance(string headerText) { waitForPage(headerText); testRunner.ClickByName("Next Button"); } testRunner.Delay(); testRunner.WaitFor(() => headerExists("Initial Printer Setup")); if (headerExists("Initial Printer Setup")) { // do print leveling steps waitForPageAndAdvance("Initial Printer Setup"); } waitForPageAndAdvance("Print Leveling Overview"); waitForPageAndAdvance("Select Material"); waitForPageAndAdvance("Homing The Printer"); waitForPageAndAdvance("Waiting For Printer To Heat"); for (int i = 0; i < 3; i++) { var section = (i * 3) + 1; waitForPage($"Step {section} of 9"); for (int j = 0; j < numUpClicks; j++) { testRunner.Delay(); testRunner.ClickByName("Move Z positive"); } waitForPage($"Step {section} of 9"); testRunner.ClickByName("Next Button"); waitForPage($"Step {section + 1} of 9"); testRunner.ClickByName("Next Button"); waitForPage($"Step {section + 2} of 9"); testRunner.ClickByName("Next Button"); } testRunner.ClickByName("Done Button"); }