2021-02-18 10:40:44 -08:00
using System ;
using System.Linq ;
2016-09-21 15:34:53 -07:00
using System.Threading ;
2016-10-25 06:17:37 -07:00
using System.Threading.Tasks ;
2017-06-16 18:04:47 -07:00
using MatterHackers.Agg ;
2018-01-13 18:10:28 -08:00
using MatterHackers.Agg.Platform ;
2016-09-20 14:32:22 -07:00
using MatterHackers.Agg.UI ;
2016-05-11 09:13:56 -07:00
using MatterHackers.GuiAutomation ;
2018-11-21 18:05:59 -08:00
using MatterHackers.MatterControl.PartPreviewWindow ;
2016-08-24 15:53:46 -07:00
using MatterHackers.MatterControl.SlicerConfiguration ;
2016-03-03 16:57:43 -08:00
using NUnit.Framework ;
2022-07-15 17:28:39 -07:00
using TestInvoker ;
2016-03-03 16:57:43 -08:00
2016-05-11 09:13:56 -07:00
namespace MatterHackers.MatterControl.Tests.Automation
2016-03-03 16:57:43 -08:00
{
2022-07-15 17:28:39 -07:00
[TestFixture, Category("MatterControl.UI.Automation"), Parallelizable(ParallelScope.Children)]
2016-03-03 16:57:43 -08:00
public class SliceSetingsTests
{
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2016-10-25 06:17:37 -07:00
public async Task RaftEnabledPassedToSliceEngine ( )
2016-03-03 16:57:43 -08:00
{
2017-06-04 08:17:05 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2016-03-03 16:57:43 -08:00
{
2021-02-18 10:40:44 -08:00
testRunner . WaitForFirstDraw ( )
. AddAndSelectPrinter ( )
. AddTestAssetsToLibrary ( new [ ] { "Rook.amf" } )
2021-06-06 22:18:29 -07:00
. AddItemToBed ( "" , "Row Item Rook" )
2021-02-18 10:40:44 -08:00
. SwitchToSliceSettings ( )
. SelectSliceSettingsField ( SettingsKey . create_raft )
. WaitForReloadAll ( ( ) = > testRunner . StartSlicing ( ) )
. WaitFor ( ( ) = > MatterControlUtilities . CompareExpectedSliceSettingValueWithActualVaue ( "enableRaft" , "True" ) , 10 ) ;
2016-03-03 16:57:43 -08:00
2021-02-18 10:40:44 -08:00
// Call compare slice settings method here
Assert . IsTrue ( MatterControlUtilities . CompareExpectedSliceSettingValueWithActualVaue ( "enableRaft" , "True" ) ) ;
2016-11-04 10:23:29 -07:00
2021-02-18 10:40:44 -08:00
return Task . CompletedTask ;
} , overrideWidth : 1224 , overrideHeight : 800 ) ;
}
2016-09-20 14:32:22 -07:00
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2021-02-18 10:40:44 -08:00
public async Task RelativeRetractionExecutesCorrectly ( )
{
2022-07-15 17:28:39 -07:00
// NOTE: This test once timed out at 120, but took 38.4s when run on its own.
2021-02-18 10:40:44 -08:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
{
testRunner . WaitForName ( "Cancel Wizard Button" ) ;
2016-11-04 10:23:29 -07:00
2021-02-18 10:40:44 -08:00
using ( var emulator = testRunner . LaunchAndConnectToPrinterEmulator ( "Other" , "Other" ) )
{
var printer = testRunner . FirstPrinter ( ) ;
2020-03-25 15:29:10 -07:00
2021-02-18 10:40:44 -08:00
var farthestE = 0.0 ;
printer . Connection . LineReceived + = ( e , line ) = >
{
// make sure the extrusion never goes back very far
Assert . Greater ( printer . Connection . CurrentExtruderDestination , farthestE - 10 ) ;
farthestE = Math . Max ( farthestE , printer . Connection . CurrentExtruderDestination ) ;
} ;
2016-03-03 16:57:43 -08:00
2021-06-06 22:18:29 -07:00
testRunner . AddItemToBed ( )
2021-03-07 09:13:49 -08:00
. StartPrint ( printer )
. WaitFor ( ( ) = > printer . Connection . Printing , 60 ) // wait for the print to start
. WaitFor ( ( ) = > ! printer . Connection . Printing , 60 ) ; // wait for the print to finish
2021-02-18 10:40:44 -08:00
}
2016-10-25 06:17:37 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2021-02-18 10:40:44 -08:00
} , maxTimeToRun : 120 ) ;
2016-03-03 16:57:43 -08:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest, Category("Emulator")]
2019-04-30 11:40:56 -07:00
public async Task PauseOnLayerTest ( )
2016-09-19 14:46:47 -07:00
{
2017-06-03 19:08:14 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2016-09-19 14:46:47 -07:00
{
2017-06-14 10:05:39 -07:00
testRunner . WaitForName ( "Cancel Wizard Button" ) ;
2016-09-19 14:46:47 -07:00
2017-06-02 19:57:15 -07:00
using ( var emulator = testRunner . LaunchAndConnectToPrinterEmulator ( ) )
2017-01-10 13:43:12 -08:00
{
2018-11-30 13:04:25 -08:00
var printer = testRunner . FirstPrinter ( ) ;
2018-11-30 12:53:43 -08:00
2021-06-06 22:18:29 -07:00
testRunner . AddItemToBed ( )
2021-02-18 10:40:44 -08:00
. StartPrint ( printer , pauseAtLayers : "4;2;a;not;6" )
. WaitForLayerAndResume ( printer , 2 )
. WaitForLayerAndResume ( printer , 4 )
. WaitForLayerAndResume ( printer , 6 )
. WaitForPrintFinished ( printer ) ;
2017-01-10 13:43:12 -08:00
}
2016-10-25 06:17:37 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-06-03 19:08:14 -07:00
} , maxTimeToRun : 120 ) ;
2016-09-20 14:32:22 -07:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest, Category("Emulator")]
2020-08-27 07:47:37 -07:00
public async Task OemSettingsChangeOfferedToUserTest ( )
{
2020-08-29 10:56:16 -07:00
await MatterControlUtilities . RunTest ( async ( testRunner ) = >
2020-08-27 07:47:37 -07:00
{
using ( var emulator = testRunner . LaunchAndConnectToPrinterEmulator ( ) )
{
var printer = testRunner . FirstPrinter ( ) ;
2020-08-28 13:51:20 -07:00
var expectedWarningName = ValidationErrors . SettingsUpdateAvailable + " Row" ;
2020-08-27 09:03:35 -07:00
2020-08-29 09:00:09 -07:00
// open the print menu and prove no oem message
testRunner . OpenPrintPopupMenu ( ) ;
2020-08-28 13:51:20 -07:00
Assert . IsFalse ( testRunner . NameExists ( expectedWarningName , 1 ) ) ;
2020-08-27 07:47:37 -07:00
// close the menu
2020-08-29 09:00:09 -07:00
testRunner . ClickByName ( "PartPreviewContent" )
2021-02-18 10:40:44 -08:00
. WaitFor ( ( ) = > ! testRunner . NamedWidgetExists ( "Start Print Button" ) )
// test again in case we have not downloaded the profile the first time
. OpenPrintPopupMenu ( ) ;
2020-08-29 09:00:09 -07:00
Assert . IsFalse ( testRunner . NameExists ( expectedWarningName , 1 ) ) ;
// close the menu
testRunner . ClickByName ( "PartPreviewContent" )
. WaitFor ( ( ) = > ! testRunner . NamedWidgetExists ( "Start Print Button" ) ) ;
2020-08-27 07:47:37 -07:00
2020-08-29 10:56:16 -07:00
Assert . AreEqual ( 0 , ( await ProfileManager . GetChangedOemSettings ( printer ) ) . Count ( ) ) ;
2020-08-27 07:47:37 -07:00
// change some oem settings
printer . Settings . SetValue ( SettingsKey . layer_height , ".213" , printer . Settings . OemLayer ) ;
2020-08-29 10:56:16 -07:00
printer . Settings . SetValue ( SettingsKey . first_layer_height , ".213" , printer . Settings . OemLayer ) ;
Assert . AreEqual ( 2 , ( await ProfileManager . GetChangedOemSettings ( printer ) ) . Count ( ) ) ;
2020-08-27 07:47:37 -07:00
// open menu again and check that warning is now visible
2020-08-29 09:00:09 -07:00
testRunner . OpenPrintPopupMenu ( )
2021-02-18 10:40:44 -08:00
. ClickByName ( ValidationErrors . SettingsUpdateAvailable + " Button" )
. ClickByName ( SettingsKey . layer_height + " Update" ) ;
2020-08-29 10:56:16 -07:00
Assert . AreEqual ( 1 , ( await ProfileManager . GetChangedOemSettings ( printer ) ) . Count ( ) ) ;
testRunner . ClickByName ( "Cancel Wizard Button" ) ;
testRunner . OpenPrintPopupMenu ( ) ;
Assert . IsTrue ( testRunner . NameExists ( expectedWarningName , 1 ) ) ;
// close the menu
testRunner . ClickByName ( "PartPreviewContent" )
2021-02-18 10:40:44 -08:00
. WaitFor ( ( ) = > ! testRunner . NamedWidgetExists ( "Start Print Button" ) )
// open the menu button
. ClickByName ( "Printer Overflow Menu" )
. ClickByName ( "Update Settings... Menu Item" )
. ClickByName ( SettingsKey . first_layer_height + " Update" ) ;
2020-08-29 10:56:16 -07:00
// accept the last option
Assert . AreEqual ( 0 , ( await ProfileManager . GetChangedOemSettings ( printer ) ) . Count ( ) ) ;
}
2020-08-27 07:47:37 -07:00
} , maxTimeToRun : 120 ) ;
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest, Category("Emulator")]
2021-01-30 08:49:06 -08:00
public async Task MenuStaysOpenOnRebuildSettings ( )
{
2021-02-21 21:29:55 -08:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2021-01-30 08:49:06 -08:00
{
using ( var emulator = testRunner . LaunchAndConnectToPrinterEmulator ( ) )
{
var printer = testRunner . FirstPrinter ( ) ;
// open the print menu and prove no oem message
testRunner . OpenPrintPopupMenu ( ) ;
var supportWidegtName = SettingsKey . create_per_layer_support . SettingWidgetName ( ) ;
Assert . IsTrue ( testRunner . NameExists ( supportWidegtName , 1 ) , "support option is visible" ) ;
// toggle supports
var supportButton = testRunner . GetWidgetByName ( supportWidegtName , out _ ) as ICheckbox ;
for ( int i = 0 ; i < 3 ; i + + )
{
2021-02-18 10:40:44 -08:00
testRunner . ClickByName ( supportWidegtName )
. WaitFor ( ( ) = > supportButton . Checked )
. ClickByName ( supportWidegtName )
. WaitFor ( ( ) = > ! supportButton . Checked ) ;
2021-01-30 08:49:06 -08:00
}
Assert . IsTrue ( testRunner . NameExists ( supportWidegtName , 1 ) , "Print menu should still be open after toggle supports" ) ;
}
2021-02-21 21:29:55 -08:00
return Task . CompletedTask ;
2021-01-30 08:49:06 -08:00
} , maxTimeToRun : 120 ) ;
}
2021-01-31 08:47:36 -08:00
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest, Category("Emulator")]
2021-01-31 08:47:36 -08:00
public async Task SettingsStayOpenOnRebuildSettings ( )
{
2021-02-21 12:39:18 -08:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2021-01-31 08:47:36 -08:00
{
using ( var emulator = testRunner . LaunchAndConnectToPrinterEmulator ( pinSettingsOpen : false ) )
{
var printer = testRunner . FirstPrinter ( ) ;
testRunner . OpenSettingsSidebar ( false ) ;
for ( int i = 0 ; i < 3 ; i + + )
{
2021-02-01 20:07:06 -08:00
testRunner . Delay ( )
. ClickByName ( "Slice Settings Overflow Menu" )
. Delay ( )
. ClickByName ( "Advanced Menu Item" )
. Delay ( )
. ClickByName ( "Slice Settings Overflow Menu" )
. Delay ( )
. ClickByName ( "Simple Menu Item" ) ;
2021-01-31 08:47:36 -08:00
}
}
2021-02-21 12:39:18 -08:00
return Task . CompletedTask ;
2021-01-31 08:47:36 -08:00
} , maxTimeToRun : 120 ) ;
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest, Category("Emulator")]
2017-02-13 11:52:56 -08:00
public async Task CancelWorksAsExpected ( )
{
2017-06-03 19:13:54 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2017-02-13 11:52:56 -08:00
{
2017-06-02 19:57:15 -07:00
using ( var emulator = testRunner . LaunchAndConnectToPrinterEmulator ( ) )
2017-02-13 11:52:56 -08:00
{
2018-11-12 17:20:59 -08:00
Assert . AreEqual ( 1 , ApplicationController . Instance . ActivePrinters . Count ( ) , "One printer should exist after add" ) ;
2017-12-14 16:19:22 -08:00
2018-11-30 13:04:25 -08:00
var printer = testRunner . FirstPrinter ( ) ;
2017-12-14 16:19:22 -08:00
printer . Settings . SetValue ( SettingsKey . cancel_gcode , "G28 ; Cancel GCode" ) ;
2017-02-13 11:52:56 -08:00
2021-06-06 22:18:29 -07:00
testRunner . AddItemToBed ( )
2021-02-21 12:39:18 -08:00
. StartPrint ( printer , pauseAtLayers : "2" )
// Wait for the Ok button
. WaitForName ( "Yes Button" , 30 ) ;
2018-07-18 19:21:05 -07:00
emulator . RunSlow = true ;
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Yes Button" )
// Cancel the Printing task
. ClickByName ( "Stop Task Button" )
// Wait for and assert that printing has been canceled
. WaitFor ( ( ) = > printer . Connection . CommunicationState = = PrinterCommunication . CommunicationStates . Connected ) ;
2018-07-18 19:21:05 -07:00
Assert . AreEqual ( printer . Connection . CommunicationState , PrinterCommunication . CommunicationStates . Connected ) ;
2017-02-13 11:52:56 -08:00
2017-12-14 16:19:22 -08:00
// Assert that two G28s were output to the terminal
2020-10-06 07:50:47 -07:00
int g28Count = printer . Connection . TerminalLog . AllLines ( ) . Where ( line = > line . Contains ( "G28" ) ) . Count ( ) ;
2017-12-14 16:19:22 -08:00
Assert . AreEqual ( 2 , g28Count , "The terminal log should contain one G28 from Start-GCode and one G28 from Cancel-GCode" ) ;
2017-02-13 11:52:56 -08:00
}
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-06-03 19:13:54 -07:00
} , maxTimeToRun : 120 ) ;
2017-02-13 11:52:56 -08:00
}
2022-07-15 17:28:39 -07:00
[Test /* Test will fail if screen size is and "HeatBeforeHoming" falls below the fold */, ChildProcessTest]
2016-10-25 06:17:37 -07:00
public async Task ClearingCheckBoxClearsUserOverride ( )
2016-08-24 15:53:46 -07:00
{
2017-06-03 19:33:38 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2016-08-24 15:53:46 -07:00
{
2021-02-21 12:39:18 -08:00
testRunner . WaitForFirstDraw ( )
. AddAndSelectPrinter ( "Airwolf 3D" , "HD" )
// Navigate to Local Library
. SwitchToPrinterSettings ( )
2022-04-20 21:18:58 +01:00
. ClickByName ( "Features SliceSettingsTab" ) ;
2016-08-24 15:53:46 -07:00
2018-11-30 13:04:25 -08:00
var printer = testRunner . FirstPrinter ( ) ;
2016-08-24 15:53:46 -07:00
2018-10-05 09:24:57 -07:00
CheckAndUncheckSetting ( testRunner , printer , SettingsKey . heat_extruder_before_homing , false ) ;
CheckAndUncheckSetting ( testRunner , printer , SettingsKey . has_fan , true ) ;
2016-10-25 06:17:37 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2018-01-24 16:31:10 -08:00
} , overrideWidth : 1224 , overrideHeight : 900 , maxTimeToRun : 600 ) ;
2016-08-25 17:43:30 -07:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2018-04-10 14:40:19 -07:00
public async Task DualExtrusionShowsCorrectHotendData ( )
2017-09-07 16:24:11 -07:00
{
await MatterControlUtilities . RunTest ( ( testRunner ) = >
{
using ( var emulator = testRunner . LaunchAndConnectToPrinterEmulator ( ) )
{
2022-04-20 21:18:58 +01:00
testRunner . ClickByName ( "Features SliceSettingsTab" ) ;
2017-09-07 16:24:11 -07:00
// only 1 hotend and 1 extruder
Assert . IsTrue ( testRunner . NameExists ( "Hotend 0" ) ) ;
2018-02-08 15:42:07 -08:00
Assert . IsTrue ( testRunner . NameExists ( "Bed TemperatureWidget" ) ) ;
2017-09-07 16:24:11 -07:00
Assert . IsFalse ( testRunner . NameExists ( "Hotend 1" , . 1 ) ) ;
testRunner . ClickByName ( "Hotend 0" ) ;
// assert the temp is set when we first open (it comes from the material)
2022-07-15 17:28:39 -07:00
ThemedNumberEdit tempWidget = testRunner . GetWidgetByName ( "Temperature Input" , out _ ) as ThemedNumberEdit ;
2017-09-20 18:05:15 -07:00
Assert . AreEqual ( 240 , ( int ) tempWidget . Value ) ;
2017-09-07 16:24:11 -07:00
// change material
2017-09-21 09:12:33 -07:00
var dropDownLists = testRunner . GetWidgetsByName ( "Hotend Preset Selector" ) ;
Assert . AreEqual ( 1 , dropDownLists . Count , "There is one. The slice settings and the pop out." ) ;
2017-10-27 14:19:26 -07:00
DropDownList materialSelector = dropDownLists [ 0 ] . Widget as DropDownList ;
2017-09-07 16:24:11 -07:00
Assert . AreEqual ( "" , materialSelector . SelectedValue ) ;
2017-09-20 18:05:15 -07:00
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Hotend Preset Selector" )
. ClickByName ( "HIPS Menu" ) ;
2017-09-07 16:24:11 -07:00
2017-09-08 10:23:28 -07:00
// check the extruder count
var extrudeButtons = testRunner . GetWidgetsByName ( "Extrude Button" ) ;
Assert . AreEqual ( 1 , extrudeButtons . Count , "There should be just one." ) ;
2017-09-07 16:24:11 -07:00
int hipsGoalTemp = 220 ;
2018-10-12 15:50:25 -07:00
testRunner . Delay ( ) ;
2017-09-20 18:05:15 -07:00
2017-09-07 16:24:11 -07:00
// assert the temp changed to a new temp
2017-09-20 18:05:15 -07:00
Assert . AreEqual ( hipsGoalTemp , ( int ) tempWidget . Value , "The goal temp should match the material temp" ) ;
2017-09-07 16:24:11 -07:00
// and the printer heat is off
2018-01-10 12:55:41 -08:00
Assert . AreEqual ( 0 , ( int ) emulator . CurrentExtruder . TargetTemperature , "The printer should report the heaters are off" ) ;
2017-09-07 16:24:11 -07:00
// turn on the heater
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Toggle Heater" )
. Delay ( 1 ) ;
2017-09-07 16:24:11 -07:00
// assert the printer is heating
2018-01-10 12:55:41 -08:00
Assert . AreEqual ( hipsGoalTemp , ( int ) emulator . CurrentExtruder . TargetTemperature , "The printer should report the expected goal temp" ) ;
2017-09-07 16:24:11 -07:00
// turn off the heater
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Toggle Heater" )
. Delay ( 1 ) ;
2017-09-07 16:24:11 -07:00
// assert the printer is off
2018-01-10 12:55:41 -08:00
Assert . AreEqual ( 0 , ( int ) emulator . CurrentExtruder . TargetTemperature , "The printer should report the heaters are off" ) ;
2017-09-07 16:24:11 -07:00
// type in a temp when the heating is off
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Temperature Input" )
. Type ( "110" )
. Type ( "{Enter}" )
. Delay ( ) ;
2017-09-07 16:24:11 -07:00
// assert the printer is off
2018-01-10 12:55:41 -08:00
Assert . AreEqual ( 0 , ( int ) emulator . CurrentExtruder . TargetTemperature ) ;
2017-09-07 16:24:11 -07:00
// and the heat toggle is showing on
2018-04-13 17:10:31 -07:00
ICheckbox heatToggle = testRunner . GetWidgetByName ( "Toggle Heater" , out _ ) as ICheckbox ;
2017-09-07 16:24:11 -07:00
Assert . IsFalse ( heatToggle . Checked ) ;
// turn it on
testRunner . ClickByName ( "Toggle Heater" ) ;
2018-01-10 12:55:41 -08:00
Assert . AreEqual ( 110 , ( int ) emulator . CurrentExtruder . TargetTemperature ) ;
2017-09-07 16:24:11 -07:00
// adjust when on
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Temperature Input" )
. Type ( "104" )
. Type ( "{Enter}" )
. Delay ( ) ;
2018-01-10 12:55:41 -08:00
Assert . AreEqual ( 104 , ( int ) emulator . CurrentExtruder . TargetTemperature ) ;
2017-09-07 16:24:11 -07:00
// type in 0 and have the heater turn off
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Temperature Input" )
. Type ( "^a" )
. Type ( "0" )
. Type ( "{Enter}" )
. Delay ( )
// type in 60 and have the heater turn on
. ClickByName ( "Temperature Input" )
. Type ( "^a" )
. Type ( "60" )
. Type ( "{Enter}" )
. Delay ( )
. ClickByName ( "Toggle Heater" ) ;
2018-10-12 15:50:25 -07:00
Assert . AreEqual ( 60 , ( int ) emulator . CurrentExtruder . TargetTemperature ) ;
// click the remove override and have it change to default temp
2022-07-15 17:28:39 -07:00
// NOTE: Got test failure twice: The printer should report the expected goal temp
// Expected: 220
// But was: 60
// Even though WaitFor was used. Maybe the emulator is just delayed sometimes.
// Adding Math.Round anyway. And more waiting.
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Restore temperature" )
2022-07-15 17:28:39 -07:00
. WaitFor ( ( ) = > hipsGoalTemp = = ( int ) Math . Round ( emulator . CurrentExtruder . TargetTemperature ) , maxSeconds : 10 ) ;
Assert . AreEqual ( hipsGoalTemp , ( int ) Math . Round ( emulator . CurrentExtruder . TargetTemperature ) , "The printer should report the expected goal temp" ) ;
2018-10-12 15:50:25 -07:00
// type in 60 and have the heater turn on
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Temperature Input" )
. Type ( "^a" )
. Type ( "60" )
. Type ( "{Enter}" )
. Delay ( ) ;
2018-10-12 15:50:25 -07:00
Assert . AreEqual ( 60 , ( int ) emulator . CurrentExtruder . TargetTemperature ) ;
// type in 0 and have the heater turn off
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Temperature Input" )
. Type ( "^a" )
. Type ( "0" )
. Type ( "{Enter}" )
. Delay ( ) ;
2018-10-12 15:50:25 -07:00
2017-09-07 16:24:11 -07:00
// assert the printer is not heating
2018-01-10 12:55:41 -08:00
Assert . AreEqual ( 0 , ( int ) emulator . CurrentExtruder . TargetTemperature ) ;
2017-09-07 16:24:11 -07:00
// and the on toggle is showing off
Assert . IsFalse ( heatToggle . Checked ) ;
2018-08-23 14:46:06 -07:00
// test that the load filament button works and closes correctly
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Temperature Input" )
. Type ( "^a" )
. Type ( "104" )
. Type ( "{Enter}" )
. Delay ( )
. ClickByName ( "Load Filament Button" )
. ClickByName ( "Load Filament" ) ;
2018-08-23 14:46:06 -07:00
Assert . AreEqual ( 104 , ( int ) emulator . CurrentExtruder . TargetTemperature ) ;
2021-02-21 12:39:18 -08:00
testRunner . Delay ( )
. ClickByName ( "Cancel Wizard Button" )
. Delay ( ) ;
2018-08-23 14:46:06 -07:00
Assert . AreEqual ( 0 , ( int ) emulator . CurrentExtruder . TargetTemperature ) ;
2021-02-21 12:39:18 -08:00
testRunner . ClickByName ( "Hotend 0" )
. ClickByName ( "Load Filament Button" )
. ClickByName ( "Load Filament" )
. Delay ( ) ;
2018-08-23 14:46:06 -07:00
Assert . AreEqual ( 104 , ( int ) emulator . CurrentExtruder . TargetTemperature ) ;
var systemWindow = testRunner . GetWidgetByName ( "Cancel Wizard Button" , out SystemWindow containingWindow ) ;
// close the window through windows (alt-f4)
testRunner . Type ( "%{F4}" ) ;
Assert . AreEqual ( 0 , ( int ) emulator . CurrentExtruder . TargetTemperature ) ;
// Switch back to the general tab
2022-04-20 21:18:58 +01:00
testRunner . ClickByName ( "General SliceSettingsTab" )
2021-02-21 12:39:18 -08:00
. SelectSliceSettingsField ( SettingsKey . extruder_count )
. Type ( "2" )
. Type ( "{Enter}" ) ;
2017-09-07 16:24:11 -07:00
// there are now 2 hotends and 2 extruders
Assert . IsTrue ( testRunner . NameExists ( "Hotend 0" ) ) ;
Assert . IsTrue ( testRunner . NameExists ( "Hotend 1" ) ) ;
2018-11-30 13:04:25 -08:00
var printer = testRunner . FirstPrinter ( ) ;
2018-10-05 09:24:57 -07:00
SetCheckBoxSetting ( testRunner , printer , SettingsKey . extruders_share_temperature , true ) ;
2017-09-07 16:24:11 -07:00
// there is one hotend and 2 extruders
Assert . IsTrue ( testRunner . NameExists ( "Hotend 0" ) ) ;
Assert . IsFalse ( testRunner . NameExists ( "Hotend 1" , . 1 ) ) ;
testRunner . ClickByName ( "Hotend 0" ) ;
2017-09-08 10:23:28 -07:00
extrudeButtons = testRunner . GetWidgetsByName ( "Extrude Button" ) ;
Assert . AreEqual ( 2 , extrudeButtons . Count , "Now there should be two." ) ;
2017-09-07 16:24:11 -07:00
}
return Task . CompletedTask ;
2018-09-10 13:41:36 -07:00
} , maxTimeToRun : 120 ) ;
2017-09-07 16:24:11 -07:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2018-10-05 09:24:57 -07:00
public void SliceSettingsOrganizerSupportsKeyLookup ( )
2018-01-13 18:10:28 -08:00
{
2022-07-15 17:28:39 -07:00
StaticData . RootPath = MatterControlUtilities . StaticDataPath ;
2018-01-13 18:10:28 -08:00
2019-01-06 13:28:37 -08:00
var organizer = PrinterSettings . Layout ;
2018-01-13 18:10:28 -08:00
2020-12-30 14:44:24 -08:00
var userLevel = organizer . AllSliceSettings ;
2018-01-13 18:10:28 -08:00
Assert . IsNotNull ( userLevel ) ;
// Confirm expected keys
Assert . IsTrue ( userLevel . ContainsKey ( "bed_temperature" ) ) ;
2020-12-30 14:44:24 -08:00
Assert . IsTrue ( organizer . AllSliceSettings . ContainsKey ( "bed_temperature" ) ) ;
Assert . IsTrue ( organizer . AllPrinterSettings . ContainsKey ( "extruder_count" ) ) ;
2018-01-13 18:10:28 -08:00
// Confirm non-existent key
Assert . IsFalse ( userLevel . ContainsKey ( "non_existing_setting" ) ) ;
2020-12-30 14:44:24 -08:00
Assert . IsFalse ( organizer . AllSliceSettings . ContainsKey ( "non_existing_setting" ) ) ;
2018-01-13 18:10:28 -08:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2017-02-22 11:15:51 -08:00
public async Task SwitchingMaterialsCausesSettingsChangedEvents ( )
{
2017-06-03 19:33:53 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2017-02-22 11:15:51 -08:00
{
2018-10-10 13:33:16 -07:00
testRunner . AddAndSelectPrinter ( ) ;
2017-09-07 16:24:11 -07:00
2020-09-01 18:07:34 -07:00
var printer = testRunner . FirstPrinter ( ) ;
printer . Settings . OemLayer [ SettingsKey . layer_height ] = ".2" ;
2017-02-22 11:15:51 -08:00
int layerHeightChangedCount = 0 ;
2017-06-03 19:33:53 -07:00
2018-12-20 12:38:05 -08:00
PrinterSettings . AnyPrinterSettingChanged + = ( s , stringEvent ) = >
2017-02-22 11:15:51 -08:00
{
if ( stringEvent ! = null )
{
if ( stringEvent . Data = = SettingsKey . layer_height )
{
layerHeightChangedCount + + ;
}
}
2018-11-13 09:47:58 -08:00
} ;
2017-02-22 11:15:51 -08:00
2018-04-23 13:43:42 -07:00
// Navigate to Local Library
2017-12-14 16:19:22 -08:00
testRunner . SwitchToSliceSettings ( ) ;
2017-02-22 11:15:51 -08:00
2018-01-07 17:33:43 -08:00
// Navigate to General Tab -> Layers / Surface Tab
2021-01-31 18:33:34 -08:00
testRunner . SelectSliceSettingsField ( SettingsKey . layer_height ) ;
2017-02-22 11:15:51 -08:00
Assert . AreEqual ( 0 , layerHeightChangedCount , "No change to layer height yet." ) ;
2017-12-06 17:21:53 -08:00
2020-09-01 18:07:34 -07:00
var theme = ApplicationController . Instance . Theme ;
var indicator = testRunner . GetWidgetByName ( "Layer Thickness OverrideIndicator" , out _ ) ;
Assert . AreEqual ( Color . Transparent , indicator . BackgroundColor ) ;
testRunner . ClickByName ( "Quality" )
. ClickByName ( "Fine Menu" )
. Delay ( . 5 ) ;
2017-02-22 11:15:51 -08:00
Assert . AreEqual ( 1 , layerHeightChangedCount , "Changed to fine." ) ;
2020-09-01 18:07:34 -07:00
Assert . AreEqual ( theme . PresetColors . QualityPreset , indicator . BackgroundColor ) ;
2017-12-06 17:21:53 -08:00
2020-09-01 18:07:34 -07:00
testRunner . ClickByName ( "Quality" )
. ClickByName ( "Standard Menu" )
. Delay ( . 5 ) ;
2017-02-22 11:15:51 -08:00
Assert . AreEqual ( 2 , layerHeightChangedCount , "Changed to standard." ) ;
2020-09-01 18:07:34 -07:00
Assert . AreEqual ( theme . PresetColors . QualityPreset , indicator . BackgroundColor ) ;
testRunner . ClickByName ( "Quality" )
. ClickByName ( "- none - Menu Item" )
. Delay ( . 5 ) ;
Assert . AreEqual ( Color . Transparent , indicator . BackgroundColor ) ;
Assert . AreEqual ( 3 , layerHeightChangedCount , "Changed to - none -." ) ;
testRunner . ClickByName ( "Quality" )
. ClickByName ( "Standard Menu" )
. Delay ( . 5 ) ;
Assert . AreEqual ( 4 , layerHeightChangedCount , "Changed to standard." ) ;
Assert . AreEqual ( theme . PresetColors . QualityPreset , indicator . BackgroundColor ) ;
2017-02-22 11:15:51 -08:00
2020-09-01 18:12:13 -07:00
// TODO: delete one of the settings
// asserts that the deleted setting has been removed from the list
2022-07-31 18:27:18 +09:00
return Task . CompletedTask ;
} , maxTimeToRun : 1000 ) ;
}
[Test, ChildProcessTest]
public async Task ValidateSaveMenuItemLabels ( )
{
await MatterControlUtilities . RunTest ( ( testRunner ) = >
{
testRunner . AddAndSelectPrinter ( "Airwolf 3D" , "HD" ) ;
// Navigate to Slice Settings Tab and make sure Layer Thickness row is visible
testRunner . SwitchToSliceSettings ( )
. NavigateToSliceSettingsField ( SettingsKey . layer_height ) ;
// Set Quality to "Coarse" and Material to "ABS"
testRunner . ClickByName ( "Quality" )
. ClickByName ( "Coarse Menu" )
. ClickByName ( "Material" )
. ClickByName ( "ABS Menu" )
. RightClickByName ( "Layer Thickness OverrideIndicator" , offset : new Point2D ( 30 , 0 ) )
. ClickByName ( "Save to Menu Item" )
. Delay ( . 5 ) ;
Assert . IsTrue ( testRunner . NameExists ( "Quality Setting 'Coarse' Menu Item" ) ) ;
Assert . IsTrue ( testRunner . NameExists ( "Material Setting 'ABS' Menu Item" ) ) ;
// Set Quality to "Fine" and Material to "BENDLAY"
testRunner . ClickByName ( "Quality" )
. ClickByName ( "Fine Menu" )
. ClickByName ( "Material" )
. ClickByName ( "BENDLAY Menu" )
. RightClickByName ( "Layer Thickness OverrideIndicator" , offset : new Point2D ( 30 , 0 ) )
. ClickByName ( "Save to Menu Item" )
. Delay ( . 5 ) ;
Assert . IsTrue ( testRunner . NameExists ( "Quality Setting 'Fine' Menu Item" ) ) ;
Assert . IsTrue ( testRunner . NameExists ( "Material Setting 'BENDLAY' Menu Item" ) ) ;
// Set Quality to none
testRunner . ClickByName ( "Quality" )
. ClickByName ( "- none - Menu Item" )
. RightClickByName ( "Layer Thickness OverrideIndicator" , offset : new Point2D ( 30 , 0 ) )
. ClickByName ( "Save to Menu Item" )
. Delay ( . 5 ) ;
Assert . IsTrue ( testRunner . NameExists ( "Quality Setting Menu Item" ) ) ;
Assert . IsTrue ( testRunner . NameExists ( "Material Setting 'BENDLAY' Menu Item" ) ) ;
// Set Quality to "Standard" and Material to none
testRunner . ClickByName ( "Quality" )
. ClickByName ( "Standard Menu" )
. ClickByName ( "Material" )
. ClickByName ( "- none - Menu Item" )
. RightClickByName ( "Layer Thickness OverrideIndicator" , offset : new Point2D ( 30 , 0 ) )
. ClickByName ( "Save to Menu Item" )
. Delay ( . 5 ) ;
Assert . IsTrue ( testRunner . NameExists ( "Quality Setting 'Standard' Menu Item" ) ) ;
Assert . IsTrue ( testRunner . NameExists ( "Material Setting Menu Item" ) ) ;
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2020-09-01 18:07:34 -07:00
} , maxTimeToRun : 1000 ) ;
2017-02-22 11:15:51 -08:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2016-10-25 06:17:37 -07:00
public async Task DeleteProfileWorksForGuest ( )
2016-09-07 17:00:17 -07:00
{
2017-06-03 19:39:54 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2016-09-07 17:00:17 -07:00
{
2018-02-08 15:42:07 -08:00
testRunner . WaitForFirstDraw ( ) ;
2017-08-30 16:43:58 -07:00
2016-10-19 11:10:30 -07:00
// assert no profiles
2017-06-03 19:39:54 -07:00
Assert . AreEqual ( 0 , ProfileManager . Instance . ActiveProfiles . Count ( ) ) ;
2016-09-07 17:00:17 -07:00
2017-06-04 09:01:56 -07:00
testRunner . AddAndSelectPrinter ( "Airwolf 3D" , "HD" ) ;
2016-09-07 17:00:17 -07:00
2016-10-19 11:10:30 -07:00
// assert one profile
2017-06-03 19:39:54 -07:00
Assert . AreEqual ( 1 , ProfileManager . Instance . ActiveProfiles . Count ( ) , "One profile should exist after add" ) ;
2016-09-07 17:00:17 -07:00
2016-10-19 11:10:30 -07:00
MatterControlUtilities . DeleteSelectedPrinter ( testRunner ) ;
2016-09-07 17:00:17 -07:00
2016-10-19 11:10:30 -07:00
// assert no profiles
2017-06-03 19:39:54 -07:00
Assert . AreEqual ( 0 , ProfileManager . Instance . ActiveProfiles . Count ( ) , "No profiles should exist after delete" ) ;
2016-09-07 17:00:17 -07:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-06-03 19:39:54 -07:00
} , overrideWidth : 1224 , overrideHeight : 900 ) ;
2016-09-07 17:00:17 -07:00
}
2018-10-05 09:24:57 -07:00
private static void SetCheckBoxSetting ( AutomationRunner testRunner , PrinterConfig printer , string settingToChange , bool valueToSet )
2017-09-07 16:24:11 -07:00
{
2019-01-06 13:19:01 -08:00
var settingsData = PrinterSettings . SettingsData [ settingToChange ] ;
2017-09-14 14:47:08 -07:00
string checkBoxName = $"{settingsData.PresentationName} Field" ;
2017-09-07 16:24:11 -07:00
2018-10-05 09:24:57 -07:00
Assert . IsTrue ( printer . Settings . GetValue < bool > ( settingToChange ) ! = valueToSet ) ;
2017-09-07 16:24:11 -07:00
2018-02-08 15:42:07 -08:00
//testRunner.ScrollIntoView(checkBoxName);
//testRunner.ClickByName(checkBoxName);
2021-02-18 10:40:44 -08:00
testRunner . SelectSliceSettingsField ( settingToChange )
// give some time for the ui to update if necessary
. Delay ( 2 ) ;
2017-09-07 16:24:11 -07:00
2018-10-05 09:24:57 -07:00
Assert . IsTrue ( printer . Settings . GetValue < bool > ( settingToChange ) = = valueToSet ) ;
2017-09-07 16:24:11 -07:00
}
2018-10-05 09:24:57 -07:00
private static void CheckAndUncheckSetting ( AutomationRunner testRunner , PrinterConfig printer , string settingToChange , bool expected )
2016-08-25 17:43:30 -07:00
{
// Assert that the checkbox is currently unchecked, and there is no user override
2018-10-05 09:24:57 -07:00
Assert . IsFalse ( printer . Settings . UserLayer . ContainsKey ( settingToChange ) ) ;
2016-08-25 17:43:30 -07:00
// Click the checkbox
2018-10-05 09:24:57 -07:00
SetCheckBoxSetting ( testRunner , printer , settingToChange , ! expected ) ;
2016-08-25 17:43:30 -07:00
// Assert the checkbox is checked and the user override is set
2018-10-05 09:24:57 -07:00
Assert . IsTrue ( printer . Settings . UserLayer . ContainsKey ( settingToChange ) ) ;
2016-08-25 17:43:30 -07:00
2018-02-08 15:42:07 -08:00
// make sure the setting is still open in case of a reload all
2021-02-18 10:40:44 -08:00
testRunner . NavigateToSliceSettingsField ( settingToChange )
// Click the cancel user override button
. ClickByName ( "Restore " + settingToChange )
. Delay ( 2 ) ;
2016-08-25 17:43:30 -07:00
// Assert the checkbox is unchecked and there is no user override
2018-10-05 09:24:57 -07:00
Assert . IsTrue ( printer . Settings . GetValue < bool > ( settingToChange ) = = expected ) ;
Assert . IsFalse ( printer . Settings . UserLayer . ContainsKey ( settingToChange ) ) ;
2016-08-24 15:53:46 -07:00
}
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2016-10-25 06:17:37 -07:00
public async Task HasHeatedBedCheckedHidesBedTemperatureOptions ( )
2016-03-03 17:57:14 -08:00
{
2017-06-04 07:11:44 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2016-03-03 17:57:14 -08:00
{
2021-02-18 10:40:44 -08:00
testRunner . WaitForFirstDraw ( )
. AddAndSelectPrinter ( "Airwolf 3D" , "HD" )
// Navigate to Settings Tab and make sure Bed Temp Text box is visible
. SwitchToSliceSettings ( )
2022-05-17 14:37:00 -07:00
. ClickByName ( "Slice Settings Overflow Menu" )
. ClickByName ( "Advanced Menu Item" )
2022-06-19 20:13:32 -07:00
. Delay ( )
2021-02-18 10:40:44 -08:00
. SelectSliceSettingsField ( SettingsKey . bed_temperature )
. SelectSliceSettingsField ( SettingsKey . temperature )
// Uncheck Has Heated Bed checkbox and make sure Bed Temp Textbox is not visible
. SwitchToPrinterSettings ( )
2022-07-15 17:28:39 -07:00
//.SelectSliceSettingsField(SettingsKey.has_heated_bed) // NOTE: Happened once: System.Exception : ClickByName Failed: Named GuiWidget not found [Hardware SliceSettingsTab]
//.Delay(1.0) // Wait for reload reliably:
. WaitForReloadAll ( ( ) = > testRunner . SelectSliceSettingsField ( SettingsKey . has_heated_bed ) )
2021-02-18 10:40:44 -08:00
. SwitchToSliceSettings ( )
. NavigateToSliceSettingsField ( SettingsKey . temperature ) ;
2016-10-19 11:10:30 -07:00
2017-06-17 18:48:40 -07:00
Assert . IsFalse ( testRunner . WaitForName ( "Bed Temperature Textbox" , . 5 ) , "Filament -> Bed Temp should not be visible after Heated Bed unchecked" ) ;
2016-10-19 11:10:30 -07:00
2017-06-04 07:11:44 -07:00
// Make sure Bed Temperature Options are not visible in printer controls
2017-06-13 13:22:22 -07:00
testRunner . SwitchToControlsTab ( ) ;
2016-10-25 06:17:37 -07:00
2017-06-17 18:48:40 -07:00
Assert . IsFalse ( testRunner . WaitForName ( "Bed Temperature Controls Widget" , . 5 ) , "Controls -> Bed Temp should not be visible after Heated Bed unchecked" ) ;
2016-03-03 17:57:14 -08:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2018-01-25 09:02:33 -08:00
} ) ;
2016-03-03 17:57:14 -08:00
}
2017-09-23 14:44:43 -07:00
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2017-06-03 18:33:48 -07:00
public async Task QualitySettingsStayAsOverrides ( )
2016-12-06 17:48:13 -08:00
{
2017-06-03 18:33:48 -07:00
await MatterControlUtilities . RunTest ( ( testRunner ) = >
2016-12-06 17:48:13 -08:00
{
2018-02-08 15:42:07 -08:00
testRunner . WaitForFirstDraw ( ) ;
2017-08-30 16:43:58 -07:00
2016-12-06 17:48:13 -08:00
// Add Guest printers
2021-02-18 10:40:44 -08:00
testRunner . AddAndSelectPrinter ( "Airwolf 3D" , "HD" )
. SwitchToSliceSettings ( ) ;
2016-12-06 17:48:13 -08:00
2018-11-30 13:04:25 -08:00
var printer = testRunner . FirstPrinter ( ) ;
2017-12-14 17:44:46 -08:00
2021-02-18 10:40:44 -08:00
testRunner . SelectSliceSettingsField ( SettingsKey . layer_height )
. Type ( ".5" )
// Force lose focus
. SelectSliceSettingsField ( SettingsKey . first_layer_height )
. WaitFor ( ( ) = > printer . Settings . GetValue < double > ( SettingsKey . layer_height ) = = 0.5 ) ;
2017-12-14 17:44:46 -08:00
Assert . AreEqual ( printer . Settings . GetValue < double > ( SettingsKey . layer_height ) . ToString ( ) , "0.5" , "Layer height is what we set it to" ) ;
2021-02-18 10:40:44 -08:00
testRunner . ClickByName ( "Quality" )
. ClickByName ( "Fine Menu" ) ;
2016-12-06 17:48:13 -08:00
2017-12-15 19:28:25 -08:00
testRunner . WaitFor ( ( ) = > printer . Settings . GetValue < double > ( SettingsKey . layer_height ) = = 0.1 ) ;
2017-12-14 17:44:46 -08:00
Assert . AreEqual ( printer . Settings . GetValue < double > ( SettingsKey . layer_height ) . ToString ( ) , "0.1" , "Layer height is the fine override" ) ;
2016-12-06 17:48:13 -08:00
2018-11-21 18:05:59 -08:00
// Close Airwolf
2018-12-26 16:16:19 -08:00
testRunner . CloseFirstPrinterTab ( ) ;
2018-12-19 09:09:17 -08:00
// 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" ) ;
2018-11-21 18:05:59 -08:00
2019-05-29 17:01:44 -07:00
testRunner . AddAndSelectPrinter ( "BCN3D" , "Sigma" ) ;
2016-12-06 17:48:13 -08:00
2018-12-19 09:09:17 -08:00
// Assert printer counts
2018-11-21 18:05:59 -08:00
Assert . AreEqual ( 2 , ProfileManager . Instance . ActiveProfiles . Count ( ) , "ProfileManager has 2 profiles" ) ;
2018-12-19 09:09:17 -08:00
Assert . AreEqual ( 1 , ApplicationController . Instance . ActivePrinters . Count ( ) , "One printer should be active after BCN add" ) ;
2016-12-06 17:48:13 -08:00
2018-11-21 18:05:59 -08:00
// Close BCN
2021-02-18 10:40:44 -08:00
testRunner . CloseFirstPrinterTab ( )
// Reopen Airwolf
. SwitchToHardwareTab ( )
. DoubleClickByName ( "Airwolf 3D HD Node" )
. Delay ( 0.2 ) ;
2016-12-06 17:48:13 -08:00
2018-11-30 13:04:25 -08:00
printer = testRunner . FirstPrinter ( ) ;
2017-12-14 17:44:46 -08:00
2017-12-15 19:28:25 -08:00
testRunner . WaitFor ( ( ) = > printer . Settings . GetValue < double > ( SettingsKey . layer_height ) = = 0.1 ) ;
2017-12-14 17:44:46 -08:00
Assert . AreEqual ( printer . Settings . GetValue < double > ( SettingsKey . layer_height ) . ToString ( ) , "0.1" , "Layer height is the fine override" ) ;
2016-12-06 17:48:13 -08:00
2017-06-03 18:33:48 -07:00
// Switch to Slice Settings Tab
2021-02-18 10:40:44 -08:00
testRunner . ClickByName ( "Slice Settings Tab" )
. ClickByName ( "Quality" )
. ClickByName ( "- none - Menu Item" )
. WaitFor ( ( ) = > printer . Settings . GetValue < double > ( SettingsKey . layer_height ) = = 0.5 ) ;
2017-12-14 17:44:46 -08:00
Assert . AreEqual ( printer . Settings . GetValue < double > ( SettingsKey . layer_height ) . ToString ( ) , "0.5" , "Layer height is what we set it to" ) ;
2016-12-06 18:12:57 -08:00
2017-06-04 08:35:29 -07:00
return Task . CompletedTask ;
2017-06-03 18:33:48 -07:00
} , maxTimeToRun : 120 ) ;
2016-12-06 17:48:13 -08:00
}
2018-11-21 18:05:59 -08:00
2022-07-15 17:28:39 -07:00
[Test, ChildProcessTest]
2019-03-06 08:23:54 -08:00
public void CopyFromTest ( )
{
2022-07-15 17:28:39 -07:00
StaticData . RootPath = MatterControlUtilities . StaticDataPath ;
MatterControlUtilities . OverrideAppDataLocation ( MatterControlUtilities . RootPath ) ;
2019-03-06 08:23:54 -08:00
var settings = new PrinterSettings ( ) ;
settings . ID = "12345-print" ;
settings . SetValue ( SettingsKey . auto_connect , "1" ) ;
settings . SetValue ( SettingsKey . com_port , "some_com_port" ) ;
settings . SetValue ( SettingsKey . cancel_gcode , "hello world" ) ;
settings . Macros . Add ( new GCodeMacro ( ) { Name = "Macro1" , GCode = "G28 ; Home Printer" } ) ;
settings . StagedUserSettings [ "retract_restart_extra_time_to_apply" ] = "4" ;
settings . StagedUserSettings [ "retract_restart_extra" ] = "0.3" ;
settings . StagedUserSettings [ "bridge_fan_speed" ] = "50" ;
var sha1 = settings . ComputeSHA1 ( ) ;
var clone = new PrinterSettings ( ) ;
clone . CopyFrom ( settings ) ;
Assert . AreEqual ( settings . ToJson ( ) , clone . ToJson ( ) , "Cloned settings via CopyFrom should equal source" ) ;
Assert . AreEqual ( sha1 , clone . ComputeSHA1 ( ) , "Cloned settings via CopyFrom should equal source" ) ;
}
2018-11-21 18:05:59 -08:00
private void CloseAllPrinterTabs ( AutomationRunner testRunner )
{
// Close all printer tabs
var mainViewWidget = testRunner . GetWidgetByName ( "PartPreviewContent" , out _ ) as MainViewWidget ;
foreach ( var tab in mainViewWidget . TabControl . AllTabs . Where ( t = > t . TabContent is PrinterTabPage ) . ToList ( ) )
{
if ( tab is GuiWidget widget )
{
var closeWidget = widget . Descendants < ImageWidget > ( ) . First ( ) ;
closeWidget . InvokeClick ( ) ;
}
}
}
2016-12-06 17:48:13 -08:00
}
2016-03-03 16:57:43 -08:00
}