2018-11-12 14:45:53 -08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Threading;
|
2016-10-25 06:17:37 -07:00
|
|
|
|
using System.Threading.Tasks;
|
2018-11-12 14:45:53 -08:00
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
2016-09-13 12:02:54 -07:00
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
2016-09-21 15:34:53 -07:00
|
|
|
|
using NUnit.Framework;
|
2022-07-15 17:28:39 -07:00
|
|
|
|
using TestInvoker;
|
2016-09-13 12:02:54 -07:00
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.Tests.Automation
|
|
|
|
|
|
{
|
2022-07-15 17:28:39 -07:00
|
|
|
|
[TestFixture, Category("MatterControl.UI.Automation"), Parallelizable(ParallelScope.Children)]
|
2020-10-03 17:57:53 -07:00
|
|
|
|
public class PrinterNameChangeTests
|
2016-09-13 12:02:54 -07:00
|
|
|
|
{
|
2022-07-15 17:28:39 -07:00
|
|
|
|
[Test, ChildProcessTest]
|
2020-10-03 17:57:53 -07:00
|
|
|
|
public async Task NameChangeOnlyEffectsOnePrinter()
|
|
|
|
|
|
{
|
|
|
|
|
|
await MatterControlUtilities.RunTest((testRunner) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
testRunner.WaitForFirstDraw();
|
|
|
|
|
|
|
|
|
|
|
|
// Add Guest printers
|
|
|
|
|
|
testRunner.AddAndSelectPrinter("Airwolf 3D", "HD");
|
|
|
|
|
|
|
|
|
|
|
|
var printer1 = testRunner.FirstPrinter();
|
|
|
|
|
|
|
|
|
|
|
|
testRunner.AddAndSelectPrinter("BCN3D", "Sigma");
|
|
|
|
|
|
|
|
|
|
|
|
var printer2 = ApplicationController.Instance.ActivePrinters.Last();
|
|
|
|
|
|
|
|
|
|
|
|
string newName0 = "Updated name 0";
|
|
|
|
|
|
string newName1 = "Updated name 1";
|
|
|
|
|
|
var printerTab0 = testRunner.GetWidgetByName("3D View Tab 0", out _) as ChromeTab;
|
|
|
|
|
|
var printerTab1 = testRunner.GetWidgetByName("3D View Tab 1", out _) as ChromeTab;
|
|
|
|
|
|
|
|
|
|
|
|
// switch back to airwolf tab
|
|
|
|
|
|
testRunner.ClickByName("3D View Tab 0")
|
|
|
|
|
|
.SwitchToPrinterSettings()
|
|
|
|
|
|
.InlineTitleEdit("Printer Name", newName0);
|
|
|
|
|
|
|
2022-02-02 17:31:44 -08:00
|
|
|
|
Assert.AreEqual(newName0, printerTab0.Text);
|
|
|
|
|
|
Assert.AreEqual("BCN3D Sigma", printerTab1.Text);
|
2020-10-03 17:57:53 -07:00
|
|
|
|
|
|
|
|
|
|
// switch back to BCN tab
|
|
|
|
|
|
testRunner.ClickByName("3D View Tab 1")
|
|
|
|
|
|
.SwitchToPrinterSettings()
|
|
|
|
|
|
.InlineTitleEdit("Printer Name", newName1);
|
|
|
|
|
|
|
2022-02-02 17:31:44 -08:00
|
|
|
|
Assert.AreEqual(newName1, printerTab1.Text);
|
|
|
|
|
|
Assert.AreEqual(newName0, printerTab0.Text, "Name did not change");
|
2020-10-03 17:57:53 -07:00
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
|
}, maxTimeToRun: 120);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-15 17:28:39 -07:00
|
|
|
|
[Test, ChildProcessTest]
|
2020-10-03 17:57:53 -07:00
|
|
|
|
public async Task NameChangePersists()
|
2016-09-13 12:02:54 -07:00
|
|
|
|
{
|
2018-10-25 07:35:49 -07:00
|
|
|
|
// Ensures that printer model changes are applied correctly and observed by the view
|
2017-06-09 20:12:25 -07:00
|
|
|
|
await MatterControlUtilities.RunTest((testRunner) =>
|
2016-09-13 12:02:54 -07:00
|
|
|
|
{
|
2018-02-08 15:42:07 -08:00
|
|
|
|
testRunner.WaitForFirstDraw();
|
2017-08-30 16:43:58 -07:00
|
|
|
|
|
2017-06-04 09:01:56 -07:00
|
|
|
|
testRunner.AddAndSelectPrinter("Airwolf 3D", "HD");
|
2016-09-13 12:02:54 -07:00
|
|
|
|
|
2018-11-12 17:20:59 -08:00
|
|
|
|
Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should exist after add");
|
2018-11-12 14:45:53 -08:00
|
|
|
|
|
2017-12-28 09:02:44 -08:00
|
|
|
|
testRunner.SwitchToPrinterSettings();
|
2016-09-13 12:02:54 -07:00
|
|
|
|
|
2018-10-25 07:35:49 -07:00
|
|
|
|
// Change the printer name
|
2016-10-19 11:10:30 -07:00
|
|
|
|
string newName = "Updated name";
|
2018-01-24 17:49:16 -08:00
|
|
|
|
testRunner.InlineTitleEdit("Printer Name", newName);
|
2018-11-12 14:45:53 -08:00
|
|
|
|
|
2018-11-30 13:04:25 -08:00
|
|
|
|
var printer = testRunner.FirstPrinter();
|
2018-11-12 14:45:53 -08:00
|
|
|
|
string printerID = printer.Settings.ID;
|
|
|
|
|
|
|
|
|
|
|
|
// Wait for change
|
|
|
|
|
|
testRunner.WaitFor(() => newName == ProfileManager.Instance[printerID].Name);
|
2017-12-28 09:02:44 -08:00
|
|
|
|
|
2018-10-25 07:35:49 -07:00
|
|
|
|
// Validate that the model reflects the new name
|
2018-11-12 14:45:53 -08:00
|
|
|
|
Assert.AreEqual(newName, ProfileManager.Instance[printerID].Name, "ActiveProfile has updated name");
|
2016-09-13 12:02:54 -07:00
|
|
|
|
|
2018-10-25 07:35:49 -07:00
|
|
|
|
// Validate that the treeview reflects the new name
|
2018-10-11 21:47:19 -07:00
|
|
|
|
testRunner.SwitchToHardwareTab();
|
2018-10-11 17:24:42 -07:00
|
|
|
|
Assert.IsTrue(testRunner.WaitForName(newName + " Node"), "Widget with updated printer name exists");
|
2016-09-23 19:01:41 -07:00
|
|
|
|
|
2018-10-25 07:35:49 -07:00
|
|
|
|
// Validate that the tab reflects the new name
|
2020-10-03 17:57:53 -07:00
|
|
|
|
var printerTab = testRunner.GetWidgetByName("3D View Tab 0", out _) as ChromeTab;
|
2022-02-02 17:31:44 -08:00
|
|
|
|
Assert.AreEqual(newName, printerTab.Text);
|
2018-11-12 14:45:53 -08:00
|
|
|
|
|
|
|
|
|
|
// Validate that the settings layer reflects the new name
|
2022-01-27 16:49:46 -08:00
|
|
|
|
Assert.AreEqual(newName, printer.PrinterName);
|
2018-11-12 14:45:53 -08:00
|
|
|
|
|
2017-06-04 08:35:29 -07:00
|
|
|
|
return Task.CompletedTask;
|
2017-06-09 20:12:25 -07:00
|
|
|
|
});
|
2016-09-13 12:02:54 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|