diff options
author | Artur Signell <artur@vaadin.com> | 2014-12-13 12:12:12 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2014-12-14 21:24:26 +0200 |
commit | 3f7c75415bc73ab750f809bde0c5da02f5d8e7c2 (patch) | |
tree | ab81704a3c74a6ee6d4f5e431c220eaa155050a7 /server/tests | |
parent | 2789f701678106e9f5141b096706ace0d6880780 (diff) | |
download | vaadin-framework-3f7c75415bc73ab750f809bde0c5da02f5d8e7c2.tar.gz vaadin-framework-3f7c75415bc73ab750f809bde0c5da02f5d8e7c2.zip |
Support plain-text attribute for Label (#7749)
Change-Id: I4ef210d131f1e616b501468cb94ea518945a3b30
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/button/TestSynchronizeToDesign.java | 13 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/label/TestSynchronizeToDesign.java | 43 |
2 files changed, 53 insertions, 3 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/button/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/button/TestSynchronizeToDesign.java index 7e9d673f35..c96fd36d5d 100644 --- a/server/tests/src/com/vaadin/tests/server/component/button/TestSynchronizeToDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/button/TestSynchronizeToDesign.java @@ -66,6 +66,19 @@ public class TestSynchronizeToDesign extends TestCase { assertEquals("ctrl-shift-o", e.attr("click-shortcut")); } + @Test + public void testUpdateContentMode() { + Button button = new Button("OK"); + Element e = new Element(Tag.valueOf("v-button"), "", new Attributes()); + button.synchronizeToDesign(e, ctx); + assertTrue("Button is plain text by default", e.hasAttr("plain-text")); + + button.setHtmlContentAllowed(true); + button.synchronizeToDesign(e, ctx); + assertTrue("Button is updated to HTML", !e.hasAttr("plain-text")); + + } + private void createAndTestButtons(String content) { Button b1 = new Button(content); // we need to set this on, since the plain-text attribute will appear diff --git a/server/tests/src/com/vaadin/tests/server/component/label/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/label/TestSynchronizeToDesign.java index 462e6a087b..869546ac3d 100644 --- a/server/tests/src/com/vaadin/tests/server/component/label/TestSynchronizeToDesign.java +++ b/server/tests/src/com/vaadin/tests/server/component/label/TestSynchronizeToDesign.java @@ -17,9 +17,12 @@ package com.vaadin.tests.server.component.label; import junit.framework.TestCase; +import org.jsoup.nodes.Attributes; import org.jsoup.nodes.Element; +import org.jsoup.parser.Tag; import org.junit.Test; +import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Label; import com.vaadin.ui.declarative.DesignContext; @@ -57,6 +60,43 @@ public class TestSynchronizeToDesign extends TestCase { } @Test + public void testContentModeText() { + Label l = new Label("plain text label"); + Element e = new Element(Tag.valueOf("v-label"), "", new Attributes()); + l.synchronizeToDesign(e, ctx); + assertTrue("Label should be marked as plain text", + e.hasAttr("plain-text")); + } + + @Test + public void testContentModeHtml() { + Label l = new Label("html label"); + l.setContentMode(ContentMode.HTML); + + Element e = new Element(Tag.valueOf("v-label"), "", new Attributes()); + l.synchronizeToDesign(e, ctx); + assertFalse("Label should not be marked as plain text", + e.hasAttr("plain-text")); + } + + @Test + public void testChangeContentMode() { + Label l = new Label("html label"); + l.setContentMode(ContentMode.HTML); + + Element e = new Element(Tag.valueOf("v-label"), "", new Attributes()); + l.synchronizeToDesign(e, ctx); + + assertFalse("Label should not be marked as plain text", + e.hasAttr("plain-text")); + l.setContentMode(ContentMode.TEXT); + l.synchronizeToDesign(e, ctx); + + assertTrue("Label should be marked as plain text", + e.hasAttr("plain-text")); + } + + @Test public void testWithoutContentAndCaption() { createAndTestLabel(null, null); } @@ -75,9 +115,6 @@ public class TestSynchronizeToDesign extends TestCase { assertTrue("Unexpected content in the v-label element.", e.html() == null || "".equals(e.html())); } - int numAttributes = (caption == null ? 0 : 1); - assertEquals("Wrong number of attributes in v-label.", numAttributes, e - .attributes().size()); if (caption != null) { assertEquals("Wrong caption in the v-label element.", caption, e.attr("caption")); |