sb.append("</").append(producedElem.tagName()).append(">");
return sb.toString();
}
+
+ protected String stripOptionTags(String design) {
+ return design.replaceAll("[ \n]*<option(.*)</option>[ \n]*", "");
+
+ }
+
}
@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() {
--- /dev/null
+/*
+ * 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;
+ }
+}
--- /dev/null
+/*
+ * 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());
+ }
+
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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());
+ }
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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());
+ }
+}