diff options
author | Anastasia Smirnova <anasmi@utu.fi> | 2018-04-13 17:48:27 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2018-04-13 17:48:27 +0300 |
commit | 1719e35ae9377075f26f0daab6e7e2c789186ac0 (patch) | |
tree | b51fb5af27997c0d996d04cf73ce70261c681a4b /uitest | |
parent | da8f5adcae46ba7533578b4d8a9e5e1ac5dfe536 (diff) | |
download | vaadin-framework-1719e35ae9377075f26f0daab6e7e2c789186ac0.tar.gz vaadin-framework-1719e35ae9377075f26f0daab6e7e2c789186ac0.zip |
Fix incorrect color value handling in ColorPicker (#10812)
Diffstat (limited to 'uitest')
3 files changed, 66 insertions, 2 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerTestUI.java index 121ddf8ddb..65a7d2ece0 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerTestUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerTestUI.java @@ -17,7 +17,7 @@ import com.vaadin.server.StreamResource; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ContentMode; import com.vaadin.shared.ui.colorpicker.Color; -import com.vaadin.tests.components.AbstractReindeerTestUI; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.AbstractColorPicker; import com.vaadin.ui.Alignment; import com.vaadin.ui.CheckBox; @@ -31,7 +31,7 @@ import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; @Widgetset("com.vaadin.DefaultWidgetSet") -public class ColorPickerTestUI extends AbstractReindeerTestUI { +public class ColorPickerTestUI extends AbstractTestUI { @Override public String getTestDescription() { diff --git a/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerValueTest.java b/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerValueTest.java new file mode 100644 index 0000000000..7a1fc5bcd9 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerValueTest.java @@ -0,0 +1,31 @@ +package com.vaadin.tests.components.colorpicker; + +import com.vaadin.annotations.Widgetset; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.colorpicker.Color; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.AbstractColorPicker; + +import com.vaadin.ui.Button; +import com.vaadin.ui.ColorPicker; + +@Widgetset("com.vaadin.DefaultWidgetSet") +public class ColorPickerValueTest extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + AbstractColorPicker colorpicker = new ColorPicker("ColorPicker", + Color.GREEN); + colorpicker.setPosition(250, 0); + colorpicker.setId("clp"); + colorpicker.setRGBVisibility(true); + colorpicker.setHSVVisibility(true); + colorpicker.setTextfieldVisibility(true); + colorpicker.setSwatchesVisibility(true); + addComponent(colorpicker); + addComponent(new Button("Change Color", e -> { + colorpicker.setValue(Color.YELLOW); + })); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerValueTestTest.java b/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerValueTestTest.java new file mode 100644 index 0000000000..35487a0773 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerValueTestTest.java @@ -0,0 +1,33 @@ +package com.vaadin.tests.components.colorpicker; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.ColorPickerElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; + +import static org.junit.Assert.assertEquals; + +public class ColorPickerValueTestTest extends MultiBrowserTest { + + @Test + public void testValue() throws Exception { + openTestURL(); + + // Open ColorPicker + findElement(By.id("clp")).click(); + // Click Button to change color + ButtonElement button = $(ButtonElement.class).first(); + button.click(); + Thread.sleep(300); + assertEquals("#ffff00", getColorpickerValue()); + } + + private String getColorpickerValue() { + WebElement field = findElement( + By.className("v-colorpicker-preview-textfield")); + return field.getAttribute("value"); + } +} |