From 9dd64e2ce1f02bdeefd63cbb65e0f92ad1e37f07 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 21 Dec 2016 17:02:25 -0800 Subject: [PATCH] Wrote a test for clicking on the queue check box button --- Queue/QueueDataView.cs | 2 +- Queue/QueueRowItem.cs | 3 +- .../PrintQueueTests.cs | 43 +++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Queue/QueueDataView.cs b/Queue/QueueDataView.cs index 4e1671864..201aa84bc 100644 --- a/Queue/QueueDataView.cs +++ b/Queue/QueueDataView.cs @@ -327,7 +327,7 @@ namespace MatterHackers.MatterControl.PrintQueue { // Hard-coded processing rule to avoid changing the SelectedIndex when clicks occur // with the thumbnail region - aka the first 55 pixels - if (mouseEvent.X < 56) return; + if (!EditMode && mouseEvent.X < 56) return; GuiWidget widgetClicked = ((GuiWidget)sender); for (int index = 0; index < topToBottomItemList.Children.Count; index++) diff --git a/Queue/QueueRowItem.cs b/Queue/QueueRowItem.cs index 11c70cbca..249ef010e 100644 --- a/Queue/QueueRowItem.cs +++ b/Queue/QueueRowItem.cs @@ -58,8 +58,6 @@ namespace MatterHackers.MatterControl.PrintQueue private SlideWidget actionButtonContainer; - private Button addToLibraryLink; - private string alsoRemoveFromSdCardMessage = "Would you also like to remove this file from the Printer's SD Card?".Localize(); private string alsoRemoveFromSdCardTitle = "Remove From Printer's SD Card?"; @@ -220,6 +218,7 @@ namespace MatterHackers.MatterControl.PrintQueue selectionCheckBoxContainer.Visible = false; selectionCheckBoxContainer.Margin = new BorderDouble(left: 6); selectionCheckBox = new CheckBox(""); + selectionCheckBox.Name = "Queue Item Checkbox"; selectionCheckBox.VAnchor = VAnchor.ParentCenter; selectionCheckBox.HAnchor = HAnchor.ParentCenter; diff --git a/Tests/MatterControl.AutomationTests/PrintQueueTests.cs b/Tests/MatterControl.AutomationTests/PrintQueueTests.cs index 646a3e8b5..c0a71dc22 100644 --- a/Tests/MatterControl.AutomationTests/PrintQueueTests.cs +++ b/Tests/MatterControl.AutomationTests/PrintQueueTests.cs @@ -461,6 +461,49 @@ namespace MatterHackers.MatterControl.Tests.Automation await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); } + [Test, Apartment(ApartmentState.STA)] + public async Task QueueSelectCheckBoxWorks() + { + 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 items 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.ItemCount; + + bool queueItemExists = testRunner.WaitForName("Queue Item Batman", 2); + bool secondQueueItemExists = testRunner.WaitForName("Queue Item 2013-01-25_Mouthpiece_v2", 2); + + SystemWindow systemWindow; + GuiWidget rowItem = testRunner.GetWidgetByName("Queue Item Batman", out systemWindow, 3); + + SearchRegion rowItemRegion = testRunner.GetRegionByName("Queue Item Batman", 3); + + testRunner.ClickByName("Queue Edit Button", 3); + + GuiWidget foundWidget = testRunner.GetWidgetByName("Queue Item Checkbox", out systemWindow, 3, searchRegion: rowItemRegion); + CheckBox checkBoxWidget = foundWidget as CheckBox; + Assert.IsTrue(checkBoxWidget != null, "We should have an actual checkbox"); + Assert.IsTrue(checkBoxWidget.Checked == false, "currently not checked"); + + testRunner.ClickByName("Queue Item Batman", 3); + Assert.IsTrue(checkBoxWidget.Checked == true, "currently checked"); + + testRunner.ClickByName("Queue Item Checkbox", 3, searchRegion: rowItemRegion); + Assert.IsTrue(checkBoxWidget.Checked == false, "currently not checked"); + + + return Task.FromResult(0); + }; + + await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items); + } + /// /// Confirms the Export to Zip feature compresses and exports to a zip file and that file imports without issue ///