Added some automated tests around Local Library functionality
This commit is contained in:
parent
9b3a34257c
commit
66dc5b9a57
6 changed files with 324 additions and 2 deletions
|
|
@ -81,6 +81,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
|
||||
Button createFolderButton = textImageButtonFactory.Generate("Create".Localize(), centerText: true);
|
||||
createFolderButton.Name = "Create Folder Button";
|
||||
createFolderButton.Visible = true;
|
||||
createFolderButton.Cursor = Cursors.Hand;
|
||||
buttonRow.AddChild(createFolderButton);
|
||||
|
|
|
|||
|
|
@ -268,6 +268,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
addToLibraryButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
|
||||
addToLibraryButton.Enabled = false; // The library selector (the first library selected) is protected so we can't add to it.
|
||||
addToLibraryButton.ToolTipText = "Add an .stl, .amf, .gcode or .zip file to the Library".Localize();
|
||||
addToLibraryButton.Name = "Library Add Button";
|
||||
buttonPanel.AddChild(addToLibraryButton);
|
||||
addToLibraryButton.Margin = new BorderDouble(0, 0, 3, 0);
|
||||
addToLibraryButton.Click += (sender, e) => UiThread.RunOnIdle(importToLibraryloadFile_ClickOnIdle);
|
||||
|
|
@ -277,7 +278,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
createFolderButton = textImageButtonFactory.Generate(LocalizedString.Get("Create Folder"));
|
||||
createFolderButton.Enabled = false; // The library selector (the first library selected) is protected so we can't add to it.
|
||||
createFolderButton.Name = "Create Folder Button";
|
||||
createFolderButton.Name = "Create Folder From Library Button";
|
||||
buttonPanel.AddChild(createFolderButton);
|
||||
createFolderButton.Margin = new BorderDouble(0, 0, 3, 0);
|
||||
createFolderButton.Click += (sender, e) =>
|
||||
|
|
@ -368,6 +369,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
// add a rename button
|
||||
{
|
||||
Button renameFromLibraryButton = editButtonFactory.Generate("Rename".Localize());
|
||||
renameFromLibraryButton.Name = "Rename From Library Button";
|
||||
renameFromLibraryButton.Margin = new BorderDouble(3, 0);
|
||||
editButtonsEnableData.Add(new ButtonEnableData(false, false, true));
|
||||
itemOperationButtons.AddChild(renameFromLibraryButton);
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
|
||||
Button renameItemButton = textImageButtonFactory.Generate("Rename".Localize(), centerText: true);
|
||||
renameItemButton.Name = "Rename Button";
|
||||
renameItemButton.Visible = true;
|
||||
renameItemButton.Cursor = Cursors.Hand;
|
||||
buttonRow.AddChild(renameItemButton);
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@
|
|||
<Compile Include="MatterControl\AutomationTests\SqLiteLibraryProvider.cs" />
|
||||
<Compile Include="MatterControl\LibraryProviderSqliteTests.cs" />
|
||||
<Compile Include="MatterControl\AutomationTests\CreateLibraryFolder.cs" />
|
||||
<Compile Include="MatterControl\LocalLibraryTests.cs" />
|
||||
<Compile Include="MatterControl\MatterControlUiFeatures.cs" />
|
||||
<Compile Include="MatterControl\MatterControlUtilities.cs" />
|
||||
<Compile Include="MatterControl\HtmlParser.cs" />
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
{
|
||||
testRunner.ClickByName("Library Tab");
|
||||
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
|
||||
testRunner.ClickByName("Create Folder Button");
|
||||
testRunner.ClickByName("Create Folder From Library Button");
|
||||
|
||||
testRunner.Wait(.5);
|
||||
testRunner.Type("Test Text");
|
||||
|
|
|
|||
317
Tests/MatterControl.Tests/MatterControl/LocalLibraryTests.cs
Normal file
317
Tests/MatterControl.Tests/MatterControl/LocalLibraryTests.cs
Normal file
|
|
@ -0,0 +1,317 @@
|
|||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.UI;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.GuiAutomation;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using System.IO;
|
||||
using MatterHackers.MatterControl.CreatorPlugins;
|
||||
using MatterHackers.Agg.UI.Tests;
|
||||
using MatterHackers.MatterControl.PrintQueue;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace MatterHackers.MatterControl.UI
|
||||
{
|
||||
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
|
||||
public class AddSingleItemToLocalLibrary
|
||||
{
|
||||
[Test, RequiresSTA, RunInApplicationDomain]
|
||||
public void LocalLibraryAddButtonAddSingleItemToLibrary()
|
||||
{
|
||||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
|
||||
string itemName = "Row Item " + "Fennec Fox";
|
||||
|
||||
|
||||
//Navigate to Local Library
|
||||
testRunner.ClickByName("Library Tab");
|
||||
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
|
||||
|
||||
//Make sure that Item does not exist before the test begins
|
||||
bool rowItemExists = testRunner.WaitForName(itemName, 1);
|
||||
resultsHarness.AddTestResult(rowItemExists == false);
|
||||
|
||||
//Click Local Library Add Button
|
||||
testRunner.ClickByName("Library Add Button");
|
||||
|
||||
//Get Library Item to Add
|
||||
string rowItemPath = MatterControlUtilities.PathToQueueItemsFolder("Fennec_Fox.stl");
|
||||
testRunner.Wait(2);
|
||||
testRunner.Type(rowItemPath);
|
||||
testRunner.Wait(1);
|
||||
testRunner.Type("{Enter}");
|
||||
|
||||
bool rowItemWasAdded = testRunner.WaitForName(itemName, 2);
|
||||
resultsHarness.AddTestResult(rowItemWasAdded == 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 AddMultipleItemsToLocalLibrary
|
||||
{
|
||||
[Test, RequiresSTA, RunInApplicationDomain]
|
||||
public void LocalLibraryAddButtonAddsMultipleItemsToLibrary()
|
||||
{
|
||||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
|
||||
|
||||
//Names of Items to be added
|
||||
string firstItemName = "Row Item " + "Fennec Fox";
|
||||
string secondItemName = "Row Item " + "Batman";
|
||||
|
||||
//Navigate to Local Library
|
||||
testRunner.ClickByName("Library Tab");
|
||||
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
|
||||
|
||||
//Make sure both Items do not exist before the test begins
|
||||
bool firstItemExists= testRunner.WaitForName(firstItemName, 1);
|
||||
bool secondItemExists = testRunner.WaitForName(secondItemName, 1);
|
||||
resultsHarness.AddTestResult(firstItemExists == false);
|
||||
resultsHarness.AddTestResult(secondItemExists == false);
|
||||
|
||||
//Click Local Library Add Button
|
||||
testRunner.ClickByName("Library Add Button");
|
||||
|
||||
//Get Library Item to Add
|
||||
string firstRowItemPath = MatterControlUtilities.PathToQueueItemsFolder("Fennec_Fox.stl");
|
||||
string secondRowItemPath = MatterControlUtilities.PathToQueueItemsFolder("Batman.stl");
|
||||
|
||||
string textForBothRowItems = String.Format("\"{0}\" \"{1}\"", firstRowItemPath, secondRowItemPath);
|
||||
testRunner.Wait(2);
|
||||
testRunner.Type(textForBothRowItems);
|
||||
testRunner.Wait(1);
|
||||
testRunner.Type("{Enter}");
|
||||
|
||||
|
||||
bool firstRowItemWasAdded = testRunner.WaitForName(firstItemName, 2);
|
||||
bool secondRowItemWasAdded = testRunner.WaitForName(secondItemName, 2);
|
||||
resultsHarness.AddTestResult(firstRowItemWasAdded == true);
|
||||
resultsHarness.AddTestResult(secondRowItemWasAdded == true);
|
||||
|
||||
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);
|
||||
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 4); // make sure we ran all our tests
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
|
||||
public class AddAMFItemToLocalLibrary
|
||||
{
|
||||
[Test, RequiresSTA, RunInApplicationDomain]
|
||||
public void LocalLibraryAddButtonAddAMFToLibrary()
|
||||
{
|
||||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
|
||||
string itemName = "Row Item " + "Rook";
|
||||
|
||||
//Navigate to Local Library
|
||||
testRunner.ClickByName("Library Tab");
|
||||
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
|
||||
|
||||
//Make sure that Item does not exist before the test begins
|
||||
bool rowItemExists = testRunner.WaitForName(itemName, 1);
|
||||
resultsHarness.AddTestResult(rowItemExists == false);
|
||||
|
||||
//Click Local Library Add Button
|
||||
testRunner.ClickByName("Library Add Button");
|
||||
|
||||
//Get Library Item to Add
|
||||
string rowItemPath = MatterControlUtilities.PathToQueueItemsFolder("Rook.amf");
|
||||
testRunner.Wait(2);
|
||||
testRunner.Type(rowItemPath);
|
||||
testRunner.Wait(1);
|
||||
testRunner.Type("{Enter}");
|
||||
|
||||
bool rowItemWasAdded = testRunner.WaitForName(itemName, 2);
|
||||
resultsHarness.AddTestResult(rowItemWasAdded == 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 AddZipFileToLocalLibrary
|
||||
{
|
||||
[Test, RequiresSTA, RunInApplicationDomain]
|
||||
public void LocalLibraryAddButtonAddZipToLibrary()
|
||||
{
|
||||
// Run a copy of MatterControl
|
||||
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
|
||||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
|
||||
//Items in Batman.zip
|
||||
string firstItemName = "Row Item " + "Batman";
|
||||
string secondItemName = "Row Item " + "2013-01-25 Mouthpiece v2";
|
||||
|
||||
//Navigate to Local Library
|
||||
testRunner.ClickByName("Library Tab");
|
||||
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
|
||||
|
||||
//Make sure that Item does not exist before the test begins
|
||||
bool firstItemInZipExists = testRunner.WaitForName(firstItemName, 1);
|
||||
bool secondItemInZipExists = testRunner.WaitForName(secondItemName, 1);
|
||||
resultsHarness.AddTestResult(firstItemInZipExists == false);
|
||||
resultsHarness.AddTestResult(firstItemInZipExists == false);
|
||||
|
||||
//Click Local Library Add Button
|
||||
testRunner.ClickByName("Library Add Button");
|
||||
|
||||
//Get Library Item to Add
|
||||
string rowItemPath = MatterControlUtilities.PathToQueueItemsFolder("Batman.zip");
|
||||
testRunner.Wait(2);
|
||||
testRunner.Type(rowItemPath);
|
||||
testRunner.Wait(1);
|
||||
testRunner.Type("{Enter}");
|
||||
|
||||
bool firstItemInZipWasAdded = testRunner.WaitForName(firstItemName, 2);
|
||||
bool secondItemInZipWasAdded = testRunner.WaitForName(secondItemName, 2);
|
||||
resultsHarness.AddTestResult(firstItemInZipWasAdded == true);
|
||||
resultsHarness.AddTestResult(secondItemInZipWasAdded == true);
|
||||
|
||||
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);
|
||||
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 4); // make sure we ran all our tests
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
|
||||
public class RenameButtonRenamesLibraryRowItem
|
||||
{
|
||||
[Test, RequiresSTA, RunInApplicationDomain]
|
||||
public void RenameButtonRenameLocalLibraryItem()
|
||||
{
|
||||
// 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 rowItemToRename = "Row Item " + "Calibration - Box";
|
||||
testRunner.ClickByName("Library Edit Button");
|
||||
testRunner.Wait(1);
|
||||
testRunner.ClickByName(rowItemToRename);
|
||||
testRunner.ClickByName("Rename From Library Button");
|
||||
|
||||
testRunner.Wait(2);
|
||||
|
||||
testRunner.Type("Library Item Renamed");
|
||||
|
||||
testRunner.ClickByName("Rename Button");
|
||||
|
||||
string renamedRowItem = "Row Item " + "Library Item Renamed";
|
||||
bool libraryItemWasRenamed = testRunner.WaitForName(renamedRowItem, 2);
|
||||
bool libraryItemBeforeRenameExists = testRunner.WaitForName(rowItemToRename, 2);
|
||||
|
||||
resultsHarness.AddTestResult(libraryItemWasRenamed == true);
|
||||
resultsHarness.AddTestResult(libraryItemBeforeRenameExists == false);
|
||||
|
||||
|
||||
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 UserCanSuccessfullyCreateLibraryFolder
|
||||
{
|
||||
[Test, RequiresSTA, RunInApplicationDomain]
|
||||
public void RenameButtonRenameLocalLibraryItem()
|
||||
{
|
||||
// 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");
|
||||
|
||||
//Create New Folder
|
||||
testRunner.ClickByName("Create Folder From Library Button");
|
||||
testRunner.Wait(.5);
|
||||
testRunner.Type("New Folder");
|
||||
testRunner.Wait(.5);
|
||||
testRunner.ClickByName("Create Folder Button");
|
||||
|
||||
//Check for Created Folder
|
||||
string newLibraryFolder = "New Folder Row Item Collection";
|
||||
bool newFolderWasCreated = testRunner.WaitForName(newLibraryFolder, 1);
|
||||
resultsHarness.AddTestResult(newFolderWasCreated == 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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue