Use automation helper to validate ActivePrinters.First is valid
- Not valid for use in multi-printer scenarios
This commit is contained in:
parent
05d7ae286c
commit
5804173ab9
5 changed files with 23 additions and 19 deletions
|
|
@ -28,7 +28,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
string newName = "Updated name";
|
||||
testRunner.InlineTitleEdit("Printer Name", newName);
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
string printerID = printer.Settings.ID;
|
||||
|
||||
// Wait for change
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
testRunner.SelectSliceSettingsField("Printer", "start_gcode");
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
|
||||
// Validate GCode fields persist values
|
||||
Assert.AreEqual(
|
||||
|
|
@ -99,7 +99,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
// print a part
|
||||
testRunner.AddItemToBedplate();
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.FirstOrDefault();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
|
||||
var currentSettings = printer.Settings;
|
||||
currentSettings.SetValue(SettingsKey.pause_gcode, "");
|
||||
|
|
@ -312,7 +312,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.ClickByName("Yes Button");
|
||||
|
||||
// Wait for done
|
||||
testRunner.WaitForPrintFinished(ApplicationController.Instance.ActivePrinters.First());
|
||||
testRunner.WaitForPrintFinished(testRunner.FirstPrinter());
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
|
@ -328,7 +328,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
{
|
||||
Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should exist after add");
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
printer.Settings.SetValue(SettingsKey.recover_is_enabled, "1");
|
||||
printer.Settings.SetValue(SettingsKey.has_hardware_leveling, "0");
|
||||
|
||||
|
|
@ -410,7 +410,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
testRunner.SwitchToControlsTab();
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.FirstOrDefault();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
|
||||
// Wait for printing to complete
|
||||
var printFinishedResetEvent = new AutoResetEvent(false);
|
||||
|
|
@ -508,7 +508,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
testRunner.SwitchToControlsTab();
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
|
||||
var printFinishedResetEvent = new AutoResetEvent(false);
|
||||
printer.Connection.PrintFinished += (s, e) => printFinishedResetEvent.Set();
|
||||
|
|
@ -639,7 +639,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
fanChangedCount++;
|
||||
};
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
|
||||
emulator.WaitForLayer(printer.Settings, 2);
|
||||
emulator.RunSlow = true;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator())
|
||||
{
|
||||
var printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
printer.Settings.SetValue(SettingsKey.enable_line_splitting, "0");
|
||||
|
||||
var view3D = testRunner.GetWidgetByName("View3DWidget", out _) as View3DWidget;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
testRunner.StartPrint();
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
|
||||
WaitForLayerAndResume(testRunner, printer, 2);
|
||||
WaitForLayerAndResume(testRunner, printer, 4);
|
||||
|
|
@ -86,7 +86,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
{
|
||||
Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should exist after add");
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
printer.Settings.SetValue(SettingsKey.cancel_gcode, "G28 ; Cancel GCode");
|
||||
|
||||
testRunner.AddItemToBedplate();
|
||||
|
|
@ -146,7 +146,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
testRunner.ClickByName("Features Tab");
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
|
||||
CheckAndUncheckSetting(testRunner, printer, SettingsKey.heat_extruder_before_homing, false);
|
||||
|
||||
|
|
@ -310,9 +310,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
Assert.IsTrue(testRunner.NameExists("Hotend 0"));
|
||||
Assert.IsTrue(testRunner.NameExists("Hotend 1"));
|
||||
|
||||
Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count, "ActivePrinters.First is only valid in single printer scenarios");
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
|
||||
SetCheckBoxSetting(testRunner, printer, SettingsKey.extruders_share_temperature, true);
|
||||
|
||||
|
|
@ -502,7 +500,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.AddAndSelectPrinter("Airwolf 3D", "HD");
|
||||
testRunner.SwitchToSliceSettings();
|
||||
|
||||
var printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
var printer = testRunner.FirstPrinter();
|
||||
|
||||
testRunner.SelectSliceSettingsField("Advanced", "layer_height");
|
||||
testRunner.Type(".5");
|
||||
|
|
@ -536,7 +534,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.DoubleClickByName("Airwolf 3D HD Node");
|
||||
testRunner.Delay(0.2);
|
||||
|
||||
printer = ApplicationController.Instance.ActivePrinters.First();
|
||||
printer = testRunner.FirstPrinter();
|
||||
|
||||
testRunner.WaitFor(() => printer.Settings.GetValue<double>(SettingsKey.layer_height) == 0.1);
|
||||
Assert.AreEqual(printer.Settings.GetValue<double>(SettingsKey.layer_height).ToString(), "0.1", "Layer height is the fine override");
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.AddAndSelectPrinter(make, model);
|
||||
|
||||
// Force the configured printer to use the emulator driver
|
||||
ApplicationController.Instance.ActivePrinters.First().Settings.SetValue("driver_type", "Emulator");
|
||||
testRunner.FirstPrinter().Settings.SetValue("driver_type", "Emulator");
|
||||
|
||||
// edit the com port
|
||||
testRunner.SwitchToPrinterSettings();
|
||||
|
|
@ -625,12 +625,18 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.FinishedPrint, maxSeconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the first and only active printer. Throws if called when multiple active printers exists
|
||||
/// </summary>
|
||||
/// <param name="testRunner"></param>
|
||||
/// <returns>The first active printer</returns>
|
||||
public static PrinterConfig FirstPrinter(this AutomationRunner testRunner)
|
||||
{
|
||||
Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count, "FirstPrinter() is only valid in single printer scenarios");
|
||||
|
||||
return ApplicationController.Instance.ActivePrinters.First();
|
||||
}
|
||||
|
||||
|
||||
public static void WaitForCommunicationStateDisconnected(this AutomationRunner testRunner, PrinterConfig printer, int maxSeconds = 500)
|
||||
{
|
||||
testRunner.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Disconnected, maxSeconds);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue