summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2018-03-13 14:03:29 +0200
committerIlia Motornyi <elmot@vaadin.com>2018-03-13 15:03:29 +0300
commite813c97e0bdc00c5542c9bf0f55eef65f34ac093 (patch)
treedf2557a4a63a9de77234358e0c55bfc8ca1185ff /uitest
parent0af3b7d717b44b0de1af82143b3c3d3aece587ab (diff)
downloadvaadin-framework-e813c97e0bdc00c5542c9bf0f55eef65f34ac093.tar.gz
vaadin-framework-e813c97e0bdc00c5542c9bf0f55eef65f34ac093.zip
Setting of tooltips for grid header/footer cells (#10489)
Fixes #7527
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridHeaderFooterTooltip.java113
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterTooltipTest.java93
2 files changed, 206 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridHeaderFooterTooltip.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridHeaderFooterTooltip.java
new file mode 100644
index 0000000000..c5684e6311
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridHeaderFooterTooltip.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2000-2016 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.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ContentMode;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.data.bean.Person;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.Column;
+import com.vaadin.ui.Grid.SelectionMode;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.components.grid.FooterRow;
+import com.vaadin.ui.components.grid.HeaderCell;
+import com.vaadin.ui.components.grid.HeaderRow;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class GridHeaderFooterTooltip extends AbstractTestUI {
+
+ private static final long serialVersionUID = -2787771187365766027L;
+
+ private HeaderRow row;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Grid<Person> grid = new Grid<>(Person.class);
+ grid.setWidth("600px");
+
+ grid.setSelectionMode(SelectionMode.SINGLE);
+ addComponent(grid);
+
+ grid.getDefaultHeaderRow().getCell("firstName").setDescription(
+ "Text: Header tooltip for <b>first</b> name", ContentMode.TEXT);
+ grid.getDefaultHeaderRow().getCell("lastName").setDescription(
+ "HTML: Header tooltip for <b>last</b> name", ContentMode.HTML);
+ grid.getDefaultHeaderRow().getCell("deceased").setDescription(
+ "PRE\nHeader tooltip for\n<b>deceased</b>",
+ ContentMode.PREFORMATTED);
+ grid.setDescription("Tooltip for the whole grid");
+
+ FooterRow footer = grid.addFooterRowAt(0);
+ footer.getCell("firstName").setDescription(
+ "Text: Footer tooltip for <b>first</b> name", ContentMode.TEXT);
+ footer.getCell("lastName").setDescription(
+ "HTML: Footer tooltip for <b>last</b> name", ContentMode.HTML);
+ footer.getCell("deceased").setDescription(
+ "PRE\nFooter tooltip for\n<b>deceased</b>",
+ ContentMode.PREFORMATTED);
+
+ grid.setItems(Person.createTestPerson1(), Person.createTestPerson2());
+
+ Button showHide = new Button("Hide firstName", event -> {
+ Column<Person, ?> column = grid.getColumn("firstName");
+ if (grid.getColumn("firstName") != null) {
+ grid.removeColumn(column);
+ event.getButton().setCaption("Show firstName");
+ } else {
+ grid.addColumn(Person::getFirstName).setId("firstName");
+ grid.setColumnOrder(grid.getColumn("firstName"),
+ grid.getColumn("lastName"),
+ grid.getColumn("streetAddress"), grid.getColumn("zip"),
+ grid.getColumn("city"));
+
+ event.getButton().setCaption("Hide firstName");
+ }
+ });
+ showHide.setId("show_hide");
+
+ Button join = new Button("Add Join header column", event -> {
+ if (row == null) {
+ row = grid.prependHeaderRow();
+ HeaderCell joinedCell = row.join(
+ grid.getDefaultHeaderRow()
+ .getCell(grid.getColumn("firstName")),
+ grid.getDefaultHeaderRow()
+ .getCell(grid.getColumn("lastName")));
+ joinedCell.setText("Full Name");
+ joinedCell.setDescription("Full name tooltip");
+ } else {
+ grid.removeHeaderRow(row);
+ row = null;
+ }
+ });
+ join.setId("join");
+ addComponent(new HorizontalLayout(showHide, join));
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Grid for testing header re-rendering.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 17131;
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterTooltipTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterTooltipTest.java
new file mode 100644
index 0000000000..8752196e1c
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterTooltipTest.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2000-2016 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 org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.testbench.elements.GridElement.GridCellElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class GridHeaderFooterTooltipTest extends SingleBrowserTest {
+
+ private GridElement grid;
+
+ @Override
+ public void setup() throws Exception {
+ super.setup();
+ openTestURL();
+ grid = $(GridElement.class).first();
+ }
+
+ @Test
+ public void headerTooltipShown() {
+ GridCellElement lastName = grid.getHeaderCell(0, 0);
+ GridCellElement firstName = grid.getHeaderCell(0, 1);
+ GridCellElement deceased = grid.getHeaderCell(0, 2);
+
+ lastName.showTooltip();
+ Assert.assertEquals("HTML: Header tooltip for last name",
+ getTooltipElement().getText());
+
+ firstName.showTooltip();
+ Assert.assertEquals("Text: Header tooltip for <b>first</b> name",
+ getTooltipElement().getText());
+
+ deceased.showTooltip();
+ Assert.assertEquals("PRE\nHeader tooltip for\n<b>deceased</b>",
+ getTooltipElement().getText());
+ }
+
+ @Test
+ public void headerWithoutTooltipShowsGridTooltip() {
+ GridCellElement otherHeader = grid.getHeaderCell(0, 3);
+
+ otherHeader.showTooltip();
+ Assert.assertEquals("Tooltip for the whole grid",
+ getTooltipElement().getText());
+
+ }
+
+ @Test
+ public void joinedHeaderTooltipShown() {
+ $(ButtonElement.class).id("join").click();
+ GridCellElement fullName = grid.getHeaderCell(0, 0);
+ fullName.showTooltip();
+ Assert.assertEquals("Full name tooltip", getTooltipElement().getText());
+ }
+
+ @Test
+ public void footerTooltipShown() {
+ GridCellElement lastName = grid.getFooterCell(0, 0);
+ GridCellElement firstName = grid.getFooterCell(0, 1);
+ GridCellElement deceased = grid.getFooterCell(0, 2);
+
+ lastName.showTooltip();
+ Assert.assertEquals("HTML: Footer tooltip for last name",
+ getTooltipElement().getText());
+
+ firstName.showTooltip();
+ Assert.assertEquals("Text: Footer tooltip for <b>first</b> name",
+ getTooltipElement().getText());
+
+ deceased.showTooltip();
+ Assert.assertEquals("PRE\nFooter tooltip for\n<b>deceased</b>",
+ getTooltipElement().getText());
+
+ }
+}