mattercontrol/Tests/MatterControl.AutomationTests/PrinterDropDownTests.cs

57 lines
1.9 KiB
C#
Raw Normal View History

2018-11-12 14:45:53 -08:00
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
2018-11-12 14:45:53 -08:00
using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.MatterControl.SlicerConfiguration;
using NUnit.Framework;
namespace MatterHackers.MatterControl.Tests.Automation
{
[TestFixture, Category("MatterControl.UI.Automation"), RunInApplicationDomain, Apartment(ApartmentState.STA)]
public class PrinterNameChangePersists
{
[Test]
public async Task PrinterNameChangeTest()
{
// Ensures that printer model changes are applied correctly and observed by the view
await MatterControlUtilities.RunTest((testRunner) =>
{
testRunner.WaitForFirstDraw();
2017-08-30 16:43:58 -07:00
testRunner.AddAndSelectPrinter("Airwolf 3D", "HD");
Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should exist after add");
2018-11-12 14:45:53 -08:00
testRunner.SwitchToPrinterSettings();
// 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
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);
// 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");
// 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");
// 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));
return Task.CompletedTask;
});
}
}
}