]> source.dussan.org Git - vaadin-framework.git/commitdiff
SynchronizeFrom/ToDesign -> read/writeDesign (#7749)
authorArtur Signell <artur@vaadin.com>
Sun, 14 Dec 2014 19:34:01 +0000 (21:34 +0200)
committerMatti Hosio <mhosio@vaadin.com>
Mon, 15 Dec 2014 12:29:25 +0000 (14:29 +0200)
Change-Id: Ie5e420ac5d62a2aa3206051888e6dd0f8f30df11

70 files changed:
server/src/com/vaadin/server/ClientConnector.java
server/src/com/vaadin/ui/AbsoluteLayout.java
server/src/com/vaadin/ui/AbstractComponent.java
server/src/com/vaadin/ui/AbstractField.java
server/src/com/vaadin/ui/AbstractOrderedLayout.java
server/src/com/vaadin/ui/AbstractSingleComponentContainer.java
server/src/com/vaadin/ui/AbstractSplitPanel.java
server/src/com/vaadin/ui/AbstractTextField.java
server/src/com/vaadin/ui/Button.java
server/src/com/vaadin/ui/Component.java
server/src/com/vaadin/ui/CssLayout.java
server/src/com/vaadin/ui/Label.java
server/src/com/vaadin/ui/Panel.java
server/src/com/vaadin/ui/PasswordField.java
server/src/com/vaadin/ui/TabSheet.java
server/src/com/vaadin/ui/TextArea.java
server/src/com/vaadin/ui/TextField.java
server/src/com/vaadin/ui/declarative/DesignContext.java
server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/abstractfield/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/abstractfield/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/abstractfield/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/abstractfield/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/button/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/button/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/button/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/button/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/csslayout/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/csslayout/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/csslayout/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/csslayout/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/label/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/label/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/label/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/label/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/panel/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/panel/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/panel/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/panel/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/tabsheet/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/tabsheet/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/tabsheet/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/tabsheet/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/textarea/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/textarea/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/textarea/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/textarea/TestWriteDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/textfield/TestReadDesign.java [new file with mode: 0644]
server/tests/src/com/vaadin/tests/server/component/textfield/TestSynchronizeFromDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/textfield/TestSynchronizeToDesign.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/textfield/TestWriteDesign.java [new file with mode: 0644]

index 50ce2754cbf19a536010daa1d335223688213dd8..b784aa5d35cdb9df4b0e66f66c2365982eb2d495 100644 (file)
@@ -26,6 +26,7 @@ import com.vaadin.shared.Connector;
 import com.vaadin.shared.communication.SharedState;
 import com.vaadin.ui.UI;
 import com.vaadin.util.ReflectTools;
+
 import elemental.json.JsonObject;
 
 /**
@@ -277,9 +278,8 @@ public interface ClientConnector extends Connector {
      * .
      * 
      * @return a JSON object with the encoded connector state
-     *             if the state can not be encoded
      */
-    public JsonObject encodeState() ;
+    public JsonObject encodeState();
 
     /**
      * Handle a request directed to this connector. This can be used by
index 7af22ba5c670bc46813351c3b087835a4e5b6445..3e1e7bfbdb40e89020e818c80bb6ed25c3863ad2 100644 (file)
@@ -677,15 +677,13 @@ public class AbsoluteLayout extends AbstractLayout implements
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes
-     * .Node, com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractComponent#readDesign(org.jsoup.nodes .Node,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
+    public void readDesign(Element design, DesignContext designContext) {
         // process default attributes
-        super.synchronizeFromDesign(design, designContext);
+        super.readDesign(design, designContext);
         // remove current children
         removeAllComponents();
         // handle children
@@ -716,19 +714,18 @@ public class AbsoluteLayout extends AbstractLayout implements
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeToDesign(org.jsoup.nodes.Node,
+     * @see com.vaadin.ui.AbstractComponent#writeDesign(org.jsoup.nodes.Node,
      * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
-        super.synchronizeToDesign(design, designContext);
+    public void writeDesign(Element design, DesignContext designContext) {
+        super.writeDesign(design, designContext);
         // handle children
         Element designElement = design;
         for (Component child : this) {
             Element childNode = designContext.createNode(child);
             designElement.appendChild(childNode);
-            child.synchronizeToDesign(childNode, designContext);
+            child.writeDesign(childNode, designContext);
             // handle position
             ComponentPosition position = getPosition(child);
             writePositionAttribute(childNode, ATTR_TOP, position.getTopUnits()
index 808b70386f890bcdb57cbb8d739102a34f988643..3c68fde9b234fa4147e6d92c42d5673b943b250b 100644 (file)
@@ -914,13 +914,11 @@ public abstract class AbstractComponent extends AbstractClientConnector
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.Component#synchronizeFromDesign(org.jsoup.nodes.Element,
+     * @see com.vaadin.ui.Component#readDesign(org.jsoup.nodes.Element,
      * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
+    public void readDesign(Element design, DesignContext designContext) {
         Attributes attr = design.attributes();
         AbstractComponent def = designContext.getDefaultInstance(this
                 .getClass());
@@ -1190,8 +1188,8 @@ public abstract class AbstractComponent extends AbstractClientConnector
     /**
      * Returns a collection of attributes that should not be handled by the
      * basic implementation of the {@link synhronizeFromDesign} and
-     * {@link synchronizeToDesign} methods. Typically these are handled in a
-     * custom way in the overridden versions of the above methods
+     * {@link writeDesign} methods. Typically these are handled in a custom way
+     * in the overridden versions of the above methods
      * 
      * @return the collection of attributes that are not handled by the basic
      *         implementation
@@ -1208,11 +1206,11 @@ public abstract class AbstractComponent extends AbstractClientConnector
     /*
      * (non-Javadoc)
      * 
-     * @see com.vaadin.ui.Component#synchronizeToDesign(org.jsoup.nodes.Element,
+     * @see com.vaadin.ui.Component#writeDesign(org.jsoup.nodes.Element,
      * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
+    public void writeDesign(Element design, DesignContext designContext) {
         // clear element contents
         DesignAttributeHandler.clearElement(design);
         AbstractComponent def = designContext.getDefaultInstance(this
index fc3129d1badb5e35aaf3a03811026917b5c4b281..ba518000d62173f76eb0601ad07fcaab64f20ada 100644 (file)
@@ -1761,14 +1761,12 @@ public abstract class AbstractField<T> extends AbstractComponent implements
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractComponent#readDesign(org.jsoup.nodes .Element,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
-        super.synchronizeFromDesign(design, designContext);
+    public void readDesign(Element design, DesignContext designContext) {
+        super.readDesign(design, designContext);
         AbstractField def = designContext.getDefaultInstance(this.getClass());
         Attributes attr = design.attributes();
         boolean readOnly = DesignAttributeHandler.readAttribute("readonly",
@@ -1798,13 +1796,12 @@ public abstract class AbstractField<T> extends AbstractComponent implements
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeToDesign(org.jsoup.nodes.Element
+     * @see com.vaadin.ui.AbstractComponent#writeDesign(org.jsoup.nodes.Element
      * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
-        super.synchronizeToDesign(design, designContext);
+    public void writeDesign(Element design, DesignContext designContext) {
+        super.writeDesign(design, designContext);
         AbstractField def = designContext.getDefaultInstance(this.getClass());
         Attributes attr = design.attributes();
         // handle readonly
index d2a302cff5adafd5db2a3d265712cc32fcf2d073..e99641a9ab4cd3f344d8277bbe4a1e56bc92ceb8 100644 (file)
@@ -470,15 +470,13 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractComponent#readDesign(org.jsoup.nodes .Element,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
+    public void readDesign(Element design, DesignContext designContext) {
         // process default attributes
-        super.synchronizeFromDesign(design, designContext);
+        super.readDesign(design, designContext);
         // remove current children
         removeAllComponents();
         // handle margin
@@ -535,14 +533,13 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeToDesign(org.jsoup.nodes.Element
+     * @see com.vaadin.ui.AbstractComponent#writeDesign(org.jsoup.nodes.Element
      * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
+    public void writeDesign(Element design, DesignContext designContext) {
         // synchronize default attributes
-        super.synchronizeToDesign(design, designContext);
+        super.writeDesign(design, designContext);
         // handle margin
         AbstractOrderedLayout def = designContext.getDefaultInstance(this
                 .getClass());
index 6c8d4fcde2c6765a65e8ac657ac6d642ff69aca7..330fcfeae18414509a7e24391b2b97a45231e1ed 100644 (file)
@@ -281,15 +281,13 @@ public abstract class AbstractSingleComponentContainer extends
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractComponent#readDesign(org.jsoup.nodes .Element,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
+    public void readDesign(Element design, DesignContext designContext) {
         // process default attributes
-        super.synchronizeFromDesign(design, designContext);
+        super.readDesign(design, designContext);
         // handle child element, checking that the design specifies at most one
         // child
         int childCount = design.children().size();
@@ -309,14 +307,13 @@ public abstract class AbstractSingleComponentContainer extends
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeToDesign(org.jsoup.nodes.Element
+     * @see com.vaadin.ui.AbstractComponent#writeDesign(org.jsoup.nodes.Element
      * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
+    public void writeDesign(Element design, DesignContext designContext) {
         // synchronize default attributes (also clears children and attributes)
-        super.synchronizeToDesign(design, designContext);
+        super.writeDesign(design, designContext);
         // handle child component
         Component child = getContent();
         if (child != null) {
index 1400bcf092962909bcf4519766dd34956eba8024..66d01084d185adeb6ad43f774ab042ec2ba68658 100644 (file)
@@ -557,15 +557,13 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractComponent#readDesign(org.jsoup.nodes .Element,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
+    public void readDesign(Element design, DesignContext designContext) {
         // handle default attributes
-        super.synchronizeFromDesign(design, designContext);
+        super.readDesign(design, designContext);
         // handle custom attributes, use default values if no explicit value
         // set
         AbstractSplitPanel def = designContext.getDefaultInstance(this
@@ -634,9 +632,9 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
     }
 
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
+    public void writeDesign(Element design, DesignContext designContext) {
         // handle default attributes (also clears children and attributes)
-        super.synchronizeToDesign(design, designContext);
+        super.writeDesign(design, designContext);
         // handle custom attributes (write only if a value is not the
         // default value)
         AbstractSplitPanel def = designContext.getDefaultInstance(this
index 2de8555b260cfd8cab6dac9587e548d7f08791f2..79492ecf5e0055c8fb1fc2fce2aa2331ab33d76d 100644 (file)
@@ -766,14 +766,12 @@ public abstract class AbstractTextField extends AbstractField<String> implements
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractField#synchronizeFromDesign(org.jsoup.nodes.Element
-     * , com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractField#readDesign(org.jsoup.nodes.Element ,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
-        super.synchronizeFromDesign(design, designContext);
+    public void readDesign(Element design, DesignContext designContext) {
+        super.readDesign(design, designContext);
         AbstractTextField def = designContext.getDefaultInstance(this
                 .getClass());
         Attributes attr = design.attributes();
@@ -800,13 +798,12 @@ public abstract class AbstractTextField extends AbstractField<String> implements
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractField#synchronizeToDesign(org.jsoup.nodes.Element,
+     * @see com.vaadin.ui.AbstractField#writeDesign(org.jsoup.nodes.Element,
      * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
-        super.synchronizeToDesign(design, designContext);
+    public void writeDesign(Element design, DesignContext designContext) {
+        super.writeDesign(design, designContext);
         AbstractTextField def = designContext.getDefaultInstance(this
                 .getClass());
         Attributes attr = design.attributes();
index 9a754c24d9160f2adedca01fa575ef5979947cab..2d0a0cf8dabc75961e85f3d7d0606d128e80540f 100644 (file)
@@ -669,14 +669,12 @@ public class Button extends AbstractComponent implements
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractComponent#readDesign(org.jsoup.nodes .Element,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
-        super.synchronizeFromDesign(design, designContext);
+    public void readDesign(Element design, DesignContext designContext) {
+        super.readDesign(design, designContext);
         Button def = designContext.getDefaultInstance(this.getClass());
         Attributes attr = design.attributes();
         String content = design.html();
@@ -718,13 +716,12 @@ public class Button extends AbstractComponent implements
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeToDesign(org.jsoup.nodes.Element
+     * @see com.vaadin.ui.AbstractComponent#writeDesign(org.jsoup.nodes.Element
      * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
-        super.synchronizeToDesign(design, designContext);
+    public void writeDesign(Element design, DesignContext designContext) {
+        super.writeDesign(design, designContext);
         Attributes attr = design.attributes();
         Button def = designContext.getDefaultInstance(this.getClass());
         String content = getCaption();
index 024c3eb433e8b1bd8d7719054e18def0e07859c9..78fb643ba9b27f3e2cf7cb2d4e74a0bb1adf026a 100644 (file)
@@ -744,8 +744,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
      * @param designContext
      *            The DesignContext instance used for parsing the design
      */
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext);
+    public void readDesign(Element design, DesignContext designContext);
 
     /**
      * Update the given design based on the component state. The component is
@@ -761,7 +760,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
      *            The design as HTML to update with the current state
      * @param designContext
      */
-    public void synchronizeToDesign(Element design, DesignContext designContext);
+    public void writeDesign(Element design, DesignContext designContext);
 
     /* Component event framework */
 
index 0b4e9cda7baf2722bd72e45c10e7d9ddf3864017..5c7471522d0d0ab655608c021f8049418006597c 100644 (file)
@@ -364,15 +364,13 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractComponent#readDesign(org.jsoup.nodes .Element,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
+    public void readDesign(Element design, DesignContext designContext) {
         // process default attributes
-        super.synchronizeFromDesign(design, designContext);
+        super.readDesign(design, designContext);
         // remove current children
         removeAllComponents();
         // handle children
@@ -385,14 +383,13 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeToDesign(org.jsoup.nodes.Element
+     * @see com.vaadin.ui.AbstractComponent#writeDesign(org.jsoup.nodes.Element
      * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
+    public void writeDesign(Element design, DesignContext designContext) {
         // synchronize default attributes
-        super.synchronizeToDesign(design, designContext);
+        super.writeDesign(design, designContext);
         // handle children
         Element designElement = design;
         for (Component child : this) {
index f882940fe66fbcbd35d88a03a823561212f42129..fc18c374b424b51ec6f780e2a568087e9673eea9 100644 (file)
@@ -578,14 +578,12 @@ public class Label extends AbstractComponent implements Property<String>,
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractComponent#readDesign(org.jsoup.nodes .Element,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
-        super.synchronizeFromDesign(design, designContext);
+    public void readDesign(Element design, DesignContext designContext) {
+        super.readDesign(design, designContext);
         String innerHtml = design.html();
         if (innerHtml != null && !"".equals(innerHtml)) {
             setValue(innerHtml);
@@ -613,13 +611,12 @@ public class Label extends AbstractComponent implements Property<String>,
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeToDesign(org.jsoup.nodes.Element
+     * @see com.vaadin.ui.AbstractComponent#writeDesign(org.jsoup.nodes.Element
      * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
-        super.synchronizeToDesign(design, designContext);
+    public void writeDesign(Element design, DesignContext designContext) {
+        super.writeDesign(design, designContext);
         String content = getValue();
         if (content != null) {
             design.html(getValue());
index 46ad801a6d1bfc145d2b19866d55cc918061289b..5112a732acf422b519c61de0499eb28b7e07893f 100644 (file)
@@ -345,9 +345,8 @@ public class Panel extends AbstractSingleComponentContainer implements
     }
 
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
-        super.synchronizeFromDesign(design, designContext);
+    public void readDesign(Element design, DesignContext designContext) {
+        super.readDesign(design, designContext);
         // handle tabindex
         Panel def = designContext.getDefaultInstance(this.getClass());
         int tabIndex = DesignAttributeHandler.readAttribute("tabindex",
@@ -364,8 +363,8 @@ public class Panel extends AbstractSingleComponentContainer implements
     }
 
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
-        super.synchronizeToDesign(design, designContext);
+    public void writeDesign(Element design, DesignContext designContext) {
+        super.writeDesign(design, designContext);
         // handle tabindex
         Panel def = designContext.getDefaultInstance(this.getClass());
         DesignAttributeHandler.writeAttribute("tabindex", design.attributes(),
index b842fc55695d0a1655f2e93d47ffe47cb1b5ac22..5f27eb59c978d5c22015304d532ba8af978e127a 100644 (file)
@@ -85,14 +85,12 @@ public class PasswordField extends AbstractTextField {
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractField#synchronizeFromDesign(org.jsoup.nodes.Element
-     * , com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractField#readDesign(org.jsoup.nodes.Element ,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
-        super.synchronizeFromDesign(design, designContext);
+    public void readDesign(Element design, DesignContext designContext) {
+        super.readDesign(design, designContext);
         AbstractTextField def = designContext.getDefaultInstance(this
                 .getClass());
         Attributes attr = design.attributes();
@@ -104,13 +102,12 @@ public class PasswordField extends AbstractTextField {
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractTextField#synchronizeToDesign(org.jsoup.nodes.Element
+     * @see com.vaadin.ui.AbstractTextField#writeDesign(org.jsoup.nodes.Element
      * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
-        super.synchronizeToDesign(design, designContext);
+    public void writeDesign(Element design, DesignContext designContext) {
+        super.writeDesign(design, designContext);
         AbstractTextField def = designContext.getDefaultInstance(this
                 .getClass());
         Attributes attr = design.attributes();
index 121ba89e06056e4661276ab226f1f18d0f45e3d2..94bcb8027994295e8d5426cdae2c3b734e608ac2 100644 (file)
@@ -1458,14 +1458,12 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeFromDesign(org.jsoup.nodes
-     * .Element, com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractComponent#readDesign(org.jsoup.nodes .Element,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
-        super.synchronizeFromDesign(design, designContext);
+    public void readDesign(Element design, DesignContext designContext) {
+        super.readDesign(design, designContext);
         Attributes attr = design.attributes();
         TabSheet def = designContext.getDefaultInstance(this.getClass());
         // handle tab index
@@ -1594,13 +1592,12 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractComponent#synchronizeToDesign(org.jsoup.nodes.Element
+     * @see com.vaadin.ui.AbstractComponent#writeDesign(org.jsoup.nodes.Element
      * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
-        super.synchronizeToDesign(design, designContext);
+    public void writeDesign(Element design, DesignContext designContext) {
+        super.writeDesign(design, designContext);
         TabSheet def = designContext.getDefaultInstance(this.getClass());
         Attributes attr = design.attributes();
         // handle tab index
index 70b9268228730fa3d4ca11ee84be485cb00d32bf..c8103f9c5b236dbbc669c146f2d0436836d3131d 100644 (file)
@@ -139,27 +139,24 @@ public class TextArea extends AbstractTextField {
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractField#synchronizeFromDesign(org.jsoup.nodes.Element
-     * , com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractField#readDesign(org.jsoup.nodes.Element ,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
-        super.synchronizeFromDesign(design, designContext);
+    public void readDesign(Element design, DesignContext designContext) {
+        super.readDesign(design, designContext);
         setValue(design.html());
     }
 
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractTextField#synchronizeToDesign(org.jsoup.nodes.Element
+     * @see com.vaadin.ui.AbstractTextField#writeDesign(org.jsoup.nodes.Element
      * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
-        super.synchronizeToDesign(design, designContext);
+    public void writeDesign(Element design, DesignContext designContext) {
+        super.writeDesign(design, designContext);
         design.html(getValue());
     }
 }
index bb855c7b90e3869d6fdb097345cca188ee00608c..03bbfd2d8f8f4863f4b26a210c6d66f233fdc626 100644 (file)
@@ -107,14 +107,12 @@ public class TextField extends AbstractTextField {
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractField#synchronizeFromDesign(org.jsoup.nodes.Element
-     * , com.vaadin.ui.declarative.DesignContext)
+     * @see com.vaadin.ui.AbstractField#readDesign(org.jsoup.nodes.Element ,
+     * com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeFromDesign(Element design,
-            DesignContext designContext) {
-        super.synchronizeFromDesign(design, designContext);
+    public void readDesign(Element design, DesignContext designContext) {
+        super.readDesign(design, designContext);
         AbstractTextField def = designContext.getDefaultInstance(this
                 .getClass());
         Attributes attr = design.attributes();
@@ -126,13 +124,12 @@ public class TextField extends AbstractTextField {
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * com.vaadin.ui.AbstractTextField#synchronizeToDesign(org.jsoup.nodes.Element
+     * @see com.vaadin.ui.AbstractTextField#writeDesign(org.jsoup.nodes.Element
      * , com.vaadin.ui.declarative.DesignContext)
      */
     @Override
-    public void synchronizeToDesign(Element design, DesignContext designContext) {
-        super.synchronizeToDesign(design, designContext);
+    public void writeDesign(Element design, DesignContext designContext) {
+        super.writeDesign(design, designContext);
         AbstractTextField def = designContext.getDefaultInstance(this
                 .getClass());
         Attributes attr = design.attributes();
index e84faa31caf8d757797a0317f6ade2172ae27850..b196c84b02a25579b4bb055feba0464b4ec34457 100644 (file)
@@ -331,9 +331,9 @@ public class DesignContext implements Serializable {
 
     /**
      * Creates an html tree node corresponding to the given element. Also
-     * initializes its attributes by calling synchronizeToDesign. As a result of
-     * the synchronizeToDesign() call, this method creates the entire subtree
-     * rooted at the returned Node.
+     * initializes its attributes by calling writeDesign. As a result of the
+     * writeDesign() call, this method creates the entire subtree rooted at the
+     * returned Node.
      * 
      * @param childComponent
      *            The component with state that is synchronized in to the node
@@ -353,9 +353,9 @@ public class DesignContext implements Serializable {
         String className = classNameToElementName(componentClass
                 .getSimpleName());
         Element newElement = doc.createElement(prefix + className);
-        childComponent.synchronizeToDesign(newElement, this);
+        childComponent.writeDesign(newElement, this);
         // Handle the local id. Global id and caption should have been taken
-        // care of by synchronizeToDesign.
+        // care of by writeDesign.
         String localId = componentToLocalId.get(childComponent);
         if (localId != null) {
             newElement.attr(LOCAL_ID_ATTRIBUTE, localId);
@@ -391,8 +391,8 @@ public class DesignContext implements Serializable {
 
     /**
      * Creates a Component corresponding to the given html node. Also calls
-     * synchronizeFromDesign() for the created node, in effect creating the
-     * entire component hierarchy rooted at the returned component.
+     * readDesign() for the created node, in effect creating the entire
+     * component hierarchy rooted at the returned component.
      * 
      * @param componentDesign
      *            The html tree node containing the description of the component
@@ -408,11 +408,10 @@ public class DesignContext implements Serializable {
     }
 
     /**
-     * Calls synchronizeFromDesign() for the given component and passes the
-     * given component design as a parameter. This creates the entire component
-     * hierarchy rooted at the given component. Also registers the componentid,
-     * localId and caption of the given component and all its children to the
-     * context
+     * Calls readDesign() for the given component and passes the given component
+     * design as a parameter. This creates the entire component hierarchy rooted
+     * at the given component. Also registers the componentid, localId and
+     * caption of the given component and all its children to the context
      * 
      * 
      * @param component
@@ -422,7 +421,7 @@ public class DesignContext implements Serializable {
      */
     public void synchronizeAndRegister(Component component,
             Element componentDesign) {
-        component.synchronizeFromDesign(componentDesign, this);
+        component.readDesign(componentDesign, this);
         // Get the ids and the caption of the component and store them in the
         // maps of this design context.
         org.jsoup.nodes.Attributes attributes = componentDesign.attributes();
diff --git a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestReadDesign.java
new file mode 100644 (file)
index 0000000..5f9674e
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * 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.absolutelayout;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.server.Sizeable;
+import com.vaadin.ui.AbsoluteLayout;
+import com.vaadin.ui.AbsoluteLayout.ComponentPosition;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for reading AbsoluteLayout from design
+ * 
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TestReadDesign extends TestCase {
+
+    private AbsoluteLayout root;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        root = createLayout();
+    }
+
+    public void testAttributes() {
+        assertEquals("test-layout", root.getCaption());
+        Iterator<Component> children = root.iterator();
+        assertEquals("test-label", children.next().getCaption());
+        assertEquals("test-button", children.next().getCaption());
+    }
+
+    public void testTopLeftPosition() {
+        ComponentPosition position = root.getPosition(root.iterator().next());
+        assertEquals(Sizeable.Unit.PIXELS, position.getTopUnits());
+        assertEquals(100.0f, position.getTopValue());
+        assertEquals(Sizeable.Unit.PERCENTAGE, position.getLeftUnits());
+        assertEquals(50.0f, position.getLeftValue());
+    }
+
+    public void testBottomRightPosition() {
+        Iterator<Component> children = root.iterator();
+        children.next();
+        ComponentPosition position = root.getPosition(children.next());
+        assertEquals(Sizeable.Unit.PIXELS, position.getBottomUnits());
+        assertEquals(100.0f, position.getBottomValue());
+        assertEquals(Sizeable.Unit.PERCENTAGE, position.getRightUnits());
+        assertEquals(50.0f, position.getRightValue());
+    }
+
+    public void testZIndex() {
+        ComponentPosition position = root.getPosition(root.iterator().next());
+        assertEquals(2, position.getZIndex());
+    }
+
+    private AbsoluteLayout createLayout() {
+        DesignContext ctx = new DesignContext();
+        Element design = createDesign();
+        Component child = ctx.createChild(design);
+        return (AbsoluteLayout) child;
+    }
+
+    private Element createDesign() {
+
+        Attributes rootAttributes = new Attributes();
+        rootAttributes.put("caption", "test-layout");
+        Element node = new Element(Tag.valueOf("v-absolute-layout"), "",
+                rootAttributes);
+
+        Attributes firstChildAttributes = new Attributes();
+        firstChildAttributes.put("caption", "test-label");
+        firstChildAttributes.put(":top", "100px");
+        firstChildAttributes.put(":left", "50%");
+        firstChildAttributes.put(":z-index", "2");
+        Element firstChild = new Element(Tag.valueOf("v-label"), "",
+                firstChildAttributes);
+        node.appendChild(firstChild);
+
+        Attributes secondChildAttributes = new Attributes();
+        secondChildAttributes.put(":bottom", "100px");
+        secondChildAttributes.put(":right", "50%");
+        Element secondChild = new Element(Tag.valueOf("v-button"), "",
+                secondChildAttributes);
+        secondChild.html("test-button");
+        node.appendChild(secondChild);
+        return node;
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index ce05400..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.absolutelayout;
-
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.server.Sizeable;
-import com.vaadin.ui.AbsoluteLayout;
-import com.vaadin.ui.AbsoluteLayout.ComponentPosition;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for reading AbsoluteLayout from design
- * 
- * @since
- * @author Vaadin Ltd
- */
-public class TestSynchronizeFromDesign extends TestCase {
-
-    private AbsoluteLayout root;
-
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        root = createLayout();
-    }
-
-    public void testAttributes() {
-        assertEquals("test-layout", root.getCaption());
-        Iterator<Component> children = root.iterator();
-        assertEquals("test-label", children.next().getCaption());
-        assertEquals("test-button", children.next().getCaption());
-    }
-
-    public void testTopLeftPosition() {
-        ComponentPosition position = root.getPosition(root.iterator().next());
-        assertEquals(Sizeable.Unit.PIXELS, position.getTopUnits());
-        assertEquals(100.0f, position.getTopValue());
-        assertEquals(Sizeable.Unit.PERCENTAGE, position.getLeftUnits());
-        assertEquals(50.0f, position.getLeftValue());
-    }
-
-    public void testBottomRightPosition() {
-        Iterator<Component> children = root.iterator();
-        children.next();
-        ComponentPosition position = root.getPosition(children.next());
-        assertEquals(Sizeable.Unit.PIXELS, position.getBottomUnits());
-        assertEquals(100.0f, position.getBottomValue());
-        assertEquals(Sizeable.Unit.PERCENTAGE, position.getRightUnits());
-        assertEquals(50.0f, position.getRightValue());
-    }
-
-    public void testZIndex() {
-        ComponentPosition position = root.getPosition(root.iterator().next());
-        assertEquals(2, position.getZIndex());
-    }
-
-    private AbsoluteLayout createLayout() {
-        DesignContext ctx = new DesignContext();
-        Element design = createDesign();
-        Component child = ctx.createChild(design);
-        return (AbsoluteLayout) child;
-    }
-
-    private Element createDesign() {
-
-        Attributes rootAttributes = new Attributes();
-        rootAttributes.put("caption", "test-layout");
-        Element node = new Element(Tag.valueOf("v-absolute-layout"), "",
-                rootAttributes);
-
-        Attributes firstChildAttributes = new Attributes();
-        firstChildAttributes.put("caption", "test-label");
-        firstChildAttributes.put(":top", "100px");
-        firstChildAttributes.put(":left", "50%");
-        firstChildAttributes.put(":z-index", "2");
-        Element firstChild = new Element(Tag.valueOf("v-label"), "",
-                firstChildAttributes);
-        node.appendChild(firstChild);
-
-        Attributes secondChildAttributes = new Attributes();
-        secondChildAttributes.put(":bottom", "100px");
-        secondChildAttributes.put(":right", "50%");
-        Element secondChild = new Element(Tag.valueOf("v-button"), "",
-                secondChildAttributes);
-        secondChild.html("test-button");
-        node.appendChild(secondChild);
-        return node;
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestSynchronizeToDesign.java
deleted file mode 100644 (file)
index eb61d13..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.absolutelayout;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.AbsoluteLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for writing AbsoluteLayout to design
- * 
- * @since
- * @author Vaadin Ltd
- */
-public class TestSynchronizeToDesign extends TestCase {
-
-    public void testSynchronizeEmptyLayout() {
-        AbsoluteLayout layout = createTestLayout();
-        layout.removeAllComponents();
-        Element design = createDesign();
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertEquals(0, design.childNodes().size());
-        assertEquals("changed-caption", design.attr("caption"));
-    }
-
-    public void testSynchronizeLayoutWithChildren() {
-        AbsoluteLayout layout = createTestLayout();
-        Element design = createDesign();
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertEquals(2, design.childNodes().size());
-        assertEquals("v-label", ((Element) design.childNode(0)).tagName());
-        assertEquals("v-label", ((Element) design.childNode(1)).tagName());
-    }
-
-    public void testSynchronizePosition() {
-        AbsoluteLayout layout = createTestLayout();
-        Element design = createDesign();
-        layout.synchronizeToDesign(design, createDesignContext());
-        Attributes attributes = design.childNode(0).attributes();
-        assertEquals("50px", attributes.get(":top"));
-        assertEquals("50%", attributes.get(":left"));
-        assertEquals("2", attributes.get(":z-index"));
-        attributes = design.childNode(1).attributes();
-        assertEquals("50px", attributes.get(":bottom"));
-        assertEquals("50%", attributes.get(":right"));
-    }
-
-    private AbsoluteLayout createTestLayout() {
-        AbsoluteLayout layout = new AbsoluteLayout();
-        layout.setCaption("changed-caption");
-        layout.addComponent(new Label("test-label"),
-                "top:50px;left:50%;z-index:2");
-        layout.addComponent(new Label("test-label-2"),
-                "bottom:50px;right:50%;z-index:3");
-        return layout;
-    }
-
-    private Element createDesign() {
-        // make sure that the design node has old content that should be removed
-        Attributes rootAttributes = new Attributes();
-        rootAttributes.put("caption", "test-layout");
-        Element node = new Element(Tag.valueOf("v-absolute-layout"), "",
-                rootAttributes);
-        Attributes firstChildAttributes = new Attributes();
-        firstChildAttributes.put("caption", "test-label");
-        Element firstChild = new Element(Tag.valueOf("v-label"), "",
-                firstChildAttributes);
-        node.appendChild(firstChild);
-
-        Attributes secondChildAttributes = new Attributes();
-        secondChildAttributes.put("caption", "test-button");
-        Element secondChild = new Element(Tag.valueOf("v-button"), "",
-                secondChildAttributes);
-        node.appendChild(secondChild);
-        return node;
-    }
-
-    private DesignContext createDesignContext() {
-        return new DesignContext();
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/absolutelayout/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..5f42b1f
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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.absolutelayout;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.AbsoluteLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for writing AbsoluteLayout to design
+ * 
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TestWriteDesign extends TestCase {
+
+    public void testSynchronizeEmptyLayout() {
+        AbsoluteLayout layout = createTestLayout();
+        layout.removeAllComponents();
+        Element design = createDesign();
+        layout.writeDesign(design, createDesignContext());
+        assertEquals(0, design.childNodes().size());
+        assertEquals("changed-caption", design.attr("caption"));
+    }
+
+    public void testSynchronizeLayoutWithChildren() {
+        AbsoluteLayout layout = createTestLayout();
+        Element design = createDesign();
+        layout.writeDesign(design, createDesignContext());
+        assertEquals(2, design.childNodes().size());
+        assertEquals("v-label", ((Element) design.childNode(0)).tagName());
+        assertEquals("v-label", ((Element) design.childNode(1)).tagName());
+    }
+
+    public void testSynchronizePosition() {
+        AbsoluteLayout layout = createTestLayout();
+        Element design = createDesign();
+        layout.writeDesign(design, createDesignContext());
+        Attributes attributes = design.childNode(0).attributes();
+        assertEquals("50px", attributes.get(":top"));
+        assertEquals("50%", attributes.get(":left"));
+        assertEquals("2", attributes.get(":z-index"));
+        attributes = design.childNode(1).attributes();
+        assertEquals("50px", attributes.get(":bottom"));
+        assertEquals("50%", attributes.get(":right"));
+    }
+
+    private AbsoluteLayout createTestLayout() {
+        AbsoluteLayout layout = new AbsoluteLayout();
+        layout.setCaption("changed-caption");
+        layout.addComponent(new Label("test-label"),
+                "top:50px;left:50%;z-index:2");
+        layout.addComponent(new Label("test-label-2"),
+                "bottom:50px;right:50%;z-index:3");
+        return layout;
+    }
+
+    private Element createDesign() {
+        // make sure that the design node has old content that should be removed
+        Attributes rootAttributes = new Attributes();
+        rootAttributes.put("caption", "test-layout");
+        Element node = new Element(Tag.valueOf("v-absolute-layout"), "",
+                rootAttributes);
+        Attributes firstChildAttributes = new Attributes();
+        firstChildAttributes.put("caption", "test-label");
+        Element firstChild = new Element(Tag.valueOf("v-label"), "",
+                firstChildAttributes);
+        node.appendChild(firstChild);
+
+        Attributes secondChildAttributes = new Attributes();
+        secondChildAttributes.put("caption", "test-button");
+        Element secondChild = new Element(Tag.valueOf("v-button"), "",
+                secondChildAttributes);
+        node.appendChild(secondChild);
+        return node;
+    }
+
+    private DesignContext createDesignContext() {
+        return new DesignContext();
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestReadDesign.java
new file mode 100644 (file)
index 0000000..760f1ca
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * 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.abstractcomponent;
+
+import java.lang.reflect.Field;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.server.ExternalResource;
+import com.vaadin.server.FileResource;
+import com.vaadin.server.Responsive;
+import com.vaadin.server.ThemeResource;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for reading the attributes of the AbstractComponent from design
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestReadDesign extends TestCase {
+
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    public void testSynchronizeId() {
+        Element design = createDesign("id", "testId");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals("testId", component.getId());
+    }
+
+    public void testSynchronizePrimaryStyleName() {
+        Element design = createDesign("primary-style-name", "test-style");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals("test-style", component.getPrimaryStyleName());
+    }
+
+    public void testSynchronizeCaption() {
+        Element design = createDesign("caption", "test-caption");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals("test-caption", component.getCaption());
+    }
+
+    public void testSynchronizeLocale() {
+        Element design = createDesign("locale", "fi_FI");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals("fi", component.getLocale().getLanguage());
+        assertEquals("FI", component.getLocale().getCountry());
+    }
+
+    public void testSynchronizeExternalIcon() {
+        Element design = createDesign("icon", "http://example.com/example.gif");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertTrue("Incorrect resource type returned", component.getIcon()
+                .getClass().isAssignableFrom(ExternalResource.class));
+        assertEquals("http://example.com/example.gif",
+                ((ExternalResource) component.getIcon()).getURL());
+    }
+
+    public void testSynchronizeThemeIcon() {
+        Element design = createDesign("icon", "theme://example.gif");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertTrue("Incorrect resource type returned", component.getIcon()
+                .getClass().isAssignableFrom(ThemeResource.class));
+    }
+
+    public void testSynchronizeFileResource() {
+        Element design = createDesign("icon", "img/example.gif");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertTrue("Incorrect resource type returned", component.getIcon()
+                .getClass().isAssignableFrom(FileResource.class));
+    }
+
+    public void testSynchronizeImmediate() {
+        Element design = createDesign("immediate", "true");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals(true, component.isImmediate());
+        assertEquals(Boolean.TRUE, getExplicitImmediate(component));
+        // Synchronize with a design having no immediate attribute -
+        // explicitImmediate should then be null.
+        design = createDesign("description", "test-description");
+        component.readDesign(design, ctx);
+        assertEquals(null, getExplicitImmediate(component));
+        // Synchronize with a design having immediate = false
+        design = createDesign("immediate", "false");
+        component.readDesign(design, ctx);
+        assertEquals(false, component.isImmediate());
+        assertEquals(Boolean.FALSE, getExplicitImmediate(component));
+        // Synchronize with a design having immediate = "" - should correspond
+        // to
+        // true.
+        design = createDesign("immediate", "");
+        component.readDesign(design, ctx);
+        assertEquals(true, component.isImmediate());
+        assertEquals(Boolean.TRUE, getExplicitImmediate(component));
+    }
+
+    public void testSynchronizeDescription() {
+        Element design = createDesign("description", "test-description");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals("test-description", component.getDescription());
+    }
+
+    public void testSynchronizeComponentError() {
+        Element design = createDesign("error", "<div>test-error</div>");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals("<div>test-error</div>", component.getComponentError()
+                .getFormattedHtmlMessage());
+    }
+
+    public void testSynchronizeSizeFull() {
+        Element design = createDesign("size-full", "");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals(100, component.getWidth(), 0.1f);
+        assertEquals(100, component.getHeight(), 0.1f);
+    }
+
+    public void testSynchronizeSizeAuto() {
+        Element design = createDesign("size-auto", "");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals(-1, component.getWidth(), 0.1f);
+        assertEquals(-1, component.getHeight(), 0.1f);
+    }
+
+    public void testSynchronizeHeightFull() {
+        Element design = createDesign("height-full", "");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals(100, component.getHeight(), 0.1f);
+    }
+
+    public void testSynchronizeHeightAuto() {
+        Element design = createDesign("height-auto", "");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals(-1, component.getHeight(), 0.1f);
+    }
+
+    public void testSynchronizeWidthFull() {
+        Element design = createDesign("width-full", "");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals(100, component.getWidth(), 0.1f);
+    }
+
+    public void testSynchronizeWidthAuto() {
+        Element design = createDesign("width-auto", "");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals(-1, component.getWidth(), 0.1f);
+    }
+
+    public void testSynchronizeWidth() {
+        Element design = createDesign("width", "12px");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals(12, component.getWidth(), 0.1f);
+        assertEquals(com.vaadin.server.Sizeable.Unit.PIXELS,
+                component.getWidthUnits());
+    }
+
+    public void testSynchronizeHeight() {
+        Element design = createDesign("height", "12px");
+        AbstractComponent component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals(12, component.getHeight(), 0.1f);
+        assertEquals(com.vaadin.server.Sizeable.Unit.PIXELS,
+                component.getHeightUnits());
+    }
+
+    public void testSynchronizeNotResponsive() {
+        AbstractComponent component = getComponent();
+        Responsive.makeResponsive(component);
+        Element design = createDesign("responsive", "false");
+        component.readDesign(design, ctx);
+        assertEquals("Component should not have extensions", 0, component
+                .getExtensions().size());
+    }
+
+    public void testSynchronizeResponsive() {
+        AbstractComponent component = getComponent();
+        Element design = createDesign("responsive", "");
+        component.readDesign(design, ctx);
+        assertEquals("Component should have one extension", 1, component
+                .getExtensions().size());
+        assertTrue("Extension should be responsive", component.getExtensions()
+                .iterator().next() instanceof Responsive);
+    }
+
+    public void testSynchronizeAlreadyResponsive() {
+        AbstractComponent component = getComponent();
+        Responsive.makeResponsive(component);
+        Element design = createDesign("responsive", "");
+        component.readDesign(design, ctx);
+        assertEquals("Component should have only one extension", 1, component
+                .getExtensions().size());
+    }
+
+    private AbstractComponent getComponent() {
+        return new Label();
+    }
+
+    private Element createDesign(String key, String value) {
+        Attributes attributes = new Attributes();
+        attributes.put(key, value);
+        Element node = new Element(Tag.valueOf("v-label"), "", attributes);
+        return node;
+    }
+
+    private Boolean getExplicitImmediate(AbstractComponent component) {
+        try {
+            Field immediate = AbstractComponent.class
+                    .getDeclaredField("explicitImmediateValue");
+            immediate.setAccessible(true);
+            return (Boolean) immediate.get(component);
+        } catch (Exception e) {
+            throw new RuntimeException(
+                    "Getting the field explicitImmediateValue failed.");
+        }
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index df6fb47..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * 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.abstractcomponent;
-
-import java.lang.reflect.Field;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.server.ExternalResource;
-import com.vaadin.server.FileResource;
-import com.vaadin.server.Responsive;
-import com.vaadin.server.ThemeResource;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for reading the attributes of the AbstractComponent from design
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeFromDesign extends TestCase {
-
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    public void testSynchronizeId() {
-        Element design = createDesign("id", "testId");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("testId", component.getId());
-    }
-
-    public void testSynchronizePrimaryStyleName() {
-        Element design = createDesign("primary-style-name", "test-style");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("test-style", component.getPrimaryStyleName());
-    }
-
-    public void testSynchronizeCaption() {
-        Element design = createDesign("caption", "test-caption");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("test-caption", component.getCaption());
-    }
-
-    public void testSynchronizeLocale() {
-        Element design = createDesign("locale", "fi_FI");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("fi", component.getLocale().getLanguage());
-        assertEquals("FI", component.getLocale().getCountry());
-    }
-
-    public void testSynchronizeExternalIcon() {
-        Element design = createDesign("icon", "http://example.com/example.gif");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertTrue("Incorrect resource type returned", component.getIcon()
-                .getClass().isAssignableFrom(ExternalResource.class));
-        assertEquals("http://example.com/example.gif",
-                ((ExternalResource) component.getIcon()).getURL());
-    }
-
-    public void testSynchronizeThemeIcon() {
-        Element design = createDesign("icon", "theme://example.gif");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertTrue("Incorrect resource type returned", component.getIcon()
-                .getClass().isAssignableFrom(ThemeResource.class));
-    }
-
-    public void testSynchronizeFileResource() {
-        Element design = createDesign("icon", "img/example.gif");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertTrue("Incorrect resource type returned", component.getIcon()
-                .getClass().isAssignableFrom(FileResource.class));
-    }
-
-    public void testSynchronizeImmediate() {
-        Element design = createDesign("immediate", "true");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(true, component.isImmediate());
-        assertEquals(Boolean.TRUE, getExplicitImmediate(component));
-        // Synchronize with a design having no immediate attribute -
-        // explicitImmediate should then be null.
-        design = createDesign("description", "test-description");
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(null, getExplicitImmediate(component));
-        // Synchronize with a design having immediate = false
-        design = createDesign("immediate", "false");
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(false, component.isImmediate());
-        assertEquals(Boolean.FALSE, getExplicitImmediate(component));
-        // Synchronize with a design having immediate = "" - should correspond
-        // to
-        // true.
-        design = createDesign("immediate", "");
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(true, component.isImmediate());
-        assertEquals(Boolean.TRUE, getExplicitImmediate(component));
-    }
-
-    public void testSynchronizeDescription() {
-        Element design = createDesign("description", "test-description");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("test-description", component.getDescription());
-    }
-
-    public void testSynchronizeComponentError() {
-        Element design = createDesign("error", "<div>test-error</div>");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("<div>test-error</div>", component.getComponentError()
-                .getFormattedHtmlMessage());
-    }
-
-    public void testSynchronizeSizeFull() {
-        Element design = createDesign("size-full", "");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(100, component.getWidth(), 0.1f);
-        assertEquals(100, component.getHeight(), 0.1f);
-    }
-
-    public void testSynchronizeSizeAuto() {
-        Element design = createDesign("size-auto", "");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(-1, component.getWidth(), 0.1f);
-        assertEquals(-1, component.getHeight(), 0.1f);
-    }
-
-    public void testSynchronizeHeightFull() {
-        Element design = createDesign("height-full", "");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(100, component.getHeight(), 0.1f);
-    }
-
-    public void testSynchronizeHeightAuto() {
-        Element design = createDesign("height-auto", "");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(-1, component.getHeight(), 0.1f);
-    }
-
-    public void testSynchronizeWidthFull() {
-        Element design = createDesign("width-full", "");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(100, component.getWidth(), 0.1f);
-    }
-
-    public void testSynchronizeWidthAuto() {
-        Element design = createDesign("width-auto", "");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(-1, component.getWidth(), 0.1f);
-    }
-
-    public void testSynchronizeWidth() {
-        Element design = createDesign("width", "12px");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(12, component.getWidth(), 0.1f);
-        assertEquals(com.vaadin.server.Sizeable.Unit.PIXELS,
-                component.getWidthUnits());
-    }
-
-    public void testSynchronizeHeight() {
-        Element design = createDesign("height", "12px");
-        AbstractComponent component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(12, component.getHeight(), 0.1f);
-        assertEquals(com.vaadin.server.Sizeable.Unit.PIXELS,
-                component.getHeightUnits());
-    }
-
-    public void testSynchronizeNotResponsive() {
-        AbstractComponent component = getComponent();
-        Responsive.makeResponsive(component);
-        Element design = createDesign("responsive", "false");
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("Component should not have extensions", 0, component
-                .getExtensions().size());
-    }
-
-    public void testSynchronizeResponsive() {
-        AbstractComponent component = getComponent();
-        Element design = createDesign("responsive", "");
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("Component should have one extension", 1, component
-                .getExtensions().size());
-        assertTrue("Extension should be responsive", component.getExtensions()
-                .iterator().next() instanceof Responsive);
-    }
-
-    public void testSynchronizeAlreadyResponsive() {
-        AbstractComponent component = getComponent();
-        Responsive.makeResponsive(component);
-        Element design = createDesign("responsive", "");
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("Component should have only one extension", 1, component
-                .getExtensions().size());
-    }
-
-    private AbstractComponent getComponent() {
-        return new Label();
-    }
-
-    private Element createDesign(String key, String value) {
-        Attributes attributes = new Attributes();
-        attributes.put(key, value);
-        Element node = new Element(Tag.valueOf("v-label"), "", attributes);
-        return node;
-    }
-
-    private Boolean getExplicitImmediate(AbstractComponent component) {
-        try {
-            Field immediate = AbstractComponent.class
-                    .getDeclaredField("explicitImmediateValue");
-            immediate.setAccessible(true);
-            return (Boolean) immediate.get(component);
-        } catch (Exception e) {
-            throw new RuntimeException(
-                    "Getting the field explicitImmediateValue failed.");
-        }
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestSynchronizeToDesign.java
deleted file mode 100644 (file)
index 349598e..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * 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.abstractcomponent;
-
-import java.io.File;
-import java.util.Locale;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.server.AbstractErrorMessage.ContentMode;
-import com.vaadin.server.ErrorMessage.ErrorLevel;
-import com.vaadin.server.ExternalResource;
-import com.vaadin.server.FileResource;
-import com.vaadin.server.Responsive;
-import com.vaadin.server.ThemeResource;
-import com.vaadin.server.UserError;
-import com.vaadin.ui.AbstractComponent;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for writing the attributes of the AbstractComponent to design
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeToDesign extends TestCase {
-
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    public void testSynchronizeId() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setId("testId");
-        component.synchronizeToDesign(design, ctx);
-        // we only changed one of the attributes, others are at default values
-        assertEquals(1, design.attributes().size());
-        assertEquals("testId", design.attr("id"));
-    }
-
-    public void testSynchronizePrimaryStyleName() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setPrimaryStyleName("test-style");
-        component.synchronizeToDesign(design, ctx);
-        // we only changed one of the attributes, others are at default values
-        assertEquals(1, design.attributes().size());
-        assertEquals("test-style", design.attr("primary-style-name"));
-    }
-
-    public void testSynchronizeCaption() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setCaption("test-caption");
-        component.synchronizeToDesign(design, ctx);
-        // We only changed the caption, which is not
-        // an attribute.
-        assertEquals(0, design.attributes().size());
-        assertEquals("test-caption", design.html());
-    }
-
-    public void testSynchronizeLocale() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setLocale(new Locale("fi", "FI"));
-        component.synchronizeToDesign(design, ctx);
-        // we only changed one of the attributes, others are at default values
-        assertEquals(1, design.attributes().size());
-        assertEquals("fi_FI", design.attr("locale"));
-    }
-
-    public void testSynchronizeExternalIcon() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component
-                .setIcon(new ExternalResource("http://example.com/example.gif"));
-        component.synchronizeToDesign(design, ctx);
-        // we only changed one of the attributes, others are at default values
-        assertEquals(1, design.attributes().size());
-        assertEquals("http://example.com/example.gif", design.attr("icon"));
-    }
-
-    public void testSynchronizeThemeIcon() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setIcon(new ThemeResource("example.gif"));
-        component.synchronizeToDesign(design, ctx);
-        // we only changed one of the attributes, others are at default values
-        assertEquals(1, design.attributes().size());
-        assertEquals("theme://example.gif", design.attr("icon"));
-    }
-
-    public void testSynchronizeFileResource() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setIcon(new FileResource(new File("img/example.gif")));
-        component.synchronizeToDesign(design, ctx);
-        // we only changed one of the attributes, others are at default values
-        assertEquals(1, design.attributes().size());
-        assertEquals("img/example.gif", design.attr("icon"));
-    }
-
-    public void testSynchronizeImmediate() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        // no immediate attribute should be written before setting immediate to
-        // some value
-        component.synchronizeToDesign(design, ctx);
-        assertFalse(design.hasAttr("immediate"));
-        component.setImmediate(true);
-        component.synchronizeToDesign(design, ctx);
-        // we only changed one of the attributes, others are at default values
-        assertEquals(1, design.attributes().size());
-        assertEquals("true", design.attr("immediate"));
-    }
-
-    public void testSynchronizeDescription() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setDescription("test-description");
-        component.synchronizeToDesign(design, ctx);
-        // we only changed one of the attributes, others are at default values
-        assertEquals(1, design.attributes().size());
-        assertEquals("test-description", design.attr("description"));
-    }
-
-    public void testSynchronizeComponentError() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setComponentError(new UserError("<div>test-error</div>",
-                ContentMode.HTML, ErrorLevel.ERROR));
-        component.synchronizeToDesign(design, ctx);
-        // we only changed one of the attributes, others are at default values
-        assertEquals(1, design.attributes().size());
-        assertEquals("<div>test-error</div>", design.attr("error"));
-    }
-
-    public void testSynchronizeSizeFull() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setSizeFull();
-        component.synchronizeToDesign(design, ctx);
-        // there should be only size full
-        assertEquals(1, design.attributes().size());
-        assertEquals("true", design.attr("size-full"));
-    }
-
-    public void testSynchronizeSizeAuto() {
-        Element design = createDesign();
-        AbstractComponent component = getPanel();
-        component.setSizeUndefined();
-        component.synchronizeToDesign(design, ctx);
-        // there should be only size auto
-        assertEquals(1, design.attributes().size());
-        assertEquals("true", design.attr("size-auto"));
-    }
-
-    public void testSynchronizeHeightFull() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setHeight("100%");
-        component.setWidth("20px");
-        component.synchronizeToDesign(design, ctx);
-        assertEquals("true", design.attr("height-full"));
-    }
-
-    public void testSynchronizeHeightAuto() {
-        Element design = createDesign();
-        // we need to have default height of 100% -> use split panel
-        AbstractComponent component = getPanel();
-        component.setHeight(null);
-        component.setWidth("20px");
-        component.synchronizeToDesign(design, ctx);
-        assertEquals("true", design.attr("height-auto"));
-    }
-
-    public void testSynchronizeWidthFull() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setHeight("20px");
-        component.setWidth("100%");
-        component.synchronizeToDesign(design, ctx);
-        assertEquals("true", design.attr("width-full"));
-    }
-
-    public void testSynchronizeWidthAuto() {
-        Element design = createDesign();
-        // need to get label, otherwise the default would be auto
-        AbstractComponent component = getPanel();
-        component.setHeight("20px");
-        component.setWidth(null);
-        component.synchronizeToDesign(design, ctx);
-        assertEquals("true", design.attr("width-auto"));
-    }
-
-    public void testSynchronizeWidth() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setHeight("20px");
-        component.setWidth("70%");
-        component.synchronizeToDesign(design, ctx);
-        assertEquals("70%", design.attr("width"));
-    }
-
-    public void testSynchronizeHeight() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        component.setHeight("20px");
-        component.setWidth("70%");
-        component.synchronizeToDesign(design, ctx);
-        assertEquals("20px", design.attr("height"));
-    }
-
-    public void testSynchronizeResponsive() {
-        Element design = createDesign();
-        AbstractComponent component = getComponent();
-        Responsive.makeResponsive(component);
-        component.synchronizeToDesign(design, ctx);
-        assertTrue("Design attributes should have key 'responsive'", design
-                .attributes().hasKey("responsive"));
-        assertFalse("Responsive attribute should not be 'false'",
-                design.attr("responsive").equalsIgnoreCase("false"));
-    }
-
-    private AbstractComponent getComponent() {
-        Button button = new Button();
-        button.setHtmlContentAllowed(true);
-        return button;
-    }
-
-    private AbstractComponent getPanel() {
-        return new HorizontalSplitPanel();
-    }
-
-    private Element createDesign() {
-        Attributes attr = new Attributes();
-        attr.put("should_be_removed", "foo");
-        Element node = new Element(Tag.valueOf("v-button"), "", attr);
-        Element child = new Element(Tag.valueOf("to-be-removed"), "foo", attr);
-        node.appendChild(child);
-        return node;
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..44c0e0b
--- /dev/null
@@ -0,0 +1,266 @@
+/*
+ * 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.abstractcomponent;
+
+import java.io.File;
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.server.AbstractErrorMessage.ContentMode;
+import com.vaadin.server.ErrorMessage.ErrorLevel;
+import com.vaadin.server.ExternalResource;
+import com.vaadin.server.FileResource;
+import com.vaadin.server.Responsive;
+import com.vaadin.server.ThemeResource;
+import com.vaadin.server.UserError;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for writing the attributes of the AbstractComponent to design
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestWriteDesign extends TestCase {
+
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    public void testSynchronizeId() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setId("testId");
+        component.writeDesign(design, ctx);
+        // we only changed one of the attributes, others are at default values
+        assertEquals(1, design.attributes().size());
+        assertEquals("testId", design.attr("id"));
+    }
+
+    public void testSynchronizePrimaryStyleName() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setPrimaryStyleName("test-style");
+        component.writeDesign(design, ctx);
+        // we only changed one of the attributes, others are at default values
+        assertEquals(1, design.attributes().size());
+        assertEquals("test-style", design.attr("primary-style-name"));
+    }
+
+    public void testSynchronizeCaption() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setCaption("test-caption");
+        component.writeDesign(design, ctx);
+        // We only changed the caption, which is not
+        // an attribute.
+        assertEquals(0, design.attributes().size());
+        assertEquals("test-caption", design.html());
+    }
+
+    public void testSynchronizeLocale() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setLocale(new Locale("fi", "FI"));
+        component.writeDesign(design, ctx);
+        // we only changed one of the attributes, others are at default values
+        assertEquals(1, design.attributes().size());
+        assertEquals("fi_FI", design.attr("locale"));
+    }
+
+    public void testSynchronizeExternalIcon() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component
+                .setIcon(new ExternalResource("http://example.com/example.gif"));
+        component.writeDesign(design, ctx);
+        // we only changed one of the attributes, others are at default values
+        assertEquals(1, design.attributes().size());
+        assertEquals("http://example.com/example.gif", design.attr("icon"));
+    }
+
+    public void testSynchronizeThemeIcon() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setIcon(new ThemeResource("example.gif"));
+        component.writeDesign(design, ctx);
+        // we only changed one of the attributes, others are at default values
+        assertEquals(1, design.attributes().size());
+        assertEquals("theme://example.gif", design.attr("icon"));
+    }
+
+    public void testSynchronizeFileResource() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setIcon(new FileResource(new File("img/example.gif")));
+        component.writeDesign(design, ctx);
+        // we only changed one of the attributes, others are at default values
+        assertEquals(1, design.attributes().size());
+        assertEquals("img/example.gif", design.attr("icon"));
+    }
+
+    public void testSynchronizeImmediate() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        // no immediate attribute should be written before setting immediate to
+        // some value
+        component.writeDesign(design, ctx);
+        assertFalse(design.hasAttr("immediate"));
+        component.setImmediate(true);
+        component.writeDesign(design, ctx);
+        // we only changed one of the attributes, others are at default values
+        assertEquals(1, design.attributes().size());
+        assertEquals("true", design.attr("immediate"));
+    }
+
+    public void testSynchronizeDescription() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setDescription("test-description");
+        component.writeDesign(design, ctx);
+        // we only changed one of the attributes, others are at default values
+        assertEquals(1, design.attributes().size());
+        assertEquals("test-description", design.attr("description"));
+    }
+
+    public void testSynchronizeComponentError() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setComponentError(new UserError("<div>test-error</div>",
+                ContentMode.HTML, ErrorLevel.ERROR));
+        component.writeDesign(design, ctx);
+        // we only changed one of the attributes, others are at default values
+        assertEquals(1, design.attributes().size());
+        assertEquals("<div>test-error</div>", design.attr("error"));
+    }
+
+    public void testSynchronizeSizeFull() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setSizeFull();
+        component.writeDesign(design, ctx);
+        // there should be only size full
+        assertEquals(1, design.attributes().size());
+        assertEquals("true", design.attr("size-full"));
+    }
+
+    public void testSynchronizeSizeAuto() {
+        Element design = createDesign();
+        AbstractComponent component = getPanel();
+        component.setSizeUndefined();
+        component.writeDesign(design, ctx);
+        // there should be only size auto
+        assertEquals(1, design.attributes().size());
+        assertEquals("true", design.attr("size-auto"));
+    }
+
+    public void testSynchronizeHeightFull() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setHeight("100%");
+        component.setWidth("20px");
+        component.writeDesign(design, ctx);
+        assertEquals("true", design.attr("height-full"));
+    }
+
+    public void testSynchronizeHeightAuto() {
+        Element design = createDesign();
+        // we need to have default height of 100% -> use split panel
+        AbstractComponent component = getPanel();
+        component.setHeight(null);
+        component.setWidth("20px");
+        component.writeDesign(design, ctx);
+        assertEquals("true", design.attr("height-auto"));
+    }
+
+    public void testSynchronizeWidthFull() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setHeight("20px");
+        component.setWidth("100%");
+        component.writeDesign(design, ctx);
+        assertEquals("true", design.attr("width-full"));
+    }
+
+    public void testSynchronizeWidthAuto() {
+        Element design = createDesign();
+        // need to get label, otherwise the default would be auto
+        AbstractComponent component = getPanel();
+        component.setHeight("20px");
+        component.setWidth(null);
+        component.writeDesign(design, ctx);
+        assertEquals("true", design.attr("width-auto"));
+    }
+
+    public void testSynchronizeWidth() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setHeight("20px");
+        component.setWidth("70%");
+        component.writeDesign(design, ctx);
+        assertEquals("70%", design.attr("width"));
+    }
+
+    public void testSynchronizeHeight() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        component.setHeight("20px");
+        component.setWidth("70%");
+        component.writeDesign(design, ctx);
+        assertEquals("20px", design.attr("height"));
+    }
+
+    public void testSynchronizeResponsive() {
+        Element design = createDesign();
+        AbstractComponent component = getComponent();
+        Responsive.makeResponsive(component);
+        component.writeDesign(design, ctx);
+        assertTrue("Design attributes should have key 'responsive'", design
+                .attributes().hasKey("responsive"));
+        assertFalse("Responsive attribute should not be 'false'",
+                design.attr("responsive").equalsIgnoreCase("false"));
+    }
+
+    private AbstractComponent getComponent() {
+        Button button = new Button();
+        button.setHtmlContentAllowed(true);
+        return button;
+    }
+
+    private AbstractComponent getPanel() {
+        return new HorizontalSplitPanel();
+    }
+
+    private Element createDesign() {
+        Attributes attr = new Attributes();
+        attr.put("should_be_removed", "foo");
+        Element node = new Element(Tag.valueOf("v-button"), "", attr);
+        Element child = new Element(Tag.valueOf("to-be-removed"), "foo", attr);
+        node.appendChild(child);
+        return node;
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestReadDesign.java
new file mode 100644 (file)
index 0000000..dd0e629
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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.abstractfield;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * 
+ * Test case for reading the attributes of the AbstractField from design
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestReadDesign extends TestCase {
+
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    public void testSynchronizeReadOnly() {
+        Element design = createDesign("readonly", "");
+        AbstractField component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals(true, component.isReadOnly());
+        design = createDesign("readonly", "false");
+        component.readDesign(design, ctx);
+        assertEquals(false, component.isReadOnly());
+    }
+
+    public void testSynchronizeTabIndex() {
+        Element design = createDesign("tabindex", "2");
+        AbstractField component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals("Tab index must be 2", 2, component.getTabIndex());
+    }
+
+    private AbstractField getComponent() {
+        return new TextField();
+    }
+
+    private Element createDesign(String key, String value) {
+        Attributes attributes = new Attributes();
+        attributes.put(key, value);
+        Element node = new Element(Tag.valueOf("v-text-field"), "", attributes);
+        return node;
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index 6a2c194..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.abstractfield;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * 
- * Test case for reading the attributes of the AbstractField from design
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeFromDesign extends TestCase {
-
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    public void testSynchronizeReadOnly() {
-        Element design = createDesign("readonly", "");
-        AbstractField component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(true, component.isReadOnly());
-        design = createDesign("readonly", "false");
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals(false, component.isReadOnly());
-    }
-
-    public void testSynchronizeTabIndex() {
-        Element design = createDesign("tabindex", "2");
-        AbstractField component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("Tab index must be 2", 2, component.getTabIndex());
-    }
-
-    private AbstractField getComponent() {
-        return new TextField();
-    }
-
-    private Element createDesign(String key, String value) {
-        Attributes attributes = new Attributes();
-        attributes.put(key, value);
-        Element node = new Element(Tag.valueOf("v-text-field"), "", attributes);
-        return node;
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestSynchronizeToDesign.java
deleted file mode 100644 (file)
index 26f64f9..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.abstractfield;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.ui.AbstractField;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for writing the attributes of the AbstractField to design
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeToDesign extends TestCase {
-
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    public void testSynchronizeReadOnly() {
-        Element design = createDesign();
-        AbstractField component = getComponent();
-        component.setReadOnly(true);
-        component.synchronizeToDesign(design, ctx);
-        // we only changed one of the attributes, others are at default values
-        assertEquals(1, design.attributes().size());
-        assertTrue("Design must contain readonly", design.hasAttr("readonly"));
-        assertTrue("Readonly must be true", design.attr("readonly").equals("")
-                || design.attr("readonly").equals("true"));
-    }
-
-    public void testSynchronizeModelReadOnly() {
-        Element design = createDesign();
-        AbstractField component = getComponent();
-        ObjectProperty property = new ObjectProperty<String>("test");
-        property.setReadOnly(true);
-        component.setPropertyDataSource(property);
-        component.synchronizeToDesign(design, ctx);
-        // make sure that property readonly is not written to design
-        assertFalse("Design must not contain readonly",
-                design.hasAttr("readonly"));
-    }
-
-    private AbstractField getComponent() {
-        return new TextField();
-    }
-
-    private Element createDesign() {
-        Attributes attr = new Attributes();
-        attr.put("should_be_removed", "foo");
-        return new Element(Tag.valueOf("v-text-field"), "", attr);
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..969713a
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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.abstractfield;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.data.util.ObjectProperty;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for writing the attributes of the AbstractField to design
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestWriteDesign extends TestCase {
+
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    public void testSynchronizeReadOnly() {
+        Element design = createDesign();
+        AbstractField component = getComponent();
+        component.setReadOnly(true);
+        component.writeDesign(design, ctx);
+        // we only changed one of the attributes, others are at default values
+        assertEquals(1, design.attributes().size());
+        assertTrue("Design must contain readonly", design.hasAttr("readonly"));
+        assertTrue("Readonly must be true", design.attr("readonly").equals("")
+                || design.attr("readonly").equals("true"));
+    }
+
+    public void testSynchronizeModelReadOnly() {
+        Element design = createDesign();
+        AbstractField component = getComponent();
+        ObjectProperty property = new ObjectProperty<String>("test");
+        property.setReadOnly(true);
+        component.setPropertyDataSource(property);
+        component.writeDesign(design, ctx);
+        // make sure that property readonly is not written to design
+        assertFalse("Design must not contain readonly",
+                design.hasAttr("readonly"));
+    }
+
+    private AbstractField getComponent() {
+        return new TextField();
+    }
+
+    private Element createDesign() {
+        Attributes attr = new Attributes();
+        attr.put("should_be_removed", "foo");
+        return new Element(Tag.valueOf("v-text-field"), "", attr);
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestReadDesign.java
new file mode 100644 (file)
index 0000000..f52a044
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * 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.abstractorderedlayout;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case from reading AbstractOrdered layouts from design
+ * 
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TestReadDesign extends TestCase {
+
+    public void testChildCount() {
+        VerticalLayout root = createLayout(0f, false);
+        assertEquals(2, root.getComponentCount());
+    }
+
+    public void testMargin() {
+        VerticalLayout root = createLayout(0f, true);
+        assertTrue(root.getMargin().getBitMask() != 0);
+        root = createLayout(0f, false);
+        assertTrue(root.getMargin().getBitMask() == 0);
+    }
+
+    public void testAttributes() {
+        VerticalLayout root = createLayout(0f, false);
+        assertEquals("test-layout", root.getCaption());
+        assertEquals("test-label", root.getComponent(0).getCaption());
+        assertEquals("test-button", root.getComponent(1).getCaption());
+    }
+
+    public void testExpandRatio() {
+        VerticalLayout root = createLayout(1f, false);
+        assertEquals(1f, root.getExpandRatio(root.getComponent(0)));
+        assertEquals(1f, root.getExpandRatio(root.getComponent(1)));
+
+        root = createLayout(0f, false);
+        assertEquals(0f, root.getExpandRatio(root.getComponent(0)));
+        assertEquals(0f, root.getExpandRatio(root.getComponent(1)));
+    }
+
+    public void testAlignment() {
+        VerticalLayout root = createLayout(0f, false, ":top", ":left");
+        assertEquals(Alignment.TOP_LEFT,
+                root.getComponentAlignment(root.getComponent(0)));
+        root = createLayout(0f, false, ":middle", ":center");
+        assertEquals(Alignment.MIDDLE_CENTER,
+                root.getComponentAlignment(root.getComponent(0)));
+        root = createLayout(0f, false, ":bottom", ":right");
+        assertEquals(Alignment.BOTTOM_RIGHT,
+                root.getComponentAlignment(root.getComponent(0)));
+
+    }
+
+    private VerticalLayout createLayout(float expandRatio, boolean margin,
+            String... alignments) {
+        DesignContext ctx = new DesignContext();
+        Element design = createDesign(expandRatio, margin, alignments);
+        Component child = ctx.createChild(design);
+        return (VerticalLayout) child;
+    }
+
+    private Element createDesign(float expandRatio, boolean margin,
+            String... alignments) {
+
+        Attributes rootAttributes = new Attributes();
+        rootAttributes.put("caption", "test-layout");
+        if (margin) {
+            rootAttributes.put("margin", "");
+        }
+        Element node = new Element(Tag.valueOf("v-vertical-layout"), "",
+                rootAttributes);
+
+        Attributes firstChildAttributes = new Attributes();
+        firstChildAttributes.put("caption", "test-label");
+        firstChildAttributes.put(":expand", String.valueOf(expandRatio));
+        for (String alignment : alignments) {
+            firstChildAttributes.put(alignment, "");
+        }
+        Element firstChild = new Element(Tag.valueOf("v-label"), "",
+                firstChildAttributes);
+        node.appendChild(firstChild);
+
+        Attributes secondChildAttributes = new Attributes();
+        secondChildAttributes.put(":expand", String.valueOf(expandRatio));
+        for (String alignment : alignments) {
+            secondChildAttributes.put(alignment, "");
+        }
+        Element secondChild = new Element(Tag.valueOf("v-button"), "",
+                secondChildAttributes);
+        secondChild.html("test-button");
+        node.appendChild(secondChild);
+        return node;
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index 2b3d4cb..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.abstractorderedlayout;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case from reading AbstractOrdered layouts from design
- * 
- * @since
- * @author Vaadin Ltd
- */
-public class TestSynchronizeFromDesign extends TestCase {
-
-    public void testChildCount() {
-        VerticalLayout root = createLayout(0f, false);
-        assertEquals(2, root.getComponentCount());
-    }
-
-    public void testMargin() {
-        VerticalLayout root = createLayout(0f, true);
-        assertTrue(root.getMargin().getBitMask() != 0);
-        root = createLayout(0f, false);
-        assertTrue(root.getMargin().getBitMask() == 0);
-    }
-
-    public void testAttributes() {
-        VerticalLayout root = createLayout(0f, false);
-        assertEquals("test-layout", root.getCaption());
-        assertEquals("test-label", root.getComponent(0).getCaption());
-        assertEquals("test-button", root.getComponent(1).getCaption());
-    }
-
-    public void testExpandRatio() {
-        VerticalLayout root = createLayout(1f, false);
-        assertEquals(1f, root.getExpandRatio(root.getComponent(0)));
-        assertEquals(1f, root.getExpandRatio(root.getComponent(1)));
-
-        root = createLayout(0f, false);
-        assertEquals(0f, root.getExpandRatio(root.getComponent(0)));
-        assertEquals(0f, root.getExpandRatio(root.getComponent(1)));
-    }
-
-    public void testAlignment() {
-        VerticalLayout root = createLayout(0f, false, ":top", ":left");
-        assertEquals(Alignment.TOP_LEFT,
-                root.getComponentAlignment(root.getComponent(0)));
-        root = createLayout(0f, false, ":middle", ":center");
-        assertEquals(Alignment.MIDDLE_CENTER,
-                root.getComponentAlignment(root.getComponent(0)));
-        root = createLayout(0f, false, ":bottom", ":right");
-        assertEquals(Alignment.BOTTOM_RIGHT,
-                root.getComponentAlignment(root.getComponent(0)));
-
-    }
-
-    private VerticalLayout createLayout(float expandRatio, boolean margin,
-            String... alignments) {
-        DesignContext ctx = new DesignContext();
-        Element design = createDesign(expandRatio, margin, alignments);
-        Component child = ctx.createChild(design);
-        return (VerticalLayout) child;
-    }
-
-    private Element createDesign(float expandRatio, boolean margin,
-            String... alignments) {
-
-        Attributes rootAttributes = new Attributes();
-        rootAttributes.put("caption", "test-layout");
-        if (margin) {
-            rootAttributes.put("margin", "");
-        }
-        Element node = new Element(Tag.valueOf("v-vertical-layout"), "",
-                rootAttributes);
-
-        Attributes firstChildAttributes = new Attributes();
-        firstChildAttributes.put("caption", "test-label");
-        firstChildAttributes.put(":expand", String.valueOf(expandRatio));
-        for (String alignment : alignments) {
-            firstChildAttributes.put(alignment, "");
-        }
-        Element firstChild = new Element(Tag.valueOf("v-label"), "",
-                firstChildAttributes);
-        node.appendChild(firstChild);
-
-        Attributes secondChildAttributes = new Attributes();
-        secondChildAttributes.put(":expand", String.valueOf(expandRatio));
-        for (String alignment : alignments) {
-            secondChildAttributes.put(alignment, "");
-        }
-        Element secondChild = new Element(Tag.valueOf("v-button"), "",
-                secondChildAttributes);
-        secondChild.html("test-button");
-        node.appendChild(secondChild);
-        return node;
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestSynchronizeToDesign.java
deleted file mode 100644 (file)
index 23cf15c..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.abstractorderedlayout;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for writing abstract ordered layout to design
- * 
- * @since
- * @author Vaadin Ltd
- */
-public class TestSynchronizeToDesign extends TestCase {
-
-    public void testSynchronizeMargin() {
-        VerticalLayout layout = new VerticalLayout();
-        layout.setMargin(true);
-        Element design = createDesign();
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertTrue("The margin must be written", design.hasAttr("margin"));
-        assertTrue("The margin must be empty or true", design.attr("margin")
-                .equals("") || design.attr("margin").equalsIgnoreCase("true"));
-    }
-
-    public void testSynchronizeEmptyLayout() {
-        VerticalLayout layout = new VerticalLayout();
-        layout.setCaption("changed-caption");
-        Element design = createDesign();
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertEquals(0, design.childNodes().size());
-        assertEquals("changed-caption", design.attr("caption"));
-    }
-
-    public void testSynchronizeLayoutWithChildren() {
-        VerticalLayout layout = new VerticalLayout();
-        layout.addComponent(new Label("test-label"));
-        layout.getComponent(0).setCaption("test-caption");
-        layout.addComponent(new Label("test-label-2"));
-        Element design = createDesign();
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertEquals(2, design.childNodes().size());
-        assertEquals("v-label", ((Element) design.childNode(0)).tagName());
-        assertEquals("test-caption", design.childNode(0).attr("caption"));
-    }
-
-    public void testSynchronizeUnitExpandRatio() {
-        VerticalLayout layout = new VerticalLayout();
-        layout.addComponent(new Label("test-label"));
-        layout.setExpandRatio(layout.getComponent(0), 1.0f);
-        Element design = createDesign();
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertTrue(design.childNode(0).hasAttr(":expand"));
-        assertEquals("", design.childNode(0).attr(":expand"));
-    }
-
-    public void testSynchronizeArbitraryExpandRatio() {
-        VerticalLayout layout = new VerticalLayout();
-        layout.addComponent(new Label("test-label"));
-        layout.setExpandRatio(layout.getComponent(0), 2.40f);
-        Element design = createDesign();
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertTrue(design.childNode(0).hasAttr(":expand"));
-        assertEquals("2.4", design.childNode(0).attr(":expand"));
-    }
-
-    public void testSynchronizeDefaultAlignment() {
-        Element design = createDesign();
-        VerticalLayout layout = createLayoutWithAlignment(design, null);
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertFalse(design.childNode(0).hasAttr(":top"));
-        assertFalse(design.childNode(0).hasAttr(":left"));
-    }
-
-    public void testSynchronizeMiddleCenter() {
-        Element design = createDesign();
-        VerticalLayout layout = createLayoutWithAlignment(design,
-                Alignment.MIDDLE_CENTER);
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertTrue(design.childNode(0).hasAttr(":middle"));
-        assertTrue(design.childNode(0).hasAttr(":center"));
-    }
-
-    public void testSynchronizeBottomRight() {
-        Element design = createDesign();
-        VerticalLayout layout = createLayoutWithAlignment(design,
-                Alignment.BOTTOM_RIGHT);
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertTrue(design.childNode(0).hasAttr(":bottom"));
-        assertTrue(design.childNode(0).hasAttr(":right"));
-    }
-
-    private VerticalLayout createLayoutWithAlignment(Element design,
-            Alignment alignment) {
-        VerticalLayout layout = new VerticalLayout();
-        layout.addComponent(new Label("test-label"));
-        if (alignment != null) {
-            layout.setComponentAlignment(layout.getComponent(0), alignment);
-        }
-        layout.synchronizeToDesign(design, createDesignContext());
-        return layout;
-    }
-
-    private Element createDesign() {
-        // make sure that the design node has old content that should be removed
-        Attributes rootAttributes = new Attributes();
-        rootAttributes.put("caption", "test-layout");
-        Element node = new Element(Tag.valueOf("v-vertical-layout"), "",
-                rootAttributes);
-        Attributes firstChildAttributes = new Attributes();
-        firstChildAttributes.put("caption", "test-label");
-        Element firstChild = new Element(Tag.valueOf("v-label"), "",
-                firstChildAttributes);
-        node.appendChild(firstChild);
-
-        Attributes secondChildAttributes = new Attributes();
-        secondChildAttributes.put("caption", "test-button");
-        Element secondChild = new Element(Tag.valueOf("v-button"), "",
-                secondChildAttributes);
-        node.appendChild(secondChild);
-        return node;
-    }
-
-    private DesignContext createDesignContext() {
-        return new DesignContext();
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..302cf98
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * 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.abstractorderedlayout;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for writing abstract ordered layout to design
+ * 
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TestWriteDesign extends TestCase {
+
+    public void testSynchronizeMargin() {
+        VerticalLayout layout = new VerticalLayout();
+        layout.setMargin(true);
+        Element design = createDesign();
+        layout.writeDesign(design, createDesignContext());
+        assertTrue("The margin must be written", design.hasAttr("margin"));
+        assertTrue("The margin must be empty or true", design.attr("margin")
+                .equals("") || design.attr("margin").equalsIgnoreCase("true"));
+    }
+
+    public void testSynchronizeEmptyLayout() {
+        VerticalLayout layout = new VerticalLayout();
+        layout.setCaption("changed-caption");
+        Element design = createDesign();
+        layout.writeDesign(design, createDesignContext());
+        assertEquals(0, design.childNodes().size());
+        assertEquals("changed-caption", design.attr("caption"));
+    }
+
+    public void testSynchronizeLayoutWithChildren() {
+        VerticalLayout layout = new VerticalLayout();
+        layout.addComponent(new Label("test-label"));
+        layout.getComponent(0).setCaption("test-caption");
+        layout.addComponent(new Label("test-label-2"));
+        Element design = createDesign();
+        layout.writeDesign(design, createDesignContext());
+        assertEquals(2, design.childNodes().size());
+        assertEquals("v-label", ((Element) design.childNode(0)).tagName());
+        assertEquals("test-caption", design.childNode(0).attr("caption"));
+    }
+
+    public void testSynchronizeUnitExpandRatio() {
+        VerticalLayout layout = new VerticalLayout();
+        layout.addComponent(new Label("test-label"));
+        layout.setExpandRatio(layout.getComponent(0), 1.0f);
+        Element design = createDesign();
+        layout.writeDesign(design, createDesignContext());
+        assertTrue(design.childNode(0).hasAttr(":expand"));
+        assertEquals("", design.childNode(0).attr(":expand"));
+    }
+
+    public void testSynchronizeArbitraryExpandRatio() {
+        VerticalLayout layout = new VerticalLayout();
+        layout.addComponent(new Label("test-label"));
+        layout.setExpandRatio(layout.getComponent(0), 2.40f);
+        Element design = createDesign();
+        layout.writeDesign(design, createDesignContext());
+        assertTrue(design.childNode(0).hasAttr(":expand"));
+        assertEquals("2.4", design.childNode(0).attr(":expand"));
+    }
+
+    public void testSynchronizeDefaultAlignment() {
+        Element design = createDesign();
+        VerticalLayout layout = createLayoutWithAlignment(design, null);
+        layout.writeDesign(design, createDesignContext());
+        assertFalse(design.childNode(0).hasAttr(":top"));
+        assertFalse(design.childNode(0).hasAttr(":left"));
+    }
+
+    public void testSynchronizeMiddleCenter() {
+        Element design = createDesign();
+        VerticalLayout layout = createLayoutWithAlignment(design,
+                Alignment.MIDDLE_CENTER);
+        layout.writeDesign(design, createDesignContext());
+        assertTrue(design.childNode(0).hasAttr(":middle"));
+        assertTrue(design.childNode(0).hasAttr(":center"));
+    }
+
+    public void testSynchronizeBottomRight() {
+        Element design = createDesign();
+        VerticalLayout layout = createLayoutWithAlignment(design,
+                Alignment.BOTTOM_RIGHT);
+        layout.writeDesign(design, createDesignContext());
+        assertTrue(design.childNode(0).hasAttr(":bottom"));
+        assertTrue(design.childNode(0).hasAttr(":right"));
+    }
+
+    private VerticalLayout createLayoutWithAlignment(Element design,
+            Alignment alignment) {
+        VerticalLayout layout = new VerticalLayout();
+        layout.addComponent(new Label("test-label"));
+        if (alignment != null) {
+            layout.setComponentAlignment(layout.getComponent(0), alignment);
+        }
+        layout.writeDesign(design, createDesignContext());
+        return layout;
+    }
+
+    private Element createDesign() {
+        // make sure that the design node has old content that should be removed
+        Attributes rootAttributes = new Attributes();
+        rootAttributes.put("caption", "test-layout");
+        Element node = new Element(Tag.valueOf("v-vertical-layout"), "",
+                rootAttributes);
+        Attributes firstChildAttributes = new Attributes();
+        firstChildAttributes.put("caption", "test-label");
+        Element firstChild = new Element(Tag.valueOf("v-label"), "",
+                firstChildAttributes);
+        node.appendChild(firstChild);
+
+        Attributes secondChildAttributes = new Attributes();
+        secondChildAttributes.put("caption", "test-button");
+        Element secondChild = new Element(Tag.valueOf("v-button"), "",
+                secondChildAttributes);
+        node.appendChild(secondChild);
+        return node;
+    }
+
+    private DesignContext createDesignContext() {
+        return new DesignContext();
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestReadDesign.java
new file mode 100644 (file)
index 0000000..c57f18c
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * 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.abstractsplitpanel;
+
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.server.Sizeable.Unit;
+import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState.SplitterState;
+import com.vaadin.ui.AbstractSplitPanel;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.VerticalSplitPanel;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Tests synchronizing the attributes and children of horizontal and vertical
+ * split panels from a design.
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestReadDesign extends TestCase {
+    DesignContext ctx;
+
+    @Override
+    protected void setUp() {
+        ctx = new DesignContext();
+    }
+
+    public void testAttributes() throws Exception {
+        // Create a design with non-default attributes values.
+        Element design = createDesign(true, false, true, true);
+        HorizontalSplitPanel sp = new HorizontalSplitPanel();
+        sp.readDesign(design, ctx);
+        // Check that the attributes are correctly parsed.
+        assertEquals(20.5f, sp.getSplitPosition());
+        assertEquals(Unit.PERCENTAGE, sp.getSplitPositionUnit());
+        assertEquals(20f, sp.getMinSplitPosition());
+        assertEquals(Unit.PERCENTAGE, sp.getMinSplitPositionUnit());
+        assertEquals(50f, sp.getMaxSplitPosition());
+        assertEquals(Unit.PIXELS, sp.getMaxSplitPositionUnit());
+        assertEquals(true, sp.isLocked());
+        checkReversed(sp, true);
+        // check that the properties get the default values if the design
+        // does not have attributes corresponding to those properties
+        design = createDesign(true, true, true, true);
+        sp.readDesign(design, ctx);
+        HorizontalSplitPanel def = new HorizontalSplitPanel();
+        assertEquals(def.getSplitPosition(), sp.getSplitPosition());
+        assertEquals(def.getSplitPositionUnit(), sp.getSplitPositionUnit());
+        assertEquals(def.getMinSplitPosition(), sp.getMinSplitPosition());
+        assertEquals(def.getMinSplitPositionUnit(),
+                sp.getMinSplitPositionUnit());
+        assertEquals(def.getMaxSplitPosition(), sp.getMaxSplitPosition());
+        assertEquals(def.getMaxSplitPositionUnit(),
+                sp.getMaxSplitPositionUnit());
+        assertEquals(def.isLocked(), sp.isLocked());
+        checkReversed(sp, false);
+    }
+
+    public void testWithNoChildren() {
+        Element design = createDesign(true, false, false, false);
+        HorizontalSplitPanel sp = new HorizontalSplitPanel();
+        sp.readDesign(design, ctx);
+        assertEquals("Unexpected child count for the split panel.", 0,
+                sp.getComponentCount());
+    }
+
+    public void testWithFirstChild() {
+        Element design = createDesign(false, false, true, false);
+        VerticalSplitPanel sp = new VerticalSplitPanel();
+        sp.readDesign(design, ctx);
+        assertEquals("Unexpected child count for the split panel.", 1,
+                sp.getComponentCount());
+        Object obj = sp.getFirstComponent();
+        assertEquals("Wrong component in split panel.", Table.class,
+                obj.getClass());
+    }
+
+    public void testWithSecondChild() {
+        Element design = createDesign(true, false, false, true);
+        HorizontalSplitPanel sp = new HorizontalSplitPanel();
+        sp.readDesign(design, ctx);
+        assertEquals("Unexpected child count for the split panel.", 1,
+                sp.getComponentCount());
+        Object obj = sp.getSecondComponent();
+        assertEquals("Wrong component in split panel.", VerticalLayout.class,
+                obj.getClass());
+    }
+
+    public void testWithBothChildren() {
+        Element design = createDesign(false, false, true, true);
+        VerticalSplitPanel sp = new VerticalSplitPanel();
+        sp.readDesign(design, ctx);
+        assertEquals("Unexpected child count for the split panel.", 2,
+                sp.getComponentCount());
+        Object first = sp.getFirstComponent();
+        Object second = sp.getSecondComponent();
+        assertEquals("Wrong first component in split panel.", Table.class,
+                first.getClass());
+        assertEquals("Wrong second component in split panel.",
+                VerticalLayout.class, second.getClass());
+    }
+
+    /*
+     * Creates an html tree node structure representing a split panel and its
+     * contents. The parameters are used for controlling whether the split panel
+     * is horizontal or vertical, whether attributes are set for the design and
+     * whether the split panel should have the first and the second child
+     * component.
+     */
+    private Element createDesign(boolean horizontal,
+            boolean useDefaultAttributes, boolean hasFirstChild,
+            boolean hasSecondChild) {
+        Attributes attributes = new Attributes();
+        if (!useDefaultAttributes) {
+            attributes.put("split-position", "20.5%");
+            // The unitless number should correspond to 20%
+            attributes.put("min-split-position", "20");
+            attributes.put("max-split-position", "50px");
+            attributes.put("locked", "");
+            attributes.put("reversed", "");
+        }
+        String tagName = horizontal ? "v-horizontal-split-panel"
+                : "v-vertical-split-panel";
+        Element element = new Element(Tag.valueOf(tagName), "", attributes);
+        // Create the children
+        if (hasFirstChild) {
+            Element child = new Element(Tag.valueOf("v-table"), "");
+            element.appendChild(child);
+        }
+        if (hasSecondChild) {
+            Element child = new Element(Tag.valueOf("v-vertical-layout"), "");
+            if (!hasFirstChild) {
+                child.attr(":second", "");
+            }
+            element.appendChild(child);
+        }
+        return element;
+    }
+
+    /*
+     * Checks the reversed property of a split panel.
+     */
+    private void checkReversed(AbstractSplitPanel sp, boolean expected)
+            throws Exception {
+        Method getter = AbstractSplitPanel.class
+                .getDeclaredMethod("getSplitterState");
+        getter.setAccessible(true);
+        SplitterState state = (SplitterState) getter.invoke(sp);
+        assertEquals("Wrong value for split panel property reversed.",
+                expected, state.positionReversed);
+    }
+}
\ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index b34e8fc..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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.abstractsplitpanel;
-
-import java.lang.reflect.Method;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.server.Sizeable.Unit;
-import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState.SplitterState;
-import com.vaadin.ui.AbstractSplitPanel;
-import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.VerticalSplitPanel;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Tests synchronizing the attributes and children of horizontal and vertical
- * split panels from a design.
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeFromDesign extends TestCase {
-    DesignContext ctx;
-
-    @Override
-    protected void setUp() {
-        ctx = new DesignContext();
-    }
-
-    public void testAttributes() throws Exception {
-        // Create a design with non-default attributes values.
-        Element design = createDesign(true, false, true, true);
-        HorizontalSplitPanel sp = new HorizontalSplitPanel();
-        sp.synchronizeFromDesign(design, ctx);
-        // Check that the attributes are correctly parsed.
-        assertEquals(20.5f, sp.getSplitPosition());
-        assertEquals(Unit.PERCENTAGE, sp.getSplitPositionUnit());
-        assertEquals(20f, sp.getMinSplitPosition());
-        assertEquals(Unit.PERCENTAGE, sp.getMinSplitPositionUnit());
-        assertEquals(50f, sp.getMaxSplitPosition());
-        assertEquals(Unit.PIXELS, sp.getMaxSplitPositionUnit());
-        assertEquals(true, sp.isLocked());
-        checkReversed(sp, true);
-        // check that the properties get the default values if the design
-        // does not have attributes corresponding to those properties
-        design = createDesign(true, true, true, true);
-        sp.synchronizeFromDesign(design, ctx);
-        HorizontalSplitPanel def = new HorizontalSplitPanel();
-        assertEquals(def.getSplitPosition(), sp.getSplitPosition());
-        assertEquals(def.getSplitPositionUnit(), sp.getSplitPositionUnit());
-        assertEquals(def.getMinSplitPosition(), sp.getMinSplitPosition());
-        assertEquals(def.getMinSplitPositionUnit(),
-                sp.getMinSplitPositionUnit());
-        assertEquals(def.getMaxSplitPosition(), sp.getMaxSplitPosition());
-        assertEquals(def.getMaxSplitPositionUnit(),
-                sp.getMaxSplitPositionUnit());
-        assertEquals(def.isLocked(), sp.isLocked());
-        checkReversed(sp, false);
-    }
-
-    public void testWithNoChildren() {
-        Element design = createDesign(true, false, false, false);
-        HorizontalSplitPanel sp = new HorizontalSplitPanel();
-        sp.synchronizeFromDesign(design, ctx);
-        assertEquals("Unexpected child count for the split panel.", 0,
-                sp.getComponentCount());
-    }
-
-    public void testWithFirstChild() {
-        Element design = createDesign(false, false, true, false);
-        VerticalSplitPanel sp = new VerticalSplitPanel();
-        sp.synchronizeFromDesign(design, ctx);
-        assertEquals("Unexpected child count for the split panel.", 1,
-                sp.getComponentCount());
-        Object obj = sp.getFirstComponent();
-        assertEquals("Wrong component in split panel.", Table.class,
-                obj.getClass());
-    }
-
-    public void testWithSecondChild() {
-        Element design = createDesign(true, false, false, true);
-        HorizontalSplitPanel sp = new HorizontalSplitPanel();
-        sp.synchronizeFromDesign(design, ctx);
-        assertEquals("Unexpected child count for the split panel.", 1,
-                sp.getComponentCount());
-        Object obj = sp.getSecondComponent();
-        assertEquals("Wrong component in split panel.", VerticalLayout.class,
-                obj.getClass());
-    }
-
-    public void testWithBothChildren() {
-        Element design = createDesign(false, false, true, true);
-        VerticalSplitPanel sp = new VerticalSplitPanel();
-        sp.synchronizeFromDesign(design, ctx);
-        assertEquals("Unexpected child count for the split panel.", 2,
-                sp.getComponentCount());
-        Object first = sp.getFirstComponent();
-        Object second = sp.getSecondComponent();
-        assertEquals("Wrong first component in split panel.", Table.class,
-                first.getClass());
-        assertEquals("Wrong second component in split panel.",
-                VerticalLayout.class, second.getClass());
-    }
-
-    /*
-     * Creates an html tree node structure representing a split panel and its
-     * contents. The parameters are used for controlling whether the split panel
-     * is horizontal or vertical, whether attributes are set for the design and
-     * whether the split panel should have the first and the second child
-     * component.
-     */
-    private Element createDesign(boolean horizontal,
-            boolean useDefaultAttributes, boolean hasFirstChild,
-            boolean hasSecondChild) {
-        Attributes attributes = new Attributes();
-        if (!useDefaultAttributes) {
-            attributes.put("split-position", "20.5%");
-            // The unitless number should correspond to 20%
-            attributes.put("min-split-position", "20");
-            attributes.put("max-split-position", "50px");
-            attributes.put("locked", "");
-            attributes.put("reversed", "");
-        }
-        String tagName = horizontal ? "v-horizontal-split-panel"
-                : "v-vertical-split-panel";
-        Element element = new Element(Tag.valueOf(tagName), "", attributes);
-        // Create the children
-        if (hasFirstChild) {
-            Element child = new Element(Tag.valueOf("v-table"), "");
-            element.appendChild(child);
-        }
-        if (hasSecondChild) {
-            Element child = new Element(Tag.valueOf("v-vertical-layout"), "");
-            if (!hasFirstChild) {
-                child.attr(":second", "");
-            }
-            element.appendChild(child);
-        }
-        return element;
-    }
-
-    /*
-     * Checks the reversed property of a split panel.
-     */
-    private void checkReversed(AbstractSplitPanel sp, boolean expected)
-            throws Exception {
-        Method getter = AbstractSplitPanel.class
-                .getDeclaredMethod("getSplitterState");
-        getter.setAccessible(true);
-        SplitterState state = (SplitterState) getter.invoke(sp);
-        assertEquals("Wrong value for split panel property reversed.",
-                expected, state.positionReversed);
-    }
-}
\ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestSynchronizeToDesign.java
deleted file mode 100644 (file)
index 3e342a0..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * 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.abstractsplitpanel;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Element;
-
-import com.vaadin.server.Sizeable.Unit;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalSplitPanel;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Tests synchronizing the properties and child components of split panels to a
- * design.
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeToDesign extends TestCase {
-    private DesignContext ctx;
-
-    @Override
-    public void setUp() {
-        ctx = new DesignContext();
-    }
-
-    public void testHorizontalWithDefaultValues() {
-        // no attributes or child elements should appear
-        HorizontalSplitPanel sp = new HorizontalSplitPanel();
-        Element e = ctx.createNode(sp);
-        assertEquals("Wrong tag name.", "v-horizontal-split-panel",
-                e.nodeName());
-        assertEquals("The split panel should not have attributes.", 0, e
-                .attributes().size());
-        assertEquals("The split panel should not have children.", 0, e
-                .children().size());
-    }
-
-    public void testVerticalWithAttributes() {
-        // All defined attributes should be output in the tree node. No child
-        // components are present in this test.
-        VerticalSplitPanel sp = new VerticalSplitPanel();
-        sp.setSplitPosition(27f, Unit.PIXELS, true);
-        sp.setMinSplitPosition(5.5f, Unit.PERCENTAGE);
-        sp.setMaxSplitPosition(95, Unit.PERCENTAGE);
-        sp.setLocked(true);
-        Element e = ctx.createNode(sp);
-        assertEquals("Wrong tag name.", "v-vertical-split-panel", e.nodeName());
-        assertEquals("Unexpected number of attributes.", 5, e.attributes()
-                .size());
-        assertEquals("Wrong split position.", "27px", e.attr("split-position"));
-        assertEquals("Wrong minimum split position.", "5.5%",
-                e.attr("min-split-position"));
-        assertEquals("Wrong maximum split position.", "95%",
-                e.attr("max-split-position"));
-        assertTrue("Unexpected value for locked: " + e.attr("locked"),
-                "true".equals(e.attr("locked")) || "".equals(e.attr("locked")));
-        assertTrue(
-                "Unexpected value for reversed: " + e.attr("reversed"),
-                "true".equals(e.attr("reversed"))
-                        || "".equals(e.attr("reversed")));
-    }
-
-    public void testHorizontalWithFirstChild() {
-        // The split panel contains only the first child.
-        HorizontalSplitPanel sp = new HorizontalSplitPanel();
-        sp.setSplitPosition(25f);
-        sp.setFirstComponent(new Button("First slot"));
-        Element e = ctx.createNode(sp);
-        assertEquals("Wrong split position.", "25%", e.attr("split-position"));
-        assertEquals("Wrong number of child elements.", 1, e.children().size());
-        Element eb = e.children().get(0);
-        assertEquals("Wrong tag name of first child element.", "v-button",
-                eb.nodeName());
-        assertEquals("Wrong text in the button element.", "First slot",
-                eb.html());
-    }
-
-    public void testVerticalWithSecondChild() {
-        // The split panel contains only the second child.
-        VerticalSplitPanel sp = new VerticalSplitPanel();
-        sp.setMinSplitPosition(25f, Unit.PIXELS);
-        sp.setSecondComponent(new Label("Second slot"));
-        Element e = ctx.createNode(sp);
-        assertEquals("Wrong minimum split position.", "25px",
-                e.attr("min-split-position"));
-        assertEquals("Wrong number of child elements.", 1, e.children().size());
-        Element el = e.children().get(0);
-        assertEquals("Wrong tag name of child element.", "v-label",
-                el.nodeName());
-        assertEquals("Wrong text in the label element.", "Second slot",
-                el.html());
-        assertTrue("Missing attribute :second in the label element.",
-                el.hasAttr(":second"));
-    }
-
-    public void testVerticalWithBothChildren() {
-        // The split panel has both child components.
-        VerticalSplitPanel sp = new VerticalSplitPanel();
-        sp.setFirstComponent(new Button("First slot"));
-        sp.setSecondComponent(new Label("Second slot"));
-        Element e = ctx.createNode(sp);
-        assertEquals("Wrong number of child elements.", 2, e.children().size());
-        Element eb = e.children().get(0);
-        assertEquals("Wrong tag name of first child element.", "v-button",
-                eb.nodeName());
-        assertEquals("Wrong text in the button element.", "First slot",
-                eb.html());
-        Element el = e.children().get(1);
-        assertEquals("Wrong tag name of second child element.", "v-label",
-                el.nodeName());
-        assertEquals("Wrong text in the label element.", "Second slot",
-                el.html());
-        assertFalse(
-                "There should be no :second attribute when a split panel has both children.",
-                el.hasAttr(":second"));
-    }
-
-    public void testReSynchronize() {
-        // Test that old children and attributes are removed when an element is
-        // synchronized to a new component.
-        VerticalSplitPanel sp = new VerticalSplitPanel();
-        sp.setMinSplitPosition(5.5f, Unit.PERCENTAGE);
-        sp.setMaxSplitPosition(95, Unit.PERCENTAGE);
-        sp.setFirstComponent(new Button("First slot"));
-        sp.setSecondComponent(new Label("Second slot"));
-        Element e = ctx.createNode(sp);
-        sp = new VerticalSplitPanel();
-        sp.synchronizeToDesign(e, ctx);
-        assertTrue("There should be no attributes in the node.", e.attributes()
-                .size() == 0);
-        assertTrue("There should be no child elements.",
-                e.children().size() == 0);
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..1027414
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * 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.abstractsplitpanel;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Element;
+
+import com.vaadin.server.Sizeable.Unit;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalSplitPanel;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Tests synchronizing the properties and child components of split panels to a
+ * design.
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestWriteDesign extends TestCase {
+    private DesignContext ctx;
+
+    @Override
+    public void setUp() {
+        ctx = new DesignContext();
+    }
+
+    public void testHorizontalWithDefaultValues() {
+        // no attributes or child elements should appear
+        HorizontalSplitPanel sp = new HorizontalSplitPanel();
+        Element e = ctx.createNode(sp);
+        assertEquals("Wrong tag name.", "v-horizontal-split-panel",
+                e.nodeName());
+        assertEquals("The split panel should not have attributes.", 0, e
+                .attributes().size());
+        assertEquals("The split panel should not have children.", 0, e
+                .children().size());
+    }
+
+    public void testVerticalWithAttributes() {
+        // All defined attributes should be output in the tree node. No child
+        // components are present in this test.
+        VerticalSplitPanel sp = new VerticalSplitPanel();
+        sp.setSplitPosition(27f, Unit.PIXELS, true);
+        sp.setMinSplitPosition(5.5f, Unit.PERCENTAGE);
+        sp.setMaxSplitPosition(95, Unit.PERCENTAGE);
+        sp.setLocked(true);
+        Element e = ctx.createNode(sp);
+        assertEquals("Wrong tag name.", "v-vertical-split-panel", e.nodeName());
+        assertEquals("Unexpected number of attributes.", 5, e.attributes()
+                .size());
+        assertEquals("Wrong split position.", "27px", e.attr("split-position"));
+        assertEquals("Wrong minimum split position.", "5.5%",
+                e.attr("min-split-position"));
+        assertEquals("Wrong maximum split position.", "95%",
+                e.attr("max-split-position"));
+        assertTrue("Unexpected value for locked: " + e.attr("locked"),
+                "true".equals(e.attr("locked")) || "".equals(e.attr("locked")));
+        assertTrue(
+                "Unexpected value for reversed: " + e.attr("reversed"),
+                "true".equals(e.attr("reversed"))
+                        || "".equals(e.attr("reversed")));
+    }
+
+    public void testHorizontalWithFirstChild() {
+        // The split panel contains only the first child.
+        HorizontalSplitPanel sp = new HorizontalSplitPanel();
+        sp.setSplitPosition(25f);
+        sp.setFirstComponent(new Button("First slot"));
+        Element e = ctx.createNode(sp);
+        assertEquals("Wrong split position.", "25%", e.attr("split-position"));
+        assertEquals("Wrong number of child elements.", 1, e.children().size());
+        Element eb = e.children().get(0);
+        assertEquals("Wrong tag name of first child element.", "v-button",
+                eb.nodeName());
+        assertEquals("Wrong text in the button element.", "First slot",
+                eb.html());
+    }
+
+    public void testVerticalWithSecondChild() {
+        // The split panel contains only the second child.
+        VerticalSplitPanel sp = new VerticalSplitPanel();
+        sp.setMinSplitPosition(25f, Unit.PIXELS);
+        sp.setSecondComponent(new Label("Second slot"));
+        Element e = ctx.createNode(sp);
+        assertEquals("Wrong minimum split position.", "25px",
+                e.attr("min-split-position"));
+        assertEquals("Wrong number of child elements.", 1, e.children().size());
+        Element el = e.children().get(0);
+        assertEquals("Wrong tag name of child element.", "v-label",
+                el.nodeName());
+        assertEquals("Wrong text in the label element.", "Second slot",
+                el.html());
+        assertTrue("Missing attribute :second in the label element.",
+                el.hasAttr(":second"));
+    }
+
+    public void testVerticalWithBothChildren() {
+        // The split panel has both child components.
+        VerticalSplitPanel sp = new VerticalSplitPanel();
+        sp.setFirstComponent(new Button("First slot"));
+        sp.setSecondComponent(new Label("Second slot"));
+        Element e = ctx.createNode(sp);
+        assertEquals("Wrong number of child elements.", 2, e.children().size());
+        Element eb = e.children().get(0);
+        assertEquals("Wrong tag name of first child element.", "v-button",
+                eb.nodeName());
+        assertEquals("Wrong text in the button element.", "First slot",
+                eb.html());
+        Element el = e.children().get(1);
+        assertEquals("Wrong tag name of second child element.", "v-label",
+                el.nodeName());
+        assertEquals("Wrong text in the label element.", "Second slot",
+                el.html());
+        assertFalse(
+                "There should be no :second attribute when a split panel has both children.",
+                el.hasAttr(":second"));
+    }
+
+    public void testReSynchronize() {
+        // Test that old children and attributes are removed when an element is
+        // synchronized to a new component.
+        VerticalSplitPanel sp = new VerticalSplitPanel();
+        sp.setMinSplitPosition(5.5f, Unit.PERCENTAGE);
+        sp.setMaxSplitPosition(95, Unit.PERCENTAGE);
+        sp.setFirstComponent(new Button("First slot"));
+        sp.setSecondComponent(new Label("Second slot"));
+        Element e = ctx.createNode(sp);
+        sp = new VerticalSplitPanel();
+        sp.writeDesign(e, ctx);
+        assertTrue("There should be no attributes in the node.", e.attributes()
+                .size() == 0);
+        assertTrue("There should be no child elements.",
+                e.children().size() == 0);
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestReadDesign.java
new file mode 100644 (file)
index 0000000..3b4b6f1
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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.abstracttextfield;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for reading the attributes of the AbstractTextField from design
+ */
+public class TestReadDesign extends TestCase {
+
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    public void testAttributes() {
+        Element design = createDesign();
+        AbstractTextField component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals("this-is-null", component.getNullRepresentation());
+        assertEquals(true, component.isNullSettingAllowed());
+        assertEquals(5, component.getMaxLength());
+        assertEquals(3, component.getColumns());
+        assertEquals("input", component.getInputPrompt());
+        assertEquals(TextChangeEventMode.EAGER,
+                component.getTextChangeEventMode());
+        assertEquals(100, component.getTextChangeTimeout());
+    }
+
+    private AbstractTextField getComponent() {
+        return new TextField();
+    }
+
+    private Element createDesign() {
+        Attributes attributes = new Attributes();
+        attributes.put("null-representation", "this-is-null");
+        attributes.put("null-setting-allowed", "true");
+        attributes.put("maxlength", "5");
+        attributes.put("columns", "3");
+        attributes.put("input-prompt", "input");
+        attributes.put("text-change-event-mode", "eager");
+        attributes.put("text-change-timeout", "100");
+        Element node = new Element(Tag.valueOf("v-text-field"), "", attributes);
+        return node;
+    }
+
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index f7ba67f..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.abstracttextfield;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.AbstractTextField;
-import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for reading the attributes of the AbstractTextField from design
- */
-public class TestSynchronizeFromDesign extends TestCase {
-
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    public void testAttributes() {
-        Element design = createDesign();
-        AbstractTextField component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("this-is-null", component.getNullRepresentation());
-        assertEquals(true, component.isNullSettingAllowed());
-        assertEquals(5, component.getMaxLength());
-        assertEquals(3, component.getColumns());
-        assertEquals("input", component.getInputPrompt());
-        assertEquals(TextChangeEventMode.EAGER,
-                component.getTextChangeEventMode());
-        assertEquals(100, component.getTextChangeTimeout());
-    }
-
-    private AbstractTextField getComponent() {
-        return new TextField();
-    }
-
-    private Element createDesign() {
-        Attributes attributes = new Attributes();
-        attributes.put("null-representation", "this-is-null");
-        attributes.put("null-setting-allowed", "true");
-        attributes.put("maxlength", "5");
-        attributes.put("columns", "3");
-        attributes.put("input-prompt", "input");
-        attributes.put("text-change-event-mode", "eager");
-        attributes.put("text-change-timeout", "100");
-        Element node = new Element(Tag.valueOf("v-text-field"), "", attributes);
-        return node;
-    }
-
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeToDesign.java
deleted file mode 100644 (file)
index b8f29b0..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.abstracttextfield;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.AbstractTextField;
-import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for writing the attributes of the AbstractTextField to design
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeToDesign extends TestCase {
-
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    public void testSynchronizetestAttributes() {
-        Element design = createDesign();
-        AbstractTextField component = getComponent();
-        component.setNullRepresentation("this-is-null");
-        component.setNullSettingAllowed(true);
-        component.setMaxLength(5);
-        component.setColumns(3);
-        component.setInputPrompt("input");
-        component.setTextChangeEventMode(TextChangeEventMode.EAGER);
-        component.setTextChangeTimeout(100);
-        component.synchronizeToDesign(design, ctx);
-        assertEquals("this-is-null", design.attr("null-representation"));
-        assertEquals("true", design.attr("null-setting-allowed"));
-        assertEquals("5", design.attr("maxlength"));
-        assertEquals("3", design.attr("columns"));
-        assertEquals("input", design.attr("input-prompt"));
-        assertEquals("EAGER", design.attr("text-change-event-mode"));
-        assertEquals("100", design.attr("text-change-timeout"));
-    }
-
-    private AbstractTextField getComponent() {
-        return new TextField();
-    }
-
-    private Element createDesign() {
-        Attributes attr = new Attributes();
-        return new Element(Tag.valueOf("v-text-field"), "", attr);
-    }
-
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..be5c384
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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.abstracttextfield;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for writing the attributes of the AbstractTextField to design
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestWriteDesign extends TestCase {
+
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    public void testSynchronizetestAttributes() {
+        Element design = createDesign();
+        AbstractTextField component = getComponent();
+        component.setNullRepresentation("this-is-null");
+        component.setNullSettingAllowed(true);
+        component.setMaxLength(5);
+        component.setColumns(3);
+        component.setInputPrompt("input");
+        component.setTextChangeEventMode(TextChangeEventMode.EAGER);
+        component.setTextChangeTimeout(100);
+        component.writeDesign(design, ctx);
+        assertEquals("this-is-null", design.attr("null-representation"));
+        assertEquals("true", design.attr("null-setting-allowed"));
+        assertEquals("5", design.attr("maxlength"));
+        assertEquals("3", design.attr("columns"));
+        assertEquals("input", design.attr("input-prompt"));
+        assertEquals("EAGER", design.attr("text-change-event-mode"));
+        assertEquals("100", design.attr("text-change-timeout"));
+    }
+
+    private AbstractTextField getComponent() {
+        return new TextField();
+    }
+
+    private Element createDesign() {
+        Attributes attr = new Attributes();
+        return new Element(Tag.valueOf("v-text-field"), "", attr);
+    }
+
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/button/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/button/TestReadDesign.java
new file mode 100644 (file)
index 0000000..48b228a
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * 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.button;
+
+import java.lang.reflect.Field;
+
+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.event.ShortcutAction.KeyCode;
+import com.vaadin.event.ShortcutAction.ModifierKey;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickShortcut;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * 
+ * Test cases for reading the contents of a Button and a NativeButton from a
+ * design.
+ * 
+ */
+public class TestReadDesign extends TestCase {
+
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    @Test
+    public void testWithContent() {
+        createAndTestButtons("Click", null);
+    }
+
+    @Test
+    public void testWithHtmlCaption() {
+        createAndTestButtons("<b>Click me</b>", null);
+    }
+
+    @Test
+    public void testWithContentAndCaption() {
+        createAndTestButtons("Click me", "caption");
+    }
+
+    @Test
+    public void testWithCaption() {
+        createAndTestButtons(null, "Click me");
+    }
+
+    @Test
+    public void testAttributes() throws IllegalArgumentException,
+            SecurityException, IllegalAccessException, NoSuchFieldException {
+        Attributes attributes = new Attributes();
+        attributes.put("tabindex", "3");
+        attributes.put("plain-text", "");
+        attributes.put("icon-alt", "OK");
+        attributes.put("click-shortcut", "ctrl-shift-o");
+        Button button = (Button) ctx
+                .createChild(createButtonWithAttributes(attributes));
+        assertEquals(3, button.getTabIndex());
+        assertEquals(false, button.isHtmlContentAllowed());
+        assertEquals("OK", button.getIconAlternateText());
+        Field field = Button.class.getDeclaredField("clickShortcut");
+        field.setAccessible(true);
+        ClickShortcut value = (ClickShortcut) field.get(button);
+        assertEquals(KeyCode.O, value.getKeyCode());
+        assertEquals(ModifierKey.CTRL, value.getModifiers()[0]);
+        assertEquals(ModifierKey.SHIFT, value.getModifiers()[1]);
+    }
+
+    /*
+     * Test both Button and NativeButton. Caption should always be ignored. If
+     * content is null, the created button should have empty content.
+     */
+    private void createAndTestButtons(String content, String caption) {
+        Element e1 = createElement("v-button", content, caption);
+        Button b1 = (Button) ctx.createChild(e1);
+        Element e2 = createElement("v-native-button", content, caption);
+        NativeButton b2 = (NativeButton) ctx.createChild(e2);
+        if (content != null) {
+            assertEquals("The button has the wrong text content.", content,
+                    b1.getCaption());
+            assertEquals("The button has the wrong text content.", content,
+                    b2.getCaption());
+        } else {
+            assertTrue("The button has the wrong content.",
+                    b1.getCaption() == null || "".equals(b1.getCaption()));
+            assertTrue("The button has the wrong content.",
+                    b2.getCaption() == null || "".equals(b2.getCaption()));
+        }
+    }
+
+    private Element createButtonWithAttributes(Attributes attributes) {
+        return new Element(Tag.valueOf("v-button"), "", attributes);
+    }
+
+    private Element createElement(String elementName, String content,
+            String caption) {
+        Attributes attributes = new Attributes();
+        if (caption != null) {
+            attributes.put("caption", caption);
+        }
+        Element node = new Element(Tag.valueOf(elementName), "", attributes);
+        if (content != null) {
+            node.html(content);
+        }
+        return node;
+    }
+}
\ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/button/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/button/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index 704192f..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.button;
-
-import java.lang.reflect.Field;
-
-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.event.ShortcutAction.KeyCode;
-import com.vaadin.event.ShortcutAction.ModifierKey;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickShortcut;
-import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * 
- * Test cases for reading the contents of a Button and a NativeButton from a
- * design.
- * 
- */
-public class TestSynchronizeFromDesign extends TestCase {
-
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    @Test
-    public void testWithContent() {
-        createAndTestButtons("Click", null);
-    }
-
-    @Test
-    public void testWithHtmlCaption() {
-        createAndTestButtons("<b>Click me</b>", null);
-    }
-
-    @Test
-    public void testWithContentAndCaption() {
-        createAndTestButtons("Click me", "caption");
-    }
-
-    @Test
-    public void testWithCaption() {
-        createAndTestButtons(null, "Click me");
-    }
-
-    @Test
-    public void testAttributes() throws IllegalArgumentException,
-            SecurityException, IllegalAccessException, NoSuchFieldException {
-        Attributes attributes = new Attributes();
-        attributes.put("tabindex", "3");
-        attributes.put("plain-text", "");
-        attributes.put("icon-alt", "OK");
-        attributes.put("click-shortcut", "ctrl-shift-o");
-        Button button = (Button) ctx
-                .createChild(createButtonWithAttributes(attributes));
-        assertEquals(3, button.getTabIndex());
-        assertEquals(false, button.isHtmlContentAllowed());
-        assertEquals("OK", button.getIconAlternateText());
-        Field field = Button.class.getDeclaredField("clickShortcut");
-        field.setAccessible(true);
-        ClickShortcut value = (ClickShortcut) field.get(button);
-        assertEquals(KeyCode.O, value.getKeyCode());
-        assertEquals(ModifierKey.CTRL, value.getModifiers()[0]);
-        assertEquals(ModifierKey.SHIFT, value.getModifiers()[1]);
-    }
-
-    /*
-     * Test both Button and NativeButton. Caption should always be ignored. If
-     * content is null, the created button should have empty content.
-     */
-    private void createAndTestButtons(String content, String caption) {
-        Element e1 = createElement("v-button", content, caption);
-        Button b1 = (Button) ctx.createChild(e1);
-        Element e2 = createElement("v-native-button", content, caption);
-        NativeButton b2 = (NativeButton) ctx.createChild(e2);
-        if (content != null) {
-            assertEquals("The button has the wrong text content.", content,
-                    b1.getCaption());
-            assertEquals("The button has the wrong text content.", content,
-                    b2.getCaption());
-        } else {
-            assertTrue("The button has the wrong content.",
-                    b1.getCaption() == null || "".equals(b1.getCaption()));
-            assertTrue("The button has the wrong content.",
-                    b2.getCaption() == null || "".equals(b2.getCaption()));
-        }
-    }
-
-    private Element createButtonWithAttributes(Attributes attributes) {
-        return new Element(Tag.valueOf("v-button"), "", attributes);
-    }
-
-    private Element createElement(String elementName, String content,
-            String caption) {
-        Attributes attributes = new Attributes();
-        if (caption != null) {
-            attributes.put("caption", caption);
-        }
-        Element node = new Element(Tag.valueOf(elementName), "", attributes);
-        if (content != null) {
-            node.html(content);
-        }
-        return node;
-    }
-}
\ No newline at end of file
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
deleted file mode 100644 (file)
index c96fd36..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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.button;
-
-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.event.ShortcutAction.KeyCode;
-import com.vaadin.event.ShortcutAction.ModifierKey;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Tests generating html tree nodes corresponding to the contents of a Button
- * and a NativeButton.
- */
-public class TestSynchronizeToDesign extends TestCase {
-
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    @Test
-    public void testWithTextContent() {
-        createAndTestButtons("Click me");
-    }
-
-    @Test
-    public void testWithHtmlContent() {
-        createAndTestButtons("<b>Click</b>");
-    }
-
-    @Test
-    public void testAttributes() {
-        Button button = new Button();
-        button.setTabIndex(3);
-        button.setIconAlternateText("OK");
-        button.setClickShortcut(KeyCode.O, ModifierKey.CTRL, ModifierKey.SHIFT);
-        Element e = new Element(Tag.valueOf("v-button"), "", new Attributes());
-        button.synchronizeToDesign(e, ctx);
-        assertEquals("3", e.attr("tabindex"));
-        assertTrue("Button is plain text by default", e.hasAttr("plain-text"));
-        assertEquals("OK", e.attr("icon-alt"));
-        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
-        // otherwise
-        b1.setHtmlContentAllowed(true);
-        Element e1 = ctx.createNode(b1);
-        assertEquals("Wrong tag name for button.", "v-button", e1.tagName());
-        assertEquals("Unexpected content in the v-button element.", content,
-                e1.html());
-        assertTrue("The v-button element should not have attributes.", e1
-                .attributes().size() == 0);
-        NativeButton b2 = new NativeButton(content);
-        b2.setHtmlContentAllowed(true);
-        Element e2 = ctx.createNode(b2);
-        assertEquals("Wrong tag name for button.", "v-native-button",
-                e2.tagName());
-        assertEquals("Unexpected content in the v-button element.", content,
-                e2.html());
-        assertTrue("The v-button element should not have attributes.", e2
-                .attributes().size() == 0);
-    }
-}
\ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/button/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/button/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..a8cf835
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * 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.button;
+
+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.event.ShortcutAction.KeyCode;
+import com.vaadin.event.ShortcutAction.ModifierKey;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.NativeButton;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Tests generating html tree nodes corresponding to the contents of a Button
+ * and a NativeButton.
+ */
+public class TestWriteDesign extends TestCase {
+
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    @Test
+    public void testWithTextContent() {
+        createAndTestButtons("Click me");
+    }
+
+    @Test
+    public void testWithHtmlContent() {
+        createAndTestButtons("<b>Click</b>");
+    }
+
+    @Test
+    public void testAttributes() {
+        Button button = new Button();
+        button.setTabIndex(3);
+        button.setIconAlternateText("OK");
+        button.setClickShortcut(KeyCode.O, ModifierKey.CTRL, ModifierKey.SHIFT);
+        Element e = new Element(Tag.valueOf("v-button"), "", new Attributes());
+        button.writeDesign(e, ctx);
+        assertEquals("3", e.attr("tabindex"));
+        assertTrue("Button is plain text by default", e.hasAttr("plain-text"));
+        assertEquals("OK", e.attr("icon-alt"));
+        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.writeDesign(e, ctx);
+        assertTrue("Button is plain text by default", e.hasAttr("plain-text"));
+
+        button.setHtmlContentAllowed(true);
+        button.writeDesign(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
+        // otherwise
+        b1.setHtmlContentAllowed(true);
+        Element e1 = ctx.createNode(b1);
+        assertEquals("Wrong tag name for button.", "v-button", e1.tagName());
+        assertEquals("Unexpected content in the v-button element.", content,
+                e1.html());
+        assertTrue("The v-button element should not have attributes.", e1
+                .attributes().size() == 0);
+        NativeButton b2 = new NativeButton(content);
+        b2.setHtmlContentAllowed(true);
+        Element e2 = ctx.createNode(b2);
+        assertEquals("Wrong tag name for button.", "v-native-button",
+                e2.tagName());
+        assertEquals("Unexpected content in the v-button element.", content,
+                e2.html());
+        assertTrue("The v-button element should not have attributes.", e2
+                .attributes().size() == 0);
+    }
+}
\ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/csslayout/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/csslayout/TestReadDesign.java
new file mode 100644 (file)
index 0000000..51f763b
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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.csslayout;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for reading CssLayout from design
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestReadDesign extends TestCase {
+
+    public void testChildCount() {
+        CssLayout root = createLayout();
+        assertEquals(2, root.getComponentCount());
+    }
+
+    public void testAttributes() {
+        CssLayout root = createLayout();
+        assertEquals("test-layout", root.getCaption());
+        assertEquals("test-label", root.getComponent(0).getCaption());
+        assertEquals("test-button", root.getComponent(1).getCaption());
+    }
+
+    private CssLayout createLayout() {
+        DesignContext ctx = new DesignContext();
+        Element design = createDesign();
+        Component child = ctx.createChild(design);
+        return (CssLayout) child;
+    }
+
+    private Element createDesign() {
+
+        Attributes rootAttributes = new Attributes();
+        rootAttributes.put("caption", "test-layout");
+        Element node = new Element(Tag.valueOf("v-css-layout"), "",
+                rootAttributes);
+
+        Attributes firstChildAttributes = new Attributes();
+        firstChildAttributes.put("caption", "test-label");
+        Element firstChild = new Element(Tag.valueOf("v-label"), "",
+                firstChildAttributes);
+        node.appendChild(firstChild);
+
+        Attributes secondChildAttributes = new Attributes();
+        Element secondChild = new Element(Tag.valueOf("v-button"), "",
+                secondChildAttributes);
+        secondChild.html("test-button");
+        node.appendChild(secondChild);
+        return node;
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/csslayout/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/csslayout/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index e9694f0..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.csslayout;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.Component;
-import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for reading CssLayout from design
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeFromDesign extends TestCase {
-
-    public void testChildCount() {
-        CssLayout root = createLayout();
-        assertEquals(2, root.getComponentCount());
-    }
-
-    public void testAttributes() {
-        CssLayout root = createLayout();
-        assertEquals("test-layout", root.getCaption());
-        assertEquals("test-label", root.getComponent(0).getCaption());
-        assertEquals("test-button", root.getComponent(1).getCaption());
-    }
-
-    private CssLayout createLayout() {
-        DesignContext ctx = new DesignContext();
-        Element design = createDesign();
-        Component child = ctx.createChild(design);
-        return (CssLayout) child;
-    }
-
-    private Element createDesign() {
-
-        Attributes rootAttributes = new Attributes();
-        rootAttributes.put("caption", "test-layout");
-        Element node = new Element(Tag.valueOf("v-css-layout"), "",
-                rootAttributes);
-
-        Attributes firstChildAttributes = new Attributes();
-        firstChildAttributes.put("caption", "test-label");
-        Element firstChild = new Element(Tag.valueOf("v-label"), "",
-                firstChildAttributes);
-        node.appendChild(firstChild);
-
-        Attributes secondChildAttributes = new Attributes();
-        Element secondChild = new Element(Tag.valueOf("v-button"), "",
-                secondChildAttributes);
-        secondChild.html("test-button");
-        node.appendChild(secondChild);
-        return node;
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/csslayout/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/csslayout/TestSynchronizeToDesign.java
deleted file mode 100644 (file)
index 2dfd560..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.csslayout;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for writing CssLayout to design
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeToDesign extends TestCase {
-
-    public void testSynchronizeEmptyLayout() {
-        CssLayout layout = new CssLayout();
-        layout.setCaption("changed-caption");
-        Element design = createDesign();
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertEquals(0, design.childNodes().size());
-        assertEquals("changed-caption", design.attr("caption"));
-    }
-
-    public void testSynchronizeLayoutWithChildren() {
-        CssLayout layout = new CssLayout();
-        layout.addComponent(new Label("test-label"));
-        layout.getComponent(0).setCaption("test-caption");
-        layout.addComponent(new Label("test-label-2"));
-        Element design = createDesign();
-        layout.synchronizeToDesign(design, createDesignContext());
-        assertEquals(2, design.childNodes().size());
-        assertEquals("v-label", ((Element) design.childNode(0)).tagName());
-        assertEquals("test-caption", design.childNode(0).attr("caption"));
-    }
-
-    private Element createDesign() {
-        // make sure that the design node has old content that should be removed
-        Attributes rootAttributes = new Attributes();
-        rootAttributes.put("caption", "test-layout");
-        Element node = new Element(Tag.valueOf("v-vertical-layout"), "",
-                rootAttributes);
-        Attributes firstChildAttributes = new Attributes();
-        firstChildAttributes.put("caption", "test-label");
-        Element firstChild = new Element(Tag.valueOf("v-label"), "",
-                firstChildAttributes);
-        node.appendChild(firstChild);
-
-        Element secondChild = new Element(Tag.valueOf("v-button"), "",
-                new Attributes());
-        secondChild.html("test-button");
-        node.appendChild(secondChild);
-        return node;
-    }
-
-    private DesignContext createDesignContext() {
-        return new DesignContext();
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/csslayout/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/csslayout/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..d660eb7
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * 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.csslayout;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for writing CssLayout to design
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestWriteDesign extends TestCase {
+
+    public void testSynchronizeEmptyLayout() {
+        CssLayout layout = new CssLayout();
+        layout.setCaption("changed-caption");
+        Element design = createDesign();
+        layout.writeDesign(design, createDesignContext());
+        assertEquals(0, design.childNodes().size());
+        assertEquals("changed-caption", design.attr("caption"));
+    }
+
+    public void testSynchronizeLayoutWithChildren() {
+        CssLayout layout = new CssLayout();
+        layout.addComponent(new Label("test-label"));
+        layout.getComponent(0).setCaption("test-caption");
+        layout.addComponent(new Label("test-label-2"));
+        Element design = createDesign();
+        layout.writeDesign(design, createDesignContext());
+        assertEquals(2, design.childNodes().size());
+        assertEquals("v-label", ((Element) design.childNode(0)).tagName());
+        assertEquals("test-caption", design.childNode(0).attr("caption"));
+    }
+
+    private Element createDesign() {
+        // make sure that the design node has old content that should be removed
+        Attributes rootAttributes = new Attributes();
+        rootAttributes.put("caption", "test-layout");
+        Element node = new Element(Tag.valueOf("v-vertical-layout"), "",
+                rootAttributes);
+        Attributes firstChildAttributes = new Attributes();
+        firstChildAttributes.put("caption", "test-label");
+        Element firstChild = new Element(Tag.valueOf("v-label"), "",
+                firstChildAttributes);
+        node.appendChild(firstChild);
+
+        Element secondChild = new Element(Tag.valueOf("v-button"), "",
+                new Attributes());
+        secondChild.html("test-button");
+        node.appendChild(secondChild);
+        return node;
+    }
+
+    private DesignContext createDesignContext() {
+        return new DesignContext();
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/label/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/label/TestReadDesign.java
new file mode 100644 (file)
index 0000000..1a02ed9
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * 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.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.ui.Label;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * 
+ * Test case for reading the contents of a Label from a design.
+ * 
+ */
+public class TestReadDesign extends TestCase {
+
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    @Test
+    public void testWithContent() {
+        createAndTestLabel("A label", null);
+    }
+
+    @Test
+    public void testWithHtmlContent() {
+        createAndTestLabel("<b>A label</b>", null);
+    }
+
+    @Test
+    public void testWithContentAndCaption() {
+        createAndTestLabel("A label", "This is a label");
+    }
+
+    @Test
+    public void testWithCaption() {
+        createAndTestLabel(null, "This is a label");
+    }
+
+    @Test
+    public void testWithoutContentAndCaption() {
+        createAndTestLabel(null, null);
+    }
+
+    /*
+     * Test creating a Label. A Label can have both caption and content.
+     */
+    private void createAndTestLabel(String content, String caption) {
+        Element e = createElement("v-label", content, caption);
+        Label l = (Label) ctx.createChild(e);
+        if (content != null) {
+            assertEquals("The label has wrong text content.", content,
+                    l.getValue());
+        } else {
+            assertTrue("The label has wrong text content.",
+                    l.getValue() == null || "".equals(l.getValue()));
+        }
+        if (caption != null) {
+            assertEquals("The label has wrong caption.", caption,
+                    l.getCaption());
+        } else {
+            assertTrue("The label has wrong caption.", l.getCaption() == null
+                    || "".equals(l.getCaption()));
+        }
+    }
+
+    private Element createElement(String elementName, String content,
+            String caption) {
+        Attributes attributes = new Attributes();
+        if (caption != null) {
+            attributes.put("caption", caption);
+        }
+        Element node = new Element(Tag.valueOf(elementName), "", attributes);
+        if (content != null) {
+            node.html(content);
+        }
+        return node;
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/label/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/label/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index 168c44c..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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.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.ui.Label;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * 
- * Test case for reading the contents of a Label from a design.
- * 
- */
-public class TestSynchronizeFromDesign extends TestCase {
-
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    @Test
-    public void testWithContent() {
-        createAndTestLabel("A label", null);
-    }
-
-    @Test
-    public void testWithHtmlContent() {
-        createAndTestLabel("<b>A label</b>", null);
-    }
-
-    @Test
-    public void testWithContentAndCaption() {
-        createAndTestLabel("A label", "This is a label");
-    }
-
-    @Test
-    public void testWithCaption() {
-        createAndTestLabel(null, "This is a label");
-    }
-
-    @Test
-    public void testWithoutContentAndCaption() {
-        createAndTestLabel(null, null);
-    }
-
-    /*
-     * Test creating a Label. A Label can have both caption and content.
-     */
-    private void createAndTestLabel(String content, String caption) {
-        Element e = createElement("v-label", content, caption);
-        Label l = (Label) ctx.createChild(e);
-        if (content != null) {
-            assertEquals("The label has wrong text content.", content,
-                    l.getValue());
-        } else {
-            assertTrue("The label has wrong text content.",
-                    l.getValue() == null || "".equals(l.getValue()));
-        }
-        if (caption != null) {
-            assertEquals("The label has wrong caption.", caption,
-                    l.getCaption());
-        } else {
-            assertTrue("The label has wrong caption.", l.getCaption() == null
-                    || "".equals(l.getCaption()));
-        }
-    }
-
-    private Element createElement(String elementName, String content,
-            String caption) {
-        Attributes attributes = new Attributes();
-        if (caption != null) {
-            attributes.put("caption", caption);
-        }
-        Element node = new Element(Tag.valueOf(elementName), "", attributes);
-        if (content != null) {
-            node.html(content);
-        }
-        return node;
-    }
-}
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
deleted file mode 100644 (file)
index 869546a..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * 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.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;
-
-/**
- * Tests generating an html tree node corresponding to a Label.
- */
-public class TestSynchronizeToDesign extends TestCase {
-
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    @Test
-    public void testWithContent() {
-        createAndTestLabel("A label", null);
-    }
-
-    @Test
-    public void testWithHtmlContent() {
-        createAndTestLabel("<b>A label</b>", null);
-    }
-
-    @Test
-    public void testWithCaption() {
-        createAndTestLabel(null, "Label caption");
-    }
-
-    @Test
-    public void testWithContentAndCaption() {
-        createAndTestLabel("A label", "Label caption");
-    }
-
-    @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);
-    }
-
-    private void createAndTestLabel(String content, String caption) {
-        Label l = new Label(content);
-        if (caption != null) {
-            l.setCaption(caption);
-        }
-        Element e = ctx.createNode(l);
-        assertEquals("Wrong tag name for label.", "v-label", e.tagName());
-        if (content != null) {
-            assertEquals("Unexpected content in the v-label element.", content,
-                    e.html());
-        } else {
-            assertTrue("Unexpected content in the v-label element.",
-                    e.html() == null || "".equals(e.html()));
-        }
-        if (caption != null) {
-            assertEquals("Wrong caption in the v-label element.", caption,
-                    e.attr("caption"));
-        } else {
-            assertTrue("Unexpected caption in the v-label element.",
-                    e.attr("caption") == null || "".equals(e.attr("caption")));
-        }
-    }
-}
\ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/label/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/label/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..fab7c1d
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * 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.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;
+
+/**
+ * Tests generating an html tree node corresponding to a Label.
+ */
+public class TestWriteDesign extends TestCase {
+
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    @Test
+    public void testWithContent() {
+        createAndTestLabel("A label", null);
+    }
+
+    @Test
+    public void testWithHtmlContent() {
+        createAndTestLabel("<b>A label</b>", null);
+    }
+
+    @Test
+    public void testWithCaption() {
+        createAndTestLabel(null, "Label caption");
+    }
+
+    @Test
+    public void testWithContentAndCaption() {
+        createAndTestLabel("A label", "Label caption");
+    }
+
+    @Test
+    public void testContentModeText() {
+        Label l = new Label("plain text label");
+        Element e = new Element(Tag.valueOf("v-label"), "", new Attributes());
+        l.writeDesign(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.writeDesign(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.writeDesign(e, ctx);
+
+        assertFalse("Label should not be marked as plain text",
+                e.hasAttr("plain-text"));
+        l.setContentMode(ContentMode.TEXT);
+        l.writeDesign(e, ctx);
+
+        assertTrue("Label should be marked as plain text",
+                e.hasAttr("plain-text"));
+    }
+
+    @Test
+    public void testWithoutContentAndCaption() {
+        createAndTestLabel(null, null);
+    }
+
+    private void createAndTestLabel(String content, String caption) {
+        Label l = new Label(content);
+        if (caption != null) {
+            l.setCaption(caption);
+        }
+        Element e = ctx.createNode(l);
+        assertEquals("Wrong tag name for label.", "v-label", e.tagName());
+        if (content != null) {
+            assertEquals("Unexpected content in the v-label element.", content,
+                    e.html());
+        } else {
+            assertTrue("Unexpected content in the v-label element.",
+                    e.html() == null || "".equals(e.html()));
+        }
+        if (caption != null) {
+            assertEquals("Wrong caption in the v-label element.", caption,
+                    e.attr("caption"));
+        } else {
+            assertTrue("Unexpected caption in the v-label element.",
+                    e.attr("caption") == null || "".equals(e.attr("caption")));
+        }
+    }
+}
\ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/panel/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/panel/TestReadDesign.java
new file mode 100644 (file)
index 0000000..3eb5230
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * 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.panel;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.declarative.DesignContext;
+import com.vaadin.ui.declarative.DesignException;
+
+/**
+ * Test case for reading the attributes of a Panel from design.
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestReadDesign extends TestCase {
+    DesignContext ctx;
+
+    @Override
+    public void setUp() {
+        ctx = new DesignContext();
+    }
+
+    public void testAttributes() {
+        Element design = createDesign();
+        Panel panel = new Panel();
+        panel.readDesign(design, ctx);
+        assertEquals("A panel", panel.getCaption());
+        assertEquals(2, panel.getTabIndex());
+        assertEquals(10, panel.getScrollLeft());
+        assertEquals(20, panel.getScrollTop());
+        assertEquals(200f, panel.getWidth());
+        assertEquals(150f, panel.getHeight());
+    }
+
+    public void testChild() {
+        Element design = createDesign();
+        Panel panel = new Panel();
+        panel.readDesign(design, ctx);
+        VerticalLayout vLayout = (VerticalLayout) panel.getContent();
+        assertEquals(300f, vLayout.getWidth());
+        assertEquals(400f, vLayout.getHeight());
+    }
+
+    public void testWithMoreThanOneChild() {
+        Element design = createDesign();
+        // Add a new child to the panel element. An exception should be
+        // thrown when parsing the design.
+        Element newChild = new Element(Tag.valueOf("v-horizontal-layout"), "");
+        design.appendChild(newChild);
+        Panel panel = new Panel();
+        try {
+            panel.readDesign(design, ctx);
+            fail("Parsing a design containing a Panel with more than one child component should have failed.");
+        } catch (DesignException e) {
+            // Nothing needs to be done, this is the expected case.
+        }
+    }
+
+    /*
+     * Creates an html document that can be parsed into a valid component
+     * hierarchy.
+     */
+    private Element createDesign() {
+        // Create a node defining a Panel
+        Element panelElement = new Element(Tag.valueOf("v-panel"), "");
+        panelElement.attr("caption", "A panel");
+        panelElement.attr("tabindex", "2");
+        panelElement.attr("scroll-left", "10");
+        panelElement.attr("scroll-top", "20");
+        panelElement.attr("width", "200px");
+        panelElement.attr("height", "150px");
+        // Add some content to the panel
+        Element layoutElement = new Element(Tag.valueOf("v-vertical-layout"),
+                "");
+        layoutElement.attr("width", "300px");
+        layoutElement.attr("height", "400px");
+        panelElement.appendChild(layoutElement);
+        return panelElement;
+    }
+}
\ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/panel/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/panel/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index bc4a597..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.panel;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.declarative.DesignContext;
-import com.vaadin.ui.declarative.DesignException;
-
-/**
- * Test case for reading the attributes of a Panel from design.
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeFromDesign extends TestCase {
-    DesignContext ctx;
-
-    @Override
-    public void setUp() {
-        ctx = new DesignContext();
-    }
-
-    public void testAttributes() {
-        Element design = createDesign();
-        Panel panel = new Panel();
-        panel.synchronizeFromDesign(design, ctx);
-        assertEquals("A panel", panel.getCaption());
-        assertEquals(2, panel.getTabIndex());
-        assertEquals(10, panel.getScrollLeft());
-        assertEquals(20, panel.getScrollTop());
-        assertEquals(200f, panel.getWidth());
-        assertEquals(150f, panel.getHeight());
-    }
-
-    public void testChild() {
-        Element design = createDesign();
-        Panel panel = new Panel();
-        panel.synchronizeFromDesign(design, ctx);
-        VerticalLayout vLayout = (VerticalLayout) panel.getContent();
-        assertEquals(300f, vLayout.getWidth());
-        assertEquals(400f, vLayout.getHeight());
-    }
-
-    public void testWithMoreThanOneChild() {
-        Element design = createDesign();
-        // Add a new child to the panel element. An exception should be
-        // thrown when parsing the design.
-        Element newChild = new Element(Tag.valueOf("v-horizontal-layout"), "");
-        design.appendChild(newChild);
-        Panel panel = new Panel();
-        try {
-            panel.synchronizeFromDesign(design, ctx);
-            fail("Parsing a design containing a Panel with more than one child component should have failed.");
-        } catch (DesignException e) {
-            // Nothing needs to be done, this is the expected case.
-        }
-    }
-
-    /*
-     * Creates an html document that can be parsed into a valid component
-     * hierarchy.
-     */
-    private Element createDesign() {
-        // Create a node defining a Panel
-        Element panelElement = new Element(Tag.valueOf("v-panel"), "");
-        panelElement.attr("caption", "A panel");
-        panelElement.attr("tabindex", "2");
-        panelElement.attr("scroll-left", "10");
-        panelElement.attr("scroll-top", "20");
-        panelElement.attr("width", "200px");
-        panelElement.attr("height", "150px");
-        // Add some content to the panel
-        Element layoutElement = new Element(Tag.valueOf("v-vertical-layout"),
-                "");
-        layoutElement.attr("width", "300px");
-        layoutElement.attr("height", "400px");
-        panelElement.appendChild(layoutElement);
-        return panelElement;
-    }
-}
\ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/panel/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/panel/TestSynchronizeToDesign.java
deleted file mode 100644 (file)
index 56ff155..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.panel;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for writing the attributes and the child element of a Panel to a
- * design.
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeToDesign extends TestCase {
-    Element panelElement;
-
-    @Override
-    public void setUp() {
-        // create a component hierarchy
-        Panel panel = new Panel("A panel");
-        panel.setId("panelId");
-        panel.setHeight("250px");
-        panel.setScrollTop(50);
-        panel.setTabIndex(4);
-        VerticalLayout vLayout = new VerticalLayout();
-        vLayout.setWidth("500px");
-        panel.setContent(vLayout);
-        // synchronize to design
-        DesignContext ctx = new DesignContext();
-        panelElement = new Element(Tag.valueOf("div"), "");
-        panel.synchronizeToDesign(panelElement, ctx);
-    }
-
-    public void testAttributes() {
-        // should have caption, id, height, scroll top and tab index
-        assertEquals(5, panelElement.attributes().size());
-        // check the values of the attributes
-        assertEquals("A panel", panelElement.attr("caption"));
-        assertEquals("panelId", panelElement.attr("id"));
-        assertEquals("250px", panelElement.attr("height"));
-        assertEquals("50", panelElement.attr("scroll-top"));
-        assertEquals("4", panelElement.attr("tabindex"));
-    }
-
-    public void testChild() {
-        // the panel element should have exactly one child, a v-vertical-layout
-        assertEquals(1, panelElement.childNodes().size());
-        Element vLayoutElement = panelElement.child(0);
-        assertEquals("v-vertical-layout", vLayoutElement.nodeName());
-        assertEquals("500px", vLayoutElement.attr("width"));
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/panel/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/panel/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..f81193d
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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.panel;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for writing the attributes and the child element of a Panel to a
+ * design.
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestWriteDesign extends TestCase {
+    Element panelElement;
+
+    @Override
+    public void setUp() {
+        // create a component hierarchy
+        Panel panel = new Panel("A panel");
+        panel.setId("panelId");
+        panel.setHeight("250px");
+        panel.setScrollTop(50);
+        panel.setTabIndex(4);
+        VerticalLayout vLayout = new VerticalLayout();
+        vLayout.setWidth("500px");
+        panel.setContent(vLayout);
+        // synchronize to design
+        DesignContext ctx = new DesignContext();
+        panelElement = new Element(Tag.valueOf("div"), "");
+        panel.writeDesign(panelElement, ctx);
+    }
+
+    public void testAttributes() {
+        // should have caption, id, height, scroll top and tab index
+        assertEquals(5, panelElement.attributes().size());
+        // check the values of the attributes
+        assertEquals("A panel", panelElement.attr("caption"));
+        assertEquals("panelId", panelElement.attr("id"));
+        assertEquals("250px", panelElement.attr("height"));
+        assertEquals("50", panelElement.attr("scroll-top"));
+        assertEquals("4", panelElement.attr("tabindex"));
+    }
+
+    public void testChild() {
+        // the panel element should have exactly one child, a v-vertical-layout
+        assertEquals(1, panelElement.childNodes().size());
+        Element vLayoutElement = panelElement.child(0);
+        assertEquals("v-vertical-layout", vLayoutElement.nodeName());
+        assertEquals("500px", vLayoutElement.attr("width"));
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestReadDesign.java
new file mode 100644 (file)
index 0000000..6a34d65
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * 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.tabsheet;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.server.ExternalResource;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case from reading TabSheet from design
+ * 
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TestReadDesign extends TestCase {
+
+    private TabSheet sheet;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        sheet = createTabSheet();
+    }
+
+    public void testChildCount() {
+        assertEquals(1, sheet.getComponentCount());
+    }
+
+    public void testTabIndex() {
+        assertEquals(5, sheet.getTabIndex());
+    }
+
+    public void testTabAttributes() {
+        Tab tab = sheet.getTab(0);
+        assertEquals("test-caption", tab.getCaption());
+        assertEquals(false, tab.isVisible());
+        assertEquals(false, tab.isClosable());
+        assertEquals(false, tab.isEnabled());
+        assertEquals("http://www.vaadin.com/test.png",
+                ((ExternalResource) tab.getIcon()).getURL());
+        assertEquals("OK", tab.getIconAlternateText());
+        assertEquals("test-desc", tab.getDescription());
+        assertEquals("test-style", tab.getStyleName());
+        assertEquals("test-id", tab.getId());
+    }
+
+    public void testSelectedComponent() {
+        TabSheet tabSheet = new TabSheet();
+        tabSheet.readDesign(createFirstTabSelectedDesign(), new DesignContext());
+        assertEquals(tabSheet.getTab(0).getComponent(),
+                tabSheet.getSelectedTab());
+    }
+
+    public void testTabContent() {
+        assertTrue("The child for the tabsheet should be textfield", sheet
+                .getTab(0).getComponent() instanceof TextField);
+    }
+
+    private TabSheet createTabSheet() {
+        TabSheet tabSheet = new TabSheet();
+        // add some tabs that should be cleared on sync
+        tabSheet.addComponent(new Label("tab1"));
+        tabSheet.addComponent(new Label("tab2"));
+        DesignContext ctx = new DesignContext();
+        Element design = createDesign();
+        tabSheet.readDesign(design, ctx);
+        return tabSheet;
+    }
+
+    private Element createDesign() {
+        // create root design
+        Attributes rootAttributes = new Attributes();
+        rootAttributes.put("tabindex", "5");
+        Element node = new Element(Tag.valueOf("v-tab-sheet"), "",
+                rootAttributes);
+        // create tab design
+        Attributes tabAttributes = new Attributes();
+        tabAttributes.put("caption", "test-caption");
+        tabAttributes.put("visible", "false");
+        tabAttributes.put("closable", "false");
+        tabAttributes.put("enabled", "false");
+        tabAttributes.put("icon", "http://www.vaadin.com/test.png");
+        tabAttributes.put("icon-alt", "OK");
+        tabAttributes.put("description", "test-desc");
+        tabAttributes.put("style-name", "test-style");
+        tabAttributes.put("id", "test-id");
+        Element tab = new Element(Tag.valueOf("tab"), "", tabAttributes);
+        // add child component to tab
+        tab.appendChild(new Element(Tag.valueOf("v-text-field"), "",
+                new Attributes()));
+        // add tab to root design
+        node.appendChild(tab);
+        return node;
+    }
+
+    private Element createFirstTabSelectedDesign() {
+        // create root design
+        Attributes rootAttributes = new Attributes();
+        Element node = new Element(Tag.valueOf("v-tab-sheet"), "",
+                rootAttributes);
+        // create tab design
+        Attributes tabAttributes = new Attributes();
+        tabAttributes.put("selected", "");
+        tabAttributes.put("caption", "test-caption");
+        Element tab = new Element(Tag.valueOf("tab"), "", tabAttributes);
+        // add child component to tab
+        tab.appendChild(new Element(Tag.valueOf("v-text-field"), "",
+                new Attributes()));
+        // add tab to root design
+        node.appendChild(tab);
+        return node;
+
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index 4c0a286..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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.tabsheet;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.server.ExternalResource;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TabSheet.Tab;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case from reading TabSheet from design
- * 
- * @since
- * @author Vaadin Ltd
- */
-public class TestSynchronizeFromDesign extends TestCase {
-
-    private TabSheet sheet;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        sheet = createTabSheet();
-    }
-
-    public void testChildCount() {
-        assertEquals(1, sheet.getComponentCount());
-    }
-
-    public void testTabIndex() {
-        assertEquals(5, sheet.getTabIndex());
-    }
-
-    public void testTabAttributes() {
-        Tab tab = sheet.getTab(0);
-        assertEquals("test-caption", tab.getCaption());
-        assertEquals(false, tab.isVisible());
-        assertEquals(false, tab.isClosable());
-        assertEquals(false, tab.isEnabled());
-        assertEquals("http://www.vaadin.com/test.png",
-                ((ExternalResource) tab.getIcon()).getURL());
-        assertEquals("OK", tab.getIconAlternateText());
-        assertEquals("test-desc", tab.getDescription());
-        assertEquals("test-style", tab.getStyleName());
-        assertEquals("test-id", tab.getId());
-    }
-
-    public void testSelectedComponent() {
-        TabSheet tabSheet = new TabSheet();
-        tabSheet.synchronizeFromDesign(createFirstTabSelectedDesign(),
-                new DesignContext());
-        assertEquals(tabSheet.getTab(0).getComponent(),
-                tabSheet.getSelectedTab());
-    }
-
-    public void testTabContent() {
-        assertTrue("The child for the tabsheet should be textfield", sheet
-                .getTab(0).getComponent() instanceof TextField);
-    }
-
-    private TabSheet createTabSheet() {
-        TabSheet tabSheet = new TabSheet();
-        // add some tabs that should be cleared on sync
-        tabSheet.addComponent(new Label("tab1"));
-        tabSheet.addComponent(new Label("tab2"));
-        DesignContext ctx = new DesignContext();
-        Element design = createDesign();
-        tabSheet.synchronizeFromDesign(design, ctx);
-        return tabSheet;
-    }
-
-    private Element createDesign() {
-        // create root design
-        Attributes rootAttributes = new Attributes();
-        rootAttributes.put("tabindex", "5");
-        Element node = new Element(Tag.valueOf("v-tab-sheet"), "",
-                rootAttributes);
-        // create tab design
-        Attributes tabAttributes = new Attributes();
-        tabAttributes.put("caption", "test-caption");
-        tabAttributes.put("visible", "false");
-        tabAttributes.put("closable", "false");
-        tabAttributes.put("enabled", "false");
-        tabAttributes.put("icon", "http://www.vaadin.com/test.png");
-        tabAttributes.put("icon-alt", "OK");
-        tabAttributes.put("description", "test-desc");
-        tabAttributes.put("style-name", "test-style");
-        tabAttributes.put("id", "test-id");
-        Element tab = new Element(Tag.valueOf("tab"), "", tabAttributes);
-        // add child component to tab
-        tab.appendChild(new Element(Tag.valueOf("v-text-field"), "",
-                new Attributes()));
-        // add tab to root design
-        node.appendChild(tab);
-        return node;
-    }
-
-    private Element createFirstTabSelectedDesign() {
-        // create root design
-        Attributes rootAttributes = new Attributes();
-        Element node = new Element(Tag.valueOf("v-tab-sheet"), "",
-                rootAttributes);
-        // create tab design
-        Attributes tabAttributes = new Attributes();
-        tabAttributes.put("selected", "");
-        tabAttributes.put("caption", "test-caption");
-        Element tab = new Element(Tag.valueOf("tab"), "", tabAttributes);
-        // add child component to tab
-        tab.appendChild(new Element(Tag.valueOf("v-text-field"), "",
-                new Attributes()));
-        // add tab to root design
-        node.appendChild(tab);
-        return node;
-
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestSynchronizeToDesign.java
deleted file mode 100644 (file)
index c33a1da..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.tabsheet;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.server.ExternalResource;
-import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TabSheet.Tab;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for writing TabSheet to design
- * 
- * @since
- * @author Vaadin Ltd
- */
-public class TestSynchronizeToDesign extends TestCase {
-
-    private TabSheet sheet;
-    private Element design;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        sheet = createTabSheet();
-        design = createDesign();
-        sheet.synchronizeToDesign(design, createDesignContext());
-    }
-
-    public void testOnlyOneTab() {
-        assertEquals("There should be only one child", 1, design.children()
-                .size());
-    }
-
-    public void testAttributes() {
-        Element tabDesign = design.child(0);
-        assertEquals("5", design.attr("tabindex"));
-        assertEquals("test-caption", tabDesign.attr("caption"));
-        assertEquals("false", tabDesign.attr("visible"));
-        assertTrue(tabDesign.hasAttr("closable"));
-        assertTrue(tabDesign.attr("closable").equals("true")
-                || tabDesign.attr("closable").equals(""));
-        assertEquals("false", tabDesign.attr("enabled"));
-        assertEquals("http://www.vaadin.com/test.png", tabDesign.attr("icon"));
-        assertEquals("OK", tabDesign.attr("icon-alt"));
-        assertEquals("test-desc", tabDesign.attr("description"));
-        assertEquals("test-style", tabDesign.attr("style-name"));
-        assertEquals("test-id", tabDesign.attr("id"));
-    }
-
-    public void testContent() {
-        Element tabDesign = design.child(0);
-        Element content = tabDesign.child(0);
-        assertEquals("Tab must have only one child", 1, tabDesign.children()
-                .size());
-        assertEquals("v-text-field", content.tagName());
-    }
-
-    private Element createDesign() {
-        // make sure that the design node has old content that should be removed
-        Element node = new Element(Tag.valueOf("v-tab-sheet"), "",
-                new Attributes());
-        node.appendChild(new Element(Tag.valueOf("tab"), "", new Attributes()));
-        node.appendChild(new Element(Tag.valueOf("tab"), "", new Attributes()));
-        node.appendChild(new Element(Tag.valueOf("tab"), "", new Attributes()));
-        return node;
-    }
-
-    private DesignContext createDesignContext() {
-        return new DesignContext();
-    }
-
-    private TabSheet createTabSheet() {
-        TabSheet sheet = new TabSheet();
-        sheet.setTabIndex(5);
-        sheet.addTab(new TextField());
-        Tab tab = sheet.getTab(0);
-        tab.setCaption("test-caption");
-        tab.setVisible(false);
-        tab.setClosable(true);
-        tab.setEnabled(false);
-        tab.setIcon(new ExternalResource("http://www.vaadin.com/test.png"));
-        tab.setIconAlternateText("OK");
-        tab.setDescription("test-desc");
-        tab.setStyleName("test-style");
-        tab.setId("test-id");
-        return sheet;
-    }
-
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/tabsheet/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..a46b33e
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * 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.tabsheet;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.server.ExternalResource;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.Tab;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for writing TabSheet to design
+ * 
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TestWriteDesign extends TestCase {
+
+    private TabSheet sheet;
+    private Element design;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        sheet = createTabSheet();
+        design = createDesign();
+        sheet.writeDesign(design, createDesignContext());
+    }
+
+    public void testOnlyOneTab() {
+        assertEquals("There should be only one child", 1, design.children()
+                .size());
+    }
+
+    public void testAttributes() {
+        Element tabDesign = design.child(0);
+        assertEquals("5", design.attr("tabindex"));
+        assertEquals("test-caption", tabDesign.attr("caption"));
+        assertEquals("false", tabDesign.attr("visible"));
+        assertTrue(tabDesign.hasAttr("closable"));
+        assertTrue(tabDesign.attr("closable").equals("true")
+                || tabDesign.attr("closable").equals(""));
+        assertEquals("false", tabDesign.attr("enabled"));
+        assertEquals("http://www.vaadin.com/test.png", tabDesign.attr("icon"));
+        assertEquals("OK", tabDesign.attr("icon-alt"));
+        assertEquals("test-desc", tabDesign.attr("description"));
+        assertEquals("test-style", tabDesign.attr("style-name"));
+        assertEquals("test-id", tabDesign.attr("id"));
+    }
+
+    public void testContent() {
+        Element tabDesign = design.child(0);
+        Element content = tabDesign.child(0);
+        assertEquals("Tab must have only one child", 1, tabDesign.children()
+                .size());
+        assertEquals("v-text-field", content.tagName());
+    }
+
+    private Element createDesign() {
+        // make sure that the design node has old content that should be removed
+        Element node = new Element(Tag.valueOf("v-tab-sheet"), "",
+                new Attributes());
+        node.appendChild(new Element(Tag.valueOf("tab"), "", new Attributes()));
+        node.appendChild(new Element(Tag.valueOf("tab"), "", new Attributes()));
+        node.appendChild(new Element(Tag.valueOf("tab"), "", new Attributes()));
+        return node;
+    }
+
+    private DesignContext createDesignContext() {
+        return new DesignContext();
+    }
+
+    private TabSheet createTabSheet() {
+        TabSheet sheet = new TabSheet();
+        sheet.setTabIndex(5);
+        sheet.addTab(new TextField());
+        Tab tab = sheet.getTab(0);
+        tab.setCaption("test-caption");
+        tab.setVisible(false);
+        tab.setClosable(true);
+        tab.setEnabled(false);
+        tab.setIcon(new ExternalResource("http://www.vaadin.com/test.png"));
+        tab.setIconAlternateText("OK");
+        tab.setDescription("test-desc");
+        tab.setStyleName("test-style");
+        tab.setId("test-id");
+        return sheet;
+    }
+
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/textarea/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/textarea/TestReadDesign.java
new file mode 100644 (file)
index 0000000..a313670
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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.textarea;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for reading the value of the TextField from design
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestReadDesign extends TestCase {
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    public void testValue() {
+        Element design = createDesign();
+        AbstractTextField component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals("test value", component.getValue());
+    }
+
+    private AbstractTextField getComponent() {
+        return new TextArea();
+    }
+
+    private Element createDesign() {
+        Attributes attributes = new Attributes();
+        Element node = new Element(Tag.valueOf("v-text-area"), "", attributes);
+        node.html("test value");
+        return node;
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/textarea/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/textarea/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index 787eac0..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.textarea;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.AbstractTextField;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for reading the value of the TextField from design
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeFromDesign extends TestCase {
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    public void testValue() {
-        Element design = createDesign();
-        AbstractTextField component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("test value", component.getValue());
-    }
-
-    private AbstractTextField getComponent() {
-        return new TextArea();
-    }
-
-    private Element createDesign() {
-        Attributes attributes = new Attributes();
-        Element node = new Element(Tag.valueOf("v-text-area"), "", attributes);
-        node.html("test value");
-        return node;
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/textarea/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/textarea/TestSynchronizeToDesign.java
deleted file mode 100644 (file)
index a316b02..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.textarea;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.AbstractTextField;
-import com.vaadin.ui.TextArea;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for writing the value of the TextField to design
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeToDesign extends TestCase {
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    public void testSynchronizeValue() {
-        Element design = createDesign();
-        AbstractTextField component = getComponent();
-        component.setValue("test value");
-        component.synchronizeToDesign(design, ctx);
-        assertEquals("test value", design.html());
-        assertFalse(design.hasAttr("value"));
-    }
-
-    private AbstractTextField getComponent() {
-        return new TextArea();
-    }
-
-    private Element createDesign() {
-        Attributes attr = new Attributes();
-        return new Element(Tag.valueOf("v-text-area"), "", attr);
-    }
-
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/textarea/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/textarea/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..01b0095
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.textarea;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for writing the value of the TextField to design
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestWriteDesign extends TestCase {
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    public void testSynchronizeValue() {
+        Element design = createDesign();
+        AbstractTextField component = getComponent();
+        component.setValue("test value");
+        component.writeDesign(design, ctx);
+        assertEquals("test value", design.html());
+        assertFalse(design.hasAttr("value"));
+    }
+
+    private AbstractTextField getComponent() {
+        return new TextArea();
+    }
+
+    private Element createDesign() {
+        Attributes attr = new Attributes();
+        return new Element(Tag.valueOf("v-text-area"), "", attr);
+    }
+
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/textfield/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/textfield/TestReadDesign.java
new file mode 100644 (file)
index 0000000..62cb1a5
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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.textfield;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for reading the value of the TextField from design
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestReadDesign extends TestCase {
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    public void testValue() {
+        Element design = createDesign();
+        AbstractTextField component = getComponent();
+        component.readDesign(design, ctx);
+        assertEquals("test value", component.getValue());
+    }
+
+    private AbstractTextField getComponent() {
+        return new TextField();
+    }
+
+    private Element createDesign() {
+        Attributes attributes = new Attributes();
+        attributes.put("value", "test value");
+        Element node = new Element(Tag.valueOf("v-text-field"), "", attributes);
+        return node;
+    }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/textfield/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/textfield/TestSynchronizeFromDesign.java
deleted file mode 100644 (file)
index 2df0ab4..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.textfield;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.AbstractTextField;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for reading the value of the TextField from design
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeFromDesign extends TestCase {
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    public void testValue() {
-        Element design = createDesign();
-        AbstractTextField component = getComponent();
-        component.synchronizeFromDesign(design, ctx);
-        assertEquals("test value", component.getValue());
-    }
-
-    private AbstractTextField getComponent() {
-        return new TextField();
-    }
-
-    private Element createDesign() {
-        Attributes attributes = new Attributes();
-        attributes.put("value", "test value");
-        Element node = new Element(Tag.valueOf("v-text-field"), "", attributes);
-        return node;
-    }
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/textfield/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/textfield/TestSynchronizeToDesign.java
deleted file mode 100644 (file)
index 58d361e..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.textfield;
-
-import junit.framework.TestCase;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.ui.AbstractTextField;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.declarative.DesignContext;
-
-/**
- * Test case for writing the value of the TextField to design
- * 
- * @author Vaadin Ltd
- */
-public class TestSynchronizeToDesign extends TestCase {
-    private DesignContext ctx;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        ctx = new DesignContext();
-    }
-
-    public void testSynchronizeValue() {
-        Element design = createDesign();
-        AbstractTextField component = getComponent();
-        component.setValue("test value");
-        component.synchronizeToDesign(design, ctx);
-        assertEquals("test value", design.attr("value"));
-    }
-
-    private AbstractTextField getComponent() {
-        return new TextField();
-    }
-
-    private Element createDesign() {
-        Attributes attr = new Attributes();
-        return new Element(Tag.valueOf("v-text-field"), "", attr);
-    }
-
-}
diff --git a/server/tests/src/com/vaadin/tests/server/component/textfield/TestWriteDesign.java b/server/tests/src/com/vaadin/tests/server/component/textfield/TestWriteDesign.java
new file mode 100644 (file)
index 0000000..479c94f
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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.textfield;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for writing the value of the TextField to design
+ * 
+ * @author Vaadin Ltd
+ */
+public class TestWriteDesign extends TestCase {
+    private DesignContext ctx;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        ctx = new DesignContext();
+    }
+
+    public void testSynchronizeValue() {
+        Element design = createDesign();
+        AbstractTextField component = getComponent();
+        component.setValue("test value");
+        component.writeDesign(design, ctx);
+        assertEquals("test value", design.attr("value"));
+    }
+
+    private AbstractTextField getComponent() {
+        return new TextField();
+    }
+
+    private Element createDesign() {
+        Attributes attr = new Attributes();
+        return new Element(Tag.valueOf("v-text-field"), "", attr);
+    }
+
+}