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;
|
2016-09-13 12:02:54 -07:00
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.Tests.Automation
|
|
|
|
|
|
{
|
2017-06-09 20:12:25 -07:00
|
|
|
|
[TestFixture, Category("MatterControl.UI.Automation"), RunInApplicationDomain, Apartment(ApartmentState.STA)]
|
2016-09-13 12:02:54 -07:00
|
|
|
|
public class PrinterNameChangePersists
|
|
|
|
|
|
{
|
2017-06-09 20:12:25 -07:00
|
|
|
|
[Test]
|
2018-10-25 07:35:49 -07:00
|
|
|
|
public async Task PrinterNameChangeTest()
|
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
|
2018-11-12 14:45:53 -08:00
|
|
|
|
var printerTab = testRunner.GetWidgetByName("3D View Tab", out _) as ChromeTab;
|
|
|
|
|
|
Assert.AreEqual(newName, printerTab.Title);
|
|
|
|
|
|
|
|
|
|
|
|
// Validate that the settings layer reflects the new name
|
|
|
|
|
|
Assert.AreEqual(newName, printer.Settings.GetValue(SettingsKey.printer_name));
|
|
|
|
|
|
|
2016-10-25 06:17:37 -07: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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|