From 43656d450181eb43ee696de92cada65802af8225 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Wed, 14 Jun 2017 14:02:29 -0700 Subject: [PATCH] Use WaitForName defaults --- .../FileMenuTest.cs | 10 +++++----- .../HardwareLevelingUITests.cs | 14 +++++++------- .../LocalLibraryTests.cs | 18 +++++++++--------- .../PartPreviewTests.cs | 2 +- .../PrintingTests.cs | 17 ++++++++--------- .../SqLiteLibraryProvider.cs | 2 +- .../MatterControl/MatterControlUtilities.cs | 7 +++---- 7 files changed, 34 insertions(+), 36 deletions(-) diff --git a/Tests/MatterControl.AutomationTests/FileMenuTest.cs b/Tests/MatterControl.AutomationTests/FileMenuTest.cs index a898bec72..30d2068c9 100644 --- a/Tests/MatterControl.AutomationTests/FileMenuTest.cs +++ b/Tests/MatterControl.AutomationTests/FileMenuTest.cs @@ -22,7 +22,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.Delay(1); testRunner.ClickByName("Add Printer Menu Item"); testRunner.Delay(1); - Assert.IsTrue(testRunner.WaitForName("Select Make", 3)); + Assert.IsTrue(testRunner.WaitForName("Select Make")); testRunner.ClickByName("Cancel Wizard Button"); @@ -83,8 +83,8 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.NavigateToFolder("Print Queue Row Item Collection"); - Assert.IsTrue(testRunner.WaitForName("Row Item Fennec_Fox", 2)); - Assert.IsTrue(testRunner.WaitForName("Row Item Batman", 2)); + Assert.IsTrue(testRunner.WaitForName("Row Item Fennec_Fox")); + Assert.IsTrue(testRunner.WaitForName("Row Item Batman")); Assert.AreEqual(expectedCount, QueueData.Instance.ItemCount, "Queue count should increase by two after adding Fennec and Batman parts"); @@ -113,8 +113,8 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.NavigateToFolder("Print Queue Row Item Collection"); - Assert.IsTrue(testRunner.WaitForName("Row Item Batman", 1)); - Assert.IsTrue(testRunner.WaitForName("Row Item 2013-01-25_Mouthpiece_v2", 1)); + Assert.IsTrue(testRunner.WaitForName("Row Item Batman")); + Assert.IsTrue(testRunner.WaitForName("Row Item 2013-01-25_Mouthpiece_v2")); Assert.AreEqual(expectedCount, QueueData.Instance.ItemCount, "Queue count should increase by two after adding contents of Batmap.zip"); diff --git a/Tests/MatterControl.AutomationTests/HardwareLevelingUITests.cs b/Tests/MatterControl.AutomationTests/HardwareLevelingUITests.cs index c1078c490..608833191 100644 --- a/Tests/MatterControl.AutomationTests/HardwareLevelingUITests.cs +++ b/Tests/MatterControl.AutomationTests/HardwareLevelingUITests.cs @@ -21,7 +21,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.ClickByName("Printer Tab"); testRunner.Delay(1); - Assert.IsFalse(testRunner.WaitForName("Print Leveling Tab", 3), "Print leveling should not exist for an Airwolf HD"); + Assert.IsFalse(testRunner.WaitForName("Print Leveling Tab"), "Print leveling should not exist for an Airwolf HD"); // Add printer that does not have hardware leveling testRunner.AddAndSelectPrinter("3D Factory", "MendelMax 1.5"); @@ -29,7 +29,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.ClickByName("Slice Settings Tab"); testRunner.ClickByName("Printer Tab"); - Assert.IsTrue(testRunner.WaitForName("Print Leveling Tab", 3), "Print leveling should exist for a 3D Factory MendelMax"); + Assert.IsTrue(testRunner.WaitForName("Print Leveling Tab"), "Print leveling should exist for a 3D Factory MendelMax"); return Task.CompletedTask; }, overrideHeight: 800); @@ -45,7 +45,7 @@ namespace MatterHackers.MatterControl.Tests.Automation { // make sure it is showing the correct button Assert.IsFalse(testRunner.WaitForName("Start Print Button", .5), "Start Print should not be visible if PrintLeveling is required"); - Assert.IsTrue(testRunner.WaitForName("Finish Setup Button", .5), "Finish Setup should be visible if PrintLeveling is required"); + Assert.IsTrue(testRunner.WaitForName("Finish Setup Button"), "Finish Setup should be visible if PrintLeveling is required"); // do print leveling testRunner.ClickByName("Next Button"); @@ -62,8 +62,8 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.ClickByName("Done Button"); // make sure the button has changed to start print - Assert.IsTrue(testRunner.WaitForName("Start Print Button", 5), "Start Print should be visible after leveling the printer"); - Assert.IsFalse(testRunner.WaitForName("Finish Setup Button", 1), "Finish Setup should not be visible after leveling the printer"); + Assert.IsTrue(testRunner.WaitForName("Start Print Button"), "Start Print should be visible after leveling the printer"); + Assert.IsFalse(testRunner.WaitForName("Finish Setup Button"), "Finish Setup should not be visible after leveling the printer"); // reset to defaults and make sure print leveling is cleared testRunner.SwitchToAdvancedSliceSettings(); @@ -74,8 +74,8 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.Delay(1); // make sure it is showing the correct button - Assert.IsTrue(!testRunner.WaitForName("Start Print Button", 1), "Start Print should be visible after reset to Defaults"); - Assert.IsTrue(testRunner.WaitForName("Finish Setup Button", 1), "Finish Setup should not be visible after reset to Defaults"); + Assert.IsTrue(!testRunner.WaitForName("Start Print Button"), "Start Print should be visible after reset to Defaults"); + Assert.IsTrue(testRunner.WaitForName("Finish Setup Button"), "Finish Setup should not be visible after reset to Defaults"); } return Task.CompletedTask; diff --git a/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs b/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs index b8f54c518..9bc9bdcbb 100644 --- a/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs +++ b/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs @@ -67,8 +67,8 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.Delay(1); testRunner.Type("{Enter}"); - Assert.IsTrue(testRunner.WaitForName("Row Item Batman", 2), "Batman part should exist after adding"); - Assert.IsTrue(testRunner.WaitForName("Row Item 2013-01-25 Mouthpiece V2", 2), "Mouthpiece part should exist after adding"); + Assert.IsTrue(testRunner.WaitForName("Row Item Batman"), "Batman part should exist after adding"); + Assert.IsTrue(testRunner.WaitForName("Row Item 2013-01-25 Mouthpiece V2"), "Mouthpiece part should exist after adding"); return Task.CompletedTask; }); @@ -96,8 +96,8 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.ClickByName("Rename Button"); // Confirm - Assert.IsTrue(testRunner.WaitForName("Row Item Rook Renamed", 5)); - Assert.IsFalse(testRunner.WaitForName("Row Item Rook", 2)); + Assert.IsTrue(testRunner.WaitForName("Row Item Rook Renamed")); + Assert.IsFalse(testRunner.WaitForName("Row Item Rook", 1)); return Task.CompletedTask; }, overrideWidth: 600); @@ -127,7 +127,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.Delay(.2); // Confirm newly created folder exists - Assert.IsTrue(testRunner.WaitForName("New Folder Row Item Collection", 1), "New folder should appear as GuiWidget"); + Assert.IsTrue(testRunner.WaitForName("New Folder Row Item Collection"), "New folder should appear as GuiWidget"); testRunner.ClickByName("New Folder Row Item Collection"); testRunner.Delay(.2); @@ -141,7 +141,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.Delay(.2); // Make sure the renamed Library Folder exists - Assert.IsTrue(testRunner.WaitForName("Renamed Library Folder Row Item Collection", 2), "Renamed folder should exist"); + Assert.IsTrue(testRunner.WaitForName("Renamed Library Folder Row Item Collection"), "Renamed folder should exist"); return Task.CompletedTask; }); @@ -217,7 +217,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.NavigateToFolder("Print Queue Row Item Collection"); // Make sure that the item exists in the PrintQueueContainer - Assert.IsTrue(testRunner.WaitForName("Row Item Rook", 5), "Rook item should exist in the Queue after Add"); + Assert.IsTrue(testRunner.WaitForName("Row Item Rook"), "Rook item should exist in the Queue after Add"); return Task.CompletedTask; }); @@ -255,8 +255,8 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.NavigateToFolder("Print Queue Row Item Collection"); // Make sure that the items exist in the PrintQueueContainer - Assert.IsTrue(testRunner.WaitForName("Row Item Rook", 5), "Rook item should exist in the Queue after Add"); - Assert.IsTrue(testRunner.WaitForName("Row Item Batman", 5), "Batman item should exist in the Queue after Add"); + Assert.IsTrue(testRunner.WaitForName("Row Item Rook"), "Rook item should exist in the Queue after Add"); + Assert.IsTrue(testRunner.WaitForName("Row Item Batman"), "Batman item should exist in the Queue after Add"); return Task.CompletedTask; }); diff --git a/Tests/MatterControl.AutomationTests/PartPreviewTests.cs b/Tests/MatterControl.AutomationTests/PartPreviewTests.cs index bcb0fa93b..a14765928 100644 --- a/Tests/MatterControl.AutomationTests/PartPreviewTests.cs +++ b/Tests/MatterControl.AutomationTests/PartPreviewTests.cs @@ -187,7 +187,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.Select3DPart("Calibration - Box.stl"); // Click Edit button to make edit controls visible - testRunner.WaitForName("3D View Copy", 3); + testRunner.WaitForName("3D View Copy"); testRunner.Delay(1); // wait for window to finish opening Assert.AreEqual(1, view3D.Scene.Children.Count, "Should have 1 part before copy"); diff --git a/Tests/MatterControl.AutomationTests/PrintingTests.cs b/Tests/MatterControl.AutomationTests/PrintingTests.cs index 98cf6d45e..4facb4b70 100644 --- a/Tests/MatterControl.AutomationTests/PrintingTests.cs +++ b/Tests/MatterControl.AutomationTests/PrintingTests.cs @@ -215,8 +215,6 @@ namespace MatterHackers.MatterControl.Tests.Automation { await MatterControlUtilities.RunTest((testRunner) => { - testRunner.WaitForName("Cancel Wizard Button", 1); - using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator()) { Assert.IsTrue(ProfileManager.Instance.ActiveProfile != null); @@ -238,12 +236,15 @@ namespace MatterHackers.MatterControl.Tests.Automation emulator.SimulateLineErrors = true; // close the pause dialog pop-up (resume) + testRunner.WaitForName("No Button", 90); testRunner.ClickByName("No Button"); // simulate board reboot emulator.SimulateReboot(); // close the pause dialog pop-up (resume) + testRunner.Delay(3); + testRunner.WaitForName("No Button", 90); testRunner.ClickByName("No Button"); // Wait for done @@ -264,9 +265,7 @@ namespace MatterHackers.MatterControl.Tests.Automation await MatterControlUtilities.RunTest((testRunner) => { - SystemWindow systemWindow; - - testRunner.WaitForName("Cancel Wizard Button", 1); + testRunner.WaitForName("Cancel Wizard Button"); using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator()) { @@ -282,7 +281,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.ClickByName("Start Print Button"); - var container = testRunner.GetWidgetByName("ManualPrinterControls.ControlsContainer", out systemWindow, 5); + var container = testRunner.GetWidgetByName("ManualPrinterControls.ControlsContainer", out _, 5); // Scroll the widget into view var scrollable = container.Parents().First().Children().First(); @@ -353,7 +352,7 @@ namespace MatterHackers.MatterControl.Tests.Automation await MatterControlUtilities.RunTest((testRunner) => { - testRunner.WaitForName("Cancel Wizard Button", 1); + testRunner.WaitForName("Cancel Wizard Button"); // Set custom adjustment values FeedRateMultiplyerStream.FeedRateRatio = initialFeedRate; @@ -437,7 +436,7 @@ namespace MatterHackers.MatterControl.Tests.Automation { await MatterControlUtilities.RunTest((testRunner) => { - testRunner.WaitForName("Cancel Wizard Button", 1); + testRunner.WaitForName("Cancel Wizard Button"); using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator()) { @@ -481,7 +480,7 @@ namespace MatterHackers.MatterControl.Tests.Automation { await MatterControlUtilities.RunTest((testRunner) => { - testRunner.WaitForName("Cancel Wizard Button", 1); + testRunner.WaitForName("Cancel Wizard Button"); using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator()) { diff --git a/Tests/MatterControl.AutomationTests/SqLiteLibraryProvider.cs b/Tests/MatterControl.AutomationTests/SqLiteLibraryProvider.cs index a29d5e13b..5fdeae79a 100644 --- a/Tests/MatterControl.AutomationTests/SqLiteLibraryProvider.cs +++ b/Tests/MatterControl.AutomationTests/SqLiteLibraryProvider.cs @@ -38,7 +38,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.NavigateToFolder("Local Library Row Item Collection"); // ensure that it is now in the library folder (that the folder updated) - Assert.IsTrue(testRunner.WaitForName("Row Item 0Test Part", 5), "The part we added should be in the library"); + Assert.IsTrue(testRunner.WaitForName("Row Item 0Test Part"), "The part we added should be in the library"); testRunner.Delay(.5); diff --git a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs index b1868888e..d738061fe 100644 --- a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs +++ b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs @@ -204,8 +204,7 @@ namespace MatterHackers.MatterControl.Tests.Automation emulator.Startup(); // edit the com port - SystemWindow containingWindow; - var editButton = testRunner.GetWidgetByName("Edit Printer Button", out containingWindow); + var editButton = testRunner.GetWidgetByName("Edit Printer Button", out _); testRunner.Delay(() => editButton.Enabled, 5); // Wait until the edit button is ready to click it. Ensures the printer is loaded. testRunner.ClickByName("Edit Printer Button"); @@ -219,7 +218,7 @@ namespace MatterHackers.MatterControl.Tests.Automation // connect to the created printer testRunner.ClickByName("Connect to printer button"); - testRunner.WaitForName("Disconnect from printer button", 5); + testRunner.WaitForName("Disconnect from printer button"); return emulator; } @@ -609,7 +608,7 @@ namespace MatterHackers.MatterControl.Tests.Automation foreach (string assetName in assetNames) { string friendlyName = Path.GetFileNameWithoutExtension(assetName); - Assert.IsTrue(testRunner.WaitForName($"Row Item {friendlyName}", 2), $"{friendlyName} part should exist after adding"); + Assert.IsTrue(testRunner.WaitForName($"Row Item {friendlyName}", 0.5), $"{friendlyName} part should exist after adding"); } }