From bdb1a2277bc59aa03143f755ea59be62df98a2da Mon Sep 17 00:00:00 2001 From: John Lewin Date: Wed, 20 Sep 2017 18:05:15 -0700 Subject: [PATCH] Fix DualExtrusionShowsCorrectHotEndData test --- ApplicationView/ApplicationController.cs | 18 ++++++---- SlicerConfiguration/PresetSelectorWidget.cs | 9 ++++- SlicerConfiguration/SliceSettingsWidget.cs | 2 -- .../SliceSettingsTests.cs | 34 ++++++++++--------- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index 94b3cf523..435d7a2fa 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -68,16 +68,16 @@ namespace MatterHackers.MatterControl public ThemeConfig Theme { get; set; } = new ThemeConfig(); // A list of printers which are open (i.e. displaying a tab) on this instance of MatterControl - public List ActivePrinters { get; } = new List(); + public IEnumerable ActivePrinters { get; } = new List(); - private PrinterConfig emptyPrinter = new PrinterConfig(false, PrinterSettings.Empty); + private static PrinterConfig emptyPrinter = new PrinterConfig(false, PrinterSettings.Empty); - // TODO: Any references to this property almost certainly need to be reconsidered. ActiveSliceSettings and PrinterConnection static references - // that assume a single printer selection are being redirected here. This allows us to break the dependency to the original statics and consolidates - // use down to a single point where code is making assumptions about the presence of a printer, printer counts, etc. If we previously checked for + // TODO: Any references to this property almost certainly need to be reconsidered. ActiveSliceSettings static references that assume a single printer + // selection are being redirected here. This allows us to break the dependency to the original statics and consolidates + // us down to a single point where code is making assumptions about the presence of a printer, printer counts, etc. If we previously checked for // PrinterConnection.IsPrinterConnected, that could should be updated to iterate ActiverPrinters, checking each one and acting on each as it would // have for the single case - public PrinterConfig ActivePrinter => ActivePrinters.FirstOrDefault() ?? emptyPrinter; + public PrinterConfig ActivePrinter { get; private set; } = emptyPrinter; public Action RedeemDesignCode; public Action EnterShareCode; @@ -111,6 +111,12 @@ namespace MatterHackers.MatterControl private Queue> queuedThumbCallbacks = new Queue>(); + public void SetActivePrinter(PrinterConfig printer) + { + (this.ActivePrinters as List).Add(printer); + this.ActivePrinter = printer; + } + private AutoResetEvent thumbGenResetEvent = new AutoResetEvent(false); Task thumbnailGenerator = null; diff --git a/SlicerConfiguration/PresetSelectorWidget.cs b/SlicerConfiguration/PresetSelectorWidget.cs index 751793b61..0a4989e4e 100644 --- a/SlicerConfiguration/PresetSelectorWidget.cs +++ b/SlicerConfiguration/PresetSelectorWidget.cs @@ -93,7 +93,14 @@ namespace MatterHackers.MatterControl.SlicerConfiguration Margin = new BorderDouble(12, 3, 0, 6) }); - this.AddChild(GetPulldownContainer()); + pullDownContainer = new GuiWidget() + { + HAnchor = HAnchor.Stretch, + VAnchor = VAnchor.Fit + }; + pullDownContainer.AddChild(GetPulldownContainer()); + this.AddChild(pullDownContainer); + this.AddChild(new VerticalSpacer()); this.AddChild(accentBar); } diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index 9b3c43419..a6ccae711 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -34,8 +34,6 @@ using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; -using MatterHackers.MatterControl.PrinterCommunication; -using MatterHackers.SerialPortCommunication.FrostedSerial; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.SlicerConfiguration diff --git a/Tests/MatterControl.AutomationTests/SliceSettingsTests.cs b/Tests/MatterControl.AutomationTests/SliceSettingsTests.cs index 1fe301908..23f72f2a7 100644 --- a/Tests/MatterControl.AutomationTests/SliceSettingsTests.cs +++ b/Tests/MatterControl.AutomationTests/SliceSettingsTests.cs @@ -176,8 +176,6 @@ namespace MatterHackers.MatterControl.Tests.Automation { await MatterControlUtilities.RunTest((testRunner) => { - testRunner.CloseSignInAndPrinterSelect(); - using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator()) { // Navigate to Local Library @@ -194,15 +192,16 @@ namespace MatterHackers.MatterControl.Tests.Automation // assert the temp is set when we first open (it comes from the material) EditableNumberDisplay tempWidget = testRunner.GetWidgetByName("Temperature Input", out _) as EditableNumberDisplay; - Assert.AreEqual(240, tempWidget.Value); + Assert.AreEqual(240, (int)tempWidget.Value); // change material var dropDownLists = testRunner.GetWidgetsByName("Material DropDown List"); Assert.AreEqual(2, dropDownLists.Count, "There are two. The slice settings and the pop out."); DropDownList materialSelector = dropDownLists[0].widget as DropDownList; Assert.AreEqual("", materialSelector.SelectedValue); + // BUG: the offest should not be required - testRunner.ClickByName("Material DropDown List", offset: new Point2D(-20, -25)); + testRunner.ClickByName("Material DropDown List", offset: new Point2D(-30, -25)); testRunner.ClickByName("HIPS Menu"); // check the extruder count @@ -210,24 +209,25 @@ namespace MatterHackers.MatterControl.Tests.Automation Assert.AreEqual(1, extrudeButtons.Count, "There should be just one."); int hipsGoalTemp = 220; + // assert the temp changed to a new temp - Assert.AreEqual(hipsGoalTemp, tempWidget.Value, "The temp should have changed to ABS"); + Assert.AreEqual(hipsGoalTemp,(int) tempWidget.Value, "The goal temp should match the material temp"); // and the printer heat is off - Assert.AreEqual(0, emulator.ExtruderGoalTemperature); + Assert.AreEqual(0, (int) emulator.ExtruderGoalTemperature, "The printer should report the heaters are off"); // turn on the heater testRunner.ClickByName("Toggle Heater"); - testRunner.Delay(); + testRunner.Delay(2); // assert the printer is heating - Assert.AreEqual(hipsGoalTemp, emulator.ExtruderGoalTemperature); + Assert.AreEqual(hipsGoalTemp, (int)emulator.ExtruderGoalTemperature, "The printer should report the expected goal temp"); // turn off the heater testRunner.ClickByName("Toggle Heater"); - testRunner.Delay(); + testRunner.Delay(2); // assert the printer is off - Assert.AreEqual(0, emulator.ExtruderGoalTemperature); + Assert.AreEqual(0, (int)emulator.ExtruderGoalTemperature, "The printer should report the heaters are off"); // type in a temp when the heating is off testRunner.ClickByName("Temperature Input"); @@ -236,7 +236,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.Delay(); // assert the printer is off - Assert.AreEqual(0, emulator.ExtruderGoalTemperature); + Assert.AreEqual(0, (int)emulator.ExtruderGoalTemperature); // and the heat toggle is showing on CheckBox heatToggle = testRunner.GetWidgetByName("Toggle Heater", out _) as CheckBox; @@ -244,14 +244,14 @@ namespace MatterHackers.MatterControl.Tests.Automation // turn it on testRunner.ClickByName("Toggle Heater"); - Assert.AreEqual(110, emulator.ExtruderGoalTemperature); + Assert.AreEqual(110, (int)emulator.ExtruderGoalTemperature); // adjust when on testRunner.ClickByName("Temperature Input"); testRunner.Type("104"); testRunner.Type("{Enter}"); testRunner.Delay(); - Assert.AreEqual(104, emulator.ExtruderGoalTemperature); + Assert.AreEqual(104, (int)emulator.ExtruderGoalTemperature); // type in 0 and have the heater turn off testRunner.ClickByName("Temperature Input"); @@ -260,11 +260,13 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.Delay(); // assert the printer is not heating - Assert.AreEqual(0, emulator.ExtruderGoalTemperature); + Assert.AreEqual(0, (int)emulator.ExtruderGoalTemperature); // and the on toggle is showing off Assert.IsFalse(heatToggle.Checked); - testRunner.ClickByName(SliceSettingsOrganizer.Instance.GetSettingsData(SettingsKey.extruder_count).PresentationName + " Edit"); + testRunner.ClickByName("Extruder Tab"); + + testRunner.ClickByName(SliceSettingsOrganizer.Instance.GetSettingsData(SettingsKey.extruder_count).PresentationName + " Field"); testRunner.Type("2"); testRunner.Type("{Enter}"); @@ -285,7 +287,7 @@ namespace MatterHackers.MatterControl.Tests.Automation } return Task.CompletedTask; - }, maxTimeToRun: 200, overrideWidth: 1224, overrideHeight: 900); + }, maxTimeToRun: 666, overrideWidth: 1224, overrideHeight: 900); } [Test /* Test will fail if screen size is and "HeatBeforeHoming" falls below the fold */]