Remove ActivePrinter

This commit is contained in:
John Lewin 2018-11-30 12:53:43 -08:00
parent bc4efaf18a
commit 05d7ae286c
5 changed files with 47 additions and 42 deletions

View file

@ -51,7 +51,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.StartPrint();
// Wait for print to finish
testRunner.WaitForPrintFinished();
testRunner.WaitForPrintFinished(printer);
// Wait for expected temp
testRunner.WaitFor(() => printer.Connection.GetActualHotendTemperature(0) <= 0, 10);
@ -65,7 +65,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.StartPrint();
// Wait for print to finish
testRunner.WaitForPrintFinished();
testRunner.WaitForPrintFinished(printer);
// Wait for expected temp
testRunner.WaitFor(() => printer.Connection.GetActualHotendTemperature(0) <= 0, 10);
@ -312,7 +312,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.ClickByName("Yes Button");
// Wait for done
testRunner.WaitForPrintFinished();
testRunner.WaitForPrintFinished(ApplicationController.Instance.ActivePrinters.First());
}
return Task.CompletedTask;
@ -354,7 +354,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
// the printer is now paused
// close the pause dialog pop-up do not resume
ClickDialogButton(testRunner, "No Button", 3);
ClickDialogButton(testRunner, printer, "No Button", 3);
// Disconnect
testRunner.ClickByName("Disconnect from printer button");
@ -368,30 +368,30 @@ namespace MatterHackers.MatterControl.Tests.Automation
// Assert that recovery happens
// Recover the print
ClickDialogButton(testRunner, "Yes Button", -1);
ClickDialogButton(testRunner, printer, "Yes Button", -1);
// The first pause that we get after recovery should be layer 6.
// wait for the pause and continue
ClickDialogButton(testRunner, "Yes Button", 5);
ClickDialogButton(testRunner, printer, "Yes Button", 5);
// Wait for done
testRunner.WaitForPrintFinished();
testRunner.WaitForPrintFinished(printer);
}
return Task.CompletedTask;
}, maxTimeToRun: 180);
}
private static void ClickDialogButton(AutomationRunner testRunner, string buttonName, int expectedLayer)
// TODO: convert to extension method
private static void ClickDialogButton(AutomationRunner testRunner, PrinterConfig printer, string buttonName, int expectedLayer)
{
testRunner.WaitForName(buttonName, 90);
Assert.AreEqual(expectedLayer, ApplicationController.Instance.ActivePrinter.Connection.CurrentlyPrintingLayer);
Assert.AreEqual(expectedLayer, printer.Connection.CurrentlyPrintingLayer);
testRunner.ClickByName(buttonName);
testRunner.WaitFor(() => !testRunner.NameExists(buttonName), 1);
}
private EventHandler unregisterEvents;
[Test, Category("Emulator")]
public async Task TuningAdjustmentsDefaultToOneAndPersists()
{
@ -462,7 +462,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
// Values should match entered values
ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After print finished");
testRunner.WaitForPrintFinished();
testRunner.WaitForPrintFinished(printer);
// Restart the print
testRunner.StartPrint();
@ -508,7 +508,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.SwitchToControlsTab();
var printer = ApplicationController.Instance.ActivePrinter;
var printer = ApplicationController.Instance.ActivePrinters.First();
var printFinishedResetEvent = new AutoResetEvent(false);
printer.Connection.PrintFinished += (s, e) => printFinishedResetEvent.Set();
@ -554,7 +554,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
// Wait for printing to complete
printFinishedResetEvent.WaitOne();
testRunner.WaitForPrintFinished();
testRunner.WaitForPrintFinished(printer);
// Values should match entered values
testRunner.StartPrint();
@ -660,7 +660,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.ClickByName("Yes Button");
// Wait for Disconnected CommunicationState which occurs after PrinterConnection.Disable()
testRunner.WaitForCommunicationStateDisconnected(maxSeconds: 30);
testRunner.WaitForCommunicationStateDisconnected(printer, maxSeconds: 30);
// Wait for close
testRunner.WaitForWidgetDisappear("Yes Button", 4);

View file

@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MatterHackers.Agg.UI;
@ -54,7 +55,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator())
{
var printer = ApplicationController.Instance.ActivePrinter;
var printer = ApplicationController.Instance.ActivePrinters.First();
printer.Settings.SetValue(SettingsKey.enable_line_splitting, "0");
var view3D = testRunner.GetWidgetByName("View3DWidget", out _) as View3DWidget;
@ -162,7 +163,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.ClickByName("Resume Task Button");
// Wait for done
testRunner.WaitForPrintFinished();
testRunner.WaitForPrintFinished(printer);
// this will make sure we turned off line splitting and had good data about the extruder position
Assert.AreEqual(-7, largestRetraction, "Airwolf HD has a retraction of 7mm, make sure we had one");

View file

@ -64,11 +64,13 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.StartPrint();
WaitForLayerAndResume(testRunner, 2);
WaitForLayerAndResume(testRunner, 4);
WaitForLayerAndResume(testRunner, 6);
var printer = ApplicationController.Instance.ActivePrinters.First();
testRunner.WaitForPrintFinished();
WaitForLayerAndResume(testRunner, printer, 2);
WaitForLayerAndResume(testRunner, printer, 4);
WaitForLayerAndResume(testRunner, printer, 6);
testRunner.WaitForPrintFinished(printer);
}
return Task.CompletedTask;
@ -117,12 +119,11 @@ namespace MatterHackers.MatterControl.Tests.Automation
}, maxTimeToRun: 120);
}
private static void WaitForLayerAndResume(AutomationRunner testRunner, int indexToWaitFor)
// TODO: Promote to extension method
private static void WaitForLayerAndResume(AutomationRunner testRunner, PrinterConfig printer, int indexToWaitFor)
{
testRunner.WaitForName("Yes Button", 30);
var printer = ApplicationController.Instance.ActivePrinter;
// Wait for layer
testRunner.WaitFor(() => printer.Bed.ActiveLayerIndex + 1 == indexToWaitFor, 30, 500);
Assert.AreEqual(indexToWaitFor, printer.Bed.ActiveLayerIndex + 1);
@ -145,7 +146,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.ClickByName("Features Tab");
var printer = ApplicationController.Instance.ActivePrinter;
var printer = ApplicationController.Instance.ActivePrinters.First();
CheckAndUncheckSetting(testRunner, printer, SettingsKey.heat_extruder_before_homing, false);
@ -309,7 +310,9 @@ namespace MatterHackers.MatterControl.Tests.Automation
Assert.IsTrue(testRunner.NameExists("Hotend 0"));
Assert.IsTrue(testRunner.NameExists("Hotend 1"));
var printer = ApplicationController.Instance.ActivePrinter;
Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count, "ActivePrinters.First is only valid in single printer scenarios");
var printer = ApplicationController.Instance.ActivePrinters.First();
SetCheckBoxSetting(testRunner, printer, SettingsKey.extruders_share_temperature, true);