From a1e49bb1e775b173a463cdde38fc2f074e2da629 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Sun, 21 May 2017 17:36:09 -0700 Subject: [PATCH] Fix QueueAddButtonAddsGcodeFile test - Rename to AddGCodeFile - Update to new format - Remove testToRun variable, pass lambda directly - Issue MatterHackers/MCCentral#1504 --- .../PrintQueueTests.cs | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Tests/MatterControl.AutomationTests/PrintQueueTests.cs b/Tests/MatterControl.AutomationTests/PrintQueueTests.cs index 68924d6d1..ffb571494 100644 --- a/Tests/MatterControl.AutomationTests/PrintQueueTests.cs +++ b/Tests/MatterControl.AutomationTests/PrintQueueTests.cs @@ -781,32 +781,34 @@ namespace MatterHackers.MatterControl.Tests.Automation } [Test, Apartment(ApartmentState.STA)] - public async Task QueueAddButtonAddsGcodeFile() + public async Task AddGCodeFile() { - AutomationTest testToRun = (testRunner) => + await MatterControlUtilities.RunTest((testRunner) => { + // Expected = initial + 1 + int expectedCount = QueueData.Instance.ItemCount + 1; + testRunner.CloseSignInAndPrinterSelect(); - int initialQueueCount = QueueData.Instance.ItemCount; + testRunner.ChangeToQueueContainer(); - // Click Add button - testRunner.ClickByName("Queue Add Button"); - testRunner.Delay(1); + // Click Add button and select files + testRunner.ClickByName("Library Add Button", 2); + testRunner.WaitForName("Automation Dialog TextEdit", 3); testRunner.Type(MatterControlUtilities.GetTestItemPath("chichen-itza_pyramid.gcode")); testRunner.Delay(1); testRunner.Type("{Enter}"); - // Widget should exist - Assert.IsTrue(testRunner.WaitForName("Queue Item chichen-itza_pyramid", 5), "Widget for added item should exist in control tree"); + // Wait up to 3 seconds for expected outcome + testRunner.Delay(() => QueueData.Instance.ItemCount == expectedCount, 3); - // Queue count should increases by one - Assert.AreEqual(initialQueueCount + 1, QueueData.Instance.ItemCount, "After adding item, queue count should increase by one"); + // Assert - one part added and queue count increases by one + Assert.AreEqual(expectedCount, QueueData.Instance.ItemCount, "Queue count should increase by 1 when adding 1 item"); + Assert.IsTrue(testRunner.WaitForName("Row Item chichen-itza_pyramid.gcode", 2), "Named widget should exist after add(chichen-itza)"); return Task.FromResult(0); - }; - - await MatterControlUtilities.RunTest(testToRun); + }); } } }