aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2016-10-27 16:13:44 +0300
committerVaadin Code Review <review@vaadin.com>2016-11-01 10:26:33 +0000
commit48c249a13ecca8c4c8bd68814850e5e3cdd37d81 (patch)
treeb1f066b2bdd48b09b38b27bd677abba1b0d5d5fc /uitest
parent92d697b9886896f1dad41026ba3519563838f93e (diff)
downloadvaadin-framework-48c249a13ecca8c4c8bd68814850e5e3cdd37d81.tar.gz
vaadin-framework-48c249a13ecca8c4c8bd68814850e5e3cdd37d81.zip
Replace setRequired & HasRequired with setRequiredIndicator
Vaadin 7 compatiblity fields still use setRequired via AbstractField (legacy). Public setRequiredIndicator is added to AbstractField, AbstractMultiSelect and AbstractSingleSelect. Internally it is still handled on AbstractComponent & -Connector level. Changes the declarative syntax, required -> required-indicator-visible. Fixes vaadin/framework8-issue#419 Change-Id: I940dc66944d27584bd78e5452aee627ee3abd03a
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java8
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/ComponentTestCase.java6
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java9
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java30
-rw-r--r--uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java2
7 files changed, 33 insertions, 26 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java
index 8dce9c73e2..f34c663029 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java
@@ -5,7 +5,7 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
-import com.vaadin.data.HasRequired;
+import com.vaadin.data.HasValue;
import com.vaadin.server.Resource;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.UserError;
@@ -109,8 +109,10 @@ public abstract class AbstractComponentTestCase<T extends AbstractComponent>
// TODO Move to AbstractFieldTestCase
protected Command<T, Boolean> requiredCommand = (c, enabled, data) -> {
- if (c instanceof HasRequired) {
- ((HasRequired) c).setRequired(enabled);
+ if (c instanceof HasValue) {
+ ((HasValue) c).setRequiredIndicatorVisible(enabled);
+ } else if (c instanceof Field) {
+ ((Field) c).setRequired(enabled);
} else {
throw new IllegalArgumentException(c.getClass().getName()
+ " is not a field and cannot be set to required");
diff --git a/uitest/src/main/java/com/vaadin/tests/components/ComponentTestCase.java b/uitest/src/main/java/com/vaadin/tests/components/ComponentTestCase.java
index 1010a42e7d..591bf599cb 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/ComponentTestCase.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/ComponentTestCase.java
@@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
-import com.vaadin.data.HasRequired;
+import com.vaadin.data.HasValue;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Alignment;
@@ -13,6 +13,7 @@ import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.v7.data.Item;
+import com.vaadin.v7.ui.Field;
import com.vaadin.v7.ui.NativeSelect;
public abstract class ComponentTestCase<T extends AbstractComponent>
@@ -71,7 +72,8 @@ public abstract class ComponentTestCase<T extends AbstractComponent>
actions.add(createReadonlyAction(false));
actions.add(createErrorIndicatorAction(false));
- if (HasRequired.class.isAssignableFrom(getTestClass())) {
+ if (HasValue.class.isAssignableFrom(getTestClass())
+ || Field.class.isAssignableFrom(getTestClass())) {
actions.add(createRequiredAction(false));
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java
index d08194681e..794db5e096 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java
@@ -15,7 +15,7 @@ public class DatePopupStyleName extends TestBase {
final AbstractDateField df = new TestDateField();
df.setValue(LocalDate.of(1970, 1, 15));
df.setWidth("200px");
- df.setRequired(true);
+ df.setRequiredIndicatorVisible(true);
df.setComponentError(new UserError("abc"));
df.addStyleName("popup-style");
addComponent(df);
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java
index b995fe9093..5c8788f53e 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java
@@ -3,7 +3,7 @@ package com.vaadin.tests.layouts;
import java.util.ArrayList;
import java.util.List;
-import com.vaadin.data.HasRequired;
+import com.vaadin.data.HasValue;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.UserError;
import com.vaadin.tests.components.TestBase;
@@ -24,6 +24,7 @@ import com.vaadin.ui.VerticalLayout;
import com.vaadin.v7.data.Item;
import com.vaadin.v7.data.Property.ValueChangeEvent;
import com.vaadin.v7.data.Property.ValueChangeListener;
+import com.vaadin.v7.ui.Field;
import com.vaadin.v7.ui.NativeSelect;
import com.vaadin.v7.ui.OptionGroup;
import com.vaadin.v7.ui.PasswordField;
@@ -140,8 +141,10 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
protected void setRequired(boolean value) {
for (AbstractComponent c : components) {
- if (c instanceof HasRequired) {
- ((HasRequired) c).setRequired(value);
+ if (c instanceof HasValue) {
+ ((HasValue) c).setRequiredIndicatorVisible(value);
+ } else if (c instanceof Field) {
+ ((Field) c).setRequired(value);
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java b/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java
index f06db44b5c..6c7b112910 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java
@@ -25,7 +25,7 @@ public class FormLayoutWithInvisibleComponent extends TestBase {
CheckBox control = new CheckBox("Messages On/Off");
control.addValueChangeListener(event -> {
messages.setVisible(event.getValue());
- messages.setRequired(true);
+ messages.setRequiredIndicatorVisible(true);
messages.setCaption("Messages visible");
});
formLayout.addComponent(control);
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java b/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java
index 4d1f0213c4..112965d06a 100644
--- a/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java
+++ b/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java
@@ -343,7 +343,7 @@ public class OrderedLayoutBasics extends TestBase {
tf = new TextArea("100% high TextField");
tf.setCaption(null);
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
tf.setValue("100% high Field");
tf.setHeight("100%");
tf.setWidth("100px");
@@ -352,7 +352,7 @@ public class OrderedLayoutBasics extends TestBase {
tf = new TextArea("100% high TextField");
tf.setCaption("100% high TextField");
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
tf.setValue("100% high Field");
tf.setHeight("100%");
tf.setWidth("100px");
@@ -602,7 +602,7 @@ public class OrderedLayoutBasics extends TestBase {
tf.setValue("60% x 100% TextField");
tf.setWidth("100%");
tf.setHeight("100%");
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
// tf.setComponentError(new UserError("It's broken!"));
// tf.setHeight("100%");
@@ -617,7 +617,7 @@ public class OrderedLayoutBasics extends TestBase {
tf.setValue("60% x 60% TextField");
tf.setWidth("100%");
tf.setHeight("60%");
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
ol.addComponent(tf);
ol.setExpandRatio(tf, 1f);
ol.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
@@ -696,7 +696,7 @@ public class OrderedLayoutBasics extends TestBase {
tf.setValue("200x200 TextField");
tf.setWidth("200px");
tf.setHeight("200px");
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
// tf.setComponentError(new UserError("It's broken!"));
// tf.setHeight("100%");
@@ -723,9 +723,9 @@ public class OrderedLayoutBasics extends TestBase {
tf = new TextArea("200x200px Field");
tf.setCaption("This one has a caption");
tf.setWidth("200px");
- tf.setHeight(((i + 1) * 50) + "px");
+ tf.setHeight((i + 1) * 50 + "px");
tf.setValue(tf.getWidth() + "x" + tf.getHeight() + " TextField");
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
// tf.setComponentError(new UserError("It's broken!"));
// tf.setHeight("100%");
@@ -814,7 +814,7 @@ public class OrderedLayoutBasics extends TestBase {
tf = new TextField(
"A very long caption which is probably much longer than the field and includes indicators");
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
tf.setComponentError(new UserError("abc123"));
ol.addComponent(tf);
@@ -852,7 +852,7 @@ public class OrderedLayoutBasics extends TestBase {
tf = new TextField(
"A long caption which is probably much longer than the field");
tf.setValue("Undefined width");
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
tf.setComponentError(new UserError("123"));
ol.addComponent(tf);
ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -861,7 +861,7 @@ public class OrderedLayoutBasics extends TestBase {
"A very long caption which is probably much longer than the field and includes indicators");
tf.setValue("Undefined width");
tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
tf.setComponentError(new UserError("abc123"));
ol.addComponent(tf);
ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -905,7 +905,7 @@ public class OrderedLayoutBasics extends TestBase {
"A long caption which is probably much longer than the field");
tf.setValue("100% wide field, ratio 2");
tf.setSizeFull();
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
tf.setComponentError(new UserError("123"));
ol.addComponent(tf);
ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -916,7 +916,7 @@ public class OrderedLayoutBasics extends TestBase {
tf.setValue("100% wide field, ratio 3");
tf.setSizeFull();
tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
tf.setComponentError(new UserError("abc123"));
ol.addComponent(tf);
ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -959,7 +959,7 @@ public class OrderedLayoutBasics extends TestBase {
"A long caption which is probably much longer than the field");
tf.setWidth("250px");
tf.setValue("250px wide field");
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
tf.setComponentError(new UserError("123"));
ol.addComponent(tf);
ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -969,7 +969,7 @@ public class OrderedLayoutBasics extends TestBase {
tf.setValue("200px wide field");
tf.setWidth("200px");
tf.setIcon(new ThemeResource("icons/16/document-add.png"));
- tf.setRequired(true);
+ tf.setRequiredIndicatorVisible(true);
tf.setComponentError(new UserError("abc123"));
ol.addComponent(tf);
ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT);
@@ -1209,7 +1209,7 @@ public class OrderedLayoutBasics extends TestBase {
ta.setValue("60% x 100% TextField");
ta.setWidth("60%");
ta.setHeight("100%");
- ta.setRequired(true);
+ ta.setRequiredIndicatorVisible(true);
ta.setRows(2);
ol.addComponent(ta);
diff --git a/uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java b/uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java
index bd9df1e8f8..db29239bf3 100644
--- a/uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java
+++ b/uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java
@@ -26,7 +26,7 @@ public class CheckBoxWithPropertyDataSource extends CheckBox {
}
public void validate() {
- if (isRequired() && !getValue()) {
+ if (isRequiredIndicatorVisible() && !getValue()) {
throw new InvalidValueException(
"Required CheckBox should be checked");
}