Browse Source

Merge test for #11623 to 7.0.

The fix itself is not required due to the changed style name handling.

svn changeset:25902/svn branch:6.8
svn changeset:25903/svn branch:6.8

Change-Id: I95a9adbcac82236017369003765735bbaacfe980
tags/7.0.6
Johannes Dahlström 11 years ago
parent
commit
bdb793187c

+ 72
- 0
tests/testbench/com/vaadin/tests/components/textfield/TextChangeListenerLosesFocus.html View File

@@ -0,0 +1,72 @@
<?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:8068/" />
<title>TextChangeListenerLosesFocus</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">TextChangeListenerLosesFocus</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/run/com.vaadin.tests.components.textfield.TextChangeListenerLosesFocus?restartApplication</td>
<td></td>
</tr>
<tr>
<td>focus</td>
<td>test-textfield</td>
<td></td>
</tr>
<tr>
<td>enterCharacter</td>
<td>test-textfield</td>
<td>123</td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>assertValue</td>
<td>test-textfield</td>
<td>Updated by TextChangeListener</td>
</tr>
<tr>
<td>assertCSSClass</td>
<td>test-textfield</td>
<td>v-textfield-focus</td>
</tr>
<tr>
<td>focus</td>
<td>test-textarea</td>
<td></td>
</tr>
<tr>
<td>enterCharacter</td>
<td>test-textarea</td>
<td>123</td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>assertValue</td>
<td>test-textarea</td>
<td>Updated by TextChangeListener</td>
</tr>
<tr>
<td>assertCSSClass</td>
<td>test-textarea</td>
<td>v-textarea-focus</td>
</tr>

</tbody></table>
</body>
</html>

+ 69
- 0
uitest/src/com/vaadin/tests/components/textfield/TextChangeListenerLosesFocus.java View File

@@ -0,0 +1,69 @@
/*
* Copyright 2012 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.textfield;

import com.vaadin.event.FieldEvents.TextChangeEvent;
import com.vaadin.event.FieldEvents.TextChangeListener;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.util.TestUtils;
import com.vaadin.ui.AbstractTextField;
import com.vaadin.ui.Field;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;

public class TextChangeListenerLosesFocus extends TestBase {

private final TextChangeListener listener = new TextChangeListener() {
public void textChange(TextChangeEvent event) {
final String value = event.getText();
if (value.length() > 2) {
((Field) event.getComponent())
.setValue("Updated by TextChangeListener");
}
}
};

@Override
protected void setup() {
TestUtils.injectCSS(getMainWindow(),
".v-textfield-focus, .v-textarea-focus { "
+ " background: #E8F0FF !important }");

AbstractTextField field = new TextField();
field.setDebugId("test-textfield");
field.setInputPrompt("Enter at least 3 characters");
field.addListener(listener);
addComponent(field);

field = new TextArea();
field.setDebugId("test-textarea");
field.setInputPrompt("Enter at least 3 characters");
field.addListener(listener);
addComponent(field);

}

@Override
protected String getDescription() {
return "Updating a focused TextField overwrites the focus stylename";
}

@Override
protected Integer getTicketNumber() {
return 11623;
}
}

Loading…
Cancel
Save