Added Android Automated tests to be incorporated at a later date

This commit is contained in:
Gregory Diaz 2016-01-15 17:39:19 -08:00
parent d7bc6af53d
commit c64bef5be2
3 changed files with 74 additions and 30 deletions

View file

@ -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));

View file

@ -22,7 +22,7 @@ namespace MatterControl.AutomationTests
{
[Test, RequiresSTA, RunInApplicationDomain]
public void DownloadsExportButtonExportsGcode()
public void ExportAsGcode()
{
// Run a copy of MatterControl
Action<AutomationTesterHarness> 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);
}
}

View file

@ -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;
}
}
}