refactoring
This commit is contained in:
parent
27dc4b1f0a
commit
bae0720164
4 changed files with 164 additions and 163 deletions
|
|
@ -94,14 +94,10 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
{
|
||||
Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should be defined after add");
|
||||
|
||||
testRunner.OpenPrintPopupMenu();
|
||||
|
||||
testRunner.ClickByName("SetupPrinter");
|
||||
|
||||
testRunner.Complete9StepLeveling();
|
||||
|
||||
// print a part
|
||||
testRunner.AddItemToBedplate();
|
||||
testRunner.OpenPrintPopupMenu()
|
||||
.ClickByName("SetupPrinter")
|
||||
.Complete9StepLeveling()
|
||||
.AddItemToBedplate();
|
||||
|
||||
var printer = testRunner.FirstPrinter();
|
||||
|
||||
|
|
@ -363,43 +359,21 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
Assert.IsTrue(printer.Connection.RecoveryIsEnabled);
|
||||
|
||||
// print a part
|
||||
testRunner.AddItemToBedplate();
|
||||
testRunner.StartPrint(pauseAtLayers: "2;4;6");
|
||||
|
||||
// Wait for pause dialog
|
||||
testRunner.WaitForName("Yes Button", 15); // the yes button is 'Resume'
|
||||
|
||||
// validate the current layer
|
||||
Assert.AreEqual(1, printer.Connection.CurrentlyPrintingLayer);
|
||||
|
||||
// Resume
|
||||
testRunner.ClickByName("Yes Button");
|
||||
|
||||
// the printer is now paused
|
||||
// close the pause dialog pop-up do not resume
|
||||
testRunner.ClickResumeButton(printer, false, 3);
|
||||
|
||||
// Disconnect
|
||||
testRunner.ClickByName("Disconnect from printer button");
|
||||
|
||||
// Reconnect
|
||||
testRunner.WaitForName("Connect to printer button", 10);
|
||||
testRunner.ClickByName("Connect to printer button");
|
||||
|
||||
testRunner.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Connected);
|
||||
testRunner.AddItemToBedplate()
|
||||
.StartPrint(pauseAtLayers: "2;4;6")
|
||||
.ClickResumeButton(printer, true, 1) // Resume
|
||||
.ClickResumeButton(printer, false, 3) // close the pause dialog pop-up do not resume
|
||||
.ClickByName("Disconnect from printer button")
|
||||
.ClickByName("Connect to printer button") // Reconnect
|
||||
.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Connected);
|
||||
|
||||
// Assert that recovery happens
|
||||
Assert.IsTrue(PrintRecovery.RecoveryAvailable(printer), "Recovery should be enabled after Disconnect while printing");
|
||||
|
||||
// Recover the print
|
||||
testRunner.ClickResumeButton(printer, true, -1);
|
||||
|
||||
// The first pause that we get after recovery should be layer 6.
|
||||
// wait for the pause and continue
|
||||
testRunner.ClickResumeButton(printer, true, 5);
|
||||
|
||||
// Wait for done
|
||||
testRunner.WaitForPrintFinished(printer);
|
||||
testRunner.ClickButton("Yes Button", "Recover Print")
|
||||
.ClickResumeButton(printer, true, 5) // The first pause that we get after recovery should be layer 6.
|
||||
.WaitForPrintFinished(printer);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
|
@ -433,23 +407,20 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
printFinishedResetEvent.Set();
|
||||
};
|
||||
|
||||
testRunner.StartPrint();
|
||||
|
||||
testRunner.ScrollIntoView("Extrusion Multiplier NumberEdit");
|
||||
testRunner.ScrollIntoView("Feed Rate NumberEdit");
|
||||
testRunner.StartPrint()
|
||||
.ScrollIntoView("Extrusion Multiplier NumberEdit")
|
||||
.ScrollIntoView("Feed Rate NumberEdit");
|
||||
|
||||
// Tuning values should default to 1 when missing
|
||||
ConfirmExpectedSpeeds(testRunner, 1, 1, "Initial case");
|
||||
|
||||
testRunner.Delay();
|
||||
testRunner.ClickByName("Extrusion Multiplier NumberEdit");
|
||||
testRunner.Type(targetExtrusionRate.ToString());
|
||||
|
||||
testRunner.ClickByName("Feed Rate NumberEdit");
|
||||
testRunner.Type(targetFeedRate.ToString());
|
||||
|
||||
// Force focus away from the feed rate field, causing an persisted update
|
||||
testRunner.ClickByName("Extrusion Multiplier NumberEdit");
|
||||
testRunner.Delay()
|
||||
.ClickByName("Extrusion Multiplier NumberEdit")
|
||||
.Type(targetExtrusionRate.ToString())
|
||||
.ClickByName("Feed Rate NumberEdit")
|
||||
.Type(targetFeedRate.ToString())
|
||||
// Force focus away from the feed rate field, causing an persisted update
|
||||
.ClickByName("Extrusion Multiplier NumberEdit");
|
||||
|
||||
ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After setting TextEdit values");
|
||||
|
||||
|
|
@ -465,17 +436,15 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
// Values should match entered values
|
||||
ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After print finished");
|
||||
|
||||
testRunner.WaitForPrintFinished(printer);
|
||||
|
||||
// Restart the print
|
||||
testRunner.StartPrint();
|
||||
testRunner.Delay(1);
|
||||
testRunner.WaitForPrintFinished(printer)
|
||||
.StartPrint() // Restart the print
|
||||
.Delay(1);
|
||||
|
||||
// Values should match entered values
|
||||
ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After print restarted");
|
||||
|
||||
testRunner.CancelPrint();
|
||||
testRunner.Delay(1);
|
||||
testRunner.CancelPrint()
|
||||
.Delay(1);
|
||||
|
||||
// Values should match entered values
|
||||
ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After canceled print");
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
{
|
||||
private static bool saveImagesForDebug = true;
|
||||
|
||||
private static event EventHandler unregisterEvents;
|
||||
private static event EventHandler UnregisterEvents;
|
||||
|
||||
private static int testID = 0;
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
{
|
||||
// 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);
|
||||
ApplicationController.Instance.DoneReloadingAll.RegisterEvent((s, e) => resetEvent.Set(), ref UnregisterEvents);
|
||||
|
||||
// Start the procedure that begins a ReloadAll event in MatterControl
|
||||
reloadAllAction();
|
||||
|
|
@ -127,13 +127,13 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
resetEvent.WaitOne(10 * 1000);
|
||||
|
||||
// Remove our DoneReloadingAll listener
|
||||
unregisterEvents(null, null);
|
||||
UnregisterEvents(null, null);
|
||||
|
||||
// Wait for any post DoneReloadingAll code to finish up and return
|
||||
testRunner.Delay(.2);
|
||||
}
|
||||
|
||||
public static void WaitForPage(this AutomationRunner testRunner, string headerText)
|
||||
public static AutomationRunner WaitForPage(this AutomationRunner testRunner, string headerText)
|
||||
{
|
||||
// Helper methods
|
||||
bool HeaderExists(string text)
|
||||
|
|
@ -147,8 +147,9 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.WaitFor(() => HeaderExists(headerText));
|
||||
|
||||
Assert.IsTrue(HeaderExists(headerText), "Expected page not found: " + headerText);
|
||||
}
|
||||
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
public static string PathToExportGcodeFolder
|
||||
{
|
||||
|
|
@ -168,7 +169,8 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
public enum PrepAction
|
||||
{
|
||||
CloseSignInAndPrinterSelect
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
public static void ExpandEditTool(this AutomationRunner testRunner, string expandCheckboxButtonName)
|
||||
{
|
||||
|
|
@ -186,6 +188,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
{
|
||||
testRunner.ClickByName("3D View Edit");
|
||||
}
|
||||
|
||||
testRunner.DragDropByName("InteractionLayer", "InteractionLayer", offsetDrop: new Agg.Point2D(10, 15), mouseButtons: MouseButtons.Right);
|
||||
|
||||
testRunner.Delay(1);
|
||||
|
|
@ -252,23 +255,16 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
WaitForTempStream.WaitAfterReachTempTime = config.TempStabilizationTime;
|
||||
|
||||
// Create the printer
|
||||
testRunner.AddAndSelectPrinter(make, model);
|
||||
|
||||
// edit the com port
|
||||
testRunner.SwitchToPrinterSettings();
|
||||
testRunner.AddAndSelectPrinter(make, model)
|
||||
.SwitchToPrinterSettings();
|
||||
|
||||
var serialPortDropDown = testRunner.GetWidgetByName("com_port Field", out _, 1);
|
||||
|
||||
testRunner.WaitFor(() => serialPortDropDown.Enabled); // Wait until the serialPortDropDown is ready to click it. Ensures the printer is loaded.
|
||||
|
||||
testRunner.ClickByName("com_port Field");
|
||||
|
||||
testRunner.ClickByName("Emulator Menu Item");
|
||||
|
||||
// connect to the created printer
|
||||
testRunner.ClickByName("Connect to printer button");
|
||||
|
||||
testRunner.WaitForName("Disconnect from printer button");
|
||||
testRunner.ClickByName("com_port Field")
|
||||
.ClickByName("Emulator Menu Item")
|
||||
.ClickByName("Connect to printer button") // connect to the created printer
|
||||
.WaitForName("Disconnect from printer button");
|
||||
|
||||
// replace the old behavior of clicking the 'Already Loaded' button by setting to filament_has_been_loaded.
|
||||
ApplicationController.Instance.ActivePrinters.First().Settings.SetValue(SettingsKey.filament_has_been_loaded, "1");
|
||||
|
|
@ -279,22 +275,22 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
return Emulator.Instance;
|
||||
}
|
||||
|
||||
public static void CancelPrint(this AutomationRunner testRunner)
|
||||
public static AutomationRunner CancelPrint(this AutomationRunner testRunner)
|
||||
{
|
||||
// If the pause/resume dialog is open, dismiss it before canceling the print
|
||||
if (testRunner.WaitForName("Yes Button", 1))
|
||||
if (testRunner.NamedWidgetExists("Yes Button"))
|
||||
{
|
||||
testRunner.ClickByName("Yes Button");
|
||||
}
|
||||
|
||||
testRunner.WaitForWidgetEnabled("Print Progress Dial", 15);
|
||||
testRunner.WaitForWidgetEnabled("Print Progress Dial", 15)
|
||||
.WaitForWidgetEnabled("Stop Task Button")
|
||||
.ClickByName("Stop Task Button")
|
||||
.WaitForName("Ok Button", 10); // Wait for and dismiss the new PrintCompleted dialog
|
||||
|
||||
testRunner.WaitForWidgetEnabled("Stop Task Button");
|
||||
testRunner.ClickByName("Stop Task Button");
|
||||
|
||||
// Wait for and dismiss the new PrintCompleted dialog
|
||||
testRunner.WaitForName("Ok Button", 10);
|
||||
testRunner.ClickByName("Ok Button");
|
||||
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
public static void WaitForLayer(this Emulator emulator, PrinterSettings printerSettings, int layerNumber, double secondsToWait = 30)
|
||||
|
|
@ -343,16 +339,13 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.ClickByName("Yes Button");
|
||||
}
|
||||
|
||||
public static void AddAndSelectPrinter(this AutomationRunner testRunner, string make = "Airwolf 3D", string model = "HD")
|
||||
public static AutomationRunner AddAndSelectPrinter(this AutomationRunner testRunner, string make = "Airwolf 3D", string model = "HD")
|
||||
{
|
||||
testRunner.GetWidgetByName("PartPreviewContent", out SystemWindow systemWindow, 10);
|
||||
|
||||
// make sure we wait for MC to be up and running
|
||||
testRunner.WaitforDraw(systemWindow);
|
||||
testRunner.WaitforDraw(systemWindow) // make sure we wait for MC to be up and running
|
||||
.EnsureWelcomePageClosed(); // close the welcome message
|
||||
|
||||
// close the welcome message
|
||||
testRunner.EnsureWelcomePageClosed();
|
||||
testRunner.Delay();
|
||||
if (testRunner.NamedWidgetExists("Cancel Wizard Button"))
|
||||
{
|
||||
testRunner.ClickByName("Cancel Wizard Button");
|
||||
|
|
@ -388,26 +381,21 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
});
|
||||
|
||||
// Apply filter
|
||||
testRunner.ClickByName("Search");
|
||||
testRunner.Type(model);
|
||||
testRunner.Type("{Enter}");
|
||||
testRunner.ClickByName("Search")
|
||||
.Type(model)
|
||||
.Type("{Enter}")
|
||||
.Delay()
|
||||
.ClickByName($"Node{make}{model}") // Click printer node
|
||||
.ClickByName("Next Button") // Continue to next page
|
||||
.Delay()
|
||||
.WaitFor(() => testRunner.ChildExists<SetupStepComPortOne>());
|
||||
testRunner.ClickByName("Cancel Wizard Button")
|
||||
.WaitFor(() => !testRunner.ChildExists<SetupStepComPortOne>());
|
||||
|
||||
// Click printer node
|
||||
testRunner.Delay();
|
||||
testRunner.ClickByName($"Node{make}{model}");
|
||||
|
||||
// Continue to next page
|
||||
testRunner.ClickByName("Next Button");
|
||||
|
||||
testRunner.Delay();
|
||||
|
||||
testRunner.WaitFor(() => testRunner.ChildExists<SetupStepComPortOne>());
|
||||
testRunner.ClickByName("Cancel Wizard Button");
|
||||
|
||||
testRunner.WaitFor(() => !testRunner.ChildExists<SetupStepComPortOne>());
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
public static void EnsureWelcomePageClosed(this AutomationRunner testRunner)
|
||||
public static AutomationRunner EnsureWelcomePageClosed(this AutomationRunner testRunner)
|
||||
{
|
||||
// Close the WelcomePage window if active
|
||||
if (testRunner.GetWidgetByName("HeaderRow", out _) is GuiWidget headerRow
|
||||
|
|
@ -416,6 +404,10 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
{
|
||||
testRunner.ClickByName("Cancel Wizard Button");
|
||||
}
|
||||
|
||||
testRunner.WaitFor(() => !testRunner.NameExists("Cancel Wizard Button", .1));
|
||||
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
public static void WaitForAndCancelPrinterSetupPage(this AutomationRunner testRunner)
|
||||
|
|
@ -511,14 +503,30 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.ClickByName("User Options Menu");
|
||||
}
|
||||
|
||||
public static void ClickResumeButton(this AutomationRunner testRunner, PrinterConfig printer, bool resume, int expectedLayer)
|
||||
public static AutomationRunner ClickButton(this AutomationRunner testRunner, string buttonName, string buttonText, double maxWait = 5)
|
||||
{
|
||||
testRunner.WaitForName(buttonName, maxWait, predicate: (w) => w.Children.FirstOrDefault().Text == buttonText);
|
||||
testRunner.ClickByName(buttonName);
|
||||
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
public static AutomationRunner ClickResumeButton(this AutomationRunner testRunner,
|
||||
PrinterConfig printer,
|
||||
bool resume,
|
||||
int expectedLayer)
|
||||
{
|
||||
var buttonName = resume ? "Yes Button" : "No Button";
|
||||
testRunner.WaitForName(buttonName, 90);
|
||||
Assert.AreEqual(expectedLayer, printer.Connection.CurrentlyPrintingLayer);
|
||||
var buttonText = resume ? "Resume" : "OK";
|
||||
testRunner.WaitForName(buttonName, 90, predicate: (w) => w.Children.FirstOrDefault().Text == buttonText);
|
||||
Assert.AreEqual(expectedLayer,
|
||||
printer.Connection.CurrentlyPrintingLayer,
|
||||
$"Expected the paused layer to be {expectedLayer} but was {printer.Connection.CurrentlyPrintingLayer}.");
|
||||
|
||||
testRunner.ClickByName(buttonName);
|
||||
testRunner.WaitFor(() => !testRunner.NameExists(buttonName), 1);
|
||||
testRunner.WaitFor(() => !testRunner.NameExists(buttonName), 2);
|
||||
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
public static void NavigateToFolder(this AutomationRunner testRunner, string libraryRowItemName)
|
||||
|
|
@ -604,8 +612,8 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.ClickByName("SetupPrinter");
|
||||
|
||||
// Configure ABS as selected material
|
||||
//testRunner.ClickByName("Material DropDown List");
|
||||
//testRunner.ClickByName("ABS Menu");
|
||||
// testRunner.ClickByName("Material DropDown List");
|
||||
// testRunner.ClickByName("ABS Menu");
|
||||
|
||||
// Currently material selection is not required, simply act of clicking 'Select' clears setup required
|
||||
testRunner.ClickByName("Already Loaded Button");
|
||||
|
|
@ -669,7 +677,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.WaitForWidgetDisappear("Automation Dialog TextEdit", 5);
|
||||
}
|
||||
|
||||
public static void AddItemToBedplate(this AutomationRunner testRunner, string containerName = "Calibration Parts Row Item Collection", string partName = "Row Item Calibration - Box.stl")
|
||||
public static AutomationRunner AddItemToBedplate(this AutomationRunner testRunner, string containerName = "Calibration Parts Row Item Collection", string partName = "Row Item Calibration - Box.stl")
|
||||
{
|
||||
if (!testRunner.NameExists(partName, 1) && !string.IsNullOrEmpty(containerName))
|
||||
{
|
||||
|
|
@ -697,6 +705,8 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
{
|
||||
testRunner.WaitFor(() => scene.Children.LastOrDefault() as InsertionGroupObject3D != null, 10);
|
||||
}
|
||||
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
public static void SaveBedplateToFolder(this AutomationRunner testRunner, string newFileName, string folderName)
|
||||
|
|
@ -717,17 +727,19 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.Delay(2);
|
||||
}
|
||||
|
||||
public static void WaitForPrintFinished(this AutomationRunner testRunner, PrinterConfig printer, int maxSeconds = 500)
|
||||
public static AutomationRunner WaitForPrintFinished(this AutomationRunner testRunner, PrinterConfig printer, int maxSeconds = 500)
|
||||
{
|
||||
testRunner.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.FinishedPrint, maxSeconds);
|
||||
// click the ok button on the print complete dialog
|
||||
testRunner.ClickByName("Ok Button");
|
||||
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the first and only active printer. Throws if called when multiple active printers exists
|
||||
/// </summary>
|
||||
/// <param name="testRunner"></param>
|
||||
/// <param name="testRunner">The AutomationRunner in use</param>
|
||||
/// <returns>The first active printer</returns>
|
||||
public static PrinterConfig FirstPrinter(this AutomationRunner testRunner)
|
||||
{
|
||||
|
|
@ -764,8 +776,8 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
string defaultTestImages = null)
|
||||
{
|
||||
// Walk back a step in the stack and output the callers name
|
||||
//StackTrace st = new StackTrace(false);
|
||||
//Debug.WriteLine("\r\n ***** Running automation test: {0} {1} ", st.GetFrames().Skip(1).First().GetMethod().Name, DateTime.Now);
|
||||
// StackTrace st = new StackTrace(false);
|
||||
// Debug.WriteLine("\r\n ***** Running automation test: {0} {1} ", st.GetFrames().Skip(1).First().GetMethod().Name, DateTime.Now);
|
||||
|
||||
if (staticDataPathOverride == null)
|
||||
{
|
||||
|
|
@ -782,7 +794,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
Environment.CurrentDirectory = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "bin", outputDirectory);
|
||||
|
||||
// Override the default SystemWindow type without config.json
|
||||
//AggContext.Config.ProviderTypes.SystemWindowProvider = "MatterHackers.Agg.UI.OpenGLWinformsWindowProvider, agg_platform_win32";
|
||||
// AggContext.Config.ProviderTypes.SystemWindowProvider = "MatterHackers.Agg.UI.OpenGLWinformsWindowProvider, agg_platform_win32";
|
||||
AggContext.Config.ProviderTypes.SystemWindowProvider = "MatterHackers.MatterControl.WinformsSingleWindowProvider, MatterControl.Winforms";
|
||||
|
||||
#if !__ANDROID__
|
||||
|
|
@ -803,7 +815,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
}
|
||||
|
||||
UserSettings.Instance.set(UserSettingsKey.ThumbnailRenderingMode, "orthographic");
|
||||
//GL.HardwareAvailable = false;
|
||||
// GL.HardwareAvailable = false;
|
||||
|
||||
var config = TestAutomationConfig.Load();
|
||||
if (config.UseAutomationDialogs)
|
||||
|
|
@ -902,12 +914,13 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
}
|
||||
|
||||
public static void StartSlicing(this AutomationRunner testRunner)
|
||||
public static AutomationRunner StartSlicing(this AutomationRunner testRunner)
|
||||
{
|
||||
testRunner.ClickByName("Generate Gcode Button");
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
public static void OpenPrintPopupMenu(this AutomationRunner testRunner)
|
||||
public static AutomationRunner OpenPrintPopupMenu(this AutomationRunner testRunner)
|
||||
{
|
||||
var printerConnection = ApplicationController.Instance.DragDropData.View3DWidget.Printer.Connection;
|
||||
|
||||
|
|
@ -923,13 +936,16 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
// Wait for child control
|
||||
testRunner.WaitForName("Start Print Button");
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open the Print popup menu and click the Start Print button
|
||||
/// </summary>
|
||||
/// <param name="testRunner"></param>
|
||||
public static void StartPrint(this AutomationRunner testRunner, string pauseAtLayers = null)
|
||||
/// <param name="testRunner">The AutomationRunner we are using.</param>
|
||||
/// <param name="pauseAtLayers">The string to write into the pause field in the print menu.</param>
|
||||
/// <returns></returns>
|
||||
public static AutomationRunner StartPrint(this AutomationRunner testRunner, string pauseAtLayers = null)
|
||||
{
|
||||
// Open popup
|
||||
testRunner.OpenPrintPopupMenu();
|
||||
|
|
@ -943,6 +959,20 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
}
|
||||
|
||||
testRunner.ClickByName("Start Print Button");
|
||||
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
public static AutomationRunner WaitForPause(this AutomationRunner testRunner, PrinterConfig printer, int expectedLayer)
|
||||
{
|
||||
testRunner.WaitForName("Yes Button", 15, predicate: (w) => w.Children.FirstOrDefault().Text == "Resume");
|
||||
// validate the current layer
|
||||
if (expectedLayer != printer.Connection.CurrentlyPrintingLayer)
|
||||
{
|
||||
throw new Exception($"Expected the paused layer to be {expectedLayer} but was {printer.Connection.CurrentlyPrintingLayer}.");
|
||||
}
|
||||
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
public static void OpenPrintPopupAdvanced(this AutomationRunner testRunner)
|
||||
|
|
@ -971,7 +1001,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
/// <summary>
|
||||
/// Switch to the primary SliceSettings tab
|
||||
/// </summary>
|
||||
/// <param name="testRunner"></param>
|
||||
/// <param name="testRunner">The AutomationRunner in use</param>
|
||||
public static void SwitchToSliceSettings(this AutomationRunner testRunner)
|
||||
{
|
||||
EnsurePrinterSidebarOpen(testRunner);
|
||||
|
|
@ -981,19 +1011,19 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.ClickByName("Slice Settings Tab");
|
||||
}
|
||||
|
||||
public static void Complete9StepLeveling(this AutomationRunner testRunner, int numUpClicks = 1)
|
||||
public static AutomationRunner WaitForPageAndAdvance(this AutomationRunner testRunner, string headerText)
|
||||
{
|
||||
void waitForPageAndAdvance(string headerText)
|
||||
{
|
||||
testRunner.WaitForPage(headerText);
|
||||
testRunner.ClickByName("Next Button");
|
||||
}
|
||||
testRunner.WaitForPage(headerText)
|
||||
.ClickByName("Next Button");
|
||||
|
||||
testRunner.Delay();
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
waitForPageAndAdvance("Print Leveling Overview");
|
||||
|
||||
waitForPageAndAdvance("Heating the printer");
|
||||
public static AutomationRunner Complete9StepLeveling(this AutomationRunner testRunner, int numUpClicks = 1)
|
||||
{
|
||||
testRunner.Delay()
|
||||
.WaitForPageAndAdvance("Print Leveling Overview")
|
||||
.WaitForPageAndAdvance("Heating the printer");
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
|
|
@ -1006,19 +1036,17 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.ClickByName("Move Z positive");
|
||||
}
|
||||
|
||||
testRunner.WaitForPage($"Step {section} of 9");
|
||||
testRunner.ClickByName("Next Button");
|
||||
|
||||
testRunner.WaitForPage($"Step {section + 1} of 9");
|
||||
testRunner.ClickByName("Next Button");
|
||||
|
||||
testRunner.WaitForPage($"Step {section + 2} of 9");
|
||||
testRunner.ClickByName("Next Button");
|
||||
testRunner.WaitForPage($"Step {section} of 9")
|
||||
.ClickByName("Next Button")
|
||||
.WaitForPage($"Step {section + 1} of 9")
|
||||
.ClickByName("Next Button")
|
||||
.WaitForPage($"Step {section + 2} of 9")
|
||||
.ClickByName("Next Button");
|
||||
}
|
||||
|
||||
testRunner.ClickByName("Done Button");
|
||||
testRunner.ClickByName("Done Button")
|
||||
.Delay();
|
||||
|
||||
testRunner.Delay();
|
||||
if (testRunner.NameExists("Already Loaded Button", 0.2))
|
||||
{
|
||||
testRunner.ClickByName("Already Loaded Button");
|
||||
|
|
@ -1026,12 +1054,14 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
// Close the staged wizard window
|
||||
testRunner.ClickByName("Cancel Wizard Button");
|
||||
|
||||
return testRunner;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Switch to printer settings
|
||||
/// </summary>
|
||||
/// <param name="testRunner"></param>
|
||||
/// <param name="testRunner">The AutomationRunner in use</param>
|
||||
public static void SwitchToPrinterSettings(this AutomationRunner testRunner)
|
||||
{
|
||||
EnsurePrinterSidebarOpen(testRunner);
|
||||
|
|
@ -1041,6 +1071,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.ClickByName("Printer Overflow Menu");
|
||||
testRunner.ClickByName("Configure Printer Menu Item");
|
||||
}
|
||||
|
||||
testRunner.ClickByName("Printer Tab");
|
||||
}
|
||||
|
||||
|
|
@ -1096,7 +1127,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
/// <summary>
|
||||
/// Switch to Printer -> Controls
|
||||
/// </summary>
|
||||
/// <param name="testRunner"></param>
|
||||
/// <param name="testRunner">The AutomationRunner in use</param>
|
||||
public static void SwitchToControlsTab(this AutomationRunner testRunner)
|
||||
{
|
||||
// Change to Printer Controls
|
||||
|
|
@ -1114,7 +1145,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
/// <summary>
|
||||
/// Switch to Printer -> Terminal
|
||||
/// </summary>
|
||||
/// <param name="testRunner"></param>
|
||||
/// <param name="testRunner">The AutomationRunner in use</param>
|
||||
public static void SwitchToTerminalTab(this AutomationRunner testRunner)
|
||||
{
|
||||
// Change to Printer Controls
|
||||
|
|
@ -1132,7 +1163,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
/// <summary>
|
||||
/// Switch to Printer -> GCode Tab - NOTE: as a short term hack this helper as adds content to the bed and slices to ensure GCode view options appear as expected
|
||||
/// </summary>
|
||||
/// <param name="testRunner"></param>
|
||||
/// <param name="testRunner">The AutomationRunner in use</param>
|
||||
public static void SwitchToGCodeTab(this AutomationRunner testRunner)
|
||||
{
|
||||
testRunner.ClickByName("Layers3D Button");
|
||||
|
|
@ -1156,7 +1187,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
/// <summary>
|
||||
/// Adds the given asset names to the local library and validates the result
|
||||
/// </summary>
|
||||
/// <param name="testRunner"></param>
|
||||
/// <param name="testRunner">The AutomationRunner in use</param>
|
||||
/// <param name="assetNames">The test assets to add to the library</param>
|
||||
public static void AddTestAssetsToLibrary(this AutomationRunner testRunner, IEnumerable<string> assetNames, string targetLibrary = "Local Library Row Item Collection")
|
||||
{
|
||||
|
|
@ -1194,7 +1225,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
/// <summary>
|
||||
/// Control clicks each specified item
|
||||
/// </summary>
|
||||
/// <param name="testRunner"></param>
|
||||
/// <param name="testRunner">The AutomationRunner in use</param>
|
||||
/// <param name="widgetNames">The widgets to click</param>
|
||||
public static void SelectListItems(this AutomationRunner testRunner, params string[] widgetNames)
|
||||
{
|
||||
|
|
@ -1204,6 +1235,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
{
|
||||
testRunner.ClickByName(widgetName);
|
||||
}
|
||||
|
||||
Keyboard.SetKeyDownState(Keys.ControlKey, down: false);
|
||||
}
|
||||
}
|
||||
|
|
@ -1221,7 +1253,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
public class TestAutomationConfig
|
||||
{
|
||||
private static readonly string configPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "MHTest.config");
|
||||
private static readonly string ConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "MHTest.config");
|
||||
|
||||
/// <summary>
|
||||
/// The ClientToken used by tests to emulate an external client
|
||||
|
|
@ -1257,14 +1289,14 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
{
|
||||
TestAutomationConfig config = null;
|
||||
|
||||
if (!File.Exists(configPath))
|
||||
if (!File.Exists(ConfigPath))
|
||||
{
|
||||
config = new TestAutomationConfig();
|
||||
config.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
config = JsonConvert.DeserializeObject<TestAutomationConfig>(File.ReadAllText(configPath));
|
||||
config = JsonConvert.DeserializeObject<TestAutomationConfig>(File.ReadAllText(ConfigPath));
|
||||
}
|
||||
|
||||
return config;
|
||||
|
|
@ -1275,7 +1307,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
/// </summary>
|
||||
public void Save()
|
||||
{
|
||||
File.WriteAllText(configPath, JsonConvert.SerializeObject(this, Formatting.Indented));
|
||||
File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(this, Formatting.Indented));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue