diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2012-11-27 11:39:32 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-11-28 08:38:54 +0000 |
commit | c78e03fa5907845f745203da925f0264b1b3befc (patch) | |
tree | fab320adf75b046cc17b4f6faef881314546e0c8 /uitest/src/com/vaadin/tests/components/select | |
parent | fd815c6981fe609a05262388041d1e5793c84692 (diff) | |
download | vaadin-framework-c78e03fa5907845f745203da925f0264b1b3befc.tar.gz vaadin-framework-c78e03fa5907845f745203da925f0264b1b3befc.zip |
Properly support setWidgetEnabled for OptionGroupBased Selects #8985, #8986, #8987 and #8989.
Also fixes #7617 for OptionGroup, #9010 for TwinColSelect.
Change-Id: Ia4c2a5e6ee93847970092fcb1cd685a0173897d7
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/select')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/select/OptionGroupBaseSelects.java | 104 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/select/OptionGroupBasedSelectsParentDisabledScreenshots.html | 49 |
2 files changed, 153 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/select/OptionGroupBaseSelects.java b/uitest/src/com/vaadin/tests/components/select/OptionGroupBaseSelects.java new file mode 100644 index 0000000000..f2dee69cbf --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/select/OptionGroupBaseSelects.java @@ -0,0 +1,104 @@ +package com.vaadin.tests.components.select; + +import java.util.Iterator; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.tests.components.ComponentTestCase; +import com.vaadin.ui.AbstractSelect; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.ListSelect; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.OptionGroup; +import com.vaadin.ui.TwinColSelect; + +public class OptionGroupBaseSelects extends ComponentTestCase<HorizontalLayout> { + + private HorizontalLayout layout; + + @Override + protected Class<HorizontalLayout> getTestClass() { + return HorizontalLayout.class; + } + + @Override + protected void initializeComponents() { + + CheckBox cb = new CheckBox("Switch Selects ReadOnly", false); + cb.addListener(new ValueChangeListener() { + + public void valueChange(ValueChangeEvent event) { + for (Iterator<Component> it = layout.getComponentIterator(); it + .hasNext();) { + Component c = it.next(); + if (c instanceof AbstractSelect) { + c.setReadOnly(!c.isReadOnly()); + } + } + } + }); + CheckBox cb2 = new CheckBox("Switch Selects Enabled", true); + cb2.addListener(new ValueChangeListener() { + + public void valueChange(ValueChangeEvent event) { + for (Iterator<Component> it = layout.getComponentIterator(); it + .hasNext();) { + Component c = it.next(); + if (c instanceof AbstractSelect) { + boolean enabled = !c.isEnabled(); + c.setEnabled(enabled); + c.setCaption(c.getCaption().replace( + (enabled ? "disabled" : "enabled"), + (enabled ? "enabled" : "disabled"))); + } + } + } + }); + HorizontalLayout cbs = new HorizontalLayout(); + cbs.setSpacing(true); + cbs.addComponent(cb); + cbs.addComponent(cb2); + addComponent(cbs); + + layout = new HorizontalLayout(); + layout.setSpacing(true); + layout.addComponent(createSelect( + new ListSelect("List Select, enabled"), true)); + layout.addComponent(createSelect( + new ListSelect("List Select, disabled"), false)); + + layout.addComponent(createSelect(new NativeSelect( + "Native Select, enabled"), true)); + layout.addComponent(createSelect(new NativeSelect( + "Native Select, disabled"), false)); + + layout.addComponent(createSelect(new OptionGroup( + "Option Group, enabled"), true)); + layout.addComponent(createSelect(new OptionGroup( + "Option Group, disabled"), false)); + + layout.addComponent(createSelect(new TwinColSelect( + "Twin Column Select, enabled"), true)); + layout.addComponent(createSelect(new TwinColSelect( + "Twin Column Select, disabled"), false)); + + addTestComponent(layout); + + } + + private AbstractSelect createSelect(AbstractSelect select, boolean enabled) { + select.addContainerProperty(CAPTION, String.class, null); + for (int i = 0; i < 10; i++) { + select.addItem("" + i).getItemProperty(CAPTION) + .setValue("Item " + i); + if (select instanceof OptionGroup && i % 2 == 1) { + ((OptionGroup) select).setItemEnabled("" + i, false); + } + } + select.setEnabled(enabled); + select.setImmediate(true); + return select; + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/select/OptionGroupBasedSelectsParentDisabledScreenshots.html b/uitest/src/com/vaadin/tests/components/select/OptionGroupBasedSelectsParentDisabledScreenshots.html new file mode 100644 index 0000000000..4259da836d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/select/OptionGroupBasedSelectsParentDisabledScreenshots.html @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>TwinColSelectParentDisabled</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">TwinColSelectParentDisabled</td></tr> +</thead><tbody> +<!--Tests with screen shots that OptionGroupBased Selects are disabled / enabled correctly when the parent is disabled / enabled.--> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.select.OptionGroupBaseSelects?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>initial_state_parent_enabled</td> +</tr> +<!--disable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>7,6</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>parent_disabled</td> +</tr> +<!--enable parent--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentsselectOptionGroupBaseSelects::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VCheckBox[0]/domChild[0]</td> + <td>7,6</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>parent_enabled</td> +</tr> +</tbody></table> +</body> +</html>
\ No newline at end of file |