summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2019-07-12 09:05:20 +0300
committerZhe Sun <31067185+ZheSun88@users.noreply.github.com>2019-07-12 09:05:20 +0300
commit41de4e402e4b718804c71e9629c2030ff17df3e4 (patch)
treef824a211c7d5a0385d33957626e9f2ec42a7b43c /uitest
parent209a1cc77f619cad3e82afbd3ebd1ffbff560ef0 (diff)
downloadvaadin-framework-41de4e402e4b718804c71e9629c2030ff17df3e4.tar.gz
vaadin-framework-41de4e402e4b718804c71e9629c2030ff17df3e4.zip
Ensure the selection has been changed before updating . (#11658)
- Initial fix attempt interfered with selection events, added regression testing for those and found a better way to ensure shift selection works on IE11 also with Windows 7. Fixes #11608
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectMultiSelectionTest.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectMultiSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectMultiSelectionTest.java
index a5b2c6394c..116475c4bc 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectMultiSelectionTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectMultiSelectionTest.java
@@ -24,6 +24,7 @@ public class ListSelectMultiSelectionTest extends MultiBrowserTest {
@Test
public void testShiftSelect() {
openTestURL();
+ selectMenuPath("Component", "Listeners", "Selection listener");
ListSelectElement listSelect = $(ListSelectElement.class).first();
Select select = new Select(listSelect.getSelectElement());
@@ -31,6 +32,10 @@ public class ListSelectMultiSelectionTest extends MultiBrowserTest {
.findElements(By.tagName("option"));
options.get(0).click();
+ // ensure the selection event got through
+ assertEquals("1. Selected: [Item 0]", getLogs().get(0));
+
+ // ensure the state corresponds with the event
List<WebElement> selected = select.getAllSelectedOptions();
assertEquals(1, selected.size());
assertEquals("Item 0", selected.get(0).getText());
@@ -39,6 +44,8 @@ public class ListSelectMultiSelectionTest extends MultiBrowserTest {
options.get(1).click();
new Actions(getDriver()).keyUp(Keys.SHIFT).perform();
+ assertEquals("2. Selected: [Item 0, Item 1]", getLogs().get(0));
+
selected = select.getAllSelectedOptions();
assertEquals(2, selected.size());
assertEquals("Item 1", selected.get(1).getText());
@@ -48,6 +55,50 @@ public class ListSelectMultiSelectionTest extends MultiBrowserTest {
new Actions(getDriver()).keyUp(Keys.SHIFT).perform();
// ensure second shift selection added instead of moved
+ assertEquals("3. Selected: [Item 0, Item 1, Item 2]", getLogs().get(0));
+
+ selected = select.getAllSelectedOptions();
+ assertEquals(3, selected.size());
+ assertEquals("Item 2", selected.get(2).getText());
+ assertEquals("Item 0", selected.get(0).getText());
+ }
+
+ @Test
+ public void testShiftSelectWithKeys() {
+ openTestURL();
+ selectMenuPath("Component", "Listeners", "Selection listener");
+
+ ListSelectElement listSelect = $(ListSelectElement.class).first();
+ Select select = new Select(listSelect.getSelectElement());
+ List<WebElement> options = listSelect
+ .findElements(By.tagName("option"));
+ options.get(0).click();
+
+ // ensure the selection event got through
+ assertEquals("1. Selected: [Item 0]", getLogs().get(0));
+
+ // ensure the state corresponds with the event
+ List<WebElement> selected = select.getAllSelectedOptions();
+ assertEquals(1, selected.size());
+ assertEquals("Item 0", selected.get(0).getText());
+
+ new Actions(getDriver()).keyDown(Keys.SHIFT).perform();
+ new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform();
+ new Actions(getDriver()).keyUp(Keys.SHIFT).perform();
+
+ assertEquals("2. Selected: [Item 0, Item 1]", getLogs().get(0));
+
+ selected = select.getAllSelectedOptions();
+ assertEquals(2, selected.size());
+ assertEquals("Item 1", selected.get(1).getText());
+
+ new Actions(getDriver()).keyDown(Keys.SHIFT).perform();
+ new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform();
+ new Actions(getDriver()).keyUp(Keys.SHIFT).perform();
+
+ // ensure second shift selection added instead of moved
+ assertEquals("3. Selected: [Item 0, Item 1, Item 2]", getLogs().get(0));
+
selected = select.getAllSelectedOptions();
assertEquals(3, selected.size());
assertEquals("Item 2", selected.get(2).getText());