From 5ef925daa91b1253f170f244e2a992f4f92979e1 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Mon, 21 Aug 2017 12:01:32 +0300 Subject: Add item descriptions to Tree (#9840) Fixes #9803 --- .../com/vaadin/tests/components/tree/TreeBasicFeatures.java | 13 ++++++++++--- .../vaadin/tests/components/tree/TreeBasicFeaturesTest.java | 8 ++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'uitest') diff --git a/uitest/src/main/java/com/vaadin/tests/components/tree/TreeBasicFeatures.java b/uitest/src/main/java/com/vaadin/tests/components/tree/TreeBasicFeatures.java index edcb76e1ca..b18364ccb8 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/tree/TreeBasicFeatures.java +++ b/uitest/src/main/java/com/vaadin/tests/components/tree/TreeBasicFeatures.java @@ -1,10 +1,7 @@ package com.vaadin.tests.components.tree; import java.util.Arrays; -import java.util.Enumeration; import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; import java.util.stream.Stream; import com.vaadin.annotations.Theme; @@ -76,6 +73,7 @@ public class TreeBasicFeatures extends AbstractTestUIWithLog { MenuItem componentMenu = menu.addItem("Component", null); createIconMenu(componentMenu.addItem("Icons", null)); createCaptionMenu(componentMenu.addItem("Captions", null)); + createDescriptionMenu(componentMenu.addItem("Descriptions", null)); createContentModeMenu(componentMenu.addItem("ContentMode", null)); createSelectionModeMenu(componentMenu.addItem("Selection Mode", null)); createRowHeightMenu(componentMenu.addItem("Row Height", null)); @@ -149,6 +147,15 @@ public class TreeBasicFeatures extends AbstractTestUIWithLog { }); } + private void createDescriptionMenu(MenuItem descriptionMenu) { + descriptionMenu.addItem("No Description", menu -> { + tree.setItemDescriptionGenerator(t -> null); + }); + descriptionMenu.addItem("String.valueOf", menu -> { + tree.setItemDescriptionGenerator(String::valueOf); + }); + } + private void createContentModeMenu(MenuItem contentModeMenu) { Arrays.stream(ContentMode.values()).forEach(mode -> contentModeMenu .addItem(mode.toString(), item -> tree.setContentMode(mode))); diff --git a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java index 4137e11098..34be123ee2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java @@ -252,4 +252,12 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { .contains("height: " + height + "px;")); }); } + + @Test + public void tree_item_description() { + selectMenuPath("Component", "Descriptions", "String.valueOf"); + + $(TreeElement.class).first().getItem(0).showTooltip(); + Assert.assertEquals("", "0 | 0", getTooltipElement().getText()); + } } -- cgit v1.2.3