From 69f66c8b28119da604836bde502e2220a35216e3 Mon Sep 17 00:00:00 2001 From: Teppo Kurki Date: Wed, 3 Jun 2015 22:06:42 +0300 Subject: Do not send value change to server for non-immediate CheckBox (#18102) Change-Id: I60a58af72d7166869d8bdc8930e16440e02d2ac5 --- shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'shared/src') diff --git a/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java b/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java index 0041da4dfa..f4124100e0 100644 --- a/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java +++ b/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java @@ -16,8 +16,10 @@ package com.vaadin.shared.ui.checkbox; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.annotations.Delayed; import com.vaadin.shared.communication.ServerRpc; public interface CheckBoxServerRpc extends ServerRpc { + @Delayed public void setChecked(boolean checked, MouseEventDetails mouseEventDetails); } -- cgit v1.2.3 From d5860be5b6043c9b6f9a1b5b1550b1666af2d6ef Mon Sep 17 00:00:00 2001 From: Teppo Kurki Date: Wed, 3 Jun 2015 14:26:35 +0300 Subject: Use headerCaption as default hidingToggleCaption (#18028) Change-Id: Ifaf288da98d6d1d1c02760784b832cb5b5d93c07 --- .../vaadin/client/connectors/GridConnector.java | 2 ++ client/src/com/vaadin/client/widgets/Grid.java | 4 +-- server/src/com/vaadin/ui/Grid.java | 34 ++++++++++++---------- .../tests/server/component/grid/GridColumns.java | 16 ++++++++++ .../com/vaadin/shared/ui/grid/GridColumnState.java | 3 ++ .../grid/basicfeatures/GridBasicFeatures.java | 12 ++++++++ .../server/GridColumnVisibilityTest.java | 28 ++++++++++++++++++ 7 files changed, 82 insertions(+), 17 deletions(-) (limited to 'shared/src') diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index d3fa678c3e..f2246b1e5f 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -1198,6 +1198,8 @@ public class GridConnector extends AbstractHasComponentsConnector implements column.setSortable(state.sortable); + column.setHeaderCaption(state.headerCaption); + column.setHidden(state.hidden); column.setHidable(state.hidable); column.setHidingToggleCaption(state.hidingToggleCaption); diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 9393ffb48c..fa74b16317 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -4390,8 +4390,8 @@ public class Grid extends ResizeComposite implements * for this column in the grid's sidebar when the column is * {@link #isHidable() hidable}. *

- * Defaults to null, when will use whatever is set with - * {@link #setHeaderCaption(String)}. + * The default value is null. In this case the header + * caption is used, see {@link #setHeaderCaption(String)}. * * @since 7.5.0 * @param hidingToggleCaption diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index c061a81b73..96884d7fd5 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -2441,9 +2441,10 @@ public class Grid extends AbstractComponent implements SelectionNotifier, private Converter converter; /** - * A check for allowing the {@link #Column(Grid, GridColumnState, Object) - * constructor} to call {@link #setConverter(Converter)} with a - * null, even if model and renderer aren't compatible. + * A check for allowing the + * {@link #Column(Grid, GridColumnState, Object) constructor} to call + * {@link #setConverter(Converter)} with a null, even if + * model and renderer aren't compatible. */ private boolean isFirstConverterAssignment = true; @@ -2503,7 +2504,9 @@ public class Grid extends AbstractComponent implements SelectionNotifier, } /** - * Sets the caption of the header. + * Sets the caption of the header. This caption is also used as the + * hiding toggle caption, unless it is explicitly set via + * {@link #setHidingToggleCaption(String)}. * * @param caption * the text to show in the caption @@ -2515,6 +2518,9 @@ public class Grid extends AbstractComponent implements SelectionNotifier, public Column setHeaderCaption(String caption) throws IllegalStateException { checkColumnIsAttached(); + + state.headerCaption = caption; + HeaderRow row = grid.getHeader().getDefaultRow(); if (row != null) { row.getCell(grid.getPropertyIdByColumnId(state.id)).setText( @@ -2542,11 +2548,11 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * toggle for this column in the grid's sidebar when the column is * {@link #isHidable() hidable}. *

- * By default, before triggering this setter, a user friendly version of - * the column's {@link #getPropertyId() property id} is used. + * The default value is null, and in that case the column's + * {@link #getHeaderCaption() header caption} is used. *

- * NOTE: setting this to null or empty string - * might cause the hiding toggle to not render correctly. + * NOTE: setting this to empty string might cause the hiding + * toggle to not render correctly. * * @since 7.5.0 * @param hidingToggleCaption @@ -3207,9 +3213,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, DesignAttributeHandler.writeAttribute("hidden", attributes, isHidden(), def.hidden, boolean.class); DesignAttributeHandler.writeAttribute("hiding-toggle-caption", - attributes, getHidingToggleCaption(), - SharedUtil.propertyIdToHumanFriendly(getPropertyId()), - String.class); + attributes, getHidingToggleCaption(), null, String.class); DesignAttributeHandler.writeAttribute("property-id", attributes, getPropertyId(), null, Object.class); } @@ -3288,7 +3292,8 @@ public class Grid extends AbstractComponent implements SelectionNotifier, private final String nullRepresentation; - protected AbstractRenderer(Class presentationType, String nullRepresentation) { + protected AbstractRenderer(Class presentationType, + String nullRepresentation) { this.presentationType = presentationType; this.nullRepresentation = nullRepresentation; } @@ -3333,6 +3338,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, /** * Null representation for the renderer + * * @return a textual representation of {@code null} */ protected String getNullRepresentation() { @@ -4303,7 +4309,6 @@ public class Grid extends AbstractComponent implements SelectionNotifier, String humanFriendlyPropertyId = SharedUtil .propertyIdToHumanFriendly(String.valueOf(datasourcePropertyId)); column.setHeaderCaption(humanFriendlyPropertyId); - column.setHidingToggleCaption(humanFriendlyPropertyId); if (datasource instanceof Sortable && ((Sortable) datasource).getSortableContainerPropertyIds() @@ -4513,8 +4518,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier, * @throws IllegalArgumentException * if {@code rows} is zero or less * @throws IllegalArgumentException - * if {@code rows} is {@link Double#isInfinite(double) - * infinite} + * if {@code rows} is {@link Double#isInfinite(double) infinite} * @throws IllegalArgumentException * if {@code rows} is {@link Double#isNaN(double) NaN} */ diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java index 35553bb406..2b960d26a0 100644 --- a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java +++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java @@ -338,4 +338,20 @@ public class GridColumns { public void testAddingColumnsWithSetColumnsNonDefaultContainer() { grid.setColumns("column1", "column2", "column50"); } + + @Test + public void testDefaultColumnHidingToggleCaption() { + Column firstColumn = grid.getColumns().get(0); + firstColumn.setHeaderCaption("headerCaption"); + assertEquals(null, firstColumn.getHidingToggleCaption()); + } + + @Test + public void testOverriddenColumnHidingToggleCaption() { + Column firstColumn = grid.getColumns().get(0); + firstColumn.setHidingToggleCaption("hidingToggleCaption"); + firstColumn.setHeaderCaption("headerCaption"); + assertEquals("hidingToggleCaption", + firstColumn.getHidingToggleCaption()); + } } diff --git a/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java b/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java index 5aa9ea9b65..547a4a84ca 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridColumnState.java @@ -85,4 +85,7 @@ public class GridColumnState implements Serializable { /** The caption for the column hiding toggle. */ public String hidingToggleCaption; + + /** Column header caption */ + public String headerCaption; } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java index ecf3d53385..ef51cdf446 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java @@ -908,6 +908,18 @@ public class GridBasicFeatures extends AbstractComponentTest { } }, null, c); + createClickAction("Change header caption", getColumnProperty(c), + new Command() { + int count = 0; + + @Override + public void execute(Grid grid, String value, Object data) { + final String columnProperty = getColumnProperty((Integer) data); + grid.getColumn(columnProperty).setHeaderCaption( + columnProperty + " header " + count++); + } + }, null, c); + createCategory("Column " + c + " Width", getColumnProperty(c)); createClickAction("Auto", "Column " + c + " Width", diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java index d01e689b72..e2d7468d08 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java @@ -195,6 +195,34 @@ public class GridColumnVisibilityTest extends GridBasicFeaturesTest { assertEquals("Column 1", getColumnHidingToggle(1).getText()); } + @Test + public void testColumnHidingToggleCaption_settingColumnHeaderCaption_toggleCaptionIsEqual() { + toggleColumnHidable(1); + + selectMenuPath("Component", "Columns", "Column 1", + "Change header caption"); + + getSidebarOpenButton().click(); + assertEquals("column 1 header 0", getGridElement().getHeaderCell(0, 1) + .getText().toLowerCase()); + assertEquals("Column 1 header 0", getColumnHidingToggle(1).getText()); + } + + @Test + public void testColumnHidingToggleCaption_explicitlySet_toggleCaptionIsNotOverridden() { + toggleColumnHidable(1); + + selectMenuPath("Component", "Columns", "Column 1", + "Change hiding toggle caption"); + selectMenuPath("Component", "Columns", "Column 1", + "Change header caption"); + + getSidebarOpenButton().click(); + assertEquals("column 1 header 0", getGridElement().getHeaderCell(0, 1) + .getText().toLowerCase()); + assertEquals("Column 1 caption 0", getColumnHidingToggle(1).getText()); + } + private void toggleColumnHidingToggleCaptionChange(int index) { selectMenuPath("Component", "Columns", "Column " + index, "Change hiding toggle caption"); -- cgit v1.2.3 From 28bf60e511d1f18fdf1754c6b42ac1993eac6e10 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 28 Apr 2015 23:59:04 +0300 Subject: Deprecate streaming (#14914) Long polling should always be used instead of streaming. There are no known cases where streaming would be preferable. Change-Id: I58ad19cb7bed48430decdaef529a7f3daad19e76 --- shared/src/com/vaadin/shared/ui/ui/Transport.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'shared/src') diff --git a/shared/src/com/vaadin/shared/ui/ui/Transport.java b/shared/src/com/vaadin/shared/ui/ui/Transport.java index 1aae57e266..54d0f08434 100644 --- a/shared/src/com/vaadin/shared/ui/ui/Transport.java +++ b/shared/src/com/vaadin/shared/ui/ui/Transport.java @@ -29,7 +29,10 @@ public enum Transport { WEBSOCKET("websocket"), /** * HTTP streaming + * + * @deprecated Use the more reliable {@link Transport#LONG_POLLING} instead. */ + @Deprecated STREAMING("streaming"), /** * HTTP long polling @@ -47,11 +50,11 @@ public enum Transport { } /** - * Returns a Transport by its identifier. Returns null if no value is found - * for the given identifier. - * - * @since 7.3.10 - */ + * Returns a Transport by its identifier. Returns null if no value is found + * for the given identifier. + * + * @since 7.3.10 + */ public static Transport getByIdentifier(String identifier) { for (Transport t : values()) { if (t.getIdentifier().equals(identifier)) { -- cgit v1.2.3 From e4d7e2d500d9bb966279a6b986f65316d6b5e3d4 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Thu, 11 Jun 2015 14:16:47 +0300 Subject: Fix declarative margin reading in AbstractOrderedLayout (#18229) Change-Id: Ia212d83568e4f0c891ec1a248b6d8567c0cf0095 --- server/src/com/vaadin/ui/AbstractLayout.java | 91 ++++++++++++++++++ .../src/com/vaadin/ui/AbstractOrderedLayout.java | 51 +--------- .../AbstractLayoutDeclarativeMarginTest.java | 104 --------------------- .../server/component/DeclarativeMarginTest.java | 76 +++++++++++++++ .../AbstractOrderedLayoutDeclarativeTest.java | 49 ++++------ shared/src/com/vaadin/shared/ui/MarginInfo.java | 6 ++ 6 files changed, 191 insertions(+), 186 deletions(-) delete mode 100644 server/tests/src/com/vaadin/tests/server/component/AbstractLayoutDeclarativeMarginTest.java create mode 100644 server/tests/src/com/vaadin/tests/server/component/DeclarativeMarginTest.java (limited to 'shared/src') diff --git a/server/src/com/vaadin/ui/AbstractLayout.java b/server/src/com/vaadin/ui/AbstractLayout.java index 9cdb0a326a..0770670680 100644 --- a/server/src/com/vaadin/ui/AbstractLayout.java +++ b/server/src/com/vaadin/ui/AbstractLayout.java @@ -16,7 +16,12 @@ package com.vaadin.ui; +import org.jsoup.nodes.Element; + import com.vaadin.shared.ui.AbstractLayoutState; +import com.vaadin.shared.ui.MarginInfo; +import com.vaadin.ui.declarative.DesignAttributeHandler; +import com.vaadin.ui.declarative.DesignContext; /** * An abstract class that defines default implementation for the {@link Layout} @@ -33,4 +38,90 @@ public abstract class AbstractLayout extends AbstractComponentContainer return (AbstractLayoutState) super.getState(); } + /** + * Reads margin attributes from a design into a MarginInfo object. This + * helper method should be called from the + * {@link #readDesign(Element, DesignContext) readDesign} method of layouts + * that implement {@link MarginHandler}. + * + * @since 7.5 + * + * @param design + * the design from which to read + * @param defMargin + * the default margin state for edges that are not set in the + * design + * @param context + * the DesignContext instance used for parsing the design + * @return the margin info + */ + protected MarginInfo readMargin(Element design, MarginInfo defMargin, + DesignContext context) { + + if (design.hasAttr("margin")) { + boolean margin = DesignAttributeHandler.readAttribute("margin", + design.attributes(), boolean.class); + return new MarginInfo(margin); + } else { + boolean left = DesignAttributeHandler.readAttribute("margin-left", + design.attributes(), defMargin.hasLeft(), boolean.class); + + boolean right = DesignAttributeHandler.readAttribute( + "margin-right", design.attributes(), defMargin.hasRight(), + boolean.class); + + boolean top = DesignAttributeHandler.readAttribute("margin-top", + design.attributes(), defMargin.hasTop(), boolean.class); + + boolean bottom = DesignAttributeHandler.readAttribute( + "margin-bottom", design.attributes(), + defMargin.hasBottom(), boolean.class); + + return new MarginInfo(top, right, bottom, left); + } + } + + /** + * Writes margin attributes from a MarginInfo object to a design. This + * helper method should be called from the + * {@link #readDesign(Element, DesignContext) writeDesign} method of layouts + * that implement {@link MarginHandler}. + * + * + * @since 7.5 + * + * @param design + * the design to write to + * @param margin + * the margin state to write + * @param defMargin + * the default margin state to compare against + * @param context + * the DesignContext instance used for parsing the design + */ + protected void writeMargin(Element design, MarginInfo margin, + MarginInfo defMargin, DesignContext context) { + if (margin.hasAll()) { + DesignAttributeHandler.writeAttribute("margin", + design.attributes(), margin.hasAll(), defMargin.hasAll(), + boolean.class); + } else { + + DesignAttributeHandler.writeAttribute("margin-left", + design.attributes(), margin.hasLeft(), defMargin.hasLeft(), + boolean.class); + + DesignAttributeHandler.writeAttribute("margin-right", + design.attributes(), margin.hasRight(), + defMargin.hasRight(), boolean.class); + + DesignAttributeHandler.writeAttribute("margin-top", + design.attributes(), margin.hasTop(), defMargin.hasTop(), + boolean.class); + + DesignAttributeHandler.writeAttribute("margin-bottom", + design.attributes(), margin.hasBottom(), + defMargin.hasBottom(), boolean.class); + } + } } diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index 0214ff4be1..afe4717212 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -478,30 +478,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements // process default attributes super.readDesign(design, designContext); - // handle margins - if (design.hasAttr("margin")) { - setMargin(DesignAttributeHandler.readAttribute("margin", - design.attributes(), Boolean.class)); - } else { - boolean marginLeft = DesignAttributeHandler.readAttribute( - "margin-left", design.attributes(), getMargin().hasLeft(), - Boolean.class); - - boolean marginRight = DesignAttributeHandler.readAttribute( - "margin-right", design.attributes(), - getMargin().hasRight(), Boolean.class); - - boolean marginTop = DesignAttributeHandler.readAttribute( - "margin-top", design.attributes(), getMargin().hasTop(), - Boolean.class); - - boolean marginBottom = DesignAttributeHandler.readAttribute( - "margin-bottom", design.attributes(), getMargin() - .hasBottom(), Boolean.class); - - setMargin(new MarginInfo(marginTop, marginBottom, marginLeft, - marginRight)); - } + setMargin(readMargin(design, getMargin(), designContext)); // handle children for (Element childComponent : design.children()) { @@ -557,31 +534,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements AbstractOrderedLayout def = (AbstractOrderedLayout) designContext .getDefaultInstance(this); - // handle margin - MarginInfo marginInfo = getMargin(); - - if (marginInfo.hasAll()) { - DesignAttributeHandler.writeAttribute("margin", - design.attributes(), marginInfo.hasAll(), def.getMargin() - .hasAll(), Boolean.class); - } else { - - DesignAttributeHandler.writeAttribute("margin-left", design - .attributes(), marginInfo.hasLeft(), def.getMargin() - .hasLeft(), Boolean.class); - - DesignAttributeHandler.writeAttribute("margin-right", design - .attributes(), marginInfo.hasRight(), def.getMargin() - .hasRight(), Boolean.class); - - DesignAttributeHandler.writeAttribute("margin-top", design - .attributes(), marginInfo.hasTop(), def.getMargin() - .hasTop(), Boolean.class); - - DesignAttributeHandler.writeAttribute("margin-bottom", design - .attributes(), marginInfo.hasBottom(), def.getMargin() - .hasBottom(), Boolean.class); - } + writeMargin(design, getMargin(), def.getMargin(), designContext); // handle children if (!designContext.shouldWriteChildren(this, def)) { diff --git a/server/tests/src/com/vaadin/tests/server/component/AbstractLayoutDeclarativeMarginTest.java b/server/tests/src/com/vaadin/tests/server/component/AbstractLayoutDeclarativeMarginTest.java deleted file mode 100644 index 70855f67dc..0000000000 --- a/server/tests/src/com/vaadin/tests/server/component/AbstractLayoutDeclarativeMarginTest.java +++ /dev/null @@ -1,104 +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; - -import org.junit.Test; - -import com.vaadin.shared.ui.MarginInfo; -import com.vaadin.tests.design.DeclarativeTestBase; -import com.vaadin.ui.AbstractLayout; -import com.vaadin.ui.VerticalLayout; - -public class AbstractLayoutDeclarativeMarginTest extends - DeclarativeTestBase { - - @Test - public void testMarginInfo() { - VerticalLayout vl = new VerticalLayout(); - - String left = getMarginTag(true, false, false, false); - MarginInfo leftInfo = getMarginInfo(true, false, false, false); - - String right = getMarginTag(false, true, false, false); - MarginInfo rightInfo = getMarginInfo(false, true, false, false); - - String top = getMarginTag(false, false, true, false); - MarginInfo topInfo = getMarginInfo(false, false, true, false); - - String bottom = getMarginTag(false, false, false, true); - MarginInfo bottomInfo = getMarginInfo(false, false, false, true); - - String topLeft = getMarginTag(true, false, true, false); - MarginInfo topLeftInfo = getMarginInfo(true, false, true, false); - - String topRight = getMarginTag(false, true, true, false); - MarginInfo topRightInfo = getMarginInfo(false, true, true, false); - - String bottomLeft = getMarginTag(true, false, false, true); - MarginInfo bottomLeftInfo = getMarginInfo(true, false, false, true); - - String bottomRight = getMarginTag(false, true, false, true); - MarginInfo bottomRightInfo = getMarginInfo(false, true, false, true); - - testRW(vl, left, leftInfo); - testRW(vl, right, rightInfo); - testRW(vl, top, topInfo); - testRW(vl, bottom, bottomInfo); - - testRW(vl, topLeft, topLeftInfo); - testRW(vl, topRight, topRightInfo); - testRW(vl, bottomLeft, bottomLeftInfo); - testRW(vl, bottomRight, bottomRightInfo); - - // Test special case of all edges margin'ed - testRW(vl, getMarginTag(true, true, true, true), new MarginInfo(true)); - } - - private void testRW(VerticalLayout vl, String design, MarginInfo margin) { - vl.setMargin(margin); - testWrite(design, vl); - testRead(design, vl); - } - - private String getMarginTag(boolean left, boolean right, boolean top, - boolean bottom) { - String s = ""; - } - - private MarginInfo getMarginInfo(boolean left, boolean right, boolean top, - boolean bottom) { - return new MarginInfo(top, right, bottom, left); - } - -} diff --git a/server/tests/src/com/vaadin/tests/server/component/DeclarativeMarginTest.java b/server/tests/src/com/vaadin/tests/server/component/DeclarativeMarginTest.java new file mode 100644 index 0000000000..d31a93a68b --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/DeclarativeMarginTest.java @@ -0,0 +1,76 @@ +/* + * 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; + +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +import com.vaadin.shared.ui.MarginInfo; +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.Layout; +import com.vaadin.ui.Layout.MarginHandler; + +@Ignore +public abstract class DeclarativeMarginTest + extends DeclarativeTestBase { + + @Test + public void testMargins() { + + for (int i = 0; i < 16; ++i) { + boolean top = (i & 1) == 1; + boolean right = (i & 2) == 2; + boolean bottom = (i & 4) == 4; + boolean left = (i & 8) == 8; + + MarginInfo m = new MarginInfo(top, right, bottom, left); + + String design = getMarginTag(top, right, bottom, left); + + // The assertEquals machinery in DeclarativeTestBase uses bean + // introspection and MarginInfo is not a proper bean. It ends up + // considering *all* MarginInfo objects equal... (#18229) + L layout = read(design); + Assert.assertEquals(m, layout.getMargin()); + + testWrite(design, layout); + } + } + + private String getMarginTag(boolean top, boolean right, boolean bottom, + boolean left) { + String s = ""; + } +} 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 8ccd41f797..38bd68e6e1 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 @@ -21,7 +21,7 @@ import java.util.List; import org.junit.Test; import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.tests.server.component.DeclarativeMarginTest; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; @@ -35,58 +35,42 @@ import com.vaadin.ui.VerticalLayout; * @author Vaadin Ltd */ public class AbstractOrderedLayoutDeclarativeTest extends - DeclarativeTestBase { + DeclarativeMarginTest { private List defaultAlignments = Arrays.asList(new String[] { ":top", ":left" }); - @Test - public void testMargin() { - String design = getDesign(0, true); - AbstractOrderedLayout layout = getLayout(0, true, null); - testRead(design, layout); - testWrite(design, layout); - design = getDesign(0, false); - layout = getLayout(0, false, null); - testRead(design, layout); - testWrite(design, layout); - } - @Test public void testExpandRatio() { - String design = getDesign(1, false); - AbstractOrderedLayout layout = getLayout(1, false, null); + String design = getDesign(1); + AbstractOrderedLayout layout = getLayout(1, null); testRead(design, layout); testWrite(design, layout); - design = getDesign(0.25f, false); - layout = getLayout(0.25f, false, null); + design = getDesign(0.25f); + layout = getLayout(0.25f, null); testRead(design, layout); testWrite(design, layout); } @Test public void testAlignment() { - String design = getDesign(0, false, ":top", ":left"); - AbstractOrderedLayout layout = getLayout(0, false, Alignment.TOP_LEFT); + String design = getDesign(0, ":top", ":left"); + AbstractOrderedLayout layout = getLayout(0, Alignment.TOP_LEFT); testRead(design, layout); testWrite(design, layout); - design = getDesign(0, false, ":middle", ":center"); - layout = getLayout(0, false, Alignment.MIDDLE_CENTER); + design = getDesign(0, ":middle", ":center"); + layout = getLayout(0, Alignment.MIDDLE_CENTER); testRead(design, layout); testWrite(design, layout); - design = getDesign(0, false, ":bottom", ":right"); - layout = getLayout(0, false, Alignment.BOTTOM_RIGHT); + design = getDesign(0, ":bottom", ":right"); + layout = getLayout(0, Alignment.BOTTOM_RIGHT); testRead(design, layout); testWrite(design, layout); } - private String getDesign(float expandRatio, boolean margin, - String... alignments) { - String result = "