From c3f55a40fd5dbbb4064d5a3d1ff26ba641e920ff Mon Sep 17 00:00:00 2001 From: John Lewin Date: Fri, 5 Oct 2018 14:21:55 -0700 Subject: [PATCH] Add reusable CreateChildFolder method --- .../LibraryDownloadsTest.cs | 11 ++--------- .../LocalLibraryTests.cs | 15 ++------------- .../MatterControl/MatterControlUtilities.cs | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/Tests/MatterControl.AutomationTests/LibraryDownloadsTest.cs b/Tests/MatterControl.AutomationTests/LibraryDownloadsTest.cs index dc17cc109..09113412c 100644 --- a/Tests/MatterControl.AutomationTests/LibraryDownloadsTest.cs +++ b/Tests/MatterControl.AutomationTests/LibraryDownloadsTest.cs @@ -60,7 +60,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.NavigateToFolder("Downloads Row Item Collection"); testRunner.NavigateToFolder("-Temporary Row Item Collection"); - // Add AMF part items to Downloads and then type paths into file dialog + // Add AMF part items to Downloads and then type paths into file dialog testRunner.InvokeLibraryAddDialog(); testRunner.CompleteDialog(MatterControlUtilities.GetTestItemPath("Rook.amf"), 4); @@ -137,14 +137,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.NavigateToFolder("Downloads Row Item Collection"); testRunner.NavigateToFolder("-Temporary Row Item Collection"); - string newFolderName = "New Folder"; - - testRunner.InvokeLibraryCreateFolderDialog(); - testRunner.WaitForName("InputBoxPage Action Button"); - testRunner.Type(newFolderName); - testRunner.ClickByName("InputBoxPage Action Button"); - - Assert.IsTrue(testRunner.WaitForName(newFolderName + " Row Item Collection"), $"{newFolderName} exists"); + testRunner.CreateChildFolder("New Folder"); return Task.CompletedTask; }); diff --git a/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs b/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs index bd50e3292..7f251b5af 100644 --- a/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs +++ b/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs @@ -70,7 +70,6 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.DoubleClickByName("Batman Row Item Collection"); - Assert.IsTrue(testRunner.WaitForName("Row Item Batman.stl"), "Batman part should exist after adding"); Assert.IsTrue(testRunner.WaitForName("Row Item 2013-01-25_Mouthpiece_v2.stl"), "Mouthpiece part should exist after adding"); @@ -118,19 +117,9 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.NavigateToFolder("Local Library Row Item Collection"); // Create New Folder - testRunner.InvokeLibraryCreateFolderDialog(); - testRunner.Delay(.5); + string folderID = testRunner.CreateChildFolder("New Folder"); - testRunner.Type("New Folder"); - testRunner.Delay(.5); - - testRunner.ClickByName("InputBoxPage Action Button"); - testRunner.Delay(.2); - - // Confirm newly created folder exists - Assert.IsTrue(testRunner.WaitForName("New Folder Row Item Collection"), "New folder should appear as GuiWidget"); - - testRunner.ClickByName("New Folder Row Item Collection"); + testRunner.ClickByName(folderID); testRunner.Delay(.2); testRunner.LibraryRenameSelectedItem(); diff --git a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs index 01b8a4674..a961398b1 100644 --- a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs +++ b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs @@ -516,6 +516,20 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.ClickByName("Create Folder Menu Item"); } + public static string CreateChildFolder(this AutomationRunner testRunner, string folderName) + { + testRunner.InvokeLibraryCreateFolderDialog(); + testRunner.WaitForName("InputBoxPage Action Button"); + testRunner.Type(folderName); + testRunner.ClickByName("InputBoxPage Action Button"); + + string folderID = $"{folderName} Row Item Collection"; + + Assert.IsTrue(testRunner.WaitForName(folderID), $"{folderName} exists"); + + return folderID; + } + /// /// Types the specified text into the dialog and sends {Enter} to complete the interaction ///