summaryrefslogtreecommitdiffstats
path: root/server/tests/src/com/vaadin
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2015-04-17 15:15:25 +0300
committerVaadin Code Review <review@vaadin.com>2015-04-17 13:34:08 +0000
commit2d3ed921065acd7761df07b9b403d111bedf33d9 (patch)
treedc8ec260dfee6ad96e1080e7eb0c8fa8e67e18df /server/tests/src/com/vaadin
parent6ce22d8ad5c9e81cc2e34a70779413fb2c7040d6 (diff)
downloadvaadin-framework-2d3ed921065acd7761df07b9b403d111bedf33d9.tar.gz
vaadin-framework-2d3ed921065acd7761df07b9b403d111bedf33d9.zip
Don't clear element content in AbstractComponent.writeDesign (#17488)
WriteDesign now assumes the element it receives is pristine, so elements cannot be reused without someone else clearing them first. Currently only DesignContext.createElement directly invokes writeDesign, and it always passes a new element to it. Change-Id: Icb777da1d73a28150041914dd9743e7aa0b25e16
Diffstat (limited to 'server/tests/src/com/vaadin')
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java21
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutDeclarativeTest.java45
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/AbstractSplitPanelDeclarativeTest.java24
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java19
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutDeclarativeTest.java33
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/label/LabelDeclarativeTest.java23
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/tabsheet/TabSheetDeclarativeTest.java30
7 files changed, 0 insertions, 195 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java
index dbd945a3d8..55231e5494 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java
@@ -15,18 +15,12 @@
*/
package com.vaadin.tests.server.component.abstractfield;
-import static org.junit.Assert.assertTrue;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
import org.junit.Test;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.tests.design.DeclarativeTestBase;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.TextField;
-import com.vaadin.ui.declarative.DesignContext;
/**
* Tests declarative support for implementations of {@link AbstractField}.
@@ -64,21 +58,6 @@ public class AbstractFieldDeclarativeTest extends
}
@Test
- public void testWriteRemovesOldContent() {
- Attributes attr = new Attributes();
- attr.put("should_be_removed", "foo");
- Element design = new Element(Tag.valueOf("v-text-field"), "", attr);
- AbstractField component = new TextField();
- component.setReadOnly(true);
- component.writeDesign(design, new DesignContext());
- // 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"));
- }
-
- @Test
public void testModelReadOnly() {
// Test that read only value coming from property data source is not
// written to design.
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutDeclarativeTest.java
index 192ea0f4f3..8ccd41f797 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractorderedlayout/AbstractOrderedLayoutDeclarativeTest.java
@@ -15,14 +15,9 @@
*/
package com.vaadin.tests.server.component.abstractorderedlayout;
-import static org.junit.Assert.assertTrue;
-
import java.util.Arrays;
import java.util.List;
-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;
@@ -32,7 +27,6 @@ import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.declarative.DesignContext;
/**
* Tests declarative support for AbstractOrderedLayout.
@@ -86,45 +80,6 @@ public class AbstractOrderedLayoutDeclarativeTest extends
testWrite(design, layout);
}
- @Test
- public void testWriteRemovesOldElementContent() {
- // Create an element with some content
- Attributes rootAttributes = new Attributes();
- rootAttributes.put("caption", "test-layout");
- Element design = 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);
- design.appendChild(firstChild);
-
- Attributes secondChildAttributes = new Attributes();
- secondChildAttributes.put("caption", "test-button");
- Element secondChild = new Element(Tag.valueOf("v-button"), "",
- secondChildAttributes);
- design.appendChild(secondChild);
- Attributes thirdChildAttributes = new Attributes();
- thirdChildAttributes.put("caption", "test-button-2");
- Element thirdChild = new Element(Tag.valueOf("v-button"), "",
- thirdChildAttributes);
- design.appendChild(thirdChild);
- // Create and write a layout and check the new contents of the element
- // node
- VerticalLayout layout = new VerticalLayout();
- layout.addComponent(new Label("test-label"));
- layout.getComponent(0).setCaption("test-caption");
- layout.setExpandRatio(layout.getComponent(0), 1.0f);
- layout.addComponent(new Label("test-label-2"));
- layout.writeDesign(design, new DesignContext());
- assertEquals(2, design.childNodes().size());
- assertEquals("v-label", ((Element) design.childNode(0)).tagName());
- assertEquals("test-caption", design.childNode(0).attr("caption"));
- assertTrue(design.childNode(0).hasAttr(":expand"));
- assertEquals("", design.childNode(0).attr(":expand"));
-
- }
-
private String getDesign(float expandRatio, boolean margin,
String... alignments) {
String result = "<v-vertical-layout caption=test-layout";
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/AbstractSplitPanelDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/AbstractSplitPanelDeclarativeTest.java
index 1f2113fabc..2d6db6d19a 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/AbstractSplitPanelDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/AbstractSplitPanelDeclarativeTest.java
@@ -15,9 +15,6 @@
*/
package com.vaadin.tests.server.component.abstractsplitpanel;
-import static junit.framework.TestCase.assertTrue;
-
-import org.jsoup.nodes.Element;
import org.junit.Test;
import com.vaadin.server.Sizeable.Unit;
@@ -25,11 +22,9 @@ import com.vaadin.tests.design.DeclarativeTestBase;
import com.vaadin.ui.AbstractSplitPanel;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.VerticalSplitPanel;
-import com.vaadin.ui.declarative.DesignContext;
/**
* Tests declarative support for AbstractSplitPanel.
@@ -88,23 +83,4 @@ public class AbstractSplitPanelDeclarativeTest extends
testRead(design, sp);
testWrite(design, sp);
}
-
- @Test
- public void testReSynchronize() {
- // Test that old children and attributes are removed when an element is
- // synchronized to a new component.
- DesignContext ctx = new DesignContext();
- 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.createElement(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);
- }
} \ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java
index 02dfa22671..51abf6be96 100644
--- a/server/tests/src/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java
@@ -15,11 +15,6 @@
*/
package com.vaadin.tests.server.component.button;
-import static org.junit.Assert.assertTrue;
-
-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;
@@ -27,7 +22,6 @@ import com.vaadin.event.ShortcutAction.ModifierKey;
import com.vaadin.tests.design.DeclarativeTestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.NativeButton;
-import com.vaadin.ui.declarative.DesignContext;
/**
* Tests declarative support for implementations of {@link Button} and
@@ -112,17 +106,4 @@ public class ButtonDeclarativeTest extends DeclarativeTestBase<Button> {
testRead(design, b);
testWrite(design, b);
}
-
- @Test
- public void testWriteUpdatesContentMode() {
- DesignContext ctx = new DesignContext();
- 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"));
- }
} \ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutDeclarativeTest.java
index 4cb3fb13e5..0782295310 100644
--- a/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/csslayout/CssLayoutDeclarativeTest.java
@@ -15,9 +15,6 @@
*/
package com.vaadin.tests.server.component.csslayout;
-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;
@@ -25,7 +22,6 @@ import com.vaadin.tests.design.DeclarativeTestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.declarative.DesignContext;
/**
* Tests declarative support for CssLayout.
@@ -64,33 +60,4 @@ public class CssLayoutDeclarativeTest extends DeclarativeTestBase<CssLayout> {
testRead(design, layout);
testWrite(design, layout);
}
-
- @Test
- public void testWriteWithOldContents() {
- // Test that any old contents of an element are removed when
- // writing a design.
- Element design = createDesign();
- CssLayout layout = new CssLayout();
- layout.addComponent(new Label("test-label"));
- layout.getComponent(0).setCaption("test-caption");
- layout.addComponent(new Label("test-label-2"));
- layout.writeDesign(design, new DesignContext());
- assertEquals(2, design.childNodes().size());
- assertEquals("v-label", ((Element) design.childNode(0)).tagName());
- assertEquals("test-caption", design.childNode(0).attr("caption"));
- }
-
- private Element createDesign() {
- // create an element with some contents
- Attributes rootAttributes = new Attributes();
- rootAttributes.put("caption", "test-layout");
- Element node = new Element(Tag.valueOf("v-vertical-layout"), "",
- rootAttributes);
- Attributes childAttributes = new Attributes();
- childAttributes.put("caption", "test-label");
- Element child = new Element(Tag.valueOf("v-label"), "", childAttributes);
- node.appendChild(child);
-
- return node;
- }
}
diff --git a/server/tests/src/com/vaadin/tests/server/component/label/LabelDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/label/LabelDeclarativeTest.java
index a3f27e4397..c2fed34c7b 100644
--- a/server/tests/src/com/vaadin/tests/server/component/label/LabelDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/label/LabelDeclarativeTest.java
@@ -15,18 +15,11 @@
*/
package com.vaadin.tests.server.component.label;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-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.tests.design.DeclarativeTestBase;
import com.vaadin.ui.Label;
-import com.vaadin.ui.declarative.DesignContext;
/**
* Tests declarative support for implementations of {@link Label}.
@@ -91,22 +84,6 @@ public class LabelDeclarativeTest extends DeclarativeTestBase<Label> {
testWrite(design, l);
}
- @Test
- public void testWriteContentMode() {
- // test that the plain-text attribute is overwritten by writeDesign
- DesignContext ctx = new DesignContext();
- Label l = new Label("label");
- l.setContentMode(ContentMode.TEXT);
- 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"));
- l.setContentMode(ContentMode.HTML);
- l.writeDesign(e, ctx);
- assertFalse("Label should not be marked as plain text",
- e.hasAttr("plain-text"));
- }
-
private Label createLabel(String content, String caption, boolean html) {
Label label = new Label();
label.setContentMode(html ? ContentMode.HTML : ContentMode.TEXT);
diff --git a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TabSheetDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/tabsheet/TabSheetDeclarativeTest.java
index c614e7fa1f..bb5669a3a1 100644
--- a/server/tests/src/com/vaadin/tests/server/component/tabsheet/TabSheetDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/tabsheet/TabSheetDeclarativeTest.java
@@ -15,9 +15,6 @@
*/
package com.vaadin.tests.server.component.tabsheet;
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
import org.junit.Test;
import com.vaadin.server.ExternalResource;
@@ -25,7 +22,6 @@ import com.vaadin.tests.design.DeclarativeTestBase;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TabSheet.Tab;
import com.vaadin.ui.TextField;
-import com.vaadin.ui.declarative.DesignContext;
/**
* Tests declarative support for TabSheet.
@@ -69,30 +65,4 @@ public class TabSheetDeclarativeTest extends DeclarativeTestBase<TabSheet> {
testRead(design, ts);
testWrite(design, ts);
}
-
- @Test
- public void testWriteRemovesOldContent() {
- // create old content that should be removed when writing
- Element design = new Element(Tag.valueOf("v-tab-sheet"), "",
- new Attributes());
- design.appendChild(new Element(Tag.valueOf("tab"), "", new Attributes()));
- design.appendChild(new Element(Tag.valueOf("tab"), "", new Attributes()));
- design.appendChild(new Element(Tag.valueOf("tab"), "", new Attributes()));
- // create a new TabSheet with one tab
- TabSheet ts = new TabSheet();
- ts.setTabIndex(5);
- ts.addTab(new TextField());
- Tab tab = ts.getTab(0);
- tab.setVisible(false);
- tab.setClosable(true);
- tab.setEnabled(false);
- // write the design and check written contents
- ts.writeDesign(design, new DesignContext());
- assertEquals("There should be only one child", 1, design.children()
- .size());
- assertEquals("v-text-field", design.child(0).child(0).tagName());
- assertEquals("5", design.attr("tabindex"));
- Element tabDesign = design.child(0);
- assertEquals("false", tabDesign.attr("visible"));
- }
} \ No newline at end of file