summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorKnoobie <Knoobie@gmx.de>2017-10-11 12:15:26 +0200
committerHenri Sara <henri.sara@gmail.com>2017-10-11 13:15:26 +0300
commit0843f53881a3514a72370e51ab33f59df423aa0e (patch)
treeb094e68eb28adf57a540c2624f9ad78f888fddf9 /uitest
parent69c6675572e05c6b9c193b402f8d980f6af40884 (diff)
downloadvaadin-framework-0843f53881a3514a72370e51ab33f59df423aa0e.tar.gz
vaadin-framework-0843f53881a3514a72370e51ab33f59df423aa0e.zip
Add aria-rowcount to grid (#10167)
This is based on discussion from vaadin/vaadin-grid#1023 .
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridAriaMultiselectable.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridAriaRowcount.java54
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridAriaRowcount.java53
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridAriaRowcountTest.java74
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridAriaRowcountTest.java73
5 files changed, 255 insertions, 1 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridAriaMultiselectable.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridAriaMultiselectable.java
index 144e518c43..0841c5f3b1 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridAriaMultiselectable.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridAriaMultiselectable.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 Vaadin Ltd.
+ * Copyright 2000-2017 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
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridAriaRowcount.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridAriaRowcount.java
new file mode 100644
index 0000000000..2f67a63031
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridAriaRowcount.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2000-2017 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.grid;
+
+import com.vaadin.data.ValueProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
+
+/**
+ * @author Vaadin Ltd
+ *
+ */
+public class GridAriaRowcount extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Grid<String> grid = new Grid<>();
+ grid.addColumn(ValueProvider.identity());
+ grid.setItems("a", "b");
+ addComponent(grid);
+
+ addComponent(new Button("addFooter", event -> grid.addFooterRowAt(0)));
+ addComponent(new Button("removeFooter", event -> grid.removeFooterRow(0)));
+
+ addComponent(new Button("addHeader", event -> grid.addHeaderRowAt(1)));
+ addComponent(new Button("removeHeader", event -> grid.removeHeaderRow(1)));
+
+ addComponent(new Button("setItemsTo3", event -> grid.setItems("a", "b", "c")));
+ addComponent(new Button("setItemsTo6", event -> grid.setItems("a", "b", "c", "d", "e", "f")));
+
+ addComponent(new Button("updateAll", event -> {
+ grid.addFooterRowAt(0);
+ grid.addHeaderRowAt(0);
+ grid.setItems("a", "b", "c", "d");
+ }));
+
+ }
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridAriaRowcount.java b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridAriaRowcount.java
new file mode 100644
index 0000000000..ed0a89274a
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridAriaRowcount.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2000-2017 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.treegrid;
+
+import com.vaadin.data.ValueProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.TreeGrid;
+
+/**
+ * @author Vaadin Ltd
+ *
+ */
+public class TreeGridAriaRowcount extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ TreeGrid<String> grid = new TreeGrid<>();
+ grid.addColumn(ValueProvider.identity());
+ grid.setItems("a", "b");
+ addComponent(grid);
+
+ addComponent(new Button("addFooter", event -> grid.addFooterRowAt(0)));
+ addComponent(new Button("removeFooter", event -> grid.removeFooterRow(0)));
+
+ addComponent(new Button("addHeader", event -> grid.addHeaderRowAt(1)));
+ addComponent(new Button("removeHeader", event -> grid.removeHeaderRow(1)));
+
+ addComponent(new Button("setItemsTo3", event -> grid.setItems("a", "b", "c")));
+ addComponent(new Button("setItemsTo6", event -> grid.setItems("a", "b", "c", "d", "e", "f")));
+
+ addComponent(new Button("updateAll", event -> {
+ grid.addFooterRowAt(0);
+ grid.addHeaderRowAt(0);
+ grid.setItems("a", "b", "c", "d");
+ }));
+
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridAriaRowcountTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridAriaRowcountTest.java
new file mode 100644
index 0000000000..cf2bdebb6f
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridAriaRowcountTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2000-2017 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.grid;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Vaadin Ltd
+ */
+public class GridAriaRowcountTest extends SingleBrowserTest {
+
+ private GridElement grid;
+
+ @Test
+ public void checkGridAriaRowcount() {
+ openTestURL();
+
+ grid = $(GridElement.class).first();
+
+ // default with 1 header row and 2 body rows.
+ assertTrue("Grid should have 3 rows", containsRows(3));
+
+ $(ButtonElement.class).caption("addFooter").first().click();
+ // 1 header row, 2 body rows and 1 footer row.
+ assertTrue("Grid should have 4 rows", containsRows(4));
+
+ $(ButtonElement.class).caption("removeFooter").first().click();
+ // 1 header row and 2 body rows.
+ assertTrue("Grid should have 3 rows", containsRows(3));
+
+ $(ButtonElement.class).caption("addHeader").first().click();
+ // 2 header row and 2 body rows.
+ assertTrue("Grid should have 4 rows", containsRows(4));
+
+ $(ButtonElement.class).caption("removeHeader").first().click();
+ // 1 header row and 2 body rows.
+ assertTrue("Grid should have 3 rows", containsRows(3));
+
+ $(ButtonElement.class).caption("setItemsTo3").first().click();
+ // 1 header row and 3 body rows.
+ assertTrue("Grid should have 4 rows", containsRows(4));
+
+ $(ButtonElement.class).caption("setItemsTo6").first().click();
+ // 1 header row and 6 body rows.
+ assertTrue("Grid should have 7 rows", containsRows(7));
+
+ $(ButtonElement.class).caption("updateAll").first().click();
+ // 2 header rows, 4 body rows and 1 footer row.
+ assertTrue("Grid should have 7 rows", containsRows(7));
+ }
+
+ private boolean containsRows(int rowcount) {
+ return grid.getHTML().contains("aria-rowcount=\"" + String.valueOf(rowcount) + "\"");
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridAriaRowcountTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridAriaRowcountTest.java
new file mode 100644
index 0000000000..df940c7091
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridAriaRowcountTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2017 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.treegrid;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TreeGridElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Vaadin Ltd
+ */
+public class TreeGridAriaRowcountTest extends SingleBrowserTest {
+
+ private TreeGridElement grid;
+
+ @Test
+ public void checkTreeGridAriaRowcount() {
+ openTestURL();
+
+ grid = $(TreeGridElement.class).first();
+
+ // default with 1 header row and 2 body rows.
+ assertTrue("Grid should have 3 rows", containsRows(3));
+
+ $(ButtonElement.class).caption("addFooter").first().click();
+ // 1 header row, 2 body rows and 1 footer row.
+ assertTrue("Grid should have 4 rows", containsRows(4));
+
+ $(ButtonElement.class).caption("removeFooter").first().click();
+ // 1 header row and 2 body rows.
+ assertTrue("Grid should have 3 rows", containsRows(3));
+
+ $(ButtonElement.class).caption("addHeader").first().click();
+ // 2 header row and 2 body rows.
+ assertTrue("Grid should have 4 rows", containsRows(4));
+
+ $(ButtonElement.class).caption("removeHeader").first().click();
+ // 1 header row and 2 body rows.
+ assertTrue("Grid should have 3 rows", containsRows(3));
+
+ $(ButtonElement.class).caption("setItemsTo3").first().click();
+ // 1 header row and 3 body rows.
+ assertTrue("Grid should have 4 rows", containsRows(4));
+
+ $(ButtonElement.class).caption("setItemsTo6").first().click();
+ // 1 header row and 6 body rows.
+ assertTrue("Grid should have 7 rows", containsRows(7));
+
+ $(ButtonElement.class).caption("updateAll").first().click();
+ // 2 header rows, 4 body rows and 1 footer row.
+ assertTrue("Grid should have 7 rows", containsRows(7));
+ }
+
+ private boolean containsRows(int rowcount) {
+ return grid.getHTML().contains("aria-rowcount=\"" + String.valueOf(rowcount) + "\"");
+ }
+}