diff options
author | Artur Signell <artur@vaadin.com> | 2013-03-13 11:14:24 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-03-13 11:40:07 +0200 |
commit | 5cba827316eed64508ffb254edb95f303f44eab9 (patch) | |
tree | c0f54bcc226b3b2c24c16e459261be70305af836 /uitest | |
parent | 499e13878e3cb3711b21c21406166cee72ba98bf (diff) | |
download | vaadin-framework-5cba827316eed64508ffb254edb95f303f44eab9.tar.gz vaadin-framework-5cba827316eed64508ffb254edb95f303f44eab9.zip |
Fixed client-server value sync problem in CheckBox (#11028)
Change-Id: I1bac8e8a746bcc97b3ce929e76cf3476ad793bf6
Diffstat (limited to 'uitest')
3 files changed, 183 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUIWithLog.java b/uitest/src/com/vaadin/tests/components/AbstractTestUIWithLog.java new file mode 100644 index 0000000000..cace7c3404 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUIWithLog.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2013 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.components; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.VerticalLayout; + +public abstract class AbstractTestUIWithLog extends AbstractTestUI { + + protected Log log = new Log(5); + + @Override + public void init(VaadinRequest request) { + super.init(request); + ((VerticalLayout) getContent()).addComponent(log, 0); + } + + protected void log(String message) { + log.log(message); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRevertValueChange.html b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRevertValueChange.html new file mode 100644 index 0000000000..ea5849f99f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRevertValueChange.html @@ -0,0 +1,82 @@ +<?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="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.checkbox.CheckBoxRevertValueChange?restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VCheckBox[0]/domChild[0]</td> + <td>10,5</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::PID_SLog_row_0</td> + <td>1. I said no checking!</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VCheckBox[0]/domChild[0]</td> + <td>off</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VCheckBox[0]/domChild[1]</td> + <td>93,10</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::PID_SLog_row_0</td> + <td>2. I said no checking!</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VCheckBox[0]/domChild[0]</td> + <td>off</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td> + <td>5,8</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::PID_SLog_row_0</td> + <td>3. I said no unchecking!</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td> + <td>on</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[1]</td> + <td>78,12</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::PID_SLog_row_0</td> + <td>4. I said no unchecking!</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestscomponentscheckboxCheckBoxRevertValueChange::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td> + <td>on</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRevertValueChange.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRevertValueChange.java new file mode 100644 index 0000000000..5b086fb935 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRevertValueChange.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2013 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.components.checkbox; + +import com.vaadin.annotations.PreserveOnRefresh; +import com.vaadin.data.Property; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.CheckBox; + +@PreserveOnRefresh +public class CheckBoxRevertValueChange extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + final CheckBox alwaysUnchecked = new CheckBox("You may not check me"); + alwaysUnchecked + .addValueChangeListener(new Property.ValueChangeListener() { + public void valueChange(Property.ValueChangeEvent event) { + if (alwaysUnchecked.getValue()) { + log("I said no checking!"); + alwaysUnchecked.setValue(false); + } + } + }); + final CheckBox alwaysChecked = new CheckBox("You may not uncheck me"); + alwaysChecked.setValue(true); + alwaysChecked + .addValueChangeListener(new Property.ValueChangeListener() { + public void valueChange(Property.ValueChangeEvent event) { + if (!alwaysChecked.getValue()) { + log("I said no unchecking!"); + alwaysChecked.setValue(true); + } + } + }); + + addComponent(alwaysUnchecked); + addComponent(alwaysChecked); + } + + @Override + protected String getTestDescription() { + return "Ensure checking of a checkbox can be reverted on the server side without making the client go out of sync"; + } + + @Override + protected Integer getTicketNumber() { + return 11028; + } + +} |