From b49b4b8c7ea43179ba023ad49b2440ad640fde55 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 12 Dec 2016 17:33:02 -0800 Subject: [PATCH] Reduce hard-coded test wait times, use initial dialog to add printers --- ActionBar/PrinterConnectAndSelectControl.cs | 2 +- .../LocalLibraryTests.cs | 7 ++-- .../SliceSetingsTests.cs | 2 +- .../MatterControl/MatterControlUtilities.cs | 32 +++++++++---------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/ActionBar/PrinterConnectAndSelectControl.cs b/ActionBar/PrinterConnectAndSelectControl.cs index 800351cb7..6d3227f88 100644 --- a/ActionBar/PrinterConnectAndSelectControl.cs +++ b/ActionBar/PrinterConnectAndSelectControl.cs @@ -118,9 +118,9 @@ namespace MatterHackers.MatterControl.ActionBar }; disconnectPrinterButton = actionBarButtonFactory.Generate("Disconnect".Localize().ToUpper(), "icon_power_32x32.png"); + disconnectPrinterButton.Name = "Disconnect from printer button"; disconnectPrinterButton.ToolTipText = "Disconnect from current printer".Localize(); disconnectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); - disconnectPrinterButton.VAnchor = VAnchor.ParentTop; disconnectPrinterButton.Cursor = Cursors.Hand; disconnectPrinterButton.Click += (s, e) => UiThread.RunOnIdle(OnIdleDisconnect); diff --git a/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs b/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs index 11d72f3d7..106ad6e69 100644 --- a/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs +++ b/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs @@ -508,7 +508,7 @@ namespace MatterHackers.MatterControl.Tests.Automation { AutomationTest testToRun = (testRunner) => { - testRunner.CloseSignInAndPrinterSelect(); + testRunner.WaitForName("Cancel Wizard Button", 1); using (var emulatorProcess = testRunner.LaunchAndConnectToPrinterEmulator()) { @@ -517,13 +517,12 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.NavigateToFolder("Local Library Row Item Collection"); testRunner.ClickByName("Row Item Calibration - Box"); - testRunner.Wait(1); int initialQueueCount = QueueData.Instance.ItemCount; // Click Library Item Print Button testRunner.ClickByName("Row Item Calibration - Box Print Button"); - testRunner.Wait(2); + testRunner.Wait(.5); Assert.AreEqual(initialQueueCount + 1, QueueData.Instance.ItemCount, "Queue count should increment by one after clicking 'Print'"); Assert.AreEqual("Calibration - Box", QueueData.Instance.PrintItems[0].Name, "Library item should be inserted at queue index 0"); @@ -533,7 +532,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.ClickByName("Cancel Print Button"); } - testRunner.Wait(1); + testRunner.WaitForName("Start Print Button", 5); return Task.FromResult(0); diff --git a/Tests/MatterControl.AutomationTests/SliceSetingsTests.cs b/Tests/MatterControl.AutomationTests/SliceSetingsTests.cs index 4f27825db..ab5d25761 100644 --- a/Tests/MatterControl.AutomationTests/SliceSetingsTests.cs +++ b/Tests/MatterControl.AutomationTests/SliceSetingsTests.cs @@ -71,7 +71,7 @@ namespace MatterHackers.MatterControl.Tests.Automation { AutomationTest testToRun = (testRunner) => { - testRunner.CloseSignInAndPrinterSelect(); + testRunner.WaitForName("Cancel Wizard Button", 1); using (var emulatorProcess = testRunner.LaunchAndConnectToPrinterEmulator()) { diff --git a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs index 35f0261f7..85243eea3 100644 --- a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs +++ b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs @@ -194,10 +194,9 @@ namespace MatterHackers.MatterControl.Tests.Automation process.Start(); // edit the com port - testRunner.ClickByName("Edit Printer Button"); - testRunner.Wait(2); + testRunner.ClickByName("Edit Printer Button", 3); - testRunner.ClickByName("Serial Port Dropdown"); + testRunner.ClickByName("Serial Port Dropdown", 3); testRunner.ClickByName(config.MCPort + " Menu Item", 1); @@ -206,7 +205,7 @@ namespace MatterHackers.MatterControl.Tests.Automation // connect to the created printer testRunner.ClickByName("Connect to printer button", 2); - testRunner.Wait(2); + testRunner.WaitForName("Disconnect from printer button", 5); return process; } @@ -244,24 +243,25 @@ namespace MatterHackers.MatterControl.Tests.Automation public static void AddAndSelectPrinter(AutomationRunner testRunner, string make, string model) { - testRunner.ClickByName("Printers... Menu", 2, delayBeforeReturn: .5); - - testRunner.ClickByName("Add New Printer... Menu Item", 5, delayBeforeReturn: .5); - - testRunner.ClickByName("Select Make", 5, delayBeforeReturn: .5); + if (!testRunner.NameExists("Select Make")) + { + testRunner.ClickByName("Printers... Menu", 2, delayBeforeReturn: .5); + testRunner.ClickByName("Add New Printer... Menu Item", 5, delayBeforeReturn: .5); + } + testRunner.ClickByName("Select Make", 5); testRunner.Type(make); testRunner.Type("{Enter}"); - testRunner.ClickByName("Select Model", 5, delayBeforeReturn: .5); - - testRunner.ClickByName(model + " Menu Item", 5, delayBeforeReturn: .5); + testRunner.ClickByName("Select Model", 5); + testRunner.Type(model); + testRunner.Type("{Enter}"); // An unpredictable period of time will pass between Clicking Save, everything reloading and us returning to the caller. // Block until ReloadAll has completed then close and return to the caller, at which point hopefully everything is reloaded. WaitForReloadAll(testRunner, () => testRunner.ClickByName("Save & Continue Button", 2)); - testRunner.ClickByName("Cancel Wizard Button", 5, delayBeforeReturn: .5); + testRunner.ClickByName("Cancel Wizard Button", 5); testRunner.Wait(1); } @@ -346,11 +346,11 @@ namespace MatterHackers.MatterControl.Tests.Automation { SearchRegion libraryRowItemRegion = testRunner.GetRegionByName(libraryRowItemName, 3); testRunner.ClickByName(libraryRowItemName); - testRunner.MoveToByName(libraryRowItemName); - testRunner.Wait(.5); + //testRunner.MoveToByName(libraryRowItemName); + //testRunner.Wait(.5); testRunner.ClickByName("Open Collection", searchRegion: libraryRowItemRegion); - testRunner.Wait(.5); + //testRunner.Wait(.5); } public static async Task RunTest(