-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add explicit handling of ctrl-a (#11693)
* Add explicit handling of ctrl-a Fixes #11678 * Adds test case and formatting the code
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
uitest/src/main/java/com/vaadin/tests/components/twincolselect/TwinColSelectCtrlA.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.vaadin.tests.components.twincolselect; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
import com.vaadin.server.VaadinRequest; | ||
import com.vaadin.tests.components.AbstractTestUI; | ||
import com.vaadin.ui.TwinColSelect; | ||
|
||
public class TwinColSelectCtrlA extends AbstractTestUI { | ||
|
||
@Override | ||
protected void setup(VaadinRequest request) { | ||
List<String> data = IntStream.range(0, 6).mapToObj(i -> "Option " + i) | ||
.collect(Collectors.toList()); | ||
|
||
TwinColSelect twinColSelect = new TwinColSelect<>(null, data); | ||
|
||
twinColSelect.setRows(6); | ||
twinColSelect.setLeftColumnCaption("Available options"); | ||
twinColSelect.setRightColumnCaption("Selected options"); | ||
|
||
addComponent(twinColSelect); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectCtrlATest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.vaadin.tests.components.twincolselect; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.Keys; | ||
|
||
import com.vaadin.testbench.elements.TwinColSelectElement; | ||
import com.vaadin.tests.tb3.MultiBrowserTest; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class TwinColSelectCtrlATest extends MultiBrowserTest { | ||
|
||
@Before | ||
public void setUp() { | ||
openTestURL(); | ||
} | ||
|
||
@Test | ||
public void TestSelectionWithCtrlA() { | ||
TwinColSelectElement twinColSelectElement = $(TwinColSelectElement.class).first(); | ||
|
||
twinColSelectElement.findElement(By.tagName("select")) | ||
.sendKeys(Keys.chord(Keys.CONTROL, "a")); | ||
twinColSelectElement.findElements(By.className("v-button")).get(0) | ||
.click(); | ||
assertEquals(twinColSelectElement.getValues().size(), 6); | ||
} | ||
} |