import org.junit.Test;
import com.vaadin.shared.ui.slider.SliderOrientation;
-import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.tests.server.component.abstractfield.AbstractFieldDeclarativeTest;
import com.vaadin.ui.Slider;
/**
* @since
* @author Vaadin Ltd
*/
-public class SliderDeclarativeTest extends DeclarativeTestBase<Slider> {
+public class SliderDeclarativeTest
+ extends AbstractFieldDeclarativeTest<Slider, Double> {
+ @Override
@Test
- public void testDefault() {
- String design = "<vaadin-slider>";
+ public void valueDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ Double value = 12.3;
+ int resolution = 1;
+ String design = String.format("<%s resolution=%d value='%s'/>",
+ getComponentTag(), resolution, value);
- Slider expected = new Slider();
+ Slider component = new Slider();
+ component.setResolution(resolution);
+ component.setValue(value);
- testRead(design, expected);
- testWrite(design, expected);
+ testRead(design, component);
+ testWrite(design, component);
}
@Test
- public void testHorizontal() {
- String design = "<vaadin-slider min=10 max=20 resolution=1 value=12.3>";
+ public void testVertical() {
+ String design = "<vaadin-slider vertical>";
Slider expected = new Slider();
- expected.setMin(10.0);
- expected.setMax(20.0);
- expected.setResolution(1);
- expected.setValue(12.3);
+ expected.setOrientation(SliderOrientation.VERTICAL);
testRead(design, expected);
testWrite(design, expected);
}
- @Test
- public void testVertical() {
- String design = "<vaadin-slider vertical>";
+ @Override
+ public void readOnlyValue()
+ throws InstantiationException, IllegalAccessException {
+ Double value = 12.3;
+ int resolution = 1;
+ String design = String.format("<%s resolution=%d readonly value='%s'/>",
+ getComponentTag(), resolution, value);
- Slider expected = new Slider();
- expected.setOrientation(SliderOrientation.VERTICAL);
+ Slider component = new Slider();
+ component.setResolution(resolution);
+ component.setValue(value);
- testRead(design, expected);
- testWrite(design, expected);
+ component.setReadOnly(true);
+ testRead(design, component);
+ testWrite(design, component);
}
@Test
- public void testReadOnlyValue() {
- String design = "<vaadin-slider readonly min=10 max=20 resolution=1 value=12.3>";
+ public void remainingAttributeDeserialization() {
+ int min = 3;
+ int max = 47;
+ String design = String.format("<%s min=%d value=%d max='%d'/>",
+ getComponentTag(), min, min, max);
- Slider expected = new Slider();
- expected.setMin(10.0);
- expected.setMax(20.0);
- expected.setResolution(1);
- expected.setValue(12.3);
- expected.setReadOnly(true);
+ Slider component = new Slider();
+ component.setMin(min);
+ component.setMax(max);
+ component.setOrientation(SliderOrientation.HORIZONTAL);
- testRead(design, expected);
- testWrite(design, expected);
+ testRead(design, component);
+ testWrite(design, component);
}
+
+ @Override
+ protected String getComponentTag() {
+ return "vaadin-slider";
+ }
+
+ @Override
+ protected Class<Slider> getComponentClass() {
+ return Slider.class;
+ }
+
}
--- /dev/null
+/*
+ * Copyright 2000-2016 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.abstractcomponent;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.Locale;
+
+import org.junit.Test;
+
+import com.vaadin.server.ErrorMessage.ErrorLevel;
+import com.vaadin.server.ExternalResource;
+import com.vaadin.server.FileResource;
+import com.vaadin.server.ThemeResource;
+import com.vaadin.server.UserError;
+import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Abstract test class which contains tests for declarative format for
+ * properties that are common for AbstractComponent.
+ * <p>
+ * It's an abstract so it's not supposed to be run as is. Instead each
+ * declarative test for a real component should extend it and implement abstract
+ * methods to be able to test the common properties. Components specific
+ * properties should be tested additionally in the subclasses implementations.
+ *
+ * @author Vaadin Ltd
+ *
+ */
+public abstract class AbstractComponentDeclarativeTestBase<T extends AbstractComponent>
+ extends DeclarativeTestBase<T> {
+
+ /**
+ * Returns expected element tag for the tested component.
+ *
+ * @return expected element tag
+ */
+ protected abstract String getComponentTag();
+
+ /**
+ * Returns component class which is a subject to test
+ *
+ * @return the component class
+ */
+ protected abstract Class<? extends T> getComponentClass();
+
+ @Test
+ public void emptyAbstractComponentDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String design = String.format("<%s/> ", getComponentTag());
+ T component = getComponentClass().newInstance();
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void abstractComponentAttributesDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String id = "testId";
+ String caption = "testCaption";
+ boolean captionAsHtml = true;
+ String description = "testDescription";
+ boolean enabled = false;
+ String error = "<div>testError</div>";
+ String height = "47%";
+ String width = "83px";
+ String icon = "img/example.gif";
+ Locale locale = new Locale("fi", "FI");
+ String primaryStyle = "testPrimaryStyle";
+ boolean readOnly = true;
+ boolean responsive = true;
+ String styleName = "testStyleName";
+ boolean visible = false;
+
+ String design = String.format(
+ "<%s id='%s' caption='%s' caption-as-html description='%s' "
+ + "error='%s' enabled='false' width='%s' height='%s' "
+ + "icon='%s' locale='%s' primary-style-name='%s' "
+ + "readonly responsive style-name='%s' visible='false'/>",
+ getComponentTag(), id, caption, description, error, width,
+ height, icon, locale.toString(), primaryStyle, styleName);
+
+ T component = getComponentClass().newInstance();
+ component.setId(id);
+ component.setCaption(caption);
+ component.setCaptionAsHtml(captionAsHtml);
+ component.setDescription(description);
+ component.setEnabled(enabled);
+ component.setComponentError(new UserError(error,
+ com.vaadin.server.AbstractErrorMessage.ContentMode.HTML,
+ ErrorLevel.ERROR));
+ component.setHeight(height);
+ component.setWidth(width);
+ component.setIcon(new FileResource(new File(icon)));
+ component.setLocale(locale);
+ component.setPrimaryStyleName(primaryStyle);
+ component.setReadOnly(readOnly);
+ component.setResponsive(responsive);
+ component.setStyleName(styleName);
+ component.setVisible(visible);
+
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void externalIcon()
+ throws InstantiationException, IllegalAccessException {
+ String url = "http://example.com/example.gif";
+
+ String design = String.format("<%s icon='%s'/>", getComponentTag(),
+ url);
+
+ T component = getComponentClass().newInstance();
+
+ component.setIcon(new ExternalResource(url));
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void themeIcon()
+ throws InstantiationException, IllegalAccessException {
+ String path = "example.gif";
+
+ String design = String.format("<%s icon='theme://%s'/>",
+ getComponentTag(), path);
+
+ T component = getComponentClass().newInstance();
+
+ component.setIcon(new ThemeResource(path));
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void sizeFullDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String design = String.format("<%s size-full/>", getComponentTag());
+
+ T component = getComponentClass().newInstance();
+
+ component.setSizeFull();
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void widthFullDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String design = String.format("<%s width-full/>", getComponentTag());
+
+ T component = getComponentClass().newInstance();
+
+ component.setWidth("100%");
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void heightFullDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String design = String.format("<%s height-full/>", getComponentTag());
+
+ T component = getComponentClass().newInstance();
+
+ component.setHeight("100%");
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void sizeUnderfinedDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String design = String.format("<%s/>", getComponentTag());
+
+ T component = getComponentClass().newInstance();
+
+ component.setSizeUndefined();
+ testRead(design, component);
+ testWrite(design, component);
+
+ }
+
+ @Test
+ public void heightUnderfinedDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String design = String.format("<%s/>", getComponentTag());
+
+ T component = getComponentClass().newInstance();
+
+ component.setHeightUndefined();
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void widthUnderfinedDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String design = String.format("<%s/>", getComponentTag());
+
+ T component = getComponentClass().newInstance();
+
+ component.setWidthUndefined();
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testUnknownAttribute() {
+ String value = "bar";
+ String design = String.format("<%s foo='%s'/>", getComponentTag(),
+ value);
+
+ DesignContext context = readAndReturnContext(design);
+ T label = getComponentClass().cast(context.getRootComponent());
+ assertTrue("Custom attribute was preserved in custom attributes",
+ context.getCustomAttributes(label).containsKey("foo"));
+
+ testWrite(label, design, context);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 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.abstractdatefield;
+
+import java.time.LocalDate;
+import java.util.Locale;
+
+import org.junit.Test;
+
+import com.vaadin.shared.ui.datefield.Resolution;
+import com.vaadin.tests.server.component.abstractfield.AbstractFieldDeclarativeTest;
+import com.vaadin.ui.AbstractDateField;
+
+/**
+ * Abstract test class which contains tests for declarative format for
+ * properties that are common for AbstractDateField.
+ * <p>
+ * It's an abstract so it's not supposed to be run as is. Instead each
+ * declarative test for a real component should extend it and implement abstract
+ * methods to be able to test the common properties. Components specific
+ * properties should be tested additionally in the subclasses implementations.
+ *
+ * @author Vaadin Ltd
+ *
+ */
+public abstract class AbstarctDateFieldDeclarativeTest<T extends AbstractDateField>
+ extends AbstractFieldDeclarativeTest<T, LocalDate> {
+
+ @Override
+ public void valueDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ LocalDate value = LocalDate.of(2003, 02, 27);
+ String design = String.format("<%s value='%s'/>", getComponentTag(),
+ value);
+
+ T component = getComponentClass().newInstance();
+ component.setValue(value);
+
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void abstractDateFieldAttributesDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ boolean showIsoWeeks = true;
+ LocalDate end = LocalDate.of(2019, 01, 15);
+ LocalDate start = LocalDate.of(2001, 02, 11);
+ String dateOutOfRange = "test date out of range";
+ Resolution resolution = Resolution.MONTH;
+ String dateFormat = "test format";
+ boolean lenient = true;
+ String parseErrorMsg = "test parse error";
+ String design = String.format(
+ "<%s show-iso-week-numbers range-end='%s' range-start='%s' "
+ + "date-out-of-range-message='%s' resolution='%s' "
+ + "date-format='%s' lenient parse-error-message='%s'/>",
+ getComponentTag(), end, start, dateOutOfRange,
+ resolution.name().toLowerCase(Locale.ENGLISH), dateFormat,
+ parseErrorMsg);
+
+ T component = getComponentClass().newInstance();
+
+ component.setShowISOWeekNumbers(showIsoWeeks);
+ component.setRangeEnd(end);
+ component.setRangeStart(start);
+ component.setDateOutOfRangeMessage(dateOutOfRange);
+ component.setResolution(resolution);
+ component.setDateFormat(dateFormat);
+ component.setLenient(lenient);
+ component.setParseErrorMessage(parseErrorMsg);
+
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Override
+ public void readOnlyValue()
+ throws InstantiationException, IllegalAccessException {
+ LocalDate value = LocalDate.of(2003, 02, 27);
+ String design = String.format("<%s value='%s' readonly/>",
+ getComponentTag(), value);
+
+ T component = getComponentClass().newInstance();
+ component.setValue(value);
+ component.setReadOnly(true);
+
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 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.abstractfield;
+
+import org.junit.Test;
+
+import com.vaadin.tests.server.component.abstractcomponent.AbstractComponentDeclarativeTestBase;
+import com.vaadin.ui.AbstractField;
+
+/**
+ * Abstract test class which contains tests for declarative format for
+ * properties that are common for AbstractField.
+ * <p>
+ * It's an abstract so it's not supposed to be run as is. Instead each
+ * declarative test for a real component should extend it and implement abstract
+ * methods to be able to test the common properties. Components specific
+ * properties should be tested additionally in the subclasses implementations.
+ *
+ * @author Vaadin Ltd
+ *
+ */
+public abstract class AbstractFieldDeclarativeTest<T extends AbstractField<V>, V>
+ extends AbstractComponentDeclarativeTestBase<T> {
+
+ @Test
+ public void requiredDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ boolean isRequired = true;
+ String design = String.format("<%s required/>", getComponentTag());
+
+ T component = getComponentClass().newInstance();
+ component.setRequired(isRequired);
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void tabIndexDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ int tabIndex = 13;
+ String design = String.format("<%s tabindex='%s'/>", getComponentTag(),
+ tabIndex);
+
+ T component = getComponentClass().newInstance();
+ component.setTabIndex(tabIndex);
+
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ public abstract void valueDeserialization()
+ throws InstantiationException, IllegalAccessException;
+
+ public abstract void readOnlyValue()
+ throws InstantiationException, IllegalAccessException;
+}
*/
package com.vaadin.tests.server.component.abstracttextfield;
+import java.util.Locale;
+
import org.junit.Test;
import com.vaadin.shared.ui.ValueChangeMode;
-import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.tests.server.component.abstractfield.AbstractFieldDeclarativeTest;
import com.vaadin.ui.AbstractTextField;
-import com.vaadin.ui.TextField;
/**
* Tests declarative support for AbstractTextField.
* @since
* @author Vaadin Ltd
*/
-public class AbstractTextFieldDeclarativeTest
- extends DeclarativeTestBase<AbstractTextField> {
+public abstract class AbstractTextFieldDeclarativeTest<T extends AbstractTextField>
+ extends AbstractFieldDeclarativeTest<T, String> {
@Test
- public void testAttributes() {
- String design = "<vaadin-text-field "
- // + "null-representation=this-is-null "
- // + "null-setting-allowed "
- + "maxlength=5 " + "placeholder=input value-change-mode=eager "
- + "value-change-timeout=100 />";
- AbstractTextField tf = new TextField();
- // FIXME
- // tf.setNullRepresentation("this-is-null");
- // tf.setNullSettingAllowed(true);
- tf.setMaxLength(5);
- tf.setPlaceholder("input");
- tf.setValueChangeMode(ValueChangeMode.EAGER);
- tf.setValueChangeTimeout(100);
- testRead(design, tf);
- testWrite(design, tf);
+ public void abstractTextFieldAttributes()
+ throws InstantiationException, IllegalAccessException {
+ int maxLength = 5;
+ String placeholder = "foo";
+ ValueChangeMode mode = ValueChangeMode.EAGER;
+ int timeout = 100;
+ String design = String.format(
+ "<%s maxlength='%d' placeholder='%s' "
+ + "value-change-mode='%s' value-change-timeout='%d'/>",
+ getComponentTag(), maxLength, placeholder,
+ mode.name().toLowerCase(Locale.ENGLISH), timeout);
+
+ T component = getComponentClass().newInstance();
+
+ component.setMaxLength(maxLength);
+ component.setPlaceholder(placeholder);
+ component.setValueChangeMode(mode);
+ component.setValueChangeTimeout(timeout);
+
+ testRead(design, component);
+ testWrite(design, component);
}
}
*/
package com.vaadin.tests.server.component.checkbox;
-import org.junit.Test;
-
-import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.tests.server.component.abstractfield.AbstractFieldDeclarativeTest;
import com.vaadin.ui.CheckBox;
/**
* @since 7.4
* @author Vaadin Ltd
*/
-public class CheckboxDeclarativeTest extends DeclarativeTestBase<CheckBox> {
-
- @Test
- public void testChecked() {
- String design = "<vaadin-check-box />";
- CheckBox checkBox = new CheckBox();
- testRead(design, checkBox);
- testWrite(design, checkBox);
- }
+public class CheckboxDeclarativeTest
+ extends AbstractFieldDeclarativeTest<CheckBox, Boolean> {
- @Test
- public void testUnchecked() {
+ @Override
+ public void valueDeserialization()
+ throws InstantiationException, IllegalAccessException {
String design = "<vaadin-check-box checked />";
CheckBox checkBox = new CheckBox();
+
checkBox.setValue(true);
+
testRead(design, checkBox);
testWrite(design, checkBox);
}
- @Test
- public void testReadOnlyValue() {
+ @Override
+ public void readOnlyValue()
+ throws InstantiationException, IllegalAccessException {
String design = "<vaadin-check-box readonly checked />";
+
CheckBox checkBox = new CheckBox();
+
checkBox.setValue(true);
checkBox.setReadOnly(true);
+
testRead(design, checkBox);
testWrite(design, checkBox);
}
+
+ @Override
+ protected String getComponentTag() {
+ return "vaadin-check-box";
+ }
+
+ @Override
+ protected Class<CheckBox> getComponentClass() {
+ return CheckBox.class;
+ }
+
}
import org.junit.Test;
import com.vaadin.shared.ui.colorpicker.Color;
-import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.tests.server.component.abstractfield.AbstractFieldDeclarativeTest;
import com.vaadin.ui.AbstractColorPicker;
import com.vaadin.ui.AbstractColorPicker.PopupStyle;
-import com.vaadin.ui.ColorPicker;
-import com.vaadin.ui.ColorPickerArea;
-public class AbstractColorPickerDeclarativeTest
- extends DeclarativeTestBase<AbstractColorPicker> {
+/**
+ * Abstract test class which contains tests for declarative format for
+ * properties that are common for AbstractColorPicker.
+ * <p>
+ * It's an abstract so it's not supposed to be run as is. Instead each
+ * declarative test for a real component should extend it and implement abstract
+ * methods to be able to test the common properties. Components specific
+ * properties should be tested additionally in the subclasses implementations.
+ *
+ * @author Vaadin Ltd
+ *
+ */
+public abstract class AbstractColorPickerDeclarativeTest<T extends AbstractColorPicker>
+ extends AbstractFieldDeclarativeTest<T, Color> {
@Test
- public void testAllAbstractColorPickerFeatures() {
- String design = "<vaadin-color-picker color='#fafafa' default-caption-enabled position='100,100'"
- + " popup-style='simple' rgb-visibility='false' hsv-visibility='false'"
- + " history-visibility=false textfield-visibility=false />";
- ColorPicker colorPicker = new ColorPicker();
- int colorInt = Integer.parseInt("fafafa", 16);
- colorPicker.setValue(new Color(colorInt));
- colorPicker.setDefaultCaptionEnabled(true);
- colorPicker.setPosition(100, 100);
- colorPicker.setPopupStyle(PopupStyle.POPUP_SIMPLE);
- colorPicker.setRGBVisibility(false);
- colorPicker.setHSVVisibility(false);
- colorPicker.setSwatchesVisibility(true);
- colorPicker.setHistoryVisibility(false);
- colorPicker.setTextfieldVisibility(false);
+ public void testAllAbstractColorPickerFeatures()
+ throws InstantiationException, IllegalAccessException {
+ boolean defaultCaption = true;
+ PopupStyle popupStyle = PopupStyle.POPUP_SIMPLE;
+ int x = 79;
+ int y = 91;
+ boolean rgbVisibility = false;
+ boolean hsvVisibility = false;
+ boolean swatchesVisibility = true;
+ boolean historyVisibility = false;
+ boolean textFieldVisibility = false;
+ String design = String.format(
+ "<%s default-caption-enabled position='%s,%s'"
+ + " popup-style='%s' rgb-visibility='%s' hsv-visibility='%s' "
+ + "history-visibility='%s' textfield-visibility='%s'/>",
+ getComponentTag(), x, y, popupStyle.toString(), rgbVisibility,
+ hsvVisibility, historyVisibility, textFieldVisibility);
+
+ T colorPicker = getComponentClass().newInstance();
+
+ colorPicker.setDefaultCaptionEnabled(defaultCaption);
+ colorPicker.setPosition(x, y);
+ colorPicker.setPopupStyle(popupStyle);
+ colorPicker.setRGBVisibility(rgbVisibility);
+ colorPicker.setHSVVisibility(hsvVisibility);
+ colorPicker.setSwatchesVisibility(swatchesVisibility);
+ colorPicker.setHistoryVisibility(historyVisibility);
+ colorPicker.setTextfieldVisibility(textFieldVisibility);
testWrite(design, colorPicker);
testRead(design, colorPicker);
}
- @Test
- public void testEmptyColorPicker() {
- String design = "<vaadin-color-picker />";
- ColorPicker colorPicker = new ColorPicker();
- testRead(design, colorPicker);
- testWrite(design, colorPicker);
- }
+ @Override
+ public void valueDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String rgb = "fafafa";
+ String design = String.format("<%s color='#%s'/>", getComponentTag());
+
+ T colorPicker = getComponentClass().newInstance();
+ int colorInt = Integer.parseInt(rgb, 16);
- @Test
- public void testAllAbstractColorPickerAreaFeatures() {
- String design = "<vaadin-color-picker-area color='#fafafa' default-caption-enabled position='100,100'"
- + " popup-style='simple' rgb-visibility='false' hsv-visibility='false'"
- + " history-visibility=false textfield-visibility=false />";
- AbstractColorPicker colorPicker = new ColorPickerArea();
- int colorInt = Integer.parseInt("fafafa", 16);
colorPicker.setValue(new Color(colorInt));
- colorPicker.setDefaultCaptionEnabled(true);
- colorPicker.setPosition(100, 100);
- colorPicker.setPopupStyle(PopupStyle.POPUP_SIMPLE);
- colorPicker.setRGBVisibility(false);
- colorPicker.setHSVVisibility(false);
- colorPicker.setSwatchesVisibility(true);
- colorPicker.setHistoryVisibility(false);
- colorPicker.setTextfieldVisibility(false);
testWrite(design, colorPicker);
testRead(design, colorPicker);
}
- @Test
- public void testEmptyColorPickerArea() {
- String design = "<vaadin-color-picker-area />";
- AbstractColorPicker colorPicker = new ColorPickerArea();
- testRead(design, colorPicker);
+ @Override
+ public void readOnlyValue()
+ throws InstantiationException, IllegalAccessException {
+ String rgb = "fafafa";
+ String design = String.format("<%s color='#%s' readonly/>",
+ getComponentTag());
+
+ T colorPicker = getComponentClass().newInstance();
+ int colorInt = Integer.parseInt(rgb, 16);
+
+ colorPicker.setValue(new Color(colorInt));
+ colorPicker.setReadOnly(true);
+
testWrite(design, colorPicker);
+ testRead(design, colorPicker);
}
+
}
--- /dev/null
+/*
+ * Copyright 2000-2016 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.colorpicker;
+
+import com.vaadin.ui.ColorPickerArea;
+
+/**
+ * Declarative test for ColorPickerArea. Provides only information about
+ * ColorPickerArea class. All tests are in the superclass.
+ *
+ * @author Vaadin Ltd
+ *
+ */
+public class ColorPickerAreaDeclarativeTest
+ extends AbstractColorPickerDeclarativeTest<ColorPickerArea> {
+
+ @Override
+ protected String getComponentTag() {
+ return "vaadin-color-picker-area";
+ }
+
+ @Override
+ protected Class<ColorPickerArea> getComponentClass() {
+ return ColorPickerArea.class;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2000-2016 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.colorpicker;
+
+import com.vaadin.ui.ColorPicker;
+
+/**
+ * Declarative test for ColorPicker. Provides only information about
+ * ColorPickerArea class. All tests are in the superclass.
+ *
+ * @author Vaadin Ltd
+ *
+ */
+public class ColorPickerDeclarativeTest
+ extends AbstractColorPickerDeclarativeTest<ColorPicker> {
+
+ @Override
+ protected String getComponentTag() {
+ return "vaadin-color-picker";
+ }
+
+ @Override
+ protected Class<ColorPicker> getComponentClass() {
+ return ColorPicker.class;
+ }
+
+}
*/
package com.vaadin.tests.server.component.datefield;
-import java.time.LocalDate;
-
import org.junit.Test;
-import com.vaadin.tests.design.DeclarativeTestBase;
-import com.vaadin.ui.AbstractDateField;
+import com.vaadin.tests.server.component.abstractdatefield.AbstarctDateFieldDeclarativeTest;
import com.vaadin.ui.DateField;
/**
- * Tests the declarative support for implementations of
- * {@link AbstractDateField}.
+ * Tests the declarative support for implementations of {@link DateField}.
*
* @since 7.4
* @author Vaadin Ltd
*/
-public class DateFieldDeclarativeTest extends DeclarativeTestBase<DateField> {
-
- private String getBasicDesign() {
- return "<vaadin-date-field assistive-text='at' text-field-enabled='false' show-iso-week-numbers range-end=\"2019-01-15\" placeholder=\"Pick a day\" value=\"2003-02-27\"></vaadin-date-field>";
- }
+public class DateFieldDeclarativeTest
+ extends AbstarctDateFieldDeclarativeTest<DateField> {
- private DateField getBasicExpected() {
- DateField pdf = new DateField();
- pdf.setShowISOWeekNumbers(true);
- pdf.setRangeEnd(LocalDate.of(2019, 01, 15));
- pdf.setPlaceholder("Pick a day");
- pdf.setValue(LocalDate.of(2003, 2, 27));
- pdf.setTextFieldEnabled(false);
- pdf.setAssistiveText("at");
- return pdf;
+ @Test
+ public void remainingAttributes()
+ throws InstantiationException, IllegalAccessException {
+ String placeholder = "foo";
+ String assistiveText = "at";
+ boolean textFieldEnabled = false;
+ String design = String.format(
+ "<%s placeholder='%s' "
+ + "assistive-text='%s' text-field-enabled='%s'/>",
+ getComponentTag(), placeholder, assistiveText,
+ textFieldEnabled);
+
+ DateField component = getComponentClass().newInstance();
+ component.setPlaceholder(placeholder);
+ component.setTextFieldEnabled(textFieldEnabled);
+ component.setAssistiveText(assistiveText);
+
+ testRead(design, component);
+ testWrite(design, component);
}
- @Test
- public void readBasic() throws Exception {
- testRead(getBasicDesign(), getBasicExpected());
+ @Override
+ protected String getComponentTag() {
+ return "vaadin-date-field";
}
- @Test
- public void writeBasic() throws Exception {
- testRead(getBasicDesign(), getBasicExpected());
+ @Override
+ protected Class<? extends DateField> getComponentClass() {
+ return DateField.class;
}
}
import org.junit.Test;
-import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.tests.server.component.abstractdatefield.AbstarctDateFieldDeclarativeTest;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.InlineDateField;
import com.vaadin.ui.declarative.Design;
* @author Vaadin Ltd
*/
public class InlineDateFieldDeclarativeTest
- extends DeclarativeTestBase<InlineDateField> {
+ extends AbstarctDateFieldDeclarativeTest<InlineDateField> {
@Test
public void testInlineDateFieldToFromDesign() throws Exception {
assertEquals(field.getRangeEnd(), result.getRangeEnd());
}
+ @Override
+ protected String getComponentTag() {
+ return "vaadin-inline-date-field";
+ }
+
+ @Override
+ protected Class<? extends InlineDateField> getComponentClass() {
+ return InlineDateField.class;
+ }
+
}
*/
package com.vaadin.tests.server.component.passwordfield;
-import org.junit.Test;
-
-import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.tests.server.component.textfield.TextFieldDeclarativeTest;
import com.vaadin.ui.PasswordField;
+import com.vaadin.ui.TextField;
/**
- *
- * @since
+ * Declarative test for PasswordField. Provides only information about
+ * ColorPickerArea class. All tests are in the superclass.
+ *
* @author Vaadin Ltd
+ *
*/
-public class PasswordFieldDeclarativeTest
- extends DeclarativeTestBase<PasswordField> {
+public class PasswordFieldDeclarativeTest extends TextFieldDeclarativeTest {
+
+ @Override
+ protected Class<? extends TextField> getComponentClass() {
+ return PasswordField.class;
+ }
- @Test
- public void testReadOnlyValue() {
- String design = "<vaadin-password-field readonly value=\"test value\"/>";
- PasswordField tf = new PasswordField();
- tf.setValue("test value");
- tf.setReadOnly(true);
- testRead(design, tf);
- testWrite(design, tf);
+ @Override
+ protected String getComponentTag() {
+ return "vaadin-password-field";
}
}
--- /dev/null
+/*
+ * Copyright 2000-2016 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.reachtextarea;
+
+import java.util.Locale;
+
+import org.junit.Test;
+
+import com.vaadin.shared.ui.ValueChangeMode;
+import com.vaadin.tests.server.component.abstractfield.AbstractFieldDeclarativeTest;
+import com.vaadin.ui.RichTextArea;
+
+public class RichTextAreaDeclarativeTest
+ extends AbstractFieldDeclarativeTest<RichTextArea, String> {
+
+ public void valueDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String value = "<b>Header</b> \n<br>Some text";
+ String design = String.format("<%s>\n %s\n </%s>",
+ getComponentTag(), value, getComponentTag());
+
+ RichTextArea component = new RichTextArea();
+ component.setValue(value);
+
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ public void readOnlyValue()
+ throws InstantiationException, IllegalAccessException {
+ String value = "<b>Header</b> \n<br>Some text";
+ String design = String.format("<%s readonly>\n %s\n </%s>",
+ getComponentTag(), value, getComponentTag());
+
+ RichTextArea component = new RichTextArea();
+ component.setValue(value);
+ component.setReadOnly(true);
+
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void remainingAttributeDeserialization() {
+ ValueChangeMode mode = ValueChangeMode.TIMEOUT;
+ int timeout = 67;
+ String design = String.format(
+ "<%s value-change-mode='%s' value-change-timeout='%d'/>",
+ getComponentTag(), mode.name().toLowerCase(Locale.ENGLISH),
+ timeout);
+
+ RichTextArea component = new RichTextArea();
+ component.setValueChangeMode(mode);
+ component.setValueChangeTimeout(timeout);
+
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Override
+ protected String getComponentTag() {
+ return "vaadin-rich-text-area";
+ }
+
+ @Override
+ protected Class<RichTextArea> getComponentClass() {
+ return RichTextArea.class;
+ }
+
+}
import org.junit.Assert;
import org.junit.Test;
-import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.tests.server.component.abstracttextfield.AbstractTextFieldDeclarativeTest;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.declarative.DesignContext;
* @since 7.4
* @author Vaadin Ltd
*/
-public class TextAreaDeclarativeTest extends DeclarativeTestBase<TextArea> {
+public class TextAreaDeclarativeTest
+ extends AbstractTextFieldDeclarativeTest<TextArea> {
- @Test
- public void testTextArea() {
- String design = "<vaadin-text-area rows=6 word-wrap=false>Hello World!</vaadin-text-area>";
- TextArea ta = new TextArea();
- ta.setRows(6);
- ta.setWordWrap(false);
- ta.setValue("Hello World!");
- testRead(design, ta);
- testWrite(design, ta);
+ @Override
+ public void valueDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String value = "Hello World!";
+ String design = String.format("<%s>%s</%s>", getComponentTag(), value,
+ getComponentTag());
+
+ TextArea component = new TextArea();
+ component.setValue(value);
+
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Override
+ public void readOnlyValue()
+ throws InstantiationException, IllegalAccessException {
+ String value = "Hello World!";
+ String design = String.format("<%s readonly>%s</%s>", getComponentTag(),
+ value, getComponentTag());
+
+ TextArea component = new TextArea();
+ component.setValue(value);
+ component.setReadOnly(true);
+
+ testRead(design, component);
+ testWrite(design, component);
}
@Test
}
@Test
- public void testReadOnlyValue() {
- String design = "<vaadin-text-area readonly rows=6 word-wrap=false>Hello World!</vaadin-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);
+ public void remainingAttriburesDeserialization() {
+ int rows = 11;
+ boolean wrap = false;
+ String design = String.format("<%s rows='%s' word-wrap='%s'/>",
+ getComponentTag(), rows, wrap);
+
+ TextArea component = new TextArea();
+ component.setRows(rows);
+ component.setWordWrap(wrap);
+
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Override
+ protected String getComponentTag() {
+ return "vaadin-text-area";
}
+
+ @Override
+ protected Class<TextArea> getComponentClass() {
+ return TextArea.class;
+ }
+
}
import org.junit.Test;
-import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.tests.server.component.abstracttextfield.AbstractTextFieldDeclarativeTest;
import com.vaadin.ui.TextField;
/**
* @since 7.4
* @author Vaadin Ltd
*/
-public class TextFieldDeclarativeTest extends DeclarativeTestBase<TextField> {
+public class TextFieldDeclarativeTest
+ extends AbstractTextFieldDeclarativeTest<TextField> {
+ @Override
@Test
- public void testEmpty() {
- String design = "<vaadin-text-field/>";
- TextField tf = new TextField();
- testRead(design, tf);
- testWrite(design, tf);
+ public void valueDeserialization()
+ throws InstantiationException, IllegalAccessException {
+ String value = "foo";
+ String design = String.format("<%s value='%s'/>", getComponentTag(),
+ value);
+
+ TextField component = getComponentClass().newInstance();
+ component.setValue(value);
+ testRead(design, component);
+ testWrite(design, component);
}
+ @Override
@Test
- public void testValue() {
- String design = "<vaadin-text-field value=\"test value\"/>";
- TextField tf = new TextField();
- tf.setValue("test value");
- testRead(design, tf);
- testWrite(design, tf);
+ public void readOnlyValue()
+ throws InstantiationException, IllegalAccessException {
+ String value = "foo";
+ String design = String.format("<%s readonly value='%s'/>",
+ getComponentTag(), value);
+
+ TextField component = getComponentClass().newInstance();
+ component.setValue(value);
+
+ component.setReadOnly(true);
+ testRead(design, component);
+ testWrite(design, component);
}
- @Test
- public void testReadOnlyValue() {
- String design = "<vaadin-text-field readonly value=\"test value\"/>";
- TextField tf = new TextField();
- tf.setValue("test value");
- tf.setReadOnly(true);
- testRead(design, tf);
- testWrite(design, tf);
+ @Override
+ protected String getComponentTag() {
+ return "vaadin-text-field";
}
+
+ @Override
+ protected Class<? extends TextField> getComponentClass() {
+ return TextField.class;
+ }
+
}