diff options
Diffstat (limited to 'uitest/src')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/grid/GridAssistiveCaption.java | 40 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/GridAssistiveCaptionTest.java | 49 |
2 files changed, 89 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridAssistiveCaption.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridAssistiveCaption.java new file mode 100644 index 0000000000..83351d82f2 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridAssistiveCaption.java @@ -0,0 +1,40 @@ +/* + * 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; + +public class GridAssistiveCaption 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("addAssistiveCaption", event -> { + grid.getColumns().get(0).setAssistiveCaption("Press Enter to sort."); + })); + addComponent(new Button("removeAssistiveCaption", event -> { + grid.getColumns().get(0).setAssistiveCaption(null); + })); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridAssistiveCaptionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridAssistiveCaptionTest.java new file mode 100644 index 0000000000..e15858900a --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridAssistiveCaptionTest.java @@ -0,0 +1,49 @@ +/* + * 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 static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class GridAssistiveCaptionTest extends SingleBrowserTest { + + @Test + public void checkGridAriaLabel() { + openTestURL(); + + GridElement.GridCellElement headerCell = $(GridElement.class).first() + .getHeaderCell(0, 0); + + // default grid has no aria-label + assertNull("Column should not contain aria-label", + headerCell.getAttribute("aria-label")); + + $(ButtonElement.class).caption("addAssistiveCaption").first().click(); + assertTrue("Column should contain aria-label", headerCell + .getAttribute("aria-label").equals("Press Enter to sort.")); + + $(ButtonElement.class).caption("removeAssistiveCaption").first() + .click(); + assertNull("Column should not contain aria-label", + headerCell.getAttribute("aria-label")); + } +} |