Ensure spawned emulator process is always killed via using/Dispose
- LaunchAndConnectToPrinterEmulator -> TestRunner extension method
This commit is contained in:
parent
3c1066b0aa
commit
b54b73db7f
4 changed files with 72 additions and 83 deletions
|
|
@ -49,59 +49,52 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
[Test, Apartment(ApartmentState.STA)]
|
||||
public async Task SoftwareLevelingRequiredCorrectWorkflow()
|
||||
{
|
||||
Process emulatorProcess = null;
|
||||
|
||||
AutomationTest testToRun = (testRunner) =>
|
||||
{
|
||||
MatterControlUtilities.PrepForTestRun(testRunner);
|
||||
|
||||
// make a jump start printer
|
||||
emulatorProcess = MatterControlUtilities.LaunchAndConnectToPrinterEmulator(testRunner, false, "JumStart", "V1");
|
||||
|
||||
// make sure it is showing the correct button
|
||||
Assert.IsTrue(!testRunner.WaitForName("Start Print Button", .5), "Start Print hidden");
|
||||
Assert.IsTrue(testRunner.WaitForName("Finish Setup Button", .5), "Finish Setup showing");
|
||||
|
||||
// do print leveling
|
||||
testRunner.ClickByName("Next Button", .5);
|
||||
testRunner.ClickByName("Next Button", .5);
|
||||
testRunner.ClickByName("Next Button", .5);
|
||||
for (int i = 0; i < 3; i++)
|
||||
using (var emulatorProcess = testRunner.LaunchAndConnectToPrinterEmulator("JumpStart", "V1", runSlow: false))
|
||||
{
|
||||
testRunner.ClickByName("Move Z positive", .5);
|
||||
// make sure it is showing the correct button
|
||||
Assert.IsTrue(!testRunner.WaitForName("Start Print Button", .5), "Start Print hidden");
|
||||
Assert.IsTrue(testRunner.WaitForName("Finish Setup Button", .5), "Finish Setup showing");
|
||||
|
||||
// do print leveling
|
||||
testRunner.ClickByName("Next Button", .5);
|
||||
testRunner.ClickByName("Next Button", .5);
|
||||
testRunner.ClickByName("Next Button", .5);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
testRunner.ClickByName("Move Z positive", .5);
|
||||
testRunner.ClickByName("Next Button", .5);
|
||||
testRunner.ClickByName("Next Button", .5);
|
||||
testRunner.ClickByName("Next Button", .5);
|
||||
}
|
||||
|
||||
Assert.IsTrue(testRunner.ClickByName("Done Button", 1), "Found Done button");
|
||||
|
||||
// make sure the button has changed to start print
|
||||
Assert.IsTrue(testRunner.WaitForName("Start Print Button", 5), "Start Print showing");
|
||||
Assert.IsTrue(!testRunner.WaitForName("Finish Setup Button", 1), "Finish Setup hidden");
|
||||
|
||||
// reset to defaults and make sure print leveling is cleared
|
||||
MatterControlUtilities.SwitchToAdvancedSettings(testRunner);
|
||||
|
||||
Assert.IsTrue(testRunner.ClickByName("Slice Settings Options Menu", 1), "Click Options");
|
||||
Assert.IsTrue(testRunner.ClickByName("Reset to defaults Menu Item", 1), "Select Reset to defaults");
|
||||
Assert.IsTrue(testRunner.ClickByName("Yes Button", .5), "Click yes to revert");
|
||||
testRunner.Wait(1);
|
||||
|
||||
// make sure it is showing the correct button
|
||||
Assert.IsTrue(!testRunner.WaitForName("Start Print Button", 1), "Start Print hidden");
|
||||
Assert.IsTrue(testRunner.WaitForName("Finish Setup Button", 1), "Finish Setup showing");
|
||||
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
Assert.IsTrue(testRunner.ClickByName("Done Button", .5), "Found Done button");
|
||||
|
||||
// make sure the button has changed to start print
|
||||
Assert.IsTrue(testRunner.WaitForName("Start Print Button", .5), "Start Print showing");
|
||||
Assert.IsTrue(!testRunner.WaitForName("Finish Setup Button", .5), "Finish Setup hidden");
|
||||
|
||||
// reset to defaults and make sure print leveling is cleared
|
||||
MatterControlUtilities.SwitchToAdvancedSettings(testRunner);
|
||||
|
||||
Assert.IsTrue(testRunner.ClickByName("Slice Settings Options Menu", 1), "Click Options");
|
||||
Assert.IsTrue(testRunner.ClickByName("Reset to defaults Menu Item", 1), "Select Reset to defaults");
|
||||
Assert.IsTrue(testRunner.ClickByName("Yes Button", .5), "Click yes to revert");
|
||||
testRunner.Wait(1);
|
||||
|
||||
// make sure it is showing the correct button
|
||||
Assert.IsTrue(!testRunner.WaitForName("Start Print Button", .5), "Start Print hidden");
|
||||
Assert.IsTrue(testRunner.WaitForName("Finish Setup Button", .5), "Finish Setup showing");
|
||||
|
||||
return Task.FromResult(0);
|
||||
};
|
||||
|
||||
await MatterControlUtilities.RunTest(testToRun);
|
||||
|
||||
try
|
||||
{
|
||||
emulatorProcess?.Kill();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,11 +21,13 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
MatterControlUtilities.PrepForTestRun(testRunner);
|
||||
|
||||
SystemWindow systemWindow;
|
||||
string copyButtonName = "3D View Copy";
|
||||
|
||||
//Navigate to Local Library
|
||||
testRunner.ClickByName("Library Tab");
|
||||
testRunner.NavigateToFolder("Local Library Row Item Collection");
|
||||
testRunner.Wait(1);
|
||||
|
||||
testRunner.ClickByName("Row Item Calibration - Box");
|
||||
testRunner.ClickByName("Row Item Calibration - Box View Button");
|
||||
testRunner.Wait(1);
|
||||
|
|
@ -34,33 +36,25 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
GuiWidget partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3);
|
||||
View3DWidget view3D = partPreview as View3DWidget;
|
||||
|
||||
string copyButtonName = "3D View Copy";
|
||||
|
||||
//Click Edit button to make edit controls visible
|
||||
testRunner.ClickByName("3D View Edit");
|
||||
testRunner.Wait(1);
|
||||
int partCountBeforeCopy = view3D.MeshGroups.Count();
|
||||
Assert.IsTrue(partCountBeforeCopy == 1);
|
||||
Assert.AreEqual(view3D.MeshGroups.Count(), 1, "Should have 1 part before copy");
|
||||
|
||||
//Click Copy button and count MeshGroups
|
||||
testRunner.ClickByName(copyButtonName);
|
||||
System.Threading.Thread.Sleep(500);
|
||||
int partCountAfterCopy = view3D.MeshGroups.Count();
|
||||
Assert.IsTrue(partCountAfterCopy == 2);
|
||||
testRunner.Wait(1);
|
||||
testRunner.Wait(.5);
|
||||
Assert.AreEqual(view3D.MeshGroups.Count(), 2, "Should have 2 parts after copy");
|
||||
|
||||
//Click Copy button a second time and count MeshGroups again
|
||||
testRunner.ClickByName(copyButtonName);
|
||||
System.Threading.Thread.Sleep(500);
|
||||
int partCountAfterSecondCopy = view3D.MeshGroups.Count();
|
||||
Assert.IsTrue(partCountAfterSecondCopy == 3);
|
||||
view3D.CloseOnIdle();
|
||||
testRunner.Wait(.5);
|
||||
Assert.AreEqual(view3D.MeshGroups.Count(), 3, "Should have 3 parts after 2nd copy");
|
||||
|
||||
return Task.FromResult(0);
|
||||
};
|
||||
|
||||
await MatterControlUtilities.RunTest(testToRun);
|
||||
await MatterControlUtilities.RunTest(testToRun, overrideWidth: 800);
|
||||
}
|
||||
|
||||
[Test, Apartment(ApartmentState.STA)]
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
//Navigate to Local Library
|
||||
testRunner.ClickByName("Library Tab");
|
||||
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
|
||||
testRunner.NavigateToFolder("Local Library Row Item Collection");
|
||||
testRunner.Wait(1);
|
||||
testRunner.ClickByName("Row Item Calibration - Box");
|
||||
testRunner.ClickByName("Row Item Calibration - Box Print Button");
|
||||
|
|
@ -58,48 +58,41 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
[Test, Apartment(ApartmentState.STA)]
|
||||
public async Task PauseOnLayerDoesPauseOnPrint()
|
||||
{
|
||||
Process emulatorProcess = null;
|
||||
|
||||
AutomationTest testToRun = (testRunner) =>
|
||||
{
|
||||
MatterControlUtilities.PrepForTestRun(testRunner, MatterControlUtilities.PrepAction.CloseSignInAndPrinterSelect);
|
||||
|
||||
emulatorProcess = MatterControlUtilities.LaunchAndConnectToPrinterEmulator(testRunner);
|
||||
using (var emulatorProcess = testRunner.LaunchAndConnectToPrinterEmulator())
|
||||
{
|
||||
Assert.IsTrue(ProfileManager.Instance.ActiveProfile != null);
|
||||
|
||||
Assert.IsTrue(ProfileManager.Instance.ActiveProfile != null);
|
||||
MatterControlUtilities.SwitchToAdvancedSettings(testRunner);
|
||||
|
||||
MatterControlUtilities.SwitchToAdvancedSettings(testRunner);
|
||||
Assert.IsTrue(testRunner.ClickByName("General Tab", 1));
|
||||
Assert.IsTrue(testRunner.ClickByName("Single Print Tab", 1));
|
||||
Assert.IsTrue(testRunner.ClickByName("Layer(s) To Pause:" + " Edit"));
|
||||
testRunner.Type("4;2;a;not;6");
|
||||
|
||||
Assert.IsTrue(testRunner.ClickByName("General Tab", 1));
|
||||
Assert.IsTrue(testRunner.ClickByName("Single Print Tab", 1));
|
||||
Assert.IsTrue(testRunner.ClickByName("Layer(s) To Pause:" + " Edit"));
|
||||
testRunner.Type("4;2;a;not;6");
|
||||
Assert.IsTrue(testRunner.ClickByName("Layer View Tab"));
|
||||
|
||||
Assert.IsTrue(testRunner.ClickByName("Layer View Tab"));
|
||||
Assert.IsTrue(testRunner.ClickByName("Generate Gcode Button", 1));
|
||||
Assert.IsTrue(testRunner.ClickByName("Display Checkbox", 10));
|
||||
Assert.IsTrue(testRunner.ClickByName("Sync To Print Checkbox", 1));
|
||||
|
||||
Assert.IsTrue(testRunner.ClickByName("Generate Gcode Button", 1));
|
||||
Assert.IsTrue(testRunner.ClickByName("Display Checkbox", 10));
|
||||
Assert.IsTrue(testRunner.ClickByName("Sync To Print Checkbox", 1));
|
||||
Assert.IsTrue(testRunner.ClickByName("Start Print Button", 1));
|
||||
|
||||
Assert.IsTrue(testRunner.ClickByName("Start Print Button", 1));
|
||||
WaitForLayerAndResume(testRunner, 2);
|
||||
WaitForLayerAndResume(testRunner, 4);
|
||||
WaitForLayerAndResume(testRunner, 6);
|
||||
|
||||
WaitForLayerAndResume(testRunner, 2);
|
||||
WaitForLayerAndResume(testRunner, 4);
|
||||
WaitForLayerAndResume(testRunner, 6);
|
||||
Assert.IsTrue(testRunner.WaitForName("Done Button", 30));
|
||||
Assert.IsTrue(testRunner.WaitForName("Print Again Button", 1));
|
||||
|
||||
Assert.IsTrue(testRunner.WaitForName("Done Button", 30));
|
||||
Assert.IsTrue(testRunner.WaitForName("Print Again Button", 1));
|
||||
|
||||
return Task.FromResult(0);
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
};
|
||||
|
||||
await MatterControlUtilities.RunTest(testToRun, maxTimeToRun: 90);
|
||||
|
||||
try
|
||||
{
|
||||
emulatorProcess?.Kill();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private static void WaitForLayerAndResume(AutomationRunner testRunner, int indexToWaitFor)
|
||||
|
|
|
|||
|
|
@ -130,7 +130,16 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
}
|
||||
}
|
||||
|
||||
public static Process LaunchAndConnectToPrinterEmulator(AutomationRunner testRunner, bool runSlow = false, string make = "Airwolf 3D", string model = "HD")
|
||||
public class PrintEmulatorProcess: Process
|
||||
{
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
this.Kill();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
public static Process LaunchAndConnectToPrinterEmulator(this AutomationRunner testRunner, string make = "Airwolf 3D", string model = "HD", bool runSlow = false)
|
||||
{
|
||||
// Load the TestEnv config
|
||||
var config = TestAutomationConfig.Load();
|
||||
|
|
@ -138,7 +147,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
// Create the printer
|
||||
MatterControlUtilities.AddAndSelectPrinter(testRunner, make, model);
|
||||
|
||||
var process = new Process();
|
||||
var process = new PrintEmulatorProcess();
|
||||
process.StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
FileName = "python",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue