diff --git a/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj b/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj
index 51c48f526..17fbb3423 100644
--- a/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj
+++ b/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj
@@ -118,6 +118,10 @@
{195cbe56-e654-437b-ab05-3be1b9452497}
Agg.Tests
+
+ {D3E41B4E-BFBB-44CA-94C8-95C00F754FDD}
+ VectorMath
+
diff --git a/Tests/MatterControl.AutomationTests/PrintingTests.cs b/Tests/MatterControl.AutomationTests/PrintingTests.cs
index b3d67c213..5b85d3c26 100644
--- a/Tests/MatterControl.AutomationTests/PrintingTests.cs
+++ b/Tests/MatterControl.AutomationTests/PrintingTests.cs
@@ -1,16 +1,13 @@
using System;
-using System.Diagnostics;
-using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using MatterHackers.Agg.PlatformAbstract;
using MatterHackers.Agg.UI;
-using MatterHackers.Agg.UI.Tests;
using MatterHackers.GuiAutomation;
using MatterHackers.MatterControl.PrinterCommunication;
using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.PrinterEmulator;
+using MatterHackers.VectorMath;
using NUnit.Framework;
namespace MatterHackers.MatterControl.Tests.Automation
@@ -113,5 +110,112 @@ namespace MatterHackers.MatterControl.Tests.Automation
await MatterControlUtilities.RunTest(testToRun, maxTimeToRun: 300);
}
+
+ private EventHandler unregisterEvents;
+
+ [Test, Apartment(ApartmentState.STA)]
+ public async Task TuningAdjustmentsResetToOne()
+ {
+ AutomationTest testToRun = (testRunner) =>
+ {
+ SystemWindow systemWindow;
+
+ testRunner.WaitForName("Cancel Wizard Button", 1);
+
+ using (var emulatorDisposable = testRunner.LaunchAndConnectToPrinterEmulator())
+ {
+ SolidSlider slider;
+
+ Assert.IsTrue(ProfileManager.Instance.ActiveProfile != null);
+
+ testRunner.SwitchToSettingsAndControls();
+
+ testRunner.ClickByName("Controls Tab", 1);
+
+ testRunner.ClickByName("Start Print Button", 1);
+
+ var container = testRunner.GetWidgetByName("ManualPrinterControls.ControlsContainer", out systemWindow, 5);
+
+ // Scroll the widget into view
+ var scrollable = container.Parents().First().Parents().First();
+ var width = scrollable.Width;
+
+ double targetExtrusionRate = 1.5;
+ double targetFeedRate = 2;
+
+ // Workaround needed to scroll to the bottom of the Controls panel
+ //scrollable.ScrollPosition = new Vector2();
+ scrollable.ScrollPosition = new Vector2(0, 30);
+
+ // Workaround to force layout to fix problems with size of Tuning Widgets after setting ScrollPosition manually
+ scrollable.Width = width - 1;
+ scrollable.Width = width;
+
+ // Workaround for MatterHackers/MCCentral#1157 - wait for slicing to complete before setting tuning values
+ testRunner.Wait(5);
+
+ testRunner.ClickByName("Extrusion Multiplier NumberEdit");
+ testRunner.Wait(.2);
+ testRunner.Type(targetExtrusionRate.ToString());
+ testRunner.Wait(.2);
+
+ testRunner.ClickByName("Feed Rate NumberEdit");
+ testRunner.Wait(.2);
+ testRunner.Type(targetFeedRate.ToString());
+ testRunner.Wait(.2);
+
+ // Force focus away from the feed rate field
+ testRunner.ClickByName("Controls Tab", 1);
+
+ testRunner.Wait(.2);
+
+ // Assert the changes took effect on the UI
+ slider = testRunner.GetWidgetByName("Extrusion Multiplier Slider", out systemWindow, 5) as SolidSlider;
+ Assert.AreEqual(targetExtrusionRate, slider.Value);
+
+ slider = testRunner.GetWidgetByName("Feed Rate Slider", out systemWindow, 5) as SolidSlider;
+ Assert.AreEqual(targetFeedRate, slider.Value);
+
+ testRunner.Wait(.2);
+
+ // Assert the changes took effect on the model
+ Assert.AreEqual(targetExtrusionRate, PrinterConnectionAndCommunication.Instance.ExtrusionRatio);
+ Assert.AreEqual(targetFeedRate, PrinterConnectionAndCommunication.Instance.FeedRateRatio);
+
+ var resetEvent = new AutoResetEvent(false);
+
+ // Release reset event on PrintFinished
+ PrinterConnectionAndCommunication.Instance.PrintFinished.RegisterEvent((s, e) => resetEvent.Set(), ref unregisterEvents);
+
+ resetEvent.WaitOne();
+
+ // Finish the print
+ testRunner.WaitForName("Done Button", 30);
+ testRunner.WaitForName("Print Again Button", 1);
+
+ // Restart the print
+ testRunner.ClickByName("Print Again Button", 1);
+
+ testRunner.Wait(2);
+
+ testRunner.CancelPrint();
+
+ // Assert we've reset to 1
+ Assert.AreEqual(1, PrinterConnectionAndCommunication.Instance.FeedRateRatio);
+ Assert.AreEqual(1, PrinterConnectionAndCommunication.Instance.ExtrusionRatio);
+
+ // Assert the changes took effect on the UI
+ slider = testRunner.GetWidgetByName("Extrusion Multiplier Slider", out systemWindow, 5) as SolidSlider;
+ Assert.AreEqual(1, slider.Value);
+
+ slider = testRunner.GetWidgetByName("Feed Rate Slider", out systemWindow, 5) as SolidSlider;
+ Assert.AreEqual(1, slider.Value);
+ }
+
+ return Task.FromResult(0);
+ };
+
+ await MatterControlUtilities.RunTest(testToRun, overrideHeight:900, maxTimeToRun: 90);
+ }
}
}
diff --git a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs
index 208c70929..aff94ad76 100644
--- a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs
+++ b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs
@@ -207,6 +207,16 @@ namespace MatterHackers.MatterControl.Tests.Automation
return emulator;
}
+ public static void CancelPrint(this AutomationRunner testRunner)
+ {
+ testRunner.ClickByName("Cancel Print Button");
+
+ if (testRunner.WaitForName("Yes Button", 1))
+ {
+ testRunner.ClickByName("Yes Button");
+ }
+ }
+
public static bool CompareExpectedSliceSettingValueWithActualVaue(string sliceSetting, string expectedValue)
{
string fullPath = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "temp", runName, "Test0", "data", "gcode");
@@ -454,6 +464,15 @@ namespace MatterHackers.MatterControl.Tests.Automation
Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}
+ public static void SwitchToSettingsAndControls(this AutomationRunner testRunner)
+ {
+ if (testRunner.WaitForName("SettingsAndControls", .2))
+ {
+ testRunner.ClickByName("SettingsAndControls");
+ testRunner.Wait(.5);
+ }
+ }
+
public static void SwitchToAdvancedSettings(AutomationRunner testRunner)
{
if (testRunner.WaitForName("SettingsAndControls", .2))