Convert CloseFirstPrinterTab into a reusable test helper method

This commit is contained in:
John Lewin 2018-12-26 16:16:19 -08:00
parent 0d111a09a3
commit 8ba2299a76
2 changed files with 16 additions and 14 deletions

View file

@ -517,8 +517,8 @@ namespace MatterHackers.MatterControl.Tests.Automation
Assert.AreEqual(printer.Settings.GetValue<double>(SettingsKey.layer_height).ToString(), "0.1", "Layer height is the fine override");
// Close Airwolf
CloseFirstPrinterTab(testRunner);
testRunner.CloseFirstPrinterTab();
// Assert printer counts
Assert.AreEqual(1, ProfileManager.Instance.ActiveProfiles.Count(), "ProfileManager should have 1 profile after Airwolf close");
Assert.AreEqual(0, ApplicationController.Instance.ActivePrinters.Count(), "Zero printers should be active after Airwolf close");
@ -530,7 +530,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should be active after BCN add");
// Close BCN
CloseFirstPrinterTab(testRunner);
testRunner.CloseFirstPrinterTab();
// Reopen Airwolf
testRunner.SwitchToHardwareTab();
@ -555,17 +555,6 @@ namespace MatterHackers.MatterControl.Tests.Automation
}, maxTimeToRun: 120);
}
private void CloseFirstPrinterTab(AutomationRunner testRunner)
{
// Close all printer tabs
var mainViewWidget = testRunner.GetWidgetByName("PartPreviewContent", out _) as MainViewWidget;
if (mainViewWidget.TabControl.AllTabs.First(t => t.TabContent is PrinterTabPage) is GuiWidget widget)
{
var closeWidget = widget.Descendants<ImageWidget>().First();
testRunner.ClickWidget(closeWidget);
}
}
private void CloseAllPrinterTabs(AutomationRunner testRunner)
{
// Close all printer tabs

View file

@ -691,6 +691,19 @@ namespace MatterHackers.MatterControl.Tests.Automation
return ApplicationController.Instance.ActivePrinters.First();
}
public static void CloseFirstPrinterTab(this AutomationRunner testRunner)
{
// Close all printer tabs
var mainViewWidget = testRunner.GetWidgetByName("PartPreviewContent", out _) as MainViewWidget;
if (mainViewWidget.TabControl.AllTabs.First(t => t.TabContent is PrinterTabPage) is GuiWidget widget)
{
var closeWidget = widget.Descendants<ImageWidget>().First();
Assert.AreEqual("Close Tab Button", closeWidget.Name, "Expected widget ('Close Tab Button') not found");
testRunner.ClickWidget(closeWidget);
}
}
public static void WaitForCommunicationStateDisconnected(this AutomationRunner testRunner, PrinterConfig printer, int maxSeconds = 500)
{
testRunner.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Disconnected, maxSeconds);