summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-08-02 15:32:31 +0300
committerHenri Sara <henri.sara@gmail.com>2017-08-02 15:32:31 +0300
commit5b0accf49295cab4a494b2949d067ff7655d3c42 (patch)
tree2f932126a0665e92d865e1c9eba0c54f02c00036 /uitest
parent9153f1534aa78dc0c85c0a512f956d30c0e1c570 (diff)
downloadvaadin-framework-5b0accf49295cab4a494b2949d067ff7655d3c42.tar.gz
vaadin-framework-5b0accf49295cab4a494b2949d067ff7655d3c42.zip
Add automatic recalculation of Tree width on expand/collapse (#9767)
Fixes #9628
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/tree/TreeWideContent.java36
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/tree/TreeWideContentTest.java48
2 files changed, 84 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/tree/TreeWideContent.java b/uitest/src/main/java/com/vaadin/tests/components/tree/TreeWideContent.java
new file mode 100644
index 0000000000..2835829ae3
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/tree/TreeWideContent.java
@@ -0,0 +1,36 @@
+package com.vaadin.tests.components.tree;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.data.TreeData;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Tree;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class TreeWideContent extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Tree<String> tree = new Tree<>();
+
+ tree.setWidth("150px");
+ tree.setHeight("100px");
+
+ TreeData<String> data = new TreeData();
+ data.addItem(null, "Foo");
+ data.addItem("Foo", "Extra long text content that should be wider"
+ + " than the allocated width of the Tree.");
+ data.addItem(null, "Bar");
+ data.addItem(null, "Baz");
+ tree.setTreeData(data);
+
+ // Expand the wide one initially.
+ tree.expand("Foo");
+
+ addComponent(tree);
+ addComponent(new Button("Toggle auto recalc", e -> tree
+ .setAutoRecalculateWidth(!tree.isAutoRecalculateWidth())));
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeWideContentTest.java b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeWideContentTest.java
new file mode 100644
index 0000000000..da353b545b
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeWideContentTest.java
@@ -0,0 +1,48 @@
+package com.vaadin.tests.components.tree;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TreeElement;
+import com.vaadin.testbench.elements.TreeGridElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class TreeWideContentTest extends SingleBrowserTest {
+
+ @Test
+ public void testInitialSize() {
+ openTestURL();
+
+ TreeGridElement tree = $(TreeElement.class).first()
+ .wrap(TreeGridElement.class);
+ Assert.assertTrue("Row should be wider than tree",
+ tree.getTableWrapper().getSize().getWidth() < tree.getRow(0)
+ .getSize().getWidth());
+ }
+
+ @Test
+ public void testSizeAfterCollapse() {
+ openTestURL();
+
+ TreeElement tree = $(TreeElement.class).first();
+ tree.collapse(0);
+ TreeGridElement treeGrid = tree.wrap(TreeGridElement.class);
+ Assert.assertTrue("Row should be as wide as tree",
+ treeGrid.getTableWrapper().getSize().getWidth() == treeGrid
+ .getRow(0).getSize().getWidth());
+ }
+
+ @Test
+ public void testSizeWithAutoRecalcDisabled() {
+ openTestURL();
+ // Disable auto recalc
+ $(ButtonElement.class).first().click();
+
+ TreeElement tree = $(TreeElement.class).first();
+ TreeGridElement treeGrid = tree.wrap(TreeGridElement.class);
+ Assert.assertTrue("Row should be as wide as tree",
+ treeGrid.getTableWrapper().getSize().getWidth() == treeGrid
+ .getRow(0).getSize().getWidth());
+ }
+}