aboutsummaryrefslogtreecommitdiffstats
path: root/server/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/src')
-rw-r--r--server/tests/src/com/vaadin/tests/layoutparser/all-components.html4
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeFromDesign.java73
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeToDesign.java73
3 files changed, 149 insertions, 1 deletions
diff --git a/server/tests/src/com/vaadin/tests/layoutparser/all-components.html b/server/tests/src/com/vaadin/tests/layoutparser/all-components.html
index 99e516ff55..90d483ac8b 100644
--- a/server/tests/src/com/vaadin/tests/layoutparser/all-components.html
+++ b/server/tests/src/com/vaadin/tests/layoutparser/all-components.html
@@ -39,7 +39,9 @@
</v-css-layout>
<!-- abstract field -->
- <v-text-field buffered validation-visible=false invalid-committed invalid-allowed=false required required-error="This is a required field" conversion-error="Input {0} cannot be parsed" tabindex=3 readonly/>
+ <v-text-field buffered validation-visible=false invalid-committed invalid-allowed=false required required-error="This is a required field" conversion-error="Input {0} cannot be parsed" tabindex=3 readonly />
+ <!-- abstract text field -->
+ <v-text-field null-representation="" null-setting-allowed maxlength=10 columns=5 input-prompt="Please enter a value" text-change-event-mode="eager" text-change-timeout=2 />
</v-vertical-layout>
</body>
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeFromDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeFromDesign.java
new file mode 100644
index 0000000000..f7ba67f506
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeFromDesign.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2014 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.server.component.abstracttextfield;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for reading the attributes of the AbstractTextField from design
+ */
+public class TestSynchronizeFromDesign extends TestCase {
+
+ private DesignContext ctx;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ ctx = new DesignContext();
+ }
+
+ public void testAttributes() {
+ Element design = createDesign();
+ AbstractTextField component = getComponent();
+ component.synchronizeFromDesign(design, ctx);
+ assertEquals("this-is-null", component.getNullRepresentation());
+ assertEquals(true, component.isNullSettingAllowed());
+ assertEquals(5, component.getMaxLength());
+ assertEquals(3, component.getColumns());
+ assertEquals("input", component.getInputPrompt());
+ assertEquals(TextChangeEventMode.EAGER,
+ component.getTextChangeEventMode());
+ assertEquals(100, component.getTextChangeTimeout());
+ }
+
+ private AbstractTextField getComponent() {
+ return new TextField();
+ }
+
+ private Element createDesign() {
+ Attributes attributes = new Attributes();
+ attributes.put("null-representation", "this-is-null");
+ attributes.put("null-setting-allowed", "true");
+ attributes.put("maxlength", "5");
+ attributes.put("columns", "3");
+ attributes.put("input-prompt", "input");
+ attributes.put("text-change-event-mode", "eager");
+ attributes.put("text-change-timeout", "100");
+ Element node = new Element(Tag.valueOf("v-text-field"), "", attributes);
+ return node;
+ }
+
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeToDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeToDesign.java
new file mode 100644
index 0000000000..b8f29b0ac9
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/TestSynchronizeToDesign.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2014 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.server.component.abstracttextfield;
+
+import junit.framework.TestCase;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test case for writing the attributes of the AbstractTextField to design
+ *
+ * @author Vaadin Ltd
+ */
+public class TestSynchronizeToDesign extends TestCase {
+
+ private DesignContext ctx;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ ctx = new DesignContext();
+ }
+
+ public void testSynchronizetestAttributes() {
+ Element design = createDesign();
+ AbstractTextField component = getComponent();
+ component.setNullRepresentation("this-is-null");
+ component.setNullSettingAllowed(true);
+ component.setMaxLength(5);
+ component.setColumns(3);
+ component.setInputPrompt("input");
+ component.setTextChangeEventMode(TextChangeEventMode.EAGER);
+ component.setTextChangeTimeout(100);
+ component.synchronizeToDesign(design, ctx);
+ assertEquals("this-is-null", design.attr("null-representation"));
+ assertEquals("true", design.attr("null-setting-allowed"));
+ assertEquals("5", design.attr("maxlength"));
+ assertEquals("3", design.attr("columns"));
+ assertEquals("input", design.attr("input-prompt"));
+ assertEquals("EAGER", design.attr("text-change-event-mode"));
+ assertEquals("100", design.attr("text-change-timeout"));
+ }
+
+ private AbstractTextField getComponent() {
+ return new TextField();
+ }
+
+ private Element createDesign() {
+ Attributes attr = new Attributes();
+ return new Element(Tag.valueOf("v-text-field"), "", attr);
+ }
+
+}