From e65efdfb50bc10bedf506d475f582276f6be0e2f Mon Sep 17 00:00:00 2001 From: Knoobie Date: Mon, 30 Oct 2017 09:00:21 +0100 Subject: add Grid.Column#get/setAssistiveCaption (#10219) * add Grid#Column#get/setAssistiveCaption * fix test and update doc * move testGridAssistiveCaption to GridTest * delete test file * delete test file * Delete GridAssistiveCaptionTest.java * Create GridAssistiveCaptionTest * Create GridAssistiveCaption * Rename GridAssistiveCaption to GridAssistiveCaption.java * Rename GridAssistiveCaptionTest to GridAssistiveCaptionTest.java * Reformat using eclipse --- .../components/grid/GridAssistiveCaption.java | 40 ++++++++++++++++++ .../components/grid/GridAssistiveCaptionTest.java | 49 ++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 uitest/src/main/java/com/vaadin/tests/components/grid/GridAssistiveCaption.java create mode 100644 uitest/src/test/java/com/vaadin/tests/components/grid/GridAssistiveCaptionTest.java (limited to 'uitest/src') 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 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")); + } +} -- cgit v1.2.3