Added more automated Local Library Tests

This commit is contained in:
Gregory Diaz 2015-11-13 18:06:44 -08:00
parent 419961d8ef
commit 3172da7b55
7 changed files with 163 additions and 6 deletions

View file

@ -46,6 +46,7 @@ namespace MatterHackers.MatterControl
this.Title = McExportFileTitleFull;
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
this.Name = "Export Item Window";
CreateWindowContent();
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(ReloadAfterPrinterProfileChanged, ref unregisterEvents);
@ -235,6 +236,7 @@ namespace MatterHackers.MatterControl
}
Button cancelButton = textImageButtonFactory.Generate("Cancel");
cancelButton.Name = "Export Item Window Cancel Button";
cancelButton.Cursor = Cursors.Hand;
cancelButton.Click += (sender, e) =>
{

View file

@ -332,12 +332,14 @@ namespace MatterHackers.MatterControl.PrintLibrary
editButtonFactory.FixedWidth = 0;
Button exportItemButton = editButtonFactory.Generate("Export".Localize());
exportItemButton.Name = "Library Export Button";
exportItemButton.Margin = new BorderDouble(3, 0);
exportItemButton.Click += exportButton_Click;
editButtonsEnableData.Add(new ButtonEnableData(false, false, false));
itemOperationButtons.AddChild(exportItemButton);
Button editItemButton = editButtonFactory.Generate("Edit".Localize());
editItemButton.Name = "Library Edit Item Button";
editItemButton.Margin = new BorderDouble(3, 0);
editItemButton.Click += editButton_Click;
editButtonsEnableData.Add(new ButtonEnableData(false, false, false));
@ -346,6 +348,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
// add the remove button
{
Button removeFromLibraryButton = editButtonFactory.Generate("Remove".Localize());
removeFromLibraryButton.Name = "Library Remove Item Button";
removeFromLibraryButton.Margin = new BorderDouble(3, 0);
removeFromLibraryButton.Click += deleteFromLibraryButton_Click;
editButtonsEnableData.Add(new ButtonEnableData(true, false, true));

View file

@ -49,6 +49,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
string partPreviewTitle = LocalizedString.Get("MatterControl");
Title = string.Format("{0}: ", partPreviewTitle) + Path.GetFileName(printItem.Name);
this.Name = "Part Preview Window";
partPreviewWidget = new PartPreviewContent(printItem, View3DWidget.WindowMode.StandAlone, autoRotate3DView, openMode);
partPreviewWidget.Closed += (sender, e) =>
{

View file

@ -635,7 +635,6 @@ namespace MatterHackers.MatterControl.PrintQueue
if (exportingWindowIsOpen == false)
{
exportingWindow = new ExportPrintItemWindow(printItem);
exportingWindow.Name = "Export Window Queue";
this.exportingWindowIsOpen = true;
exportingWindow.Closed += (source, e) => this.exportingWindowIsOpen = false;
exportingWindow.ShowAsSystemWindow();

@ -1 +1 @@
Subproject commit 4af867ee01ebaec1d3e82a069ed9528178e1dba8
Subproject commit 3a5be63fcbea303f96cbf44754416151834a5949

View file

@ -139,12 +139,12 @@ namespace MatterHackers.MatterControl.UI
*/
//Make sure that the export window does not exist
bool exportWindowExists1 = testRunner.WaitForName( "Export Window Queue", 0);
bool exportWindowExists1 = testRunner.WaitForName( "Export Item Window", 0);
resultsHarness.AddTestResult(exportWindowExists1 == false, "Export window does not exist");
testRunner.ClickByName("Export Queue Button", 5);
SystemWindow containingWindow;
GuiWidget exportWindow = testRunner.GetWidgetByName("Export Window Queue", out containingWindow, 5);
GuiWidget exportWindow = testRunner.GetWidgetByName("Export Item Window", out containingWindow, 5);
resultsHarness.AddTestResult(exportWindow != null, "Export window does exist");
if (exportWindow != null)
{
@ -213,7 +213,7 @@ namespace MatterHackers.MatterControl.UI
testRunner.ClickByName("Queue Item Thumbnail");
SystemWindow containingWindow;
GuiWidget partPreviewWindowExists = testRunner.GetWidgetByName("Part Preview Window Thumbnail", out containingWindow, 3);
GuiWidget partPreviewWindowExists = testRunner.GetWidgetByName("Part Preview Window", out containingWindow, 3);
resultsHarness.AddTestResult(partPreviewWindowExists != null, "Part Preview Window Exists");
partPreviewWindowExists.CloseOnIdle();
testRunner.Wait(.5);

View file

@ -273,7 +273,7 @@ namespace MatterHackers.MatterControl.UI
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
public class UserCanSuccessfullyCreateLibraryFolder
public class UserCanSuccessfullyCreateAndRenameLibraryFolder
{
[Test, RequiresSTA, RunInApplicationDomain]
public void RenameButtonRenameLocalLibraryItem()
@ -299,6 +299,97 @@ namespace MatterHackers.MatterControl.UI
bool newFolderWasCreated = testRunner.WaitForName(newLibraryFolder, 1);
resultsHarness.AddTestResult(newFolderWasCreated == true);
testRunner.ClickByName("Library Edit Button");
testRunner.ClickByName("New Folder Row Item Collection");
testRunner.ClickByName("Rename From Library Button");
testRunner.Wait(1);
testRunner.Type("Renamed Library Folder");
testRunner.ClickByName("Rename Button");
//Make sure that renamed Library Folder Exists
bool renamedLibraryFolderExists = testRunner.WaitForName("Renamed Library Folder Row Item Collection", 2);
resultsHarness.AddTestResult(renamedLibraryFolderExists == true);
MatterControlUtilities.CloseMatterControl(testRunner);
}
};
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);
Assert.IsTrue(testHarness.AllTestsPassed);
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
}
}
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
public class LibraryEditButtonOpensUpPartPreviewWindow
{
[Test, RequiresSTA, RunInApplicationDomain]
public void ClickLibraryEditButtonOpensPartPreviewWindow()
{
// Run a copy of MatterControl
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
{
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
{
//Navigate to Local Library
testRunner.ClickByName("Library Tab");
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
testRunner.Wait(1);
string rowItem = "Row Item " + "Calibration - Box";
testRunner.ClickByName("Library Edit Button");
testRunner.Wait(1);
testRunner.ClickByName(rowItem);
testRunner.ClickByName("Library Edit Item Button");
//Make sure that Export Item Window exists after Export button is clicked
bool exportItemWindowExists = testRunner.WaitForName("Part Preview Window", 2);
resultsHarness.AddTestResult(exportItemWindowExists == true);
MatterControlUtilities.CloseMatterControl(testRunner);
}
};
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);
Assert.IsTrue(testHarness.AllTestsPassed);
Assert.IsTrue(testHarness.TestCount == 1); // make sure we ran all our tests
}
}
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
public class OneLibraryItemSelectedRemoveButtonRemovesItem
{
[Test, RequiresSTA, RunInApplicationDomain]
public void RemoveButtonClickedRemovesSingleItem()
{
// Run a copy of MatterControl
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
{
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
{
//Navigate to Local Library
testRunner.ClickByName("Library Tab");
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
testRunner.Wait(1);
string rowItem = "Row Item " + "Calibration - Box";
testRunner.ClickByName("Library Edit Button");
testRunner.Wait(1);
testRunner.ClickByName(rowItem);
testRunner.ClickByName("Library Remove Item Button");
testRunner.Wait(1);
//Make sure that Export Item Window exists after Export button is clicked
bool rowItemExists = testRunner.WaitForName(rowItem, 2);
resultsHarness.AddTestResult(rowItemExists == false);
MatterControlUtilities.CloseMatterControl(testRunner);
}
};
@ -311,6 +402,66 @@ namespace MatterHackers.MatterControl.UI
}
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
public class MultipleLibraryItemsSelectedRemoveButtonRemovesItem
{
[Test, RequiresSTA, RunInApplicationDomain]
public void RemoveButtonClickedRemovesMultipleItems()
{
// Run a copy of MatterControl
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
{
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
{
//Navigate to Local Library
testRunner.ClickByName("Library Tab");
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
testRunner.Wait(1);
testRunner.ClickByName("Library Edit Button");
testRunner.Wait(1);
string rowItemPath = MatterControlUtilities.PathToQueueItemsFolder("Fennec_Fox.stl");
testRunner.ClickByName("Library Add Button");
testRunner.Wait(2);
testRunner.Type(rowItemPath);
testRunner.Type("{Enter}");
string rowItemOne = "Row Item " + "Calibration - Box";
testRunner.ClickByName(rowItemOne);
string rowItemTwo = "Row Item " + "Fennec Fox";
testRunner.ClickByName(rowItemTwo);
testRunner.Wait(1);
//Make sure row items exist before remove
bool rowItemOneExistsBeforeRemove = testRunner.WaitForName(rowItemOne, 2);
bool rowItemTwoExistsBeforeRemove = testRunner.WaitForName(rowItemTwo, 2);
resultsHarness.AddTestResult(rowItemOneExistsBeforeRemove == true);
resultsHarness.AddTestResult(rowItemTwoExistsBeforeRemove == true);
testRunner.ClickByName("Library Remove Item Button");
testRunner.Wait(1);
//Make sure both selected items are removed
bool rowItemOneExists = testRunner.WaitForName(rowItemOne, 2);
bool rowItemTwoExists = testRunner.WaitForName(rowItemTwo, 2);
resultsHarness.AddTestResult(rowItemOneExists == false);
resultsHarness.AddTestResult(rowItemTwoExists == false);
MatterControlUtilities.CloseMatterControl(testRunner);
}
};
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);
Assert.IsTrue(testHarness.AllTestsPassed);
Assert.IsTrue(testHarness.TestCount == 4); // make sure we ran all our tests
}
}