summaryrefslogtreecommitdiffstats
path: root/server/tests/src/com/vaadin
diff options
context:
space:
mode:
authortapio <tapio@vaadin.com>2012-11-08 13:32:06 +0200
committertapio <tapio@vaadin.com>2012-11-08 13:32:06 +0200
commit9b69534bc46e01f5a762284542db460930de44fa (patch)
tree4a192ecb96e7edf5c4305aa0bab5bf5dfa889380 /server/tests/src/com/vaadin
parente8ae9f7d6427f7f6daae300dee7931a6e8394bdb (diff)
downloadvaadin-framework-9b69534bc46e01f5a762284542db460930de44fa.tar.gz
vaadin-framework-9b69534bc46e01f5a762284542db460930de44fa.zip
Modified FieldGroup so that fields configured with read only properties
will also be made read only (#9076). Change-Id: I183ae263f4952a51513623d38dc9e04ce1482f45
Diffstat (limited to 'server/tests/src/com/vaadin')
-rw-r--r--server/tests/src/com/vaadin/tests/data/bean/BeanWithReadOnlyField.java18
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/fieldgroup/FieldGroupWithReadOnlyPropertiesTest.java51
2 files changed, 69 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/data/bean/BeanWithReadOnlyField.java b/server/tests/src/com/vaadin/tests/data/bean/BeanWithReadOnlyField.java
new file mode 100644
index 0000000000..77f5613f86
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/data/bean/BeanWithReadOnlyField.java
@@ -0,0 +1,18 @@
+package com.vaadin.tests.data.bean;
+
+public class BeanWithReadOnlyField {
+ private String readOnlyField;
+ private String writableField;
+
+ public String getWritableField() {
+ return writableField;
+ }
+
+ public void setWritableField(String writableField) {
+ this.writableField = writableField;
+ }
+
+ public String getReadOnlyField() {
+ return readOnlyField;
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/FieldGroupWithReadOnlyPropertiesTest.java b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/FieldGroupWithReadOnlyPropertiesTest.java
new file mode 100644
index 0000000000..60a92d7d73
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/FieldGroupWithReadOnlyPropertiesTest.java
@@ -0,0 +1,51 @@
+package com.vaadin.tests.server.component.fieldgroup;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.vaadin.data.fieldgroup.FieldGroup;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.tests.data.bean.BeanWithReadOnlyField;
+import com.vaadin.ui.TextField;
+
+public class FieldGroupWithReadOnlyPropertiesTest {
+
+ private TextField readOnlyField = new TextField();
+ private TextField writableField = new TextField();
+
+ @Test
+ public void bindReadOnlyPropertyToFieldGroup() {
+ BeanWithReadOnlyField bean = new BeanWithReadOnlyField();
+ BeanItem<BeanWithReadOnlyField> beanItem = new BeanItem<BeanWithReadOnlyField>(
+ bean);
+ beanItem.getItemProperty("readOnlyField").setReadOnly(true);
+
+ FieldGroup fieldGroup = new FieldGroup(beanItem);
+ fieldGroup.bindMemberFields(this);
+
+ assertTrue(readOnlyField.isReadOnly());
+ assertFalse(writableField.isReadOnly());
+ }
+
+ @Test
+ public void fieldGroupSetReadOnlyTest() {
+ BeanWithReadOnlyField bean = new BeanWithReadOnlyField();
+ BeanItem<BeanWithReadOnlyField> beanItem = new BeanItem<BeanWithReadOnlyField>(
+ bean);
+ beanItem.getItemProperty("readOnlyField").setReadOnly(true);
+
+ FieldGroup fieldGroup = new FieldGroup(beanItem);
+ fieldGroup.bindMemberFields(this);
+
+ fieldGroup.setReadOnly(true);
+ assertTrue(readOnlyField.isReadOnly());
+ assertTrue(writableField.isReadOnly());
+
+ fieldGroup.setReadOnly(false);
+ assertTrue(readOnlyField.isReadOnly());
+ assertFalse(writableField.isReadOnly());
+ }
+
+}