summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/ui/table/TableConnector.java6
-rw-r--r--uitest/src/com/vaadin/tests/components/table/SelectAllRows.java83
-rw-r--r--uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java105
3 files changed, 191 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java
index 07689a640f..80a84f0a19 100644
--- a/client/src/com/vaadin/client/ui/table/TableConnector.java
+++ b/client/src/com/vaadin/client/ui/table/TableConnector.java
@@ -142,9 +142,6 @@ public class TableConnector extends AbstractHasComponentsConnector implements
getWidget().updateSortingProperties(uidl);
- boolean keyboardSelectionOverRowFetchInProgress = getWidget()
- .selectSelectedRows(uidl);
-
getWidget().updateActionMap(uidl);
getWidget().updateColumnProperties(uidl);
@@ -216,6 +213,9 @@ public class TableConnector extends AbstractHasComponentsConnector implements
}
}
+ boolean keyboardSelectionOverRowFetchInProgress = getWidget()
+ .selectSelectedRows(uidl);
+
// If a row had an open context menu before the update, and after the
// update there's a row with the same key as that row, restore the
// context menu. See #8526.
diff --git a/uitest/src/com/vaadin/tests/components/table/SelectAllRows.java b/uitest/src/com/vaadin/tests/components/table/SelectAllRows.java
new file mode 100644
index 0000000000..6007ea2984
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/SelectAllRows.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.table;
+
+import java.util.Set;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+public class SelectAllRows extends AbstractTestUI {
+
+ static final String TABLE = "table";
+ static final String COUNT_SELECTED_BUTTON = "button";
+ static final int TOTAL_NUMBER_OF_ROWS = 300;
+ static final String COUNT_OF_SELECTED_ROWS_LABEL = "label";
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ layout.setSpacing(true);
+ setContent(layout);
+
+ final Table table = new Table();
+ table.setId(TABLE);
+ table.setImmediate(true);
+ table.setMultiSelect(true);
+ table.setSelectable(true);
+ table.addContainerProperty("row", String.class, null);
+ layout.addComponent(table);
+
+ Button button = new Button("Count");
+ button.setId(COUNT_SELECTED_BUTTON);
+ layout.addComponent(button);
+
+ final Label label = new Label();
+ label.setId(COUNT_OF_SELECTED_ROWS_LABEL);
+ label.setCaption("Selected count:");
+ layout.addComponent(label);
+
+ button.addClickListener(new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ Set selected = (Set) table.getValue();
+ label.setValue(String.valueOf(selected.size()));
+ }
+ });
+
+ for (int i = 0; i < TOTAL_NUMBER_OF_ROWS; i++) {
+ Object itemId = table.addItem();
+ table.getContainerProperty(itemId, "row").setValue("row " + i);
+ }
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Selecting all rows does not work by selecting first row, press shift then select last row";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 13008;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java b/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java
new file mode 100644
index 0000000000..664b36fa75
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.table;
+
+import static com.vaadin.tests.components.table.SelectAllRows.COUNT_OF_SELECTED_ROWS_LABEL;
+import static com.vaadin.tests.components.table.SelectAllRows.COUNT_SELECTED_BUTTON;
+import static com.vaadin.tests.components.table.SelectAllRows.TABLE;
+import static com.vaadin.tests.components.table.SelectAllRows.TOTAL_NUMBER_OF_ROWS;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class SelectAllRowsTest extends MultiBrowserTest {
+
+ private final static String TABLE_ROW = "v-table-row";
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ // Pressing Shift modifier key does not work with TestBench and IE
+ // (#8621)
+ return Arrays.asList(Browser.FIREFOX.getDesiredCapabilities(),
+ Browser.CHROME.getDesiredCapabilities());
+ }
+
+ @Test
+ public void testAllRowsAreSelected() {
+ openTestURL();
+
+ selectAllRowsInTable();
+ int selectedRows = countSelectedItems();
+
+ assertEquals(TOTAL_NUMBER_OF_ROWS, selectedRows);
+ }
+
+ private int countSelectedItems() {
+ WebElement countButton = vaadinElementById(COUNT_SELECTED_BUTTON);
+ countButton.click();
+ WebElement countOfSelectedRows = vaadinElementById(COUNT_OF_SELECTED_ROWS_LABEL);
+ String count = countOfSelectedRows.getText();
+ return Integer.parseInt(count);
+ }
+
+ private void selectAllRowsInTable() {
+ clickFirstRow();
+ scrollTableToBottom();
+ new Actions(getDriver()).keyDown(Keys.SHIFT).perform();
+ clickLastRow();
+ new Actions(getDriver()).keyUp(Keys.SHIFT).perform();
+ }
+
+ private void clickLastRow() {
+ List<WebElement> rows = allVisibleTableRows();
+ WebElement lastRow = rows.get(rows.size() - 1);
+ lastRow.click();
+ }
+
+ private void clickFirstRow() {
+ WebElement firstRow = allVisibleTableRows().get(0);
+ firstRow.click();
+ }
+
+ private void scrollTableToBottom() {
+ WebElement table = vaadinElementById(TABLE);
+ testBenchElement(table.findElement(By.className("v-scrollable")))
+ .scroll(TOTAL_NUMBER_OF_ROWS * 30);
+
+ // Wait for scrolling to complete. Otherwise, clicking last row will
+ // fail with Chrome
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private List<WebElement> allVisibleTableRows() {
+ WebElement table = vaadinElementById(TABLE);
+ List<WebElement> rows = table.findElements(By
+ .cssSelector(".v-table-table tr"));
+ return rows;
+ }
+}