From c64bef5be2336d721493e9771db4657fd2dd79ce Mon Sep 17 00:00:00 2001 From: Gregory Diaz Date: Fri, 15 Jan 2016 17:39:19 -0800 Subject: [PATCH] Added Android Automated tests to be incorporated at a later date --- Queue/QueueDataWidget.cs | 2 +- .../ExportItemWindowTests.cs | 44 +++++--------- Utilities/PerformanceTests.cs | 58 +++++++++++++++++++ 3 files changed, 74 insertions(+), 30 deletions(-) diff --git a/Queue/QueueDataWidget.cs b/Queue/QueueDataWidget.cs index 4e9bc3c6a..b65e3b92b 100644 --- a/Queue/QueueDataWidget.cs +++ b/Queue/QueueDataWidget.cs @@ -241,7 +241,7 @@ namespace MatterHackers.MatterControl.PrintQueue editButtonFactory.FixedWidth = 0; Button exportItemButton = editButtonFactory.Generate("Export".Localize()); - exportItemButton.Name = "Export Queue Button"; + exportItemButton.Name = "Queue Export Button"; exportItemButton.Margin = new BorderDouble(3, 0); exportItemButton.Click += new EventHandler(exportButton_Click); editButtonsEnableData.Add(new ButtonEnableData(false, false, false)); diff --git a/Tests/MatterControl.AutomationTests/ExportItemWindowTests.cs b/Tests/MatterControl.AutomationTests/ExportItemWindowTests.cs index 597a2c13c..0fc489ae5 100644 --- a/Tests/MatterControl.AutomationTests/ExportItemWindowTests.cs +++ b/Tests/MatterControl.AutomationTests/ExportItemWindowTests.cs @@ -22,7 +22,7 @@ namespace MatterControl.AutomationTests { [Test, RequiresSTA, RunInApplicationDomain] - public void DownloadsExportButtonExportsGcode() + public void ExportAsGcode() { // Run a copy of MatterControl Action testToRun = (AutomationTesterHarness resultsHarness) => @@ -32,38 +32,30 @@ namespace MatterControl.AutomationTests MatterControlUtilities.SelectAndAddPrinter(testRunner, "Airwolf 3D", "HD"); - string firstItemName = "Row Item " + "Batman"; - + string firstItemName = "Row Item Batman"; //Navigate to Downloads Library Provider - testRunner.ClickByName("Library Tab"); - MatterControlUtilities.NavigateToFolder(testRunner, "Downloads Row Item Collection"); - testRunner.ClickByName("Library Add Button"); - testRunner.Wait(2); + testRunner.ClickByName("Queue Tab"); + testRunner.ClickByName("Queue Add Button", 2); //Get parts to add string rowItemPath = MatterControlUtilities.GetTestItemPath("Batman.stl"); - //Get files to delete from Downloads once each test has completed and then add them to List - string firstFileToDelete = Path.Combine(MatterControlUtilities.PathToDownloadsSubFolder, "Batman.stl"); - - //Add STL part items to Downloads and then type paths into file dialogue - testRunner.Wait(2); - testRunner.Type(rowItemPath); + testRunner.Wait(1); + testRunner.Type(MatterControlUtilities.GetTestItemPath("Batman.stl")); testRunner.Wait(1); testRunner.Type("{Enter}"); //Get test results - bool firstRowItemWasAdded = testRunner.WaitForName(firstItemName, 2); - resultsHarness.AddTestResult(firstRowItemWasAdded == true); + resultsHarness.AddTestResult(testRunner.WaitForName(firstItemName, 2) == true); - testRunner.ClickByName("Library Edit Button"); + testRunner.ClickByName("Queue Edit Button"); testRunner.ClickByName(firstItemName); - testRunner.ClickByName("Library Export Button"); + testRunner.ClickByName("Queue Export Button"); testRunner.Wait(2); - //testRunner.WaitForName("Export Item Window", 2); - testRunner.ClickByName("Export as GCode Button"); + testRunner.WaitForName("Export Item Window", 2); + testRunner.ClickByName("Export as GCode Button", 2); testRunner.Wait(2); string gcodeExportPath = MatterControlUtilities.PathToExportGcodeFolder; @@ -71,25 +63,19 @@ namespace MatterControl.AutomationTests testRunner.Type("{Enter}"); testRunner.Wait(2); - bool gcodeExported = false; - - if (File.Exists(gcodeExportPath)) - { - gcodeExported = true; - } - - resultsHarness.AddTestResult(gcodeExported == true); + Console.WriteLine(gcodeExportPath); + resultsHarness.AddTestResult(File.Exists(gcodeExportPath) == true); + Debugger.Break(); MatterControlUtilities.CloseMatterControl(testRunner); } }; AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun); - //MatterControlUtilities.CleanUpDownloadsDirectoryAfterTest(addedFiles); Assert.IsTrue(testHarness.AllTestsPassed); - Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests + Assert.IsTrue(testHarness.TestCount == 2); } } diff --git a/Utilities/PerformanceTests.cs b/Utilities/PerformanceTests.cs index 0e7fbf647..0117452db 100644 --- a/Utilities/PerformanceTests.cs +++ b/Utilities/PerformanceTests.cs @@ -125,5 +125,63 @@ namespace MatterHackers.MatterControl container.DrawBefore += beforeDraw; } + + public static void CreateButtonOpensPluginWindow(GuiWidget container, double secondsBetweenClicks = .1) + { + //To run test invoke method in the queue data widget + AutomationRunner testRunner; + DrawEventHandler beforeDraw = null; + beforeDraw = (sender, e) => + { + testRunner = new AutomationRunner(); + Task.Run(() => + { + testRunner.ClickByName("Queue Tab"); + testRunner.ClickByName("Design Tool Button"); + }); + container.DrawBefore -= beforeDraw; + }; + container.DrawBefore += beforeDraw; + + } + + public static void AddLocalLibraryItemToQueue(GuiWidget container, double secondsBetweenClicks = .1) + { + AutomationRunner testrunner; + DrawEventHandler beforeDraw = null; + beforeDraw = (sender, e) => + { + testrunner = new AutomationRunner(); + Task.Run(() => + { + testrunner.ClickByName("Library Tab"); + NavigateToFolder(testrunner, "Local Library Row Item Collection"); + + testrunner.ClickByName("Library Edit Button"); + testrunner.ClickByName("Row Item Calibration - Box"); + testrunner.Wait(2); + testrunner.ClickByName("Library Add To Queue Button"); + testrunner.ClickByName("Queue Tab"); + + + }); + container.DrawBefore -= beforeDraw; + }; + container.DrawBefore += beforeDraw; + } + + //This is Temporary and will probably be moved once we get a functional test harness!!! + public static bool NavigateToFolder(AutomationRunner testRunner, string libraryRowItemName) + { + bool goodNavigate = true; + SearchRegion libraryRowItemRegion = testRunner.GetRegionByName(libraryRowItemName, 3); + goodNavigate &= testRunner.ClickByName(libraryRowItemName); + goodNavigate &= testRunner.MoveToByName(libraryRowItemName); + testRunner.Wait(.5); + goodNavigate &= testRunner.ClickByName("Open Collection", searchRegion: libraryRowItemRegion); + testRunner.Wait(.5); + + return goodNavigate; + } } } \ No newline at end of file