2018-10-03 12:32:26 -07:00
using System.Threading ;
2016-10-25 06:17:37 -07:00
using System.Threading.Tasks ;
2016-02-01 17:20:18 -08:00
using NUnit.Framework ;
2022-07-15 17:28:39 -07:00
using TestInvoker ;
2016-02-01 17:20:18 -08:00
2016-05-11 09:13:56 -07:00
namespace MatterHackers.MatterControl.Tests.Automation
2016-02-01 17:20:18 -08:00
{
2022-07-15 17:28:39 -07:00
[TestFixture, Category("MatterControl.UI.Automation"), Parallelizable(ParallelScope.Children)]
2016-02-01 17:20:18 -08:00
public class HardwareLevelingUITests
{
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2016-10-25 06:17:37 -07:00
public async Task HasHardwareLevelingHidesLevelingSettings ( )
2016-02-01 17:20:18 -08:00
{
2017-06-03 08:20:09 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2016-02-01 17:20:18 -08:00
{
2018-02-08 15:42:07 -08:00
testRunner . WaitForFirstDraw ( ) ;
2017-06-03 08:20:09 -07:00
// Add printer that has hardware leveling
2017-06-04 09:01:56 -07:00
testRunner . AddAndSelectPrinter ( "Airwolf 3D" , "HD" ) ;
2016-02-01 17:20:18 -08:00
2017-12-28 09:02:44 -08:00
testRunner . SwitchToPrinterSettings ( ) ;
2022-04-20 21:18:58 +01:00
testRunner . ClickByName ( "Features SliceSettingsTab" ) ;
2018-04-05 16:16:43 -07:00
testRunner . ClickByName ( "Slice Settings Overflow Menu" ) ;
2020-12-31 13:08:37 -08:00
testRunner . ClickByName ( "Advanced Menu Item" ) ;
2017-12-28 09:02:44 -08:00
Assert . IsFalse ( testRunner . WaitForName ( "print_leveling_solution Row" , . 5 ) , "Print leveling should not exist for an Airwolf HD" ) ;
2016-02-01 17:20:18 -08:00
2017-06-03 08:20:09 -07:00
// Add printer that does not have hardware leveling
2017-06-04 09:01:56 -07:00
testRunner . AddAndSelectPrinter ( "3D Factory" , "MendelMax 1.5" ) ;
2016-09-20 14:32:22 -07:00
2017-12-28 09:02:44 -08:00
testRunner . SwitchToPrinterSettings ( ) ;
2022-04-20 21:18:58 +01:00
testRunner . ClickByName ( "Features SliceSettingsTab" ) ;
2018-04-05 16:16:43 -07:00
testRunner . ClickByName ( "Slice Settings Overflow Menu" ) ;
2020-12-31 13:08:37 -08:00
testRunner . ClickByName ( "Advanced Menu Item" ) ;
2017-12-28 09:02:44 -08:00
Assert . IsTrue ( testRunner . WaitForName ( "print_leveling_solution Row" ) , "Print leveling should exist for a 3D Factory MendelMax" ) ;
2016-10-25 06:17:37 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-06-03 08:20:09 -07:00
} , overrideHeight : 800 ) ;
2016-02-01 17:20:18 -08:00
}
2016-09-26 15:59:29 -07:00
2022-07-15 17:28:39 -07:00
// NOTE: This test once failed, due to timing probably.
[Test, ChildProcessTest, Category("Emulator")]
2019-04-30 16:44:08 -07:00
public async Task SoftwareLevelingTest ( )
2016-09-26 15:59:29 -07:00
{
2017-06-03 08:20:09 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2016-09-26 15:59:29 -07:00
{
2016-10-19 11:10:30 -07:00
// make a jump start printer
2017-06-02 19:57:15 -07:00
using ( var emulator = testRunner . LaunchAndConnectToPrinterEmulator ( "JumpStart" , "V1" , runSlow : false ) )
2016-10-19 11:10:30 -07:00
{
2017-01-10 13:43:12 -08:00
// make sure it is showing the correct button
2019-04-30 16:00:23 -07:00
testRunner . OpenPrintPopupMenu ( ) ;
2017-01-10 13:43:12 -08:00
2019-04-15 21:05:19 -07:00
var startPrintButton = testRunner . GetWidgetByName ( "Start Print Button" , out _ ) ;
Assert . IsFalse ( startPrintButton . Enabled , "Start Print should not be enabled" ) ;
2019-01-23 23:02:46 -08:00
testRunner . ClickByName ( "SetupPrinter" ) ;
2018-11-22 11:11:59 -08:00
2018-10-03 12:28:23 -07:00
testRunner . Complete9StepLeveling ( ) ;
2017-01-10 13:43:12 -08:00
2019-04-30 16:44:33 -07:00
// Satisfy non-empty bed requirement
2021-06-06 22:18:29 -07:00
testRunner . AddItemToBed ( ) ;
2019-04-30 16:44:33 -07:00
2019-04-30 16:00:23 -07:00
testRunner . OpenPrintPopupMenu ( ) ;
2019-04-15 21:05:19 -07:00
2017-01-10 13:43:12 -08:00
// make sure the button has changed to start print
2019-04-15 21:05:19 -07:00
startPrintButton = testRunner . GetWidgetByName ( "Start Print Button" , out _ ) ;
Assert . IsTrue ( startPrintButton . Enabled , "Start Print should be enabled after running printer setup" ) ;
2019-01-23 23:02:46 -08:00
Assert . IsFalse ( testRunner . WaitForName ( "SetupPrinter" , . 5 ) , "Finish Setup should not be visible after leveling the printer" ) ;
2017-01-10 13:43:12 -08:00
// reset to defaults and make sure print leveling is cleared
2017-12-14 16:19:22 -08:00
testRunner . SwitchToSliceSettings ( ) ;
2017-01-10 13:43:12 -08:00
2019-04-30 16:45:29 -07:00
testRunner . WaitForReloadAll ( ( ) = >
{
testRunner . ClickByName ( "Printer Overflow Menu" ) ;
2020-08-29 23:05:40 -07:00
testRunner . ClickByName ( "Reset to Defaults... Menu Item" ) ;
2019-04-30 16:45:29 -07:00
testRunner . ClickByName ( "Yes Button" ) ;
} ) ;
2017-01-10 13:43:12 -08:00
2019-04-30 16:00:23 -07:00
testRunner . OpenPrintPopupMenu ( ) ;
2018-12-06 11:59:37 -08:00
2017-01-10 13:43:12 -08:00
// make sure it is showing the correct button
2019-04-30 16:44:53 -07:00
Assert . IsTrue ( testRunner . WaitForName ( "SetupPrinter" ) , "Setup... should be visible after reset to Defaults" ) ;
2017-01-10 12:24:01 -08:00
}
2016-09-26 15:59:29 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2022-07-15 17:28:39 -07:00
} , maxTimeToRun : 90 ) ; // NOTE: This test got stuck in ClickByName("Yes Button") -> WaitforDraw. It appears to be because WaitforDraw waited for a closed window to redraw itself.
2016-09-26 15:59:29 -07:00
}
2016-02-01 17:20:18 -08:00
}
}