diff options
author | Artur Signell <artur@vaadin.com> | 2015-02-04 23:33:18 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-02-05 14:16:27 +0000 |
commit | db7899e6140294989664939d49c7bf1c9229d91f (patch) | |
tree | faecf9ccdd151a75e97cb25b7f9f5a3de65ecf17 | |
parent | 9d0145c09d947a58990a62b8b859fd4921e4585f (diff) | |
download | vaadin-framework-db7899e6140294989664939d49c7bf1c9229d91f.tar.gz vaadin-framework-db7899e6140294989664939d49c7bf1c9229d91f.zip |
New declarative tests
* ListSelect (#15547)
* ComboBox (#15546)
* NativeSelect (#15548)
* Upload (#16323)
* Tree (#16317)
* TwinColSelect (#16317)
Change-Id: Ic3443ec94971dc5bf9f63c8c11e5023863f9588c
8 files changed, 402 insertions, 4 deletions
diff --git a/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java b/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java index 1874c3ec95..8dc32e00d6 100644 --- a/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java +++ b/server/tests/src/com/vaadin/tests/design/DeclarativeTestBaseBase.java @@ -166,4 +166,10 @@ public abstract class DeclarativeTestBaseBase<T extends Component> { sb.append("</").append(producedElem.tagName()).append(">"); return sb.toString(); } + + protected String stripOptionTags(String design) { + return design.replaceAll("[ \n]*<option(.*)</option>[ \n]*", ""); + + } + } diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java index 1f5c90516d..61128a1803 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java @@ -138,11 +138,9 @@ public class AbstractSelectDeclarativeTest extends @Test public void testWriteInlineData() { - String modifiedDesign = getDesignForInlineData(); // No data is written by default - modifiedDesign = modifiedDesign.replaceAll( - "[ \n]*<option(.*)</option>[ \n]*", ""); - testWrite(modifiedDesign, getExpectedComponentForInlineData()); + testWrite(stripOptionTags(getDesignForInlineData()), + getExpectedComponentForInlineData()); } private String getDesignForInlineData() { diff --git a/server/tests/src/com/vaadin/tests/server/component/combobox/ComboBoxDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/combobox/ComboBoxDeclarativeTest.java new file mode 100644 index 0000000000..e9d66b478b --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/combobox/ComboBoxDeclarativeTest.java @@ -0,0 +1,72 @@ +/* + * 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.combobox; + +import org.junit.Test; + +import com.vaadin.shared.ui.combobox.FilteringMode; +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.ComboBox; + +public class ComboBoxDeclarativeTest extends DeclarativeTestBase<ComboBox> { + + @Test + public void testReadOnlyWithOptionsRead() { + testRead(getReadOnlyWithOptionsDesign(), + getReadOnlyWithOptionsExpected()); + } + + private ComboBox getReadOnlyWithOptionsExpected() { + ComboBox cb = new ComboBox(); + cb.setTextInputAllowed(false); + cb.addItem("Hello"); + cb.addItem("World"); + return cb; + } + + private String getReadOnlyWithOptionsDesign() { + return "<v-combo-box text-input-allowed='false'><option>Hello</option><option>World</option></v-combo-box>"; + } + + @Test + public void testReadOnlyWithOptionsWrite() { + testWrite(stripOptionTags(getReadOnlyWithOptionsDesign()), + getReadOnlyWithOptionsExpected()); + } + + @Test + public void testBasicRead() { + testRead(getBasicDesign(), getBasicExpected()); + } + + @Test + public void testBasicWrite() { + testWrite(getBasicDesign(), getBasicExpected()); + } + + private String getBasicDesign() { + return "<v-combo-box input-prompt=\"Select something\" filtering-mode=\"off\" scroll-to-selected-item='false'>"; + } + + private ComboBox getBasicExpected() { + ComboBox cb = new ComboBox(); + cb.setInputPrompt("Select something"); + cb.setTextInputAllowed(true); + cb.setFilteringMode(FilteringMode.OFF); + cb.setScrollToSelectedItem(false); + return cb; + } +} diff --git a/server/tests/src/com/vaadin/tests/server/component/listselect/ListSelectDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/listselect/ListSelectDeclarativeTest.java new file mode 100644 index 0000000000..fcff6cd4a5 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/listselect/ListSelectDeclarativeTest.java @@ -0,0 +1,70 @@ +/* + * 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.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 "<v-list-select rows=10>\n" + " <option>Male</option>\n" + + " <option>Female</option>\n" + "</v-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 "<v-list-select caption='Hello' />"; + } + + @Test + public void testReadBasic() { + testRead(getBasicDesign(), getBasicExpected()); + } + + @Test + public void testWriteBasic() { + testWrite(getBasicDesign(), getBasicExpected()); + } + +} diff --git a/server/tests/src/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java new file mode 100644 index 0000000000..8f1b995cc6 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java @@ -0,0 +1,53 @@ +/* + * 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.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 "<v-native-select><option>foo</option><option>bar</option></v-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()); + } + +}
\ No newline at end of file diff --git a/server/tests/src/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java new file mode 100644 index 0000000000..b5e86d0835 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java @@ -0,0 +1,64 @@ +/* + * 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.tree; + +import org.junit.Test; + +import com.vaadin.shared.ui.MultiSelectMode; +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.Tree; +import com.vaadin.ui.Tree.TreeDragMode; + +/** + * Tests the declarative support for implementations of {@link Tree}. + * + * @since 7.4 + * @author Vaadin Ltd + */ +public class TreeDeclarativeTest extends DeclarativeTestBase<Tree> { + + @Test + public void testReadBasic() { + testRead(getBasicDesign(), getBasicExpected()); + } + + @Test + public void testWriteBasic() { + testWrite(getBasicDesign(), getBasicExpected()); + } + + private String getBasicDesign() { + return "<v-tree selectable='false' drag-mode='node' multiselect-mode='simple' />"; + } + + private Tree getBasicExpected() { + Tree t = new Tree(); + t.setSelectable(false); + t.setDragMode(TreeDragMode.NODE); + t.setMultiselectMode(MultiSelectMode.SIMPLE); + return t; + } + + @Test + public void testReadEmpty() { + testRead("<v-tree />", new Tree()); + } + + @Test + public void testWriteEmpty() { + testWrite("<v-tree />", new Tree()); + } +} diff --git a/server/tests/src/com/vaadin/tests/server/component/twincolselect/TwinColSelectDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/twincolselect/TwinColSelectDeclarativeTest.java new file mode 100644 index 0000000000..569080223b --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/twincolselect/TwinColSelectDeclarativeTest.java @@ -0,0 +1,74 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.server.component.twincolselect; + +import java.util.Arrays; + +import org.junit.Test; + +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.TwinColSelect; + +/** + * Test cases for reading the properties of selection components. + * + * @author Vaadin Ltd + */ +public class TwinColSelectDeclarativeTest extends + DeclarativeTestBase<TwinColSelect> { + + public String getBasicDesign() { + return "<v-twin-col-select rows=5 right-column-caption='Selected values' left-column-caption='Unselected values'>\n" + + " <option>First item</option>\n" + + " <option selected>Second item</option>\n" + + " <option selected>Third item</option>\n" + + "</v-twin-col-select>"; + + } + + public TwinColSelect getBasicExpected() { + TwinColSelect s = new TwinColSelect(); + s.setRightColumnCaption("Selected values"); + s.setLeftColumnCaption("Unselected values"); + s.addItem("First item"); + s.addItem("Second item"); + s.addItem("Third item"); + s.setValue(Arrays.asList(new Object[] { "Second item", "Third item" })); + s.setRows(5); + return s; + } + + @Test + public void testReadBasic() { + testRead(getBasicDesign(), getBasicExpected()); + } + + @Test + public void testWriteBasic() { + testWrite(stripOptionTags(getBasicDesign()), getBasicExpected()); + } + + @Test + public void testReadEmpty() { + testRead("<v-twin-col-select />", new TwinColSelect()); + } + + @Test + public void testWriteEmpty() { + testWrite("<v-twin-col-select />", new TwinColSelect()); + } + +}
\ No newline at end of file diff --git a/server/tests/src/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java new file mode 100644 index 0000000000..e08980002d --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java @@ -0,0 +1,61 @@ +/* + * 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.upload; + +import org.junit.Test; + +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.Upload; + +/** + * Tests the declarative support for implementations of {@link Upload}. + * + * @since 7.4 + * @author Vaadin Ltd + */ +public class UploadDeclarativeTest extends DeclarativeTestBase<Upload> { + + @Test + public void testReadBasic() { + testRead(getBasicDesign(), getBasicExpected()); + } + + @Test + public void testWriteBasic() { + testWrite(getBasicDesign(), getBasicExpected()); + } + + private String getBasicDesign() { + return "<v-upload button-caption='Send the file' tabindex=5 />"; + } + + private Upload getBasicExpected() { + Upload u = new Upload(); + u.setButtonCaption("Send the file"); + u.setTabIndex(5); + return u; + } + + @Test + public void testReadEmpty() { + testRead("<v-upload />", new Upload()); + } + + @Test + public void testWriteEmpty() { + testWrite("<v-upload />", new Upload()); + } +} |