summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorPatrik Lindström <patrik@vaadin.com>2014-08-25 14:44:12 +0300
committerPatrik Lindström <patrik@vaadin.com>2014-09-02 16:22:04 +0300
commit600d5b436d7ca33840b1b697082d140a5040bdf3 (patch)
treeea4c25ef2c9d6af4c3cd7b0b4bcc976cf8baa659 /uitest
parent95f9cdf4e0d4f5d4a2991468bbb1b77bbb1e3ae3 (diff)
downloadvaadin-framework-600d5b436d7ca33840b1b697082d140a5040bdf3.tar.gz
vaadin-framework-600d5b436d7ca33840b1b697082d140a5040bdf3.zip
Add keyboard sorting controls (#13334)
Change-Id: Icb0ef5d70b5469cd87bdd079fe16f31b8cf769f1
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSortingTest.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSortingTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSortingTest.java
index 024be65e83..74a5c6ed95 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSortingTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSortingTest.java
@@ -191,6 +191,75 @@ public class GridSortingTest extends GridBasicFeaturesTest {
}
+ private void sendKeys(CharSequence... seq) {
+ new Actions(getDriver()).sendKeys(seq).perform();
+ }
+
+ private void holdKey(Keys key) {
+ new Actions(getDriver()).keyDown(key).perform();
+ }
+
+ private void releaseKey(Keys key) {
+ new Actions(getDriver()).keyUp(key).perform();
+ }
+
+ private void assertLog(String expected) {
+ assertEquals(expected, getLogRow(0));
+ }
+
+ @Test
+ public void testKeyboardMultiColumnSorting() throws InterruptedException {
+ openTestURL();
+
+ //
+ // NOTE: This is a work-around to get the focus to the first header
+ // cell.
+ // We can't use element.focus() because TestBench (or, rather, Selenium
+ // beneath it) has rather interesting bugs regarding focus handling.
+ //
+ getGridElement().getCell(0, 0).click();
+ sendKeys(Keys.ARROW_UP);
+
+ // Sort ASCENDING on first column
+ sendKeys(Keys.ENTER);
+ assertLog("2. Sort order: [Column 0 ASCENDING] by USER");
+
+ // Move to next column
+ sendKeys(Keys.RIGHT);
+
+ // Add this column to the existing sorting group
+ holdKey(Keys.SHIFT);
+ sendKeys(Keys.ENTER);
+ releaseKey(Keys.SHIFT);
+ assertLog("4. Sort order: [Column 0 ASCENDING, Column 1 ASCENDING] by USER");
+
+ // Move to next column
+ sendKeys(Keys.RIGHT);
+
+ // Add a third column to the sorting group
+ holdKey(Keys.SHIFT);
+ sendKeys(Keys.ENTER);
+ releaseKey(Keys.SHIFT);
+ assertLog("6. Sort order: [Column 0 ASCENDING, Column 1 ASCENDING, Column 2 ASCENDING] by USER");
+
+ // Move back to the second column
+ sendKeys(Keys.LEFT);
+
+ // Change sort direction of the second column to DESCENDING
+ holdKey(Keys.SHIFT);
+ sendKeys(Keys.ENTER);
+ releaseKey(Keys.SHIFT);
+ assertLog("8. Sort order: [Column 0 ASCENDING, Column 1 DESCENDING, Column 2 ASCENDING] by USER");
+
+ // Move back to the third column
+ sendKeys(Keys.RIGHT);
+
+ // Reset sorting to third column, ASCENDING
+ sendKeys(Keys.ENTER);
+ assertLog("10. Sort order: [Column 2 ASCENDING] by USER");
+
+ }
+
private void sortBy(String column) {
selectMenuPath("Component", "State", "Sort by column", column);
}