summaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2015-03-23 12:10:07 +0200
committerVaadin Code Review <review@vaadin.com>2015-03-24 09:04:25 +0000
commit2a671f2810dfb409cc4d30a1606868282d0925d3 (patch)
treeddc54f63c6dcbf82ced308659ed5a2b10869ebfe /server/tests
parent4f3397df74dc737a9c5592d5418e741433e20dee (diff)
downloadvaadin-framework-2a671f2810dfb409cc4d30a1606868282d0925d3.tar.gz
vaadin-framework-2a671f2810dfb409cc4d30a1606868282d0925d3.zip
Fix declarative support for CustomLayout (#17210)
CustomLayout now has a public default constructor. If a template is not set using one of the setters, a warning message is displayed like in the case where the template file is specified but not found. Change-Id: I5d56f24fafc5c82e6ab76dec393a0c25bd78aae5
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/customlayout/CustomLayoutDeclarativeTest.java96
1 files changed, 96 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/customlayout/CustomLayoutDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/customlayout/CustomLayoutDeclarativeTest.java
new file mode 100644
index 0000000000..44261a61dc
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/customlayout/CustomLayoutDeclarativeTest.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2000-2014 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.server.component.customlayout;
+
+import org.junit.Test;
+
+import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CustomLayout;
+import com.vaadin.ui.Label;
+
+/**
+ * Tests declarative support for {@link CustomLayout}.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class CustomLayoutDeclarativeTest extends
+ DeclarativeTestBase<CustomLayout> {
+
+ @Test
+ public void testEmpty() {
+ String design = "<v-custom-layout>";
+ CustomLayout expected = new CustomLayout();
+ test(design, expected);
+ }
+
+ @Test
+ public void testWithChildren() {
+ String design = "<v-custom-layout>" + //
+ "<v-button plain-text :location='b'></v-button>" + //
+ "<v-label plain-text :location='l'></v-label>" + //
+ "</v-custom-layout>";
+
+ CustomLayout expected = new CustomLayout();
+ expected.addComponent(new Button(), "b");
+ expected.addComponent(new Label(), "l");
+
+ test(design, expected);
+ }
+
+ @Test
+ public void testWithOneChild() {
+ String design = "<v-custom-layout><v-button plain-text></v-button></v-custom-layout>";
+
+ CustomLayout expected = new CustomLayout();
+ expected.addComponent(new Button());
+
+ test(design, expected);
+ }
+
+ @Test
+ public void testWithTemplate() {
+ String design = "<v-custom-layout template-name='template.html'></v-custom-layout>";
+ CustomLayout expected = new CustomLayout("template.html");
+ test(design, expected);
+ }
+
+ @Test
+ public void testWithDuplicateLocations() {
+ String design = "<v-custom-layout>" + //
+ "<v-button plain-text :location='foo'></v-button>" + //
+ "<v-label plain-text :location='foo'></v-label>" + //
+ "</v-custom-layout>";
+
+ CustomLayout expected = new CustomLayout();
+ expected.addComponent(new Button(), "foo");
+ expected.addComponent(new Label(), "foo");
+
+ testRead(design, expected);
+
+ String written = "<v-custom-layout>" + //
+ "<v-label plain-text :location='foo'></v-label>" + //
+ "</v-custom-layout>";
+
+ testWrite(written, expected);
+ }
+
+ protected void test(String design, CustomLayout expected) {
+ testRead(design, expected);
+ testWrite(design, expected);
+ }
+}