public void ClickQueueRoWItemViewAndRemove()
        {
            // Run a copy of MatterControl
            Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
            {
                AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
                {
                    /*
                     * Tests:
                     * 1. When the remove button on a queue item is clicked the queue tab count decreases by one
                     * 2. When the remove button on a queue item is clicked the item is removed
                     * 3. When the View button on a queue item is clicked the part preview window is opened
                     */


                    testRunner.Wait(2);
                    int  currentQueueItemCount = QueueData.Instance.Count;
                    bool threeItemsInQueue     = true;

                    if (currentQueueItemCount != 3)
                    {
                        threeItemsInQueue = false;
                    }

                    resultsHarness.AddTestResult(threeItemsInQueue == true);
                    resultsHarness.AddTestResult(testRunner.WaitForName("Queue Item " + "Batman", 1));
                    resultsHarness.AddTestResult(testRunner.WaitForName("Queue Item " + "2013-01-25_Mouthpiece_v2", 1));

                    testRunner.ClickByName("Queue Item " + "Batman", 1);
                    testRunner.ClickByName("Queue Item " + "Batman" + " Remove");
                    testRunner.Wait(2);

                    int  queueItemCountAfterRemove = QueueData.Instance.Count;
                    bool correctItemCountAfterRemove;
                    if (queueItemCountAfterRemove == 2)
                    {
                        correctItemCountAfterRemove = true;
                    }
                    else
                    {
                        correctItemCountAfterRemove = false;
                    }


                    resultsHarness.AddTestResult(correctItemCountAfterRemove == true);

                    bool batmanQueueItemExists = testRunner.WaitForName("Queue Item " + "Batman", 1);
                    resultsHarness.AddTestResult(batmanQueueItemExists == false);

                    bool partPreviewWindowExists1 = testRunner.WaitForName("Queue Item " + "2013-01-25_Mouthpiece_v2" + " Part Preview", 1);
                    resultsHarness.AddTestResult(partPreviewWindowExists1 == false);
                    testRunner.ClickByName("Queue Item " + "2013-01-25_Mouthpiece_v2", 1);
                    testRunner.Wait(2);
                    testRunner.ClickByName("Queue Item " + "2013-01-25_Mouthpiece_v2" + " View", 1);

                    bool partPreviewWindowExists2 = testRunner.WaitForName("Queue Item " + "2013-01-25_Mouthpiece_v2" + " Part Preview", 2);
                    resultsHarness.AddTestResult(partPreviewWindowExists2 == true);


                    MatterControlUtilities.CloseMatterControl(testRunner);
                }
            };

            AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, "MC_Three_Queue_Items");

            Assert.IsTrue(testHarness.AllTestsPassed);
            Assert.IsTrue(testHarness.TestCount == 7);             // make sure we ran all our tests
        }
        public void RemoveAllMenuItemClickedRemovesAll()
        {
            // Run a copy of MatterControl
            Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
            {
                AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
                {
                    /*
                     * Tests that when the Remove All menu item is clicked
                     * 1. Queue Item count is set to zero
                     * 2. All queue row items that were previously in the queue are removed
                     */

                    bool queueEmpty = true;
                    int  queueItemCountBeforeRemoveAllClicked = QueueData.Instance.Count;

                    if (queueItemCountBeforeRemoveAllClicked != 0)
                    {
                        queueEmpty = false;
                    }

                    resultsHarness.AddTestResult(queueEmpty = true);

                    bool batmanPartExists1     = testRunner.WaitForName("Queue Item " + "Batman", 1);
                    bool foxPartExistst1       = testRunner.WaitForName("Queue Item " + "Fennec_Fox", 1);
                    bool mouthpiecePartExists1 = testRunner.WaitForName("Queue Item " + "2013-01-25_Mouthpiece_v2", 1);

                    resultsHarness.AddTestResult(batmanPartExists1 == true);
                    resultsHarness.AddTestResult(mouthpiecePartExists1 == true);
                    resultsHarness.AddTestResult(foxPartExistst1 == true);


                    testRunner.ClickByName("Queue... Menu", 2);



                    testRunner.ClickByName(" Remove All Menu Item", 2);

                    testRunner.Wait(2);

                    int queueItemCountAfterRemoveAll = QueueData.Instance.Count;

                    if (queueItemCountAfterRemoveAll == 0)
                    {
                        queueEmpty = true;
                    }

                    resultsHarness.AddTestResult(queueEmpty = true);

                    bool batmanPartExists2     = testRunner.WaitForName("Queue Item " + "Batman", 1);
                    bool foxPartExistst2       = testRunner.WaitForName("Queue Item " + "Fennec_Fox", 1);
                    bool mouthpiecePartExists2 = testRunner.WaitForName("Queue Item " + "2013-01-25_Mouthpiece_v2", 1);

                    resultsHarness.AddTestResult(batmanPartExists2 == false);
                    resultsHarness.AddTestResult(mouthpiecePartExists2 == false);
                    resultsHarness.AddTestResult(foxPartExistst2 == false);

                    MatterControlUtilities.CloseMatterControl(testRunner);
                }
            };

            AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, "MC_Three_Queue_Items");

            Assert.IsTrue(testHarness.AllTestsPassed);
            Assert.IsTrue(testHarness.TestCount == 8);             // make sure we ran all our tests
        }
        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.GetTestItemPath("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
        }
        public void AddSingleItemToQueue()
        {
            // Run a copy of MatterControl
            Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
            {
                AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
                {
                    /*
                     * Tests that when the QueueData.Instance.AddItem function is called:
                     * 1. The Queue count is increased by 1
                     * 2. A QueueRowItem is created and added to the queue
                     * 3. That a copy of the part is saved to AppData\MatterControl\data\QueueItems folder
                     */
                    //TODO: Eventually modify test so that we test adding queue items via file


                    bool   queueDataCountEqualsZero               = false;
                    bool   addedPartIncreasesQueueDataCount       = false;
                    bool   queueItemAppDataDirectoryExists        = false;
                    bool   queueItemAppDataDirectoryDoesNotExists = true;
                    int    currentQueueCount    = QueueData.Instance.Count;
                    string pathToAddedQueueItem = Path.Combine(MatterHackers.MatterControl.DataStorage.ApplicationDataStorage.ApplicationUserDataPath, "data", "QueueItems", "Batman.stl");
                    string partToBeAdded        = Path.Combine("..", "..", "..", "TestData", "TestParts", "Batman.stl");

                    //Make Sure Queue Count = 0
                    if (currentQueueCount == 0)
                    {
                        queueDataCountEqualsZero = true;
                    }

                    resultsHarness.AddTestResult(queueDataCountEqualsZero == true, "Queue count is zero before the test starts");
                    testRunner.Wait(3);

                    //Make sure queue item does not exist
                    bool batmanSTLExists = testRunner.WaitForName("Queue Item " + "Batman", 2);
                    resultsHarness.AddTestResult(batmanSTLExists == false);


                    //Make sure that QueueItems directory does not exist
                    if (!File.Exists(pathToAddedQueueItem))
                    {
                        queueItemAppDataDirectoryDoesNotExists = true;
                    }

                    resultsHarness.AddTestResult(queueItemAppDataDirectoryDoesNotExists == true, "Path to QueueItems directory does not exist before tests");

                    QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileNameWithoutExtension(partToBeAdded), partToBeAdded)));

                    resultsHarness.AddTestResult(testRunner.WaitForName("Queue Item " + "Batman", 2));

                    int queueCountAfterAdd = QueueData.Instance.Count;

                    if (queueCountAfterAdd == currentQueueCount + 1)
                    {
                        addedPartIncreasesQueueDataCount = true;
                    }

                    resultsHarness.AddTestResult(addedPartIncreasesQueueDataCount == true);
                    testRunner.Wait(3);

                    if (File.Exists(pathToAddedQueueItem))
                    {
                        queueItemAppDataDirectoryExists = true;
                    }

                    resultsHarness.AddTestResult(queueItemAppDataDirectoryExists == true);

                    MatterControlUtilities.CloseMatterControl(testRunner);
                }
            };

            AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, "MC_Fresh_Installation");

            Assert.IsTrue(testHarness.AllTestsPassed);
            Assert.IsTrue(testHarness.TestCount == 6);             // make sure we ran all our tests
        }
Example #5
0
        public void UndoRedoDelete()
        {
            // Run a copy of MatterControl
            Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
            {
                AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
                {
                    SystemWindow systemWindow;

                    //Navigate to Local Library
                    testRunner.ClickByName("Library Tab");
                    MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
                    testRunner.Wait(1);
                    testRunner.ClickByName("Row Item Calibration - Box");
                    testRunner.ClickByName("Row Item Calibration - Box Print Button");
                    testRunner.Wait(1);

                    //Get View3DWidget and count MeshGroups before Copy button is clicked
                    GuiWidget    partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3);
                    View3DWidget view3D      = partPreview as View3DWidget;

                    string copyButtonName = "3D View Copy";

                    //Click Edit button to make edit controls visible
                    testRunner.ClickByName("3D View Edit");
                    testRunner.Wait(1);
                    int partCountBeforeCopy = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(partCountBeforeCopy == 1);

                    for (int i = 0; i <= 4; i++)
                    {
                        testRunner.ClickByName(copyButtonName);
                        testRunner.Wait(1);
                    }

                    testRunner.Wait(1);

                    int meshCountAfterCopy = view3D.MeshGroups.Count();
                    testRunner.ClickByName("3D View Remove");
                    System.Threading.Thread.Sleep(2000);
                    int meshCountAfterRemove = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(meshCountAfterRemove == 5);


                    testRunner.ClickByName("3D View Undo");
                    System.Threading.Thread.Sleep(2000);
                    int meshCountAfterUndo = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(meshCountAfterUndo == 6);

                    testRunner.ClickByName("3D View Redo");
                    System.Threading.Thread.Sleep(2000);
                    int meshCountAfterRedo = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(meshCountAfterRedo == 5);

                    MatterControlUtilities.CloseMatterControl(testRunner);
                }
            };

            AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);

            Assert.IsTrue(testHarness.AllTestsPassed);
            Assert.IsTrue(testHarness.TestCount == 4);             // make sure we ran all our tests
        }