summaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2015-04-10 16:24:32 +0300
committerVaadin Code Review <review@vaadin.com>2015-04-13 07:44:34 +0000
commitb3b50eb368a8b6200200b6b1f1324d0fc63f4409 (patch)
treece5de38fec4e84022029251c4783ec0d54c61851 /server/tests
parent24a192101b253bfeae73389879bfd1fea6a8a921 (diff)
downloadvaadin-framework-b3b50eb368a8b6200200b6b1f1324d0fc63f4409.tar.gz
vaadin-framework-b3b50eb368a8b6200200b6b1f1324d0fc63f4409.zip
Fix writing of child local ids in AbsoluteLayout (#17421)
Change-Id: I49eb3246061e1b011a0f87e94d2a43eb20c31a34
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java b/server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java
index c3d7e6d8cf..dffeb2e412 100644
--- a/server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java
+++ b/server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java
@@ -20,11 +20,25 @@ import static org.junit.Assert.assertEquals;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import org.jsoup.nodes.Element;
import org.junit.Test;
+import com.vaadin.ui.AbsoluteLayout;
+import com.vaadin.ui.Accordion;
import com.vaadin.ui.Button;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.CustomLayout;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.SingleComponentContainer;
+import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.VerticalSplitPanel;
+import com.vaadin.ui.Window;
import com.vaadin.ui.declarative.Design;
import com.vaadin.ui.declarative.DesignContext;
@@ -57,4 +71,46 @@ public class DesignContextLocalIdTest {
assertEquals("Found the wrong component by local id.", ctx
.getComponentByLocalId("bar").getClass(), TextField.class);
}
+
+ @Test
+ public void testWriteLocalId() {
+ DesignContext ctx = new DesignContext();
+
+ Button b = new Button();
+ ctx.setComponentLocalId(b, "button-id");
+
+ assertEquals("button-id", ctx.createElement(b).attr("_id"));
+ }
+
+ @Test
+ public void testWriteChildLocalIds() throws Exception {
+ DesignContext ctx = new DesignContext();
+
+ ComponentContainer[] ctrs = { new AbsoluteLayout(), new CssLayout(),
+ new GridLayout(1, 1), new CustomLayout(),
+ new HorizontalLayout(), new VerticalLayout(), new Accordion(),
+ new HorizontalSplitPanel(), new TabSheet(),
+ new VerticalSplitPanel() };
+
+ Button b = new Button();
+ ctx.setComponentLocalId(b, "button-id");
+
+ for (ComponentContainer ctr : ctrs) {
+ ctr.addComponent(b);
+ Element e = ctx.createElement(ctr);
+ assertEquals("Unexpected child local id for "
+ + ctr.getClass().getSimpleName(), "button-id", e
+ .getElementsByTag("v-button").first().attr("_id"));
+ }
+
+ SingleComponentContainer[] sctrs = { new Window(), new Panel() };
+
+ for (SingleComponentContainer ctr : sctrs) {
+ ctr.setContent(b);
+ Element e = ctx.createElement(ctr);
+ assertEquals("Unexpected child local id for "
+ + ctr.getClass().getSimpleName(), "button-id", e
+ .getElementsByTag("v-button").first().attr("_id"));
+ }
+ }
}