diff options
author | Artur Signell <artur@vaadin.com> | 2016-08-18 21:51:13 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2016-08-20 00:08:46 +0300 |
commit | 34852cdb88c6c27b1341684204d78db0fdd061a6 (patch) | |
tree | f55c6f9d900167a57c7eb2c96c25e1dfe0451dd8 /compatibility-server/src/test | |
parent | 6e0f2efe996cfd3b38c960e04cbced0a91215cf0 (diff) | |
download | vaadin-framework-34852cdb88c6c27b1341684204d78db0fdd061a6.tar.gz vaadin-framework-34852cdb88c6c27b1341684204d78db0fdd061a6.zip |
Move selects to compatibility package
Change-Id: I7ee02d34b230e8752174a7f19824f81cbb616c33
Diffstat (limited to 'compatibility-server/src/test')
17 files changed, 1429 insertions, 0 deletions
diff --git a/compatibility-server/src/test/java/com/vaadin/tests/design/ParseAllSupportedComponentsTest.java b/compatibility-server/src/test/java/com/vaadin/tests/design/ParseAllSupportedComponentsTest.java new file mode 100644 index 0000000000..6694372539 --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/design/ParseAllSupportedComponentsTest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2016 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.design; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.io.FileNotFoundException; + +import org.junit.Test; + +import com.vaadin.ui.declarative.Design; +import com.vaadin.ui.declarative.DesignContext; + +/** + * Just top level test case that contains all synchronizable components + * + * @author Vaadin Ltd + */ +public class ParseAllSupportedComponentsTest { + + @Test + public void allComponentsAreParsed() throws FileNotFoundException { + DesignContext ctx = Design.read( + getClass().getResourceAsStream("all-components.html"), null); + + assertThat(ctx, is(not(nullValue()))); + assertThat(ctx.getRootComponent(), is(not(nullValue()))); + } +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/design/ParseLegacyPrefixTest.java b/compatibility-server/src/test/java/com/vaadin/tests/design/ParseLegacyPrefixTest.java new file mode 100644 index 0000000000..5dd21b35f8 --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/design/ParseLegacyPrefixTest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2016 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.design; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.io.FileNotFoundException; + +import org.junit.Test; + +import com.vaadin.ui.declarative.Design; +import com.vaadin.ui.declarative.DesignContext; + +/** + * Test reading a design with all components using the legacy prefix. + */ +public class ParseLegacyPrefixTest { + + @Test + public void allComponentsAreParsed() throws FileNotFoundException { + DesignContext ctx = Design.read( + getClass().getResourceAsStream("all-components-legacy.html"), + null); + + assertThat(ctx, is(not(nullValue()))); + assertThat(ctx.getRootComponent(), is(not(nullValue()))); + } +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java new file mode 100644 index 0000000000..9a8777909f --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java @@ -0,0 +1,306 @@ +/* + * Copyright 2000-2016 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.abstractselect; + +import org.jsoup.nodes.Attributes; +import org.jsoup.nodes.Element; +import org.jsoup.parser.Tag; +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.data.Container; +import com.vaadin.data.util.IndexedContainer; +import com.vaadin.server.ExternalResource; +import com.vaadin.server.Resource; +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.tests.design.DeclarativeTestBaseBase; +import com.vaadin.ui.AbstractSelect; +import com.vaadin.ui.AbstractSelect.ItemCaptionMode; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.ListSelect; +import com.vaadin.ui.declarative.DesignContext; +import com.vaadin.ui.declarative.DesignException; + +/** + * Test cases for reading the properties of selection components. + * + * @author Vaadin Ltd + */ +public class AbstractSelectDeclarativeTest + extends DeclarativeTestBase<AbstractSelect> { + + public String getDesignSingleSelectNewItemsAllowed() { + return "<vaadin-combo-box new-items-allowed item-caption-mode='icon_only'" + + " null-selection-item-id='nullIid'/>"; + + } + + public AbstractSelect getExpectedSingleSelectNewItemsAllowed() { + ComboBox c = new ComboBox(); + c.setNewItemsAllowed(true); + c.setItemCaptionMode(ItemCaptionMode.ICON_ONLY); + c.setNullSelectionAllowed(true);// Default + c.setNullSelectionItemId("nullIid"); + return c; + } + + public String getDesignMultiSelect() { + return "<vaadin-list-select multi-select null-selection-allowed='false' new-items-allowed item-caption-mode='property' />"; + } + + public AbstractSelect getExpectedMultiSelect() { + ListSelect c = new ListSelect(); + c.setNewItemsAllowed(true); + c.setNullSelectionAllowed(false); + c.setItemCaptionMode(ItemCaptionMode.PROPERTY); + c.setMultiSelect(true); + return c; + } + + @Test + public void testReadSingleSelectNewItemsAllowed() { + testRead(getDesignSingleSelectNewItemsAllowed(), + getExpectedSingleSelectNewItemsAllowed()); + } + + @Test + public void testWriteSingleSelectNewItemsAllowed() { + testWrite(getDesignSingleSelectNewItemsAllowed(), + getExpectedSingleSelectNewItemsAllowed()); + } + + @Test + public void testReadMultiSelect() { + testRead(getDesignMultiSelect(), getExpectedMultiSelect()); + } + + @Test + public void testWriteMultiSelect() { + testWrite(getDesignMultiSelect(), getExpectedMultiSelect()); + } + + @Test + public void testReadInlineData() { + testRead(getDesignForInlineData(), getExpectedComponentForInlineData()); + } + + @Test(expected = DesignException.class) + public void testReadMultipleValuesForSingleSelect() { + testRead("<vaadin-list-select>" + "<option selected>1</option>" + + "<option selected>2</option>" + "</vaadin-list-select>", + null); + } + + @Test + public void testReadMultipleValuesForMultiSelect() { + ListSelect ls = new ListSelect(); + ls.setMultiSelect(true); + ls.addItem("1"); + ls.addItem("2"); + ls.select("1"); + ls.select("2"); + testRead("<vaadin-list-select multi-select>" + + "<option selected>1</option>" + "<option selected>2</option>" + + "</vaadin-list-select>", ls); + } + + @Test + public void testReadSingleValueForMultiSelect() { + ListSelect ls = new ListSelect(); + ls.setMultiSelect(true); + ls.addItem("1"); + ls.addItem("2"); + ls.select("1"); + testRead("<vaadin-list-select multi-select>" + + "<option selected>1</option>" + "<option>2</option>" + + "</vaadin-list-select>", ls); + } + + @Test + public void testReadSingleValueForSingleSelect() { + ListSelect ls = new ListSelect(); + ls.setMultiSelect(false); + ls.addItem("1"); + ls.addItem("2"); + ls.select("1"); + testRead("<vaadin-list-select>" + "<option selected>1</option>" + + "<option>2</option>" + "</vaadin-list-select>", ls); + } + + @Test + public void testWriteInlineDataIgnored() { + // No data is written by default + testWrite(stripOptionTags(getDesignForInlineData()), + getExpectedComponentForInlineData()); + } + + @Test + public void testWriteInlineData() { + testWrite(getDesignForInlineData(), getExpectedComponentForInlineData(), + true); + } + + private String getDesignForInlineData() { + return "<vaadin-list-select>\n" + + " <option icon='http://some.url/icon.png'>Value 1</option>\n" // + + " <option selected>Value 2</option>\n"// + + "</vaadin-list-select>"; + } + + private AbstractSelect getExpectedComponentForInlineData() { + AbstractSelect as = new ListSelect(); + as.addItem("Value 1"); + as.setItemIcon("Value 1", + new ExternalResource("http://some.url/icon.png")); + as.addItem("Value 2"); + as.setValue("Value 2"); + return as; + } + + @Test + public void testReadAttributesSingleSelect() { + Element design = createDesignWithAttributesSingleSelect(); + ComboBox cb = new ComboBox(); + IndexedContainer container = new IndexedContainer(); + container.addContainerProperty("icon", Resource.class, null); + container.addContainerProperty("name", String.class, null); + cb.setContainerDataSource(container); + cb.readDesign(design, new DesignContext()); + Assert.assertTrue("Adding new items should be allowed.", + cb.isNewItemsAllowed()); + assertEquals("Wrong item caption mode.", + AbstractSelect.ItemCaptionMode.PROPERTY, + cb.getItemCaptionMode()); + assertEquals("Wrong item caption property id.", "name", + cb.getItemCaptionPropertyId()); + assertEquals("Wrong item icon property id.", "icon", + cb.getItemIconPropertyId()); + Assert.assertTrue("Null selection should be allowed.", + cb.isNullSelectionAllowed()); + assertEquals("Wrong null selection item id.", "No items selected", + cb.getNullSelectionItemId()); + } + + @Test + public void testReadAttributesMultiSelect() { + Element design = createDesignWithAttributesMultiSelect(); + ListSelect ls = new ListSelect(); + ls.readDesign(design, new DesignContext()); + Assert.assertTrue("Multi select should be allowed.", + ls.isMultiSelect()); + assertEquals("Wrong caption mode.", + AbstractSelect.ItemCaptionMode.EXPLICIT, + ls.getItemCaptionMode()); + Assert.assertFalse("Null selection should not be allowed.", + ls.isNullSelectionAllowed()); + } + + private Element createDesignWithAttributesSingleSelect() { + Attributes attributes = new Attributes(); + attributes.put("new-items-allowed", true); + attributes.put("multi-select", "false"); + attributes.put("item-caption-mode", "property"); + attributes.put("item-caption-property-id", "name"); + attributes.put("item-icon-property-id", "icon"); + attributes.put("null-selection-allowed", true); + attributes.put("null-selection-item-id", "No items selected"); + return new Element(Tag.valueOf("vaadin-combo-box"), "", attributes); + } + + private Element createDesignWithAttributesMultiSelect() { + Attributes attributes = new Attributes(); + attributes.put("multi-select", true); + attributes.put("item-caption-mode", "EXPLICIT"); + attributes.put("null-selection-allowed", "false"); + return new Element(Tag.valueOf("vaadin-list-select"), "", attributes); + } + + @Test + public void testWriteAttributesSingleSelect() { + ComboBox cb = createSingleSelectWithOnlyAttributes(); + Element e = new Element(Tag.valueOf("vaadin-combo-box"), ""); + cb.writeDesign(e, new DesignContext()); + assertEquals("Wrong caption for the combo box.", "A combo box", + e.attr("caption")); + Assert.assertTrue("Adding new items should be allowed.", + "".equals(e.attr("new-items-allowed"))); + assertEquals("Wrong item caption mode.", "icon_only", + e.attr("item-caption-mode")); + assertEquals("Wrong item icon property id.", "icon", + e.attr("item-icon-property-id")); + Assert.assertTrue("Null selection should be allowed.", + "".equals(e.attr("null-selection-allowed")) + || "true".equals(e.attr("null-selection-allowed"))); + assertEquals("Wrong null selection item id.", "No item selected", + e.attr("null-selection-item-id")); + } + + @Test + public void testWriteMultiListSelect() { + ListSelect ls = createMultiSelect(); + Element e = new Element(Tag.valueOf("vaadin-list-select"), ""); + ls.writeDesign(e, new DesignContext()); + assertEquals("Null selection should not be allowed.", "false", + e.attr("null-selection-allowed")); + Assert.assertTrue("Multi select should be allowed.", + "".equals(e.attr("multi-select")) + || "true".equals(e.attr("multi-select"))); + } + + @Test + public void testHtmlEntities() { + String design = "<vaadin-combo-box>" + + " <option item-id=\"one\">> One</option>" + + " <option>> Two</option>" + "</vaadin-combo-box>"; + AbstractSelect read = read(design); + + Assert.assertEquals("> One", read.getItemCaption("one")); + + AbstractSelect underTest = new ComboBox(); + underTest.addItem("> One"); + + Element root = new Element(Tag.valueOf("vaadin-combo-box"), ""); + DesignContext dc = new DesignContext(); + dc.setShouldWriteDataDelegate( + DeclarativeTestBaseBase.ALWAYS_WRITE_DATA); + underTest.writeDesign(root, dc); + + Assert.assertEquals("> One", + root.getElementsByTag("option").first().html()); + } + + public ComboBox createSingleSelectWithOnlyAttributes() { + ComboBox cb = new ComboBox(); + Container dataSource = new IndexedContainer(); + dataSource.addContainerProperty("icon", Resource.class, null); + cb.setContainerDataSource(dataSource); + cb.setCaption("A combo box"); + cb.setNewItemsAllowed(true); + cb.setItemCaptionMode(ItemCaptionMode.ICON_ONLY); + cb.setItemIconPropertyId("icon"); + cb.setNullSelectionAllowed(true); + cb.setNullSelectionItemId("No item selected"); + return cb; + } + + public ListSelect createMultiSelect() { + ListSelect ls = new ListSelect(); + ls.setNullSelectionAllowed(false); + ls.setMultiSelect(true); + return ls; + } + +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java new file mode 100644 index 0000000000..7fc584e3d5 --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java @@ -0,0 +1,26 @@ +package com.vaadin.tests.server.component.abstractselect; + +import org.junit.Test; + +import com.vaadin.data.Container.ItemSetChangeEvent; +import com.vaadin.data.Container.ItemSetChangeListener; +import com.vaadin.data.Container.PropertySetChangeEvent; +import com.vaadin.data.Container.PropertySetChangeListener; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; +import com.vaadin.ui.ComboBox; + +public class AbstractSelectListenersTest + extends AbstractListenerMethodsTestBase { + + @Test + public void testItemSetChangeListenerAddGetRemove() throws Exception { + testListenerAddGetRemove(ComboBox.class, ItemSetChangeEvent.class, + ItemSetChangeListener.class); + } + + @Test + public void testPropertySetChangeListenerAddGetRemove() throws Exception { + testListenerAddGetRemove(ComboBox.class, PropertySetChangeEvent.class, + PropertySetChangeListener.class); + } +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectStateTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectStateTest.java new file mode 100644 index 0000000000..c5ff297d7b --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectStateTest.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2016 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.abstractselect; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.shared.ui.select.AbstractSelectState; +import com.vaadin.ui.AbstractSelect; + +/** + * Tests for AbstractSelect state + * + */ +public class AbstractSelectStateTest { + + @Test + public void getState_selectHasCustomState() { + TestSelect select = new TestSelect(); + AbstractSelectState state = select.getState(); + Assert.assertEquals("Unexpected state class", AbstractSelectState.class, + state.getClass()); + } + + @Test + public void getPrimaryStyleName_selectHasCustomPrimaryStyleName() { + TestSelect combobox = new TestSelect(); + AbstractSelectState state = new AbstractSelectState(); + Assert.assertEquals("Unexpected primary style name", + state.primaryStyleName, combobox.getPrimaryStyleName()); + } + + @Test + public void selectStateHasCustomPrimaryStyleName() { + AbstractSelectState state = new AbstractSelectState(); + Assert.assertEquals("Unexpected primary style name", "v-select", + state.primaryStyleName); + } + + private static class TestSelect extends AbstractSelect { + + @Override + public AbstractSelectState getState() { + return super.getState(); + } + } +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java new file mode 100644 index 0000000000..8bd253ab64 --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java @@ -0,0 +1,160 @@ +/* + * Copyright 2000-2016 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.abstractselect; + +import org.junit.Before; +import org.junit.Test; + +import com.vaadin.server.ThemeResource; +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.OptionGroup; + +public class OptionGroupDeclarativeTest + extends DeclarativeTestBase<OptionGroup> { + + private OptionGroup og; + + @Before + public void init() { + og = new OptionGroup(); + } + + @Test + public void testBasicSyntax() { + + String expected = "<vaadin-option-group />"; + testReadWrite(expected); + + } + + @Test + public void testOptionSyntax() { + + og.addItems("foo", "bar", "baz", "bang"); + + //@formatter:off + String expected = + "<vaadin-option-group>" + + "<option>foo</option>" + + "<option>bar</option>" + + "<option>baz</option>" + + "<option>bang</option>" + + "</vaadin-option-group>"; + //@formatter:on + + testReadWrite(expected); + + } + + @Test + public void testDisabledOptionSyntax() { + + og.addItems("foo", "bar", "baz", "bang"); + og.setItemEnabled("baz", false); + + //@formatter:off + String expected = + "<vaadin-option-group>" + + "<option>foo</option>" + + "<option>bar</option>" + + "<option disabled>baz</option>" + + "<option>bang</option>" + + "</vaadin-option-group>"; + //@formatter:on + + testReadWrite(expected); + + } + + @Test + public void testIconSyntax() { + + og.addItems("foo", "bar", "baz", "bang"); + og.setItemIcon("bar", new ThemeResource("foobar.png")); + + //@formatter:off + String expected = + "<vaadin-option-group>" + + "<option>foo</option>" + + "<option icon='theme://foobar.png'>bar</option>" + + "<option>baz</option>" + + "<option>bang</option>" + + "</vaadin-option-group>"; + //@formatter:on + + testReadWrite(expected); + + } + + @Test + public void testHTMLCaption() { + + og.addItems("foo", "bar", "baz", "bang"); + + og.setHtmlContentAllowed(true); + + og.setItemCaption("foo", "<b>True</b>"); + og.setItemCaption("bar", "<font color='red'>False</font>"); + + //@formatter:off + String expected = + "<vaadin-option-group html-content-allowed>" + + "<option item-id=\"foo\"><b>True</b></option>" + + "<option item-id=\"bar\"><font color='red'>False</font></option>" + + "<option>baz</option>" + + "<option>bang</option>" + + "</vaadin-option-group>"; + //@formatter:on + + testReadWrite(expected); + } + + @Test + public void testPlaintextCaption() { + + og.addItems("foo", "bar", "baz", "bang"); + + og.setItemCaption("foo", "<b>True</b>"); + og.setItemCaption("bar", "<font color=\"red\">False</font>"); + + //@formatter:off + String expected = + "<vaadin-option-group>" + + "<option item-id=\"foo\"><b>True</b></option>" + + "<option item-id=\"bar\"><font color=\"red\">False</font></option>" + + "<option>baz</option>" + + "<option>bang</option>" + + "</vaadin-option-group>"; + //@formatter:on + + testReadWrite(expected); + } + + private void testReadWrite(String design) { + testWrite(design, og, true); + testRead(design, og); + } + + @Override + public OptionGroup testRead(String design, OptionGroup expected) { + + OptionGroup read = super.testRead(design, expected); + testWrite(design, read, true); + + return read; + } + +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java new file mode 100644 index 0000000000..9a20d2fd79 --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java @@ -0,0 +1,32 @@ +package com.vaadin.tests.server.component.abstractselect; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Collection; + +import org.junit.Before; +import org.junit.Test; + +import com.vaadin.ui.OptionGroup; + +public class OptionGroupTest { + + private OptionGroup optionGroup; + + @Before + public void setup() { + optionGroup = new OptionGroup(); + } + + @Test + public void itemsAreAdded() { + optionGroup.addItems("foo", "bar"); + + Collection<?> itemIds = optionGroup.getItemIds(); + + assertEquals(2, itemIds.size()); + assertTrue(itemIds.contains("foo")); + assertTrue(itemIds.contains("bar")); + } +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectDeclarativeTest.java new file mode 100644 index 0000000000..f0fa4aad55 --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectDeclarativeTest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2000-2016 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.listselect; + +import org.junit.Test; + +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.ListSelect; + +public class ListSelectDeclarativeTest extends DeclarativeTestBase<ListSelect> { + + private ListSelect getWithOptionsExpected() { + ListSelect ls = new ListSelect(); + ls.setRows(10); + ls.addItem("Male"); + ls.addItem("Female"); + return ls; + } + + private String getWithOptionsDesign() { + return "<vaadin-list-select rows=10>\n" + + " <option>Male</option>\n" + + " <option>Female</option>\n" + + "</vaadin-list-select>\n" + ""; + } + + @Test + public void testReadWithOptions() { + testRead(getWithOptionsDesign(), getWithOptionsExpected()); + } + + @Test + public void testWriteWithOptions() { + testWrite(stripOptionTags(getWithOptionsDesign()), + getWithOptionsExpected()); + } + + private ListSelect getBasicExpected() { + ListSelect ls = new ListSelect(); + ls.setCaption("Hello"); + return ls; + } + + private String getBasicDesign() { + return "<vaadin-list-select caption='Hello' />"; + } + + @Test + public void testReadBasic() { + testRead(getBasicDesign(), getBasicExpected()); + } + + @Test + public void testWriteBasic() { + testWrite(getBasicDesign(), getBasicExpected()); + } + +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectStateTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectStateTest.java new file mode 100644 index 0000000000..595909aa69 --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectStateTest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2016 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.listselect; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.shared.ui.select.AbstractSelectState; +import com.vaadin.ui.ListSelect; + +/** + * Tests for ListSelect State. + * + */ +public class ListSelectStateTest { + + @Test + public void getState_listSelectHasCustomState() { + TestListSelect select = new TestListSelect(); + AbstractSelectState state = select.getState(); + Assert.assertEquals("Unexpected state class", AbstractSelectState.class, + state.getClass()); + } + + private static class TestListSelect extends ListSelect { + @Override + public AbstractSelectState getState() { + return super.getState(); + } + } + +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java new file mode 100644 index 0000000000..853f38c7d3 --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2016 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.nativeselect; + +import org.junit.Test; + +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.NativeSelect; + +/** + * Test cases for reading the properties of selection components. + * + * @author Vaadin Ltd + */ +public class NativeSelectDeclarativeTest + extends DeclarativeTestBase<NativeSelect> { + + public String getBasicDesign() { + return "<vaadin-native-select><option>foo</option><option>bar</option></vaadin-native-select>"; + + } + + public NativeSelect getBasicExpected() { + NativeSelect ns = new NativeSelect(); + ns.addItem("foo"); + ns.addItem("bar"); + return ns; + } + + @Test + public void testReadBasic() { + testRead(getBasicDesign(), getBasicExpected()); + } + + @Test + public void testWriteBasic() { + testWrite(stripOptionTags(getBasicDesign()), getBasicExpected()); + } + + @Test + public void testReadOnlyValue() { + String design = "<vaadin-native-select readonly><option selected>foo</option><option>bar</option></vaadin-native-select>"; + + NativeSelect ns = new NativeSelect(); + ns.addItems("foo", "bar"); + ns.setValue("foo"); + ns.setReadOnly(true); + + testRead(design, ns); + + // Selects items are not written out by default + String design2 = "<vaadin-native-select readonly></vaadin-native-select>"; + testWrite(design2, ns); + } + +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java new file mode 100644 index 0000000000..2c2a8a81fb --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java @@ -0,0 +1,25 @@ +package com.vaadin.tests.server.component.optiongroup; + +import org.junit.Test; + +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.BlurListener; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; +import com.vaadin.ui.OptionGroup; + +public class OptionGroupListenersTest extends AbstractListenerMethodsTestBase { + + @Test + public void testFocusListenerAddGetRemove() throws Exception { + testListenerAddGetRemove(OptionGroup.class, FocusEvent.class, + FocusListener.class); + } + + @Test + public void testBlurListenerAddGetRemove() throws Exception { + testListenerAddGetRemove(OptionGroup.class, BlurEvent.class, + BlurListener.class); + } +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupStateTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupStateTest.java new file mode 100644 index 0000000000..a6d04576bc --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupStateTest.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2016 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.optiongroup; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.shared.ui.optiongroup.OptionGroupState; +import com.vaadin.ui.OptionGroup; + +/** + * Tests for OptionGroup state. + * + */ +public class OptionGroupStateTest { + + @Test + public void getState_optionGroupHasCustomState() { + TestOptionGroup group = new TestOptionGroup(); + OptionGroupState state = group.getState(); + Assert.assertEquals("Unexpected state class", OptionGroupState.class, + state.getClass()); + } + + @Test + public void getPrimaryStyleName_optionGroupHasCustomPrimaryStyleName() { + OptionGroup layout = new OptionGroup(); + OptionGroupState state = new OptionGroupState(); + Assert.assertEquals("Unexpected primary style name", + state.primaryStyleName, layout.getPrimaryStyleName()); + } + + @Test + public void optionGroupStateHasCustomPrimaryStyleName() { + OptionGroupState state = new OptionGroupState(); + Assert.assertEquals("Unexpected primary style name", + "v-select-optiongroup", state.primaryStyleName); + } + + private static class TestOptionGroup extends OptionGroup { + + @Override + public OptionGroupState getState() { + return super.getState(); + } + } +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java new file mode 100644 index 0000000000..1b0ff1caff --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java @@ -0,0 +1,25 @@ +package com.vaadin.tests.server.component.select; + +import org.junit.Test; + +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.BlurListener; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; +import com.vaadin.ui.Select; + +public class SelectListenersTest extends AbstractListenerMethodsTestBase { + + @Test + public void testFocusListenerAddGetRemove() throws Exception { + testListenerAddGetRemove(Select.class, FocusEvent.class, + FocusListener.class); + } + + @Test + public void testBlurListenerAddGetRemove() throws Exception { + testListenerAddGetRemove(Select.class, BlurEvent.class, + BlurListener.class); + } +} diff --git a/compatibility-server/src/test/java/com/vaadin/ui/AbsSelectTest.java b/compatibility-server/src/test/java/com/vaadin/ui/AbsSelectTest.java new file mode 100644 index 0000000000..51556f9e1a --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/ui/AbsSelectTest.java @@ -0,0 +1,147 @@ +/* + * Copyright 2000-2016 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.ui; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.data.util.ObjectProperty; + +public class AbsSelectTest { + + @Test + public void addItemsStrings() { + NativeSelect ns = new NativeSelect(); + ns.addItems("Foo", "bar", "baz"); + Assert.assertEquals(3, ns.size()); + Assert.assertArrayEquals(new Object[] { "Foo", "bar", "baz" }, + ns.getItemIds().toArray()); + } + + @Test + public void addItemsObjects() { + Object o1 = new Object(); + Object o2 = new Object(); + Object o3 = new Object(); + + NativeSelect ns = new NativeSelect(); + ns.addItems(o1, o2, o3); + Assert.assertEquals(3, ns.size()); + Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, + ns.getItemIds().toArray()); + } + + @Test + public void addItemsStringList() { + ArrayList<String> itemIds = new ArrayList<String>(); + itemIds.add("foo"); + itemIds.add("bar"); + itemIds.add("baz"); + NativeSelect ns = new NativeSelect(); + ns.addItems(itemIds); + Assert.assertEquals(3, ns.size()); + Assert.assertArrayEquals(new Object[] { "foo", "bar", "baz" }, + ns.getItemIds().toArray()); + } + + @Test + public void addItemsObjectList() { + Object o1 = new Object(); + Object o2 = new Object(); + Object o3 = new Object(); + ArrayList<Object> itemIds = new ArrayList<Object>(); + itemIds.add(o1); + itemIds.add(o2); + itemIds.add(o3); + NativeSelect ns = new NativeSelect(); + ns.addItems(itemIds); + Assert.assertEquals(3, ns.size()); + Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, + ns.getItemIds().toArray()); + + } + + @Test + public void singleSelectInitiallyEmpty() { + AbstractSelect s = new ListSelect(); + Assert.assertTrue(s.isEmpty()); + } + + @Test + public void singleSelectEmptyAfterClearUsingPDS() { + AbstractSelect s = new ListSelect(); + s.addItem("foo"); + s.addItem("bar"); + s.setPropertyDataSource(new ObjectProperty<String>("foo")); + + Assert.assertFalse(s.isEmpty()); + s.clear(); + Assert.assertTrue(s.isEmpty()); + } + + @Test + public void singleSelectEmptyAfterClear() { + AbstractSelect s = new ListSelect(); + s.addItem("foo"); + s.addItem("bar"); + s.setValue("bar"); + + Assert.assertFalse(s.isEmpty()); + s.clear(); + Assert.assertTrue(s.isEmpty()); + } + + @Test + public void multiSelectInitiallyEmpty() { + AbstractSelect s = new ListSelect(); + s.setMultiSelect(true); + Assert.assertTrue(s.isEmpty()); + } + + @Test + public void multiSelectEmptyAfterClearUsingPDS() { + AbstractSelect s = new ListSelect(); + s.setMultiSelect(true); + s.addItem("foo"); + s.addItem("bar"); + HashSet<String> sel = new HashSet<String>(); + sel.add("foo"); + sel.add("bar"); + s.setPropertyDataSource(new ObjectProperty<HashSet>(sel)); + + Assert.assertFalse(s.isEmpty()); + s.clear(); + Assert.assertTrue(s.isEmpty()); + } + + @Test + public void multiSelectEmptyAfterClear() { + AbstractSelect s = new ListSelect(); + s.setMultiSelect(true); + s.addItem("foo"); + s.addItem("bar"); + s.select("foo"); + s.select("bar"); + + Assert.assertFalse(s.isEmpty()); + s.clear(); + Assert.assertTrue(s.isEmpty()); + } + +} diff --git a/compatibility-server/src/test/java/com/vaadin/ui/NativeSelectTest.java b/compatibility-server/src/test/java/com/vaadin/ui/NativeSelectTest.java new file mode 100644 index 0000000000..1a41fc1097 --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/ui/NativeSelectTest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2000-2016 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.ui; + +import java.util.Collections; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.data.util.IndexedContainer; +import com.vaadin.shared.ui.select.AbstractSelectState; + +public class NativeSelectTest { + + @Test + public void rpcRegisteredConstructorNoArg() { + assertFocusRpcRegistered(new NativeSelect()); + } + + @Test + public void rpcRegisteredConstructorString() { + assertFocusRpcRegistered(new NativeSelect("foo")); + } + + @Test + public void rpcRegisteredConstructorStringCollection() { + assertFocusRpcRegistered( + new NativeSelect("foo", Collections.singleton("Hello"))); + } + + @Test + public void rpcRegisteredConstructorStringContainer() { + assertFocusRpcRegistered( + new NativeSelect("foo", new IndexedContainer())); + } + + @Test + public void getState_listSelectHasCustomState() { + TestNativeSelect select = new TestNativeSelect(); + AbstractSelectState state = select.getState(); + Assert.assertEquals("Unexpected state class", AbstractSelectState.class, + state.getClass()); + } + + private static class TestNativeSelect extends NativeSelect { + @Override + public AbstractSelectState getState() { + return super.getState(); + } + } + + private void assertFocusRpcRegistered(NativeSelect s) { + Assert.assertNotNull("RPC is not correctly registered", s.getRpcManager( + "com.vaadin.shared.communication.FieldRpc$FocusAndBlurServerRpc")); + } + +} diff --git a/compatibility-server/src/test/resources/com/vaadin/tests/design/all-components-legacy.html b/compatibility-server/src/test/resources/com/vaadin/tests/design/all-components-legacy.html new file mode 100644 index 0000000000..39aecb6db1 --- /dev/null +++ b/compatibility-server/src/test/resources/com/vaadin/tests/design/all-components-legacy.html @@ -0,0 +1,122 @@ +<!DOCTYPE html> +<html> + <head> + <meta name="package-mapping" content="my:com.addon.mypackage"/> + </head> + <body> + <v-vertical-layout> + <!-- abstract component --> + <v-button primary-style-name="button" id="foo" style-name="red" caption="Some caption" icon="vaadin://themes/runo/icons/16/ok.png" description="My tooltip" error="Something went wrong" locale="en_US"></v-button> + + <!-- absolute layout --> + <v-absolute-layout> + <v-button :top="100px" :left="0px" :z-index=21>OK</v-button> + <v-button :bottom="0px" :right="0px">Cancel</v-button> + </v-absolute-layout> + + <!-- vertical layout --> + <v-vertical-layout spacing margin> + <v-button :top>OK</v-button> + <v-table size-full :expand=1 /> + </v-vertical-layout> + + <!-- horizontal layout --> + <v-horizontal-layout spacing margin> + <v-button :top>OK</v-button> + <v-table size-full :expand=1 /> + </v-horizontal-layout> + + <!-- form layout --> + <v-form-layout spacing margin> + <v-button :top>OK</v-button> + <v-table size-full :expand=1 /> + </v-form-layout> + + <!-- css layout --> + <v-css-layout> + <v-button>OK</v-button> + <v-table size-full /> + </v-css-layout> + + <!-- panel --> + <v-panel caption="Hello world" tabindex=2 scroll-left="10" scroll-top="10"> + <v-table size-full /> + </v-panel> + + <!-- abstract field --> + <v-text-field buffered validation-visible=false invalid-committed invalid-allowed=false required required-error="This is a required field" conversion-error="Input {0} cannot be parsed" tabindex=3 readonly /> + <!-- abstract text field, text field --> + <v-text-field null-representation="" null-setting-allowed maxlength=10 columns=5 input-prompt="Please enter a value" text-change-event-mode="eager" text-change-timeout=2 value="foo" /> + <!-- password field --> + <v-password-field null-representation="" null-setting-allowed maxlength=10 columns=5 input-prompt="Please enter a value" text-change-event-mode="eager" text-change-timeout=2 value="foo" /> + <!-- text area --> + <v-text-area rows=5 wordwrap=false >test value</v-text-area> + <!-- button --> + <v-button click-shortcut="ctrl-shift-o" disable-on-click tabindex=1 icon="http://vaadin.com/image.png" icon-alt="ok" plain-text>OK</v-button> + <!-- native button --> + <v-button click-shortcut="ctrl-shift-o" disable-on-click tabindex=1 icon="http://vaadin.com/image.png" icon-alt="ok" plain-text>OK</v-button> + + <!-- tabsheet --> + <v-tab-sheet tabindex=5> + <tab visible=false closable caption="My first tab"> + <v-vertical-layout> + <v-text-field/> + </v-vertical-layout> + </tab> + <tab enabled=false caption="Disabled second tab"> + <v-button>In disabled tab - can’t be shown by default</v-button> + </tab> + <tab icon="theme://../runo/icons/16/ok.png" icon-alt="Ok png from Runo - very helpful" description="Click to show a text field" style-name="red" id="uniqueDomId"> + <v-text-field input-prompt="Icon only in tab" /> + </tab> + </v-tab-sheet> + + <!-- accordion --> + <v-accordion tabindex=5> + <tab visible=false closable caption="My first tab"> + <v-vertical-layout> + <v-text-field/> + </v-vertical-layout> + </tab> + <tab enabled=false caption="Disabled second tab"> + <v-button>In disabled tab - can’t be shown by default</v-button> + </tab> + <tab icon="theme://../runo/icons/16/ok.png" icon-alt="Ok png from Runo - very helpful" description="Click to show a text field" style-name="red" id="uniqueDomId"> + <v-text-field input-prompt="Icon only in tab" /> + </tab> + </v-accordion> + + <!-- abstract split panel --> + <v-horizontal-split-panel split-position="20px" min-split-position="0px" max-split-position="50px" locked> + <v-button>First slot</v-button> + </v-horizontal-split-panel> + <v-vertical-split-panel split-position="25%" reversed> + <v-button :second>Second slot</v-button> + </v-vertical-split-panel> + <v-horizontal-split-panel split-position="25%" reversed> + <v-button>First slot</v-button> + <v-button>Second slot</v-button> + </v-horizontal-split-panel> + + <!-- label --> + <v-label>Hello world!</v-label> + <v-label>This is <b><u>Rich</u></b> content!</v-label> + <v-label plain-text>This is only <b>text</b> and will contain visible tags</v-label> + + <!-- checkbox --> + <v-check-box checked/> + + <!-- abstract select --> + <v-list-select new-items-allowed multi-select + item-caption-mode="index" + null-selection-allowed=false> + </v-list-select> + + <v-combo-box> + <option icon="http://something/my-icon.png">First value</option> + <option>Second value</option> + </v-combo-box> + + </v-vertical-layout> + </body> +</html> diff --git a/compatibility-server/src/test/resources/com/vaadin/tests/design/all-components.html b/compatibility-server/src/test/resources/com/vaadin/tests/design/all-components.html new file mode 100644 index 0000000000..6507188cd7 --- /dev/null +++ b/compatibility-server/src/test/resources/com/vaadin/tests/design/all-components.html @@ -0,0 +1,122 @@ +<!DOCTYPE html> +<html> + <head> + <meta name="package-mapping" content="my:com.addon.mypackage"/> + </head> + <body> + <vaadin-vertical-layout> + <!-- abstract component --> + <vaadin-button primary-style-name="button" id="foo" style-name="red" caption="Some caption" icon="vaadin://themes/runo/icons/16/ok.png" description="My tooltip" error="Something went wrong" locale="en_US"></vaadin-button> + + <!-- absolute layout --> + <vaadin-absolute-layout> + <vaadin-button :top="100px" :left="0px" :z-index=21>OK</vaadin-button> + <vaadin-button :bottom="0px" :right="0px">Cancel</vaadin-button> + </vaadin-absolute-layout> + + <!-- vertical layout --> + <vaadin-vertical-layout spacing margin> + <vaadin-button :top>OK</vaadin-button> + <vaadin-table size-full :expand=1 /> + </vaadin-vertical-layout> + + <!-- horizontal layout --> + <vaadin-horizontal-layout spacing margin> + <vaadin-button :top>OK</vaadin-button> + <vaadin-table size-full :expand=1 /> + </vaadin-horizontal-layout> + + <!-- form layout --> + <vaadin-form-layout spacing margin> + <vaadin-button :top>OK</vaadin-button> + <vaadin-table size-full :expand=1 /> + </vaadin-form-layout> + + <!-- css layout --> + <vaadin-css-layout> + <vaadin-button>OK</vaadin-button> + <vaadin-table size-full /> + </vaadin-css-layout> + + <!-- panel --> + <vaadin-panel caption="Hello world" tabindex=2 scroll-left="10" scroll-top="10"> + <vaadin-table size-full /> + </vaadin-panel> + + <!-- abstract field --> + <vaadin-text-field buffered validation-visible=false invalid-committed invalid-allowed=false required required-error="This is a required field" conversion-error="Input {0} cannot be parsed" tabindex=3 readonly /> + <!-- abstract text field, text field --> + <vaadin-text-field null-representation="" null-setting-allowed maxlength=10 columns=5 input-prompt="Please enter a value" text-change-event-mode="eager" text-change-timeout=2 value="foo" /> + <!-- password field --> + <vaadin-password-field null-representation="" null-setting-allowed maxlength=10 columns=5 input-prompt="Please enter a value" text-change-event-mode="eager" text-change-timeout=2 value="foo" /> + <!-- text area --> + <vaadin-text-area rows=5 wordwrap=false >test value</vaadin-text-area> + <!-- button --> + <vaadin-button click-shortcut="ctrl-shift-o" disable-on-click tabindex=1 icon="http://vaadin.com/image.png" icon-alt="ok" plain-text>OK</vaadin-button> + <!-- native button --> + <vaadin-button click-shortcut="ctrl-shift-o" disable-on-click tabindex=1 icon="http://vaadin.com/image.png" icon-alt="ok" plain-text>OK</vaadin-button> + + <!-- tabsheet --> + <vaadin-tab-sheet tabindex=5> + <tab visible=false closable caption="My first tab"> + <vaadin-vertical-layout> + <vaadin-text-field/> + </vaadin-vertical-layout> + </tab> + <tab enabled=false caption="Disabled second tab"> + <vaadin-button>In disabled tab - can’t be shown by default</vaadin-button> + </tab> + <tab icon="theme://../runo/icons/16/ok.png" icon-alt="Ok png from Runo - very helpful" description="Click to show a text field" style-name="red" id="uniqueDomId"> + <vaadin-text-field input-prompt="Icon only in tab" /> + </tab> + </vaadin-tab-sheet> + + <!-- accordion --> + <vaadin-accordion tabindex=5> + <tab visible=false closable caption="My first tab"> + <vaadin-vertical-layout> + <vaadin-text-field/> + </vaadin-vertical-layout> + </tab> + <tab enabled=false caption="Disabled second tab"> + <vaadin-button>In disabled tab - can’t be shown by default</vaadin-button> + </tab> + <tab icon="theme://../runo/icons/16/ok.png" icon-alt="Ok png from Runo - very helpful" description="Click to show a text field" style-name="red" id="uniqueDomId"> + <vaadin-text-field input-prompt="Icon only in tab" /> + </tab> + </vaadin-accordion> + + <!-- abstract split panel --> + <vaadin-horizontal-split-panel split-position="20px" min-split-position="0px" max-split-position="50px" locked> + <vaadin-button>First slot</vaadin-button> + </vaadin-horizontal-split-panel> + <vaadin-vertical-split-panel split-position="25%" reversed> + <vaadin-button :second>Second slot</vaadin-button> + </vaadin-vertical-split-panel> + <vaadin-horizontal-split-panel split-position="25%" reversed> + <vaadin-button>First slot</vaadin-button> + <vaadin-button>Second slot</vaadin-button> + </vaadin-horizontal-split-panel> + + <!-- label --> + <vaadin-label>Hello world!</vaadin-label> + <vaadin-label>This is <b><u>Rich</u></b> content!</vaadin-label> + <vaadin-label plain-text>This is only <b>text</b> and will contain visible tags</vaadin-label> + + <!-- checkbox --> + <vaadin-check-box checked/> + + <!-- abstract select --> + <vaadin-list-select new-items-allowed multi-select + item-caption-mode="index" + null-selection-allowed=false> + </vaadin-list-select> + + <vaadin-combo-box> + <option icon="http://something/my-icon.png">First value</option> + <option>Second value</option> + </vaadin-combo-box> + + </vaadin-vertical-layout> + </body> +</html> |