/* 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 System; using System.IO; using System.Threading; using System.Threading.Tasks; using MatterHackers.Agg.UI; using MatterHackers.Agg.UI.Tests; using MatterHackers.GuiAutomation; using MatterHackers.MatterControl.PrintQueue; using NUnit.Framework; namespace MatterHackers.MatterControl.Tests.Automation { [TestFixture, Category("MatterControl.UI.Automation"), Category("MatterControl.Automation"), RunInApplicationDomain] public class PrintQueueTests { [Test, Apartment(ApartmentState.STA), Category("FixNeeded" /* Not Finished */)] public async Task ClickOnBuyButton() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); //Make sure image does not exist before we click the buy button testRunner.MatchLimit = 500000; bool imageExists = testRunner.ImageExists("MatterHackersStoreImage.png"); Assert.IsTrue(imageExists == false, "Web page is not open"); //Click Buy button and test that the MatterHackers store web page is open testRunner.ClickByName("Buy Materials Button", 5); bool imageExists2 = testRunner.ImageExists("MatterHackersStoreImage.png", 10); Assert.IsTrue(imageExists2 == true, "Web page is open"); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } [Test, Apartment(ApartmentState.STA)] public async Task ClickingCreateButtonOpensPluginWindow() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); // Tests that clicking the create button opens create tools plugin window testRunner.CloseSignInAndPrinterSelect(); //Make sure that plugin window does not exist bool pluginWindowExists1 = testRunner.WaitForName("Plugin Chooser Window", 0); Assert.IsTrue(pluginWindowExists1 == false, "Plugin window does not exist"); testRunner.ClickByName("Design Tool Button", 5); //Test that the plugin window does exist after the create button is clicked SystemWindow containingWindow; GuiWidget pluginWindowExists = testRunner.GetWidgetByName("Plugin Chooser Window", out containingWindow, secondsToWait: 3); Assert.IsTrue(pluginWindowExists != null, "Plugin Chooser Window"); pluginWindowExists.CloseOnIdle(); testRunner.Wait(.5); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun); } [Test, Apartment(ApartmentState.STA)] public async Task ClickOnExportButton() { AutomationTest testToRun = (testRunner) => { // Tests that clicking the queue export button with a single item selected opens export item window testRunner.CloseSignInAndPrinterSelect(); //Make sure that the export window does not exist bool exportWindowExists1 = testRunner.WaitForName("Export Item Window", 0); Assert.IsTrue(exportWindowExists1 == false, "Export window does not exist"); testRunner.ClickByName("Queue Export Button", 5); SystemWindow containingWindow; GuiWidget exportWindow = testRunner.GetWidgetByName("Export Item Window", out containingWindow, 5); Assert.IsTrue(exportWindow != null, "Export window does exist"); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } [Test, Apartment(ApartmentState.STA), Category("FixNeeded" /* Not Finished */)] public async Task ExportButtonIsDisabledWithNoItemsInQueue() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); //bool exportButtonExists = testRunner.NameExists("Export Queue Button"); bool exportButtonExists = testRunner.WaitForName("Export Queue Button", 10); testRunner.Wait(5); Assert.IsTrue(exportButtonExists == false, "Export button is disabled"); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun); } [Test, Apartment(ApartmentState.STA)] public async Task QueueThumbnailWidgetOpensPartPreview() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); // Tests that clicking a queue item thumbnail opens a Part Preview window bool partPreviewWindowExists1 = testRunner.WaitForName("Part Preview Window Thumbnail", 0); Assert.IsTrue(partPreviewWindowExists1 == false, "Part Preview Window Does Not Exist"); testRunner.ClickByName("Queue Item Thumbnail"); SystemWindow containingWindow; GuiWidget partPreviewWindowExists = testRunner.GetWidgetByName("Part Preview Window", out containingWindow, 3); Assert.IsTrue(partPreviewWindowExists != null, "Part Preview Window Exists"); partPreviewWindowExists.CloseOnIdle(); testRunner.Wait(.5); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } [Test, Apartment(ApartmentState.STA)] public async Task CopyButtonMakesACopyOfPartInTheQueue() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* Tests that when the Queue Copy button is clicked: * 1. The Queue Tab Count is increased by one * 2. A Queue Row item is created and added to the queue with the correct name */ int queueCountBeforeCopyButtonIsClicked = QueueData.Instance.Count; bool copyIncreasesQueueDataCount = false; testRunner.ClickByName("Queue Item " + "Batman", 3); testRunner.ClickByName("Queue Copy Button", 3); testRunner.Wait(1); int currentQueueCount = QueueData.Instance.Count; if (currentQueueCount == queueCountBeforeCopyButtonIsClicked + 1) { copyIncreasesQueueDataCount = true; } Assert.IsTrue(copyIncreasesQueueDataCount == true, "Copy button clicked increases queue tab count by one"); bool batmanQueueItemCopyExists = testRunner.WaitForName("Queue Item " + "Batman" + " - copy", 2); Assert.IsTrue(batmanQueueItemCopyExists == true); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } [Test, Apartment(ApartmentState.STA)] public async Task AddSingleItemToQueue() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* * Tests that Queue Add button adds a single part to queue: * 1. The Queue count is increased by 1 * 2. A QueueRowItem is created and added to the queue */ int queueCountBeforeAdd = QueueData.Instance.Count; //Click Add Button and Add Part To Queue testRunner.ClickByName("Queue Add Button", 2); testRunner.Wait(2); string queueItemPath = MatterControlUtilities.GetTestItemPath("Fennec_Fox.stl"); testRunner.Type(queueItemPath); testRunner.Wait(1); testRunner.Type("{Enter}"); //Make sure single part is added and queue count increases by one bool fennecFoxPartWasAdded = testRunner.WaitForName("Queue Item " + "Fennec_Fox", 2); Assert.IsTrue(fennecFoxPartWasAdded == true); int queueCountAfterAdd = QueueData.Instance.Count; Assert.IsTrue(queueCountBeforeAdd + 1 == queueCountAfterAdd); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun); } [Test, Apartment(ApartmentState.STA)] public async Task AddMuiltipleItemsToQueue() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* * Tests that Add button can add multiple files to the print queue: * 1. The Queue count is increased by 2 * 2. 2 QueueRowItems are created and added to the queue */ int queueCountBeforeAdd = QueueData.Instance.Count; //Click Add Button and Add Part To Queue testRunner.ClickByName("Queue Add Button", 2); string pathToFirstQueueItem = MatterControlUtilities.GetTestItemPath("Fennec_Fox.stl"); testRunner.Wait(1); string pathToSecondQueueItem = MatterControlUtilities.GetTestItemPath("Batman.stl"); string textForBothQueueItems = string.Format("\"{0}\" \"{1}\"", pathToFirstQueueItem, pathToSecondQueueItem); testRunner.Type(textForBothQueueItems); testRunner.Wait(2); testRunner.Type("{Enter}"); testRunner.Wait(2); //Confirm that both items were added and that the queue count increases by the appropriate number int queueCountAfterAdd = QueueData.Instance.Count; Assert.IsTrue(QueueData.Instance.Count == queueCountBeforeAdd + 2); bool firstQueueItemWasAdded = testRunner.WaitForName("Queue Item " + "Fennec_Fox", 2); bool secondQueueItemWasAdded = testRunner.WaitForName("Queue Item " + "Batman", 2); Assert.IsTrue(firstQueueItemWasAdded == true); Assert.IsTrue(secondQueueItemWasAdded == true); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun); } [Test, Apartment(ApartmentState.STA)] public async Task RemoveButtonRemovesSingleItem() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* *Tests that when one item is selected *1. Queue Item count equals three before the test starts *2. Selecting single queue item and then clicking the Remove button removes the item *3. Selecting single queue items and then clicking the Remove button decreases the queue tab count by one */ int queueItemCount = QueueData.Instance.Count; testRunner.ClickByName("Queue Remove Button", 2); testRunner.Wait(1); int queueItemCountAfterRemove = QueueData.Instance.Count; Assert.IsTrue(queueItemCount - 1 == queueItemCountAfterRemove); bool queueItemExists = testRunner.WaitForName("Queue Item " + "2013-01-25_Mouthpiece_v2", 2); Assert.IsTrue(queueItemExists == false); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } [Test, Apartment(ApartmentState.STA)] public async Task EditButtonTurnsOnOffEditMode() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* *Tests that when the edit button is clicked we go into editmode (print queue items have checkboxes on them) *1. After Edit button is clicked print queue items have check boxes *2. Selecting multiple queue itema and then clicking the Remove button removes the item *3. Selecting multiple queue items and then clicking the Remove button decreases the queue tab count by one */ bool checkboxExists = testRunner.WaitForName("Queue Item Checkbox", 2); Assert.IsTrue(checkboxExists == false); Assert.IsTrue(QueueData.Instance.Count == 4); SystemWindow systemWindow; string itemName = "Queue Item " + "2013-01-25_Mouthpiece_v2"; GuiWidget queueItem = testRunner.GetWidgetByName(itemName, out systemWindow, 3); SearchRegion queueItemRegion = testRunner.GetRegionByName(itemName, 3); { testRunner.ClickByName("Queue Edit Button", 2); SystemWindow containingWindow; GuiWidget foundWidget = testRunner.GetWidgetByName("Queue Item Checkbox", out containingWindow, 3, searchRegion: queueItemRegion); Assert.IsTrue(foundWidget != null, "We should have an actual checkbox"); } { testRunner.ClickByName("Queue Done Button", 2); testRunner.Wait(.5); SystemWindow containingWindow; GuiWidget foundWidget = testRunner.GetWidgetByName("Queue Item Checkbox", out containingWindow, 1, searchRegion: queueItemRegion); Assert.IsTrue(foundWidget == null, "We should not have an actual checkbox"); } return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items, overrideWidth: 600); } [Test, Apartment(ApartmentState.STA)] public async Task DoneButtonTurnsOffEditMode() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* *Tests that when one item is selected *1. Queue Item count equals three before the test starts *2. Selecting multiple queue itema and then clicking the Remove button removes the item *3. Selecting multiple queue items and then clicking the Remove button decreases the queue tab count by one */ int queueItemCount = QueueData.Instance.Count; string itemName = "Queue Item " + "2013-01-25_Mouthpiece_v2"; SystemWindow systemWindow; GuiWidget queueItem = testRunner.GetWidgetByName(itemName, out systemWindow, 3); SearchRegion queueItemRegion = testRunner.GetRegionByName(itemName, 3); testRunner.ClickByName("Queue Edit Button", 2); GuiWidget foundWidget = testRunner.GetWidgetByName("Queue Item Checkbox", out systemWindow, 3, searchRegion: queueItemRegion); Assert.IsTrue(foundWidget != null, "We should have an actual checkbox"); testRunner.ClickByName("Queue Done Button", 1); foundWidget = testRunner.GetWidgetByName("Queue Item Checkbox", out systemWindow, 1, searchRegion: queueItemRegion); Assert.IsTrue(foundWidget != null, "Checkbox is gone"); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } [Test, Apartment(ApartmentState.STA)] public async Task RemoveButtonRemovesMultipleItems() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* *Tests that when one item is selected *1. Queue Item count equals three before the test starts *2. Selecting multiple queue itema and then clicking the Remove button removes the item *3. Selecting multiple queue items and then clicking the Remove button decreases the queue tab count by one */ int queueItemCount = QueueData.Instance.Count; testRunner.Wait(2); testRunner.ClickByName("Queue Edit Button", 2); testRunner.ClickByName("Queue Item " + "Batman", 2); testRunner.ClickByName("Queue Remove Button", 2); testRunner.Wait(1); int queueItemCountAfterRemove = QueueData.Instance.Count; Assert.IsTrue(queueItemCount - 2 == queueItemCountAfterRemove); bool queueItemExists = testRunner.WaitForName("Queue Item " + "Batman", 2); bool secondQueueItemExists = testRunner.WaitForName("Queue Item " + "2013-01-25_Mouthpiece_v2", 2); Assert.IsTrue(queueItemExists == false); Assert.IsTrue(secondQueueItemExists == false); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } [Test, Apartment(ApartmentState.STA)] public async Task ExportToZipMenuItemClicked() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* *Tests Export to Zip menu item is clicked the queue is compressed and exported to location on disk *1. Check that there are items in the queue *2. Export Queue and make sure file exists on disk */ bool queueEmpty = true; int queueItemCountBeforeRemoveAllClicked = QueueData.Instance.Count; if (queueItemCountBeforeRemoveAllClicked > 0) { queueEmpty = false; } Assert.IsTrue(queueEmpty == false); testRunner.ClickByName("Queue... Menu", 2); testRunner.ClickByName(" Export to Zip Menu Item", 2); testRunner.Wait(2); //Type in Absolute Path to Save string exportZipPath = MatterControlUtilities.GetTestItemPath("TestExportZip.zip"); // Ensure file does not exist before save if (File.Exists(exportZipPath)) { File.Delete(exportZipPath); } testRunner.Type(exportZipPath); testRunner.Wait(2); testRunner.Type("{Enter}"); testRunner.Wait(1); bool queueWasExportedToZip = File.Exists(exportZipPath); testRunner.Wait(2); Assert.IsTrue(queueWasExportedToZip == true); //Add the exprted zip file to the Queue and confirm that the Queue Count increases by 3 testRunner.ClickByName("Queue Add Button"); testRunner.Wait(1); testRunner.Type(exportZipPath); testRunner.Wait(1); testRunner.Type("{Enter}"); int queueCountAfterZipIsAdded = QueueData.Instance.Count; bool allItemsInZipWereAddedToTheQueue = false; if (queueCountAfterZipIsAdded == queueItemCountBeforeRemoveAllClicked * 2) { allItemsInZipWereAddedToTheQueue = true; } Assert.IsTrue(allItemsInZipWereAddedToTheQueue == true); if (File.Exists(exportZipPath)) { File.Delete(exportZipPath); } return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } [Test, Apartment(ApartmentState.STA)] public async Task SendMenuItemCLickedNoSignIn() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); int queueItemCountBeforeRemoveAllClicked = QueueData.Instance.Count; Assert.IsTrue(queueItemCountBeforeRemoveAllClicked > 0); testRunner.ClickByName("More... Menu", 2); testRunner.ClickByName("Send Menu Item", 2); bool signInPromptWindowOpens = testRunner.WaitForName("Ok Button", 2); Assert.IsTrue(signInPromptWindowOpens == true); testRunner.ClickByName("Ok Button"); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } /// /// Tests that when the Remove All menu item is clicked /// 1. Queue Item count is set to one /// 2. All widgets that were previously in the queue are removed /// [Test, Apartment(ApartmentState.STA)] public async Task RemoveAllMenuItemClickedRemovesAll() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); Assert.IsTrue(QueueData.Instance.Count == 4, "Queue has expected 3 items, including default Coin"); // Assert that widgets exists Assert.IsTrue(testRunner.WaitForName("Queue Item Batman"), "Batman part exists"); Assert.IsTrue(testRunner.WaitForName("Queue Item Fennec_Fox"), "Fox part exists"); Assert.IsTrue(testRunner.WaitForName("Queue Item 2013-01-25_Mouthpiece_v2"), "Mouthpiece part exists"); // Act - remove all print queue items testRunner.ClickByName("Queue... Menu", 2); testRunner.ClickByName(" Remove All Menu Item", 2); testRunner.Wait(2); // Assert that object model has been cleared Assert.IsTrue(QueueData.Instance.Count == 0, "Queue is empty after RemoveAll action"); // Assert that widgets have been removed Assert.IsTrue(!testRunner.WaitForName("Queue Item Batman"), "Batman part removed"); Assert.IsTrue(!testRunner.WaitForName("Queue Item Fennec_Fox"), "Fox part removed"); Assert.IsTrue(!testRunner.WaitForName("Queue Item 2013-01-25_Mouthpiece_v2"), "Mouthpiece part removed"); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } [Test, Apartment(ApartmentState.STA), Category("FixNeeded" /* Not Finished */)] public async Task ClickCreatePartSheetButton() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* *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 queueItemCount = QueueData.Instance.Count; if (queueItemCount == 3) { queueEmpty = false; } Assert.IsTrue(queueEmpty == false); testRunner.ClickByName("Queue... Menu", 2); testRunner.ClickByName(" Create Part Sheet Menu Item", 2); testRunner.Wait(2); string pathToSavePartSheet = MatterControlUtilities.GetTestItemPath("CreatePartSheet"); string validatePartSheetPath = Path.Combine("..", "..", "..", "TestData", "QueueItems", "CreatePartSheet.pdf"); testRunner.Type(pathToSavePartSheet); testRunner.Wait(1); testRunner.Type("{Enter}"); testRunner.Wait(1); testRunner.Wait(5); bool partSheetCreated = File.Exists(validatePartSheetPath); testRunner.Wait(2); Assert.IsTrue(partSheetCreated == true); if (File.Exists(validatePartSheetPath)) { File.Delete(validatePartSheetPath); } return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } [Test, Apartment(ApartmentState.STA)] public async Task ClickQueueRoWItemViewAndRemove() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* *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; Assert.IsTrue(testRunner.WaitForName("Queue Item " + "Batman", 1)); Assert.IsTrue(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; Assert.IsTrue(currentQueueItemCount - 1 == queueItemCountAfterRemove); bool batmanQueueItemExists = testRunner.WaitForName("Queue Item " + "Batman", 1); Assert.IsTrue(batmanQueueItemExists == false); bool partPreviewWindowExists1 = testRunner.WaitForName("Queue Item " + "2013-01-25_Mouthpiece_v2" + " Part Preview", 1); Assert.IsTrue(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); Assert.IsTrue(partPreviewWindowExists2 == true); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items, overrideWidth: 600); } [Test, Apartment(ApartmentState.STA)] public async Task QueueAddButtonAddsAMF() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* Tests that when the Queue Copy button is clicked: * 1. QueueCount = Zero * 2. Add button can add single .amf file to the queue * 3. Queue count inceases by one */ int queueCountBeforeTest = QueueData.Instance.Count; //Click Add button testRunner.ClickByName("Queue Add Button", 2); testRunner.Wait(1); string pathToType = MatterControlUtilities.GetTestItemPath("Rook.amf"); testRunner.Type(pathToType); testRunner.Wait(1); testRunner.Type("{Enter}"); //Make sure Queue Count increases by one int queueCountAfterAMFIsAdded = QueueData.Instance.Count; Assert.IsTrue(queueCountAfterAMFIsAdded == queueCountBeforeTest + 1); //Make sure amf queue item is added bool firstQueueItemExists = testRunner.WaitForName("Queue Item " + "Rook", 1); Assert.IsTrue(firstQueueItemExists == true); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun); } [Test, Apartment(ApartmentState.STA)] public async Task QueueAddButtonAddsSTL() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); /* Tests that when the Queue Copy button is clicked: * 1. QueueCount = Zero * 2. Add button can add single .stl file to the queue * 3. Queue count inceases by one */ int queueCountBeforeTest = QueueData.Instance.Count; //Click Add button testRunner.ClickByName("Queue Add Button", 2); testRunner.Wait(1); string pathToType = MatterControlUtilities.GetTestItemPath("Batman.stl"); testRunner.Type(pathToType); testRunner.Wait(1); testRunner.Type("{Enter}"); int queueCountAfterSTLIsAdded = QueueData.Instance.Count; Assert.IsTrue(queueCountAfterSTLIsAdded == queueCountBeforeTest + 1); //stl queue item is added to the queue bool firstQueueItemExists = testRunner.WaitForName("Queue Item " + "Batman", 1); Assert.IsTrue(firstQueueItemExists == true); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun); } [Test, Apartment(ApartmentState.STA)] public async Task QueueAddButtonAddsGcodeFile() { AutomationTest testToRun = (testRunner) => { testRunner.CloseSignInAndPrinterSelect(); int queueCountBeforeTest = QueueData.Instance.Count; //Click Add button testRunner.ClickByName("Queue Add Button", 2); testRunner.Wait(1); string pathToType = MatterControlUtilities.GetTestItemPath("chichen-itza_pyramid.gcode"); testRunner.Type(pathToType); testRunner.Wait(1); testRunner.Type("{Enter}"); int queueCountAfterGcodeIsAdded = QueueData.Instance.Count; Assert.IsTrue(queueCountAfterGcodeIsAdded == queueCountBeforeTest + 1); //stl queue item is added to the queue bool firstQueueItemExists = testRunner.WaitForName("Queue Item " + "chichen-itza_pyramid", 1); Assert.IsTrue(firstQueueItemExists == true); return Task.FromResult(0); }; await MatterControlUtilities.RunTest(testToRun); } } }