diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-04-22 12:44:40 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-04-22 12:44:40 +0300 |
commit | d0d0875430a6d1d57bd2ebb7d4c827c04e1c7731 (patch) | |
tree | 9a9611bbbe5216f2bdb8933d607be12de834a8b8 /server/tests/src/com/vaadin | |
parent | a69660c9d8cb35fc73af09b42df82c7a4a153caa (diff) | |
parent | c0aa2f569663b25681a61319c65d30521b5b8a85 (diff) | |
download | vaadin-framework-d0d0875430a6d1d57bd2ebb7d4c827c04e1c7731.tar.gz vaadin-framework-d0d0875430a6d1d57bd2ebb7d4c827c04e1c7731.zip |
Merge remote-tracking branch 'origin/master' into grid-7.5
Change-Id: I01c7d52b1e80483ec46f87ac8c5d7a48d4c01c84
Diffstat (limited to 'server/tests/src/com/vaadin')
10 files changed, 231 insertions, 196 deletions
diff --git a/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java b/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java index 3afef0e2ee..f0714ef3bd 100644 --- a/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java +++ b/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java @@ -94,7 +94,7 @@ public abstract class DeclarativeTestBaseBase<T extends Component> { Assert.assertEquals(message + ": array length", a1.length, a2.length); for (int i = 0; i < a1.length; i++) { - assertEquals(message, a1[i], a2[i]); + assertEquals(message + ": element " + i, a1[i], a2[i]); } return; } 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/table/TableDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/table/TableDeclarativeTest.java new file mode 100644 index 0000000000..796d30049e --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/table/TableDeclarativeTest.java @@ -0,0 +1,167 @@ +/* + * 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.table; + +import org.junit.Test; + +import com.vaadin.server.ExternalResource; +import com.vaadin.shared.ui.MultiSelectMode; +import com.vaadin.ui.Table; +import com.vaadin.ui.Table.Align; +import com.vaadin.ui.Table.ColumnHeaderMode; +import com.vaadin.ui.Table.RowHeaderMode; +import com.vaadin.ui.Table.TableDragMode; + +/** + * Test declarative support for {@link Table}. + * + * @since + * @author Vaadin Ltd + */ +public class TableDeclarativeTest extends TableDeclarativeTestBase { + + @Test + public void testBasicAttributes() { + + String design = "<v-table page-length=30 cache-rate=3 selectable=true editable=true " + + "sortable=false sort-ascending=false sort-container-property-id=foo " + + "drag-mode=row multi-select-mode=simple column-header-mode=id row-header-mode=id " + + "column-reordering-allowed=true column-collapsing-allowed=true />"; + + Table table = new Table(); + table.setPageLength(30); + table.setCacheRate(3); + table.setSelectable(true); + table.setEditable(true); + + table.setSortEnabled(false); + table.setSortAscending(false); + table.setSortContainerPropertyId("foo"); + + table.setDragMode(TableDragMode.ROW); + table.setMultiSelectMode(MultiSelectMode.SIMPLE); + table.setColumnHeaderMode(ColumnHeaderMode.ID); + table.setRowHeaderMode(RowHeaderMode.ID); + + table.setColumnReorderingAllowed(true); + table.setColumnCollapsingAllowed(true); + + testRead(design, table); + testWrite(design, table); + } + + @Test + public void testColumns() { + String design = "<v-table column-collapsing-allowed=true>" // + + " <table>" // + + " <colgroup>" + + " <col property-id='foo' width=300>" + + " <col property-id='bar' center expand=1 collapsible=false>" + + " <col property-id='baz' right expand=2 collapsed=true>" + + " </colgroup>" // + + " </table>" // + + "</v-table>"; + + Table table = new Table(); + table.setColumnCollapsingAllowed(true); + + table.addContainerProperty("foo", String.class, null); + table.setColumnAlignment("foo", Align.LEFT); + table.setColumnWidth("foo", 300); + + table.addContainerProperty("bar", String.class, null); + table.setColumnAlignment("bar", Align.CENTER); + table.setColumnExpandRatio("bar", 1); + table.setColumnCollapsible("bar", false); + + table.addContainerProperty("baz", String.class, null); + table.setColumnAlignment("baz", Align.RIGHT); + table.setColumnExpandRatio("baz", 2); + table.setColumnCollapsed("baz", true); + + testRead(design, table); + testWrite(design, table); + } + + @Test + public void testHeadersFooters() { + String design = "<v-table>" // + + " <table>" // + + " <colgroup><col property-id=foo><col property-id=bar></colgroup>" // + + " <thead>" // + + " <tr><th icon='http://example.com/icon.png'>FOO<th>BAR" // + + " </thead>" // + + " <tfoot>" // + + " <tr><td>foo<td>bar" // + + " </tfoot>" // + + " </table>" // + + "</v-table>"; + + Table table = new Table(); + table.setFooterVisible(true); + + table.addContainerProperty("foo", String.class, null); + table.setColumnHeader("foo", "FOO"); + table.setColumnIcon("foo", new ExternalResource( + "http://example.com/icon.png")); + table.setColumnFooter("foo", "foo"); + + table.addContainerProperty("bar", String.class, null); + table.setColumnHeader("bar", "BAR"); + table.setColumnFooter("bar", "bar"); + + testRead(design, table); + testWrite(design, table); + } + + @Test + public void testInlineData() { + String design = "<v-table> "// + + " <table>" // + + " <colgroup>" + + " <col property-id='foo' />" + + " <col property-id='bar' />" + + " <col property-id='baz' />" // + + " </colgroup>" + + " <thead>" + + " <tr><th>Description<th>Milestone<th>Status</tr>" + + " </thead>" + + " <tbody>" + + " <tr><td>r1c1</td><td>r1c2</td><td>r1c3</td>" // + + " <tr><td>r2c1</td><td>r2c2</td><td>r2c3</td>" // + + " </tbody>" // + + " <tfoot>" // + + " <tr><td>F1<td>F2<td>F3</tr>" // + + " </tfoot>" // + + " </table>" // + + "</v-table>"; + + Table table = new Table(); + table.addContainerProperty("foo", String.class, null); + table.addContainerProperty("bar", String.class, null); + table.addContainerProperty("baz", String.class, null); + table.setColumnHeaders("Description", "Milestone", "Status"); + table.setColumnFooter("foo", "F1"); + table.setColumnFooter("bar", "F2"); + table.setColumnFooter("baz", "F3"); + table.addItem(new Object[] { "r1c1", "r1c2", "r1c3" }, null); + table.addItem(new Object[] { "r2c1", "r2c2", "r2c3" }, null); + table.setFooterVisible(true); + + testRead(design, table); + testWrite(design, table, true); + } +} diff --git a/server/tests/src/com/vaadin/tests/server/component/table/TableDeclarativeTestBase.java b/server/tests/src/com/vaadin/tests/server/component/table/TableDeclarativeTestBase.java new file mode 100644 index 0000000000..65c9475684 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/table/TableDeclarativeTestBase.java @@ -0,0 +1,63 @@ +/* + * 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.table; + +import static org.junit.Assert.assertTrue; + +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.Table; + +public class TableDeclarativeTestBase extends DeclarativeTestBase<Table> { + + @Override + public Table testRead(String design, Table expected) { + Table read = super.testRead(design, expected); + compareColumns(read, expected); + compareBody(read, expected); + return read; + } + + private void compareBody(Table read, Table expected) { + assertEquals(expected.getItemIds().size(), read.getItemIds().size()); + for (Object rowId : expected.getItemIds()) { + assertTrue(read.containsId(rowId)); + for (Object propertyId : read.getVisibleColumns()) { + Object expectedItem = expected.getContainerProperty(rowId, + propertyId); + Object readItem = read.getContainerProperty(rowId, propertyId); + assertEquals(expectedItem, readItem); + } + } + } + + private void compareColumns(Table read, Table expected) { + for (Object pid : expected.getVisibleColumns()) { + String col = "column '" + pid + "'"; + assertEquals(col + " width", expected.getColumnWidth(pid), + read.getColumnWidth(pid)); + assertEquals(col + " expand ratio", + expected.getColumnExpandRatio(pid), + read.getColumnExpandRatio(pid)); + assertEquals(col + " collapsible", + expected.isColumnCollapsible(pid), + read.isColumnCollapsible(pid)); + assertEquals(col + " collapsed", expected.isColumnCollapsed(pid), + read.isColumnCollapsed(pid)); + assertEquals(col + " footer", expected.getColumnFooter(pid), + read.getColumnFooter(pid)); + } + } +} 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 |