aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/textfield
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-06-18 22:15:54 +0300
committerVaadin Code Review <review@vaadin.com>2013-07-01 06:14:48 +0000
commitb84d2feabf34a972b42c82ead780768883591378 (patch)
treede1fc1acdbff0f0ee270ea4878fd59fce015ee08 /uitest/src/com/vaadin/tests/components/textfield
parent6a97757139e6c544cf9d62328546eb96856e8df0 (diff)
downloadvaadin-framework-b84d2feabf34a972b42c82ead780768883591378.tar.gz
vaadin-framework-b84d2feabf34a972b42c82ead780768883591378.zip
Adds String <-> BigDecimal converter (#9997)
* BigDecimal properties connected to String based fields (TextField/TextArea/...) are now supported without custom converters Change-Id: I2dab67875b3cfdb46b17e9d4cc35ffb94c114478
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/textfield')
-rw-r--r--uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.html123
-rw-r--r--uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.java123
2 files changed, 246 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.html b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.html
new file mode 100644
index 0000000000..2428e8b4bb
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.html
@@ -0,0 +1,123 @@
+<?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.textfield.BigDecimalTextField?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertValue</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>15,2</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::PID_SLog_row_0</td>
+ <td>1. Commit ok. Property value: 15.2</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>70,12</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>130</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::</td>
+ <td>160,327</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::PID_SLog_row_0</td>
+ <td>2. Commit ok. Property value: 130</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>75,16</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>130abc</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::</td>
+ <td>96,280</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::PID_SLog_row_0</td>
+ <td>3. Commit failed: Commit failed</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td>
+ <td>v-errorindicator</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>71,12</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>130,130</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::</td>
+ <td>118,280</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<!--The converter automatically removes trailing zeros-->
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::PID_SLog_row_0</td>
+ <td>4. Commit ok. Property value: 130.13</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.java b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.java
new file mode 100644
index 0000000000..18d8679c2f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.java
@@ -0,0 +1,123 @@
+/*
+ * 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.textfield;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Locale;
+
+import com.vaadin.data.fieldgroup.FieldGroup;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+public class BigDecimalTextField extends AbstractTestUIWithLog {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ setLocale(new Locale("fi", "FI"));
+
+ BeanBigDecimal beanBigDecimal = new BeanBigDecimal();
+ BeanItem<BeanBigDecimal> beanItem = new BeanItem<BeanBigDecimal>(
+ beanBigDecimal);
+
+ FormLayout formLayout = new FormLayout();
+ TextField textField = new TextField("BigDecimal field");
+ textField.setImmediate(true);
+ textField.setValue("12");
+ formLayout.addComponent(textField);
+
+ final FieldGroup fieldGroup = new FieldGroup(beanItem);
+ fieldGroup.bind(textField, "decimal");
+
+ Button setValue = new Button("Set value to 15,2", new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ ((TextField) fieldGroup.getField("decimal")).setValue("15,2");
+ }
+ });
+
+ Button button = new Button("Commit");
+ button.addClickListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ try {
+ fieldGroup.commit();
+ log("Commit ok. Property value: "
+ + fieldGroup.getItemDataSource()
+ .getItemProperty("decimal").getValue());
+ } catch (FieldGroup.CommitException e) {
+ log("Commit failed: " + e.getMessage());
+ }
+ }
+ });
+
+ layout.addComponent(formLayout);
+ layout.addComponent(setValue);
+ layout.addComponent(button);
+
+ setContent(layout);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "Tests that BigDecimals work correctly with TextFields";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 9997;
+ }
+
+ public static class BeanBigDecimal implements Serializable {
+ BigDecimal decimal;
+
+ public BeanBigDecimal() {
+
+ }
+
+ public BigDecimal getDecimal() {
+ return decimal;
+ }
+
+ public void setDecimal(BigDecimal decimal) {
+ this.decimal = decimal;
+ }
+ }
+
+}