aboutsummaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2015-09-10 14:09:32 +0300
committerJohn Ahlroos <john@vaadin.com>2015-09-25 12:15:37 +0300
commit5e9209421ce92e16531299c8c4be5fdd412bb513 (patch)
treea45264968949607b4111c99390933dadd3bf575c /server/tests
parentccad63a4aa12a00016ac29c5b612f6f59edc379b (diff)
downloadvaadin-framework-5e9209421ce92e16531299c8c4be5fdd412bb513.tar.gz
vaadin-framework-5e9209421ce92e16531299c8c4be5fdd412bb513.zip
Parse readonly values for AbstractFields correctly #18850
Change-Id: I6f7d8731d185fe1c88e861435a401d887b2defbe
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/checkbox/CheckboxDeclarativeTest.java10
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/combobox/ComboBoxDeclarativeTest.java16
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java12
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java16
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/passwordfield/PasswordFieldDeclarativeTest.java40
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/progressbar/ProgressBarDeclarativeTest.java12
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/richtextarea/RichTextAreaDeclarativeTest.java11
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/slider/SliderDeclarativeTest.java15
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java11
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldDeclarativeTest.java10
10 files changed, 153 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/checkbox/CheckboxDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/checkbox/CheckboxDeclarativeTest.java
index e0f0b7c3e9..6206617cd8 100644
--- a/server/tests/src/com/vaadin/tests/server/component/checkbox/CheckboxDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/checkbox/CheckboxDeclarativeTest.java
@@ -44,4 +44,14 @@ public class CheckboxDeclarativeTest extends DeclarativeTestBase<CheckBox> {
testRead(design, checkBox);
testWrite(design, checkBox);
}
+
+ @Test
+ public void testReadOnlyValue() {
+ String design = "<v-check-box readonly checked='' />";
+ CheckBox checkBox = new CheckBox();
+ checkBox.setValue(true);
+ checkBox.setReadOnly(true);
+ testRead(design, checkBox);
+ testWrite(design, checkBox);
+ }
}
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
index e9d66b478b..d49d2b79e2 100644
--- a/server/tests/src/com/vaadin/tests/server/component/combobox/ComboBoxDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/combobox/ComboBoxDeclarativeTest.java
@@ -57,6 +57,22 @@ public class ComboBoxDeclarativeTest extends DeclarativeTestBase<ComboBox> {
testWrite(getBasicDesign(), getBasicExpected());
}
+ @Test
+ public void testReadOnlyValue() {
+ String design = "<v-combo-box readonly value='foo'><option selected>foo</option></v-combo-box>";
+
+ ComboBox comboBox = new ComboBox();
+ comboBox.addItems("foo", "bar");
+ comboBox.setValue("foo");
+ comboBox.setReadOnly(true);
+
+ testRead(design, comboBox);
+
+ // Selects items are not written out by default
+ String design2 = "<v-combo-box readonly></v-combo-box>";
+ testWrite(design2, comboBox);
+ }
+
private String getBasicDesign() {
return "<v-combo-box input-prompt=\"Select something\" filtering-mode=\"off\" scroll-to-selected-item='false'>";
}
diff --git a/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java
index 4087f1ad11..f5ae6871a2 100644
--- a/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java
@@ -87,4 +87,16 @@ public class DateFieldDeclarativeTest extends DeclarativeTestBase<DateField> {
"2020-01-01 00:00:00+0200"),
getYearResolutionExpected());
}
+
+ @Test
+ public void testReadOnlyValue() {
+ String design = "<v-date-field readonly resolution='year' value='2020-01-01 00:00:00+0200'/>";
+ DateField df = new DateField();
+ df.setResolution(Resolution.YEAR);
+ df.setValue(new Date(2020 - 1900, 1 - 1, 1));
+ df.setReadOnly(true);
+
+ testRead(design, df);
+ testWrite(design, df);
+ }
}
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
index 8f1b995cc6..140335e136 100644
--- a/server/tests/src/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java
@@ -50,4 +50,20 @@ public class NativeSelectDeclarativeTest extends
testWrite(stripOptionTags(getBasicDesign()), getBasicExpected());
}
+ @Test
+ public void testReadOnlyValue() {
+ String design = "<v-native-select readonly><option selected>foo</option><option>bar</option></v-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 = "<v-native-select readonly></v-native-select>";
+ testWrite(design2, ns);
+ }
+
} \ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/passwordfield/PasswordFieldDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/passwordfield/PasswordFieldDeclarativeTest.java
new file mode 100644
index 0000000000..6934d2011c
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/passwordfield/PasswordFieldDeclarativeTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.passwordfield;
+
+import org.junit.Test;
+
+import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.ui.PasswordField;
+
+/**
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class PasswordFieldDeclarativeTest extends
+ DeclarativeTestBase<PasswordField> {
+
+ @Test
+ public void testReadOnlyValue() {
+ String design = "<v-password-field readonly=\"\" value=\"test value\"/>";
+ PasswordField tf = new PasswordField();
+ tf.setValue("test value");
+ tf.setReadOnly(true);
+ testRead(design, tf);
+ testWrite(design, tf);
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/progressbar/ProgressBarDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/progressbar/ProgressBarDeclarativeTest.java
index bed19644ff..82b8acd8ab 100644
--- a/server/tests/src/com/vaadin/tests/server/component/progressbar/ProgressBarDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/progressbar/ProgressBarDeclarativeTest.java
@@ -60,4 +60,16 @@ public class ProgressBarDeclarativeTest extends
testWrite("<v-progress-bar>", new ProgressBar());
}
+ @Test
+ public void testReadOnlyValue() {
+ String design = "<v-progress-bar readonly value=0.5 indeterminate=''>";
+ ProgressBar progressBar = new ProgressBar();
+ progressBar.setIndeterminate(true);
+ progressBar.setValue(0.5f);
+ progressBar.setReadOnly(true);
+
+ testRead(design, progressBar);
+ testWrite(design, progressBar);
+ }
+
} \ No newline at end of file
diff --git a/server/tests/src/com/vaadin/tests/server/component/richtextarea/RichTextAreaDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/richtextarea/RichTextAreaDeclarativeTest.java
index 0d614b7b9a..315a5be6b6 100644
--- a/server/tests/src/com/vaadin/tests/server/component/richtextarea/RichTextAreaDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/richtextarea/RichTextAreaDeclarativeTest.java
@@ -56,4 +56,15 @@ public class RichTextAreaDeclarativeTest extends
public void testWriteEmpty() {
testWrite("<v-rich-text-area />", new RichTextArea());
}
+
+ @Test
+ public void testReadOnlyValue() {
+ String design = "<v-rich-text-area readonly style-name='v-richtextarea-readonly'>Hello World!</v-text-area>";
+ RichTextArea ta = new RichTextArea();
+ ta.setValue("Hello World!");
+ ta.setReadOnly(true);
+
+ testRead(design, ta);
+ testWrite(design, ta);
+ }
}
diff --git a/server/tests/src/com/vaadin/tests/server/component/slider/SliderDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/slider/SliderDeclarativeTest.java
index 9ef28afb82..0c2ac6bed9 100644
--- a/server/tests/src/com/vaadin/tests/server/component/slider/SliderDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/slider/SliderDeclarativeTest.java
@@ -63,4 +63,19 @@ public class SliderDeclarativeTest extends DeclarativeTestBase<Slider> {
testRead(design, expected);
testWrite(design, expected);
}
+
+ @Test
+ public void testReadOnlyValue() {
+ String design = "<v-slider readonly min=10 max=20 resolution=1 value=12.3>";
+
+ Slider expected = new Slider();
+ expected.setMin(10.0);
+ expected.setMax(20.0);
+ expected.setResolution(1);
+ expected.setValue(12.3);
+ expected.setReadOnly(true);
+
+ testRead(design, expected);
+ testWrite(design, expected);
+ }
}
diff --git a/server/tests/src/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java
index bed8851204..f70f1fde98 100644
--- a/server/tests/src/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java
@@ -58,6 +58,17 @@ public class TextAreaDeclarativeTest extends DeclarativeTestBase<TextArea> {
read.writeDesign(root, dc);
Assert.assertEquals("&amp;amp; Test", root.html());
+ }
+ @Test
+ public void testReadOnlyValue() {
+ String design = "<v-text-area readonly rows=6 wordwrap=false>Hello World!</v-text-area>";
+ TextArea ta = new TextArea();
+ ta.setRows(6);
+ ta.setWordwrap(false);
+ ta.setValue("Hello World!");
+ ta.setReadOnly(true);
+ testRead(design, ta);
+ testWrite(design, ta);
}
}
diff --git a/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldDeclarativeTest.java
index b4e7f9dae3..d545ee5a1a 100644
--- a/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/textfield/TextFieldDeclarativeTest.java
@@ -44,4 +44,14 @@ public class TextFieldDeclarativeTest extends DeclarativeTestBase<TextField> {
testRead(design, tf);
testWrite(design, tf);
}
+
+ @Test
+ public void testReadOnlyValue() {
+ String design = "<v-text-field readonly=\"\" value=\"test value\"/>";
+ TextField tf = new TextField();
+ tf.setValue("test value");
+ tf.setReadOnly(true);
+ testRead(design, tf);
+ testWrite(design, tf);
+ }
}