Extract automation tests to a separate assembly to ensure isolation/clean startup

- Fall back to English if translation data is missing, rather than crashing
 - Dump test name to console when running test harness to troubleshoot hangs
This commit is contained in:
John Lewin 2015-12-13 17:29:01 -08:00
parent b70da46e69
commit 879a2856d3
18 changed files with 227 additions and 19 deletions

View file

@ -0,0 +1,95 @@
/*
Copyright (c) 2014, Lars Brubaker
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using MatterHackers.Agg;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.UI;
using NUnit.Framework;
using System;
using System.Threading.Tasks;
using MatterHackers.GuiAutomation;
using MatterHackers.Agg.PlatformAbstract;
using System.IO;
using MatterHackers.Agg.UI.Tests;
namespace MatterHackers.MatterControl.UI
{
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
public class CheckBoxInLibraryIsClickable
{
[Test, RequiresSTA, RunInApplicationDomain]
public void ClickOnLibraryCheckBoxes()
{
// Run a copy of MatterControl
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
{
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
// Now do the actions specific to this test. (replace this for new tests)
{
testRunner.ClickByName("Library Tab", 3);
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
SystemWindow systemWindow;
string itemName = "Row Item " + "Calibration - Box";
GuiWidget rowItem = testRunner.GetWidgetByName(itemName, out systemWindow, 3);
SearchRegion rowItemRegion = testRunner.GetRegionByName(itemName, 3);
testRunner.ClickByName("Library Edit Button", 3);
testRunner.Wait(.5);
GuiWidget foundWidget = testRunner.GetWidgetByName("Row Item Select Checkbox", out systemWindow, 3, searchRegion: rowItemRegion);
CheckBox checkBoxWidget = foundWidget as CheckBox;
resultsHarness.AddTestResult(checkBoxWidget != null, "We should have an actual checkbox");
resultsHarness.AddTestResult(checkBoxWidget.Checked == false, "currently not checked");
testRunner.ClickByName("Row Item Select Checkbox", 3, searchRegion: rowItemRegion);
testRunner.ClickByName("Library Tab");
resultsHarness.AddTestResult(checkBoxWidget.Checked == true, "currently checked");
testRunner.ClickByName(itemName, 3);
testRunner.ClickByName("Library Tab");
resultsHarness.AddTestResult(checkBoxWidget.Checked == false, "currently not checked");
MatterControlUtilities.CloseMatterControl(testRunner);
}
};
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);
// NOTE: In the future we may want to make the "Local Library Row Item Collection" not clickable.
// If that is the case fix this test to click on a child of "Local Library Row Item Collection" instead.
Assert.IsTrue(testHarness.AllTestsPassed);
Assert.IsTrue(testHarness.TestCount == 4); // make sure we ran all our tests
}
}
}

View file

@ -0,0 +1,82 @@
/*
Copyright (c) 2014, Lars Brubaker
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using MatterHackers.Agg;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.UI;
using NUnit.Framework;
using System;
using System.Threading.Tasks;
using MatterHackers.GuiAutomation;
using MatterHackers.Agg.PlatformAbstract;
using System.IO;
using MatterHackers.Agg.UI.Tests;
namespace MatterHackers.MatterControl.UI
{
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
public class CreateLibraryFolder
{
[Test, RequiresSTA, RunInApplicationDomain]
public void CreateFolderStarsOutWithTextFiledFocusedAndEditable()
{
// Run a copy of MatterControl
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
{
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
// Now do the actions specific to this test. (replace this for new tests)
{
testRunner.ClickByName("Library Tab");
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
testRunner.ClickByName("Create Folder From Library Button");
testRunner.Wait(.5);
testRunner.Type("Test Text");
testRunner.Wait(.5);
SystemWindow containingWindow;
GuiWidget textInputWidget = testRunner.GetWidgetByName("Create Folder - Text Input", out containingWindow);
MHTextEditWidget textWidgetMH = textInputWidget as MHTextEditWidget;
resultsHarness.AddTestResult(textWidgetMH != null, "Found Text Widget");
resultsHarness.AddTestResult(textWidgetMH.Text == "Test Text", "Had the right text");
containingWindow.CloseOnIdle();
testRunner.Wait(.5);
MatterControlUtilities.CloseMatterControl(testRunner);
}
};
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);
Assert.IsTrue(testHarness.AllTestsPassed);
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
}
}
}

View file

@ -0,0 +1,654 @@
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 UserCanSuccessfullyCreateAndRenameLibraryFolder
{
[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);
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);
}
};
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 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
}
}
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
public class AddToQueueButtonAddsSingleItemToQueue
{
[Test, RequiresSTA, RunInApplicationDomain]
public void AddToQueueFromLibraryButtonAddsItemToQueue()
{
// 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);
//Select Library Item
string rowItemOne = "Row Item " + "Calibration - Box";
testRunner.ClickByName(rowItemOne);
testRunner.Wait(1);
//Add Library Item to the Print Queue
testRunner.ClickByName("Library Add To Queue Button");
testRunner.Wait(2);
//Make sure that the Queue Count increases by one
int queueCountAfterAdd = QueueData.Instance.Count;
bool queueCountIncreasedByOne = false;
if (queueCountAfterAdd == 1)
{
queueCountIncreasedByOne = true;
}
resultsHarness.AddTestResult(queueCountIncreasedByOne == true);
//Navigate to Queue
testRunner.ClickByName("Queue Tab");
testRunner.Wait(1);
//Make sure that the Print Item was added
string queueItem = "Queue Item " + "Calibration - Box";
bool queueItemWasAdded = testRunner.WaitForName(queueItem, 2);
resultsHarness.AddTestResult(queueItemWasAdded == 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 AddToQueueButtonAddsMultipleItemsToQueue
{
[Test, RequiresSTA, RunInApplicationDomain]
public void AddToQueueFromLibraryButtonAddsItemsToQueue()
{
// 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");
//Add an item to the library
string libraryItemToAdd = MatterControlUtilities.PathToQueueItemsFolder("Fennec_Fox.stl");
testRunner.ClickByName("Library Add Button");
testRunner.Wait(2);
testRunner.Type(libraryItemToAdd);
testRunner.Wait(2);
testRunner.Type("{Enter}");
testRunner.Wait(1);
testRunner.ClickByName("Library Edit Button");
testRunner.Wait(1);
//Select both Library Items
string rowItemOne = "Row Item " + "Calibration - Box";
testRunner.ClickByName(rowItemOne);
string rowItemTwo = "Row Item " + "Fennec Fox";
testRunner.ClickByName(rowItemTwo);
//Click the Add To Queue button
testRunner.Wait(1);
testRunner.ClickByName("Library Add To Queue Button");
testRunner.Wait(2);
//Make sure Queue Count increases by the correct amount
int queueCountAfterAdd = QueueData.Instance.Count;
bool queueCountIncreasedByTwo = false;
if (queueCountAfterAdd == 2)
{
queueCountIncreasedByTwo = true;
}
resultsHarness.AddTestResult(queueCountIncreasedByTwo == true);
//Navigate to the Print Queue
testRunner.ClickByName("Queue Tab");
testRunner.Wait(1);
//Test that both added print items exist
string queueItemOne = "Queue Item " + "Calibration - Box";
string queueItemTwo = "Queue Item " + "Fennec_Fox";
bool queueItemOneWasAdded = testRunner.WaitForName(queueItemOne, 2);
bool queueItemTwoWasAdded = testRunner.WaitForName(queueItemTwo, 2);
resultsHarness.AddTestResult(queueItemOneWasAdded == true);
resultsHarness.AddTestResult(queueItemTwoWasAdded == true);
MatterControlUtilities.CloseMatterControl(testRunner);
}
};
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);
Assert.IsTrue(testHarness.AllTestsPassed);
Assert.IsTrue(testHarness.TestCount == 3); // make sure we ran all our tests
}
}
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
public class ClickLibraryTumbnailWidgetOpensPartPreview
{
[Test, RequiresSTA, RunInApplicationDomain]
public void LibraryItemThumbnailClickedOpensPartPreview()
{
// 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");
//Make sure Part Preview Window does not exists before we click the view button
bool partPreviewExistsOne = testRunner.WaitForName("Part Preview Window", 1);
resultsHarness.AddTestResult(partPreviewExistsOne == false);
string libraryRowItemName = "Row Item " + "Calibration - Box";
testRunner.ClickByName(libraryRowItemName);
testRunner.Wait(1);
//Click Library Item View Button
string libraryItemViewButton = "Row Item " + "Calibration - Box" + " View Button";
testRunner.ClickByName(libraryItemViewButton);
//Make sure that Part Preview Window opens after View button is clicked
bool partPreviewWindowExists = testRunner.WaitForName("Part Preview Window", 1.5);
resultsHarness.AddTestResult(partPreviewWindowExists == 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
}
}
}

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{418E7058-92EE-4329-86BA-AC26B65AFB25}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MatterControl.AutomationTests</RootNamespace>
<AssemblyName>MatterControl.AutomationTests</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NUnit.ApplicationDomain, Version=5.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.ApplicationDomain.5.0.1\lib\net40\NUnit.ApplicationDomain.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Utilities\ManifestFileHandler.cs">
<Link>ManifestFileHandler.cs</Link>
</Compile>
<Compile Include="..\MatterControl.Tests\MatterControl\MatterControlUtilities.cs">
<Link>MatterControlUtilities.cs</Link>
</Compile>
<Compile Include="CheckBoxInLibraryIsClickable.cs" />
<Compile Include="CreateLibraryFolder.cs" />
<Compile Include="LocalLibraryTests.cs" />
<Compile Include="OptionsTabTests.cs" />
<Compile Include="PrintQueueTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqLiteLibraryProvider.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\MatterControl.csproj">
<Project>{0b8d6f56-bd7f-4426-b858-d9292b084656}</Project>
<Name>MatterControl</Name>
</ProjectReference>
<ProjectReference Include="..\..\Submodules\agg-sharp\agg\Agg.csproj">
<Project>{657dbc6d-c3ea-4398-a3fa-ddb73c14f71b}</Project>
<Name>Agg</Name>
</ProjectReference>
<ProjectReference Include="..\..\Submodules\agg-sharp\GuiAutomation\GuiAutomation.csproj">
<Project>{e9102310-0029-4d8f-b1e9-88fba6147d45}</Project>
<Name>GuiAutomation</Name>
</ProjectReference>
<ProjectReference Include="..\..\Submodules\agg-sharp\Gui\Gui.csproj">
<Project>{74f6bb6c-9d02-4512-a59a-21940e35c532}</Project>
<Name>Gui</Name>
</ProjectReference>
<ProjectReference Include="..\..\Submodules\agg-sharp\PlatformAbstract\PlatformAbstract.csproj">
<Project>{3e4aaba8-d85f-4922-88c6-5c1b2d2308fb}</Project>
<Name>PlatformAbstract</Name>
</ProjectReference>
<ProjectReference Include="..\..\Submodules\agg-sharp\PlatformWin32\PlatformWin32.csproj">
<Project>{670bddff-927b-425d-9dd1-22acb14356eb}</Project>
<Name>PlatformWin32</Name>
</ProjectReference>
<ProjectReference Include="..\..\Submodules\agg-sharp\Tests\Agg.Tests\Agg.Tests.csproj">
<Project>{195cbe56-e654-437b-ab05-3be1b9452497}</Project>
<Name>Agg.Tests</Name>
</ProjectReference>
<ProjectReference Include="..\..\Submodules\agg-sharp\WindowsFileDialogs\WindowsFileDialogs.csproj">
<Project>{a526dc5d-65f3-461b-805f-d3ac9665f5c9}</Project>
<Name>WindowsFileDialogs</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,88 @@
using MatterHackers.Agg;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.UI;
using NUnit.Framework;
using System;
using System.Threading.Tasks;
using MatterHackers.GuiAutomation;
using MatterHackers.Agg.PlatformAbstract;
using System.IO;
using MatterHackers.MatterControl.CreatorPlugins;
using MatterHackers.Agg.UI.Tests;
namespace MatterHackers.MatterControl.UI
{
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
public class ShowTerminalButtonClickedOpensTerminal
{
[Test, RequiresSTA, RunInApplicationDomain]
public void ClickingShowTerminalButtonOpensTerminal()
{
// Run a copy of MatterControl
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
{
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
{
testRunner.ClickByName("SettingsAndControls", 5);
testRunner.Wait(2);
testRunner.ClickByName("Options Tab", 6);
bool terminalWindowExists1 = testRunner.WaitForName("Gcode Terminal", 0);
resultsHarness.AddTestResult(terminalWindowExists1 == false, "Terminal Window does not exist");
testRunner.ClickByName("Show Terminal Button", 6);
SystemWindow containingWindow;
GuiWidget terminalWindow = testRunner.GetWidgetByName("Gcode Terminal", out containingWindow, 3);
resultsHarness.AddTestResult(terminalWindow != null, "Terminal Window exists after Show Terminal button is clicked");
containingWindow.CloseOnIdle();
testRunner.Wait(.5);
MatterControlUtilities.CloseMatterControl(testRunner);
}
};
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, "MC_Three_Queue_Items");
Assert.IsTrue(testHarness.AllTestsPassed);
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
}
}
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
public class ConfigureNotificationSettingsButtonClickedOpensNotificationWindow
{
[Test, RequiresSTA, RunInApplicationDomain, Ignore("Not Finished")]
//DOES NOT WORK
public void ClickingConfigureNotificationSettingsButtonOpensWindow()
{
// Run a copy of MatterControl
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
{
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
{
testRunner.ClickByName("SettingsAndControls", 5);
testRunner.ClickByName("Options Tab", 6);
bool printNotificationsWindowExists1 = testRunner.WaitForName("Notification Options Window", 3);
resultsHarness.AddTestResult(printNotificationsWindowExists1 == false, "Print Notification Window does not exist");
testRunner.ClickByName("Configure Notification Settings Button", 6);
bool printNotificationsWindowExists2 = testRunner.WaitForName("Notification Options Window", 3);
resultsHarness.AddTestResult(printNotificationsWindowExists2 == true, "Print Notifications Window exists after Configure button is clicked");
MatterControlUtilities.CloseMatterControl(testRunner);
}
};
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, "MC_Three_Queue_Items");
Assert.IsTrue(testHarness.AllTestsPassed);
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MatterControl.AutomationTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MatterHackers, Inc.")]
[assembly: AssemblyProduct("MatterControl.AutomationTests")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("418e7058-92ee-4329-86ba-ac26b65afb25")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,55 @@
using MatterHackers.Agg.PlatformAbstract;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.UI.Tests;
using MatterHackers.GuiAutomation;
using NUnit.Framework;
using System;
using System.IO;
namespace MatterHackers.MatterControl.UI
{
[TestFixture, Category("MatterControl.UI"), RunInApplicationDomain]
public class SqLiteLibraryProviderTests
{
[Test, RequiresSTA, RunInApplicationDomain]
public void LibraryQueueViewRefreshesOnAddItem()
{
// Run a copy of MatterControl
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
{
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
{
testRunner.ClickByName("Library Tab", 5);
MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
resultsHarness.AddTestResult(testRunner.ClickByName("3D View Edit", 3));
resultsHarness.AddTestResult(testRunner.ClickByName("3D View Copy", 3), "Click Copy");
// wait for the copy to finish
testRunner.Wait(.1);
resultsHarness.AddTestResult(testRunner.ClickByName("3D View Delete", 3), "Click Delete");
resultsHarness.AddTestResult(testRunner.ClickByName("Save As Menu", 3), "Click Save As Menu");
resultsHarness.AddTestResult(testRunner.ClickByName("Save As Menu Item", 3), "Click Save As");
testRunner.Wait(1);
testRunner.Type("Test Part");
resultsHarness.AddTestResult(MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection"));
resultsHarness.AddTestResult(testRunner.ClickByName("Save As Save Button", 1));
// ensure that it is now in the library folder (that the folder updated)
resultsHarness.AddTestResult(testRunner.WaitForName("Row Item " + "Test Part", 5), "The part we added sholud be in the library");
MatterControlUtilities.CloseMatterControl(testRunner);
}
};
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, "MC_One_Queue_No_Library");
Assert.IsTrue(testHarness.AllTestsPassed);
Assert.IsTrue(testHarness.TestCount == 8); // make sure we ran all our tests
}
}
}

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net46" />
<package id="NUnit" version="2.6.3" targetFramework="net46" />
<package id="NUnit.ApplicationDomain" version="5.0.1" targetFramework="net46" />
</packages>