diff options
author | Denis Anisimov <denis@vaadin.com> | 2016-09-21 10:41:28 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-09-22 12:55:13 +0000 |
commit | f12fbfb7044defc8442d05e6810c43875c04710c (patch) | |
tree | 26b47b9ddb48da84001ebb582a34acff5ef0042c /compatibility-server/src/test/java | |
parent | ab1fd8a7be62a2381d2aa8c5434db9c39acaad9d (diff) | |
download | vaadin-framework-f12fbfb7044defc8442d05e6810c43875c04710c.tar.gz vaadin-framework-f12fbfb7044defc8442d05e6810c43875c04710c.zip |
Re-add back Form to compatibility package (#296).
Change-Id: Id187402e78e3c368ae6530f7b7ea68d2e6c4a6ca
Diffstat (limited to 'compatibility-server/src/test/java')
-rw-r--r-- | compatibility-server/src/test/java/com/vaadin/v7/tests/server/SerializationTest.java | 22 | ||||
-rw-r--r-- | compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java | 68 |
2 files changed, 85 insertions, 5 deletions
diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/SerializationTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/SerializationTest.java index dd0148fdc9..23b3c4fc0d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/SerializationTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/SerializationTest.java @@ -17,6 +17,7 @@ import com.vaadin.v7.data.Property; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.data.util.MethodProperty; import com.vaadin.v7.data.validator.RegexpValidator; +import com.vaadin.v7.ui.Form; public class SerializationTest { @@ -29,6 +30,19 @@ public class SerializationTest { } @Test + public void testForm() throws Exception { + Form f = new Form(); + String propertyId = "My property"; + f.addItemProperty(propertyId, + new MethodProperty<>(new Data(), "dummyGetterAndSetter")); + f.replaceWithSelect(propertyId, new Object[] { "a", "b", null }, + new String[] { "Item a", "ITem b", "Null item" }); + + serializeAndDeserialize(f); + + } + + @Test public void testIndedexContainerItemIds() throws Exception { IndexedContainer ic = new IndexedContainer(); ic.addContainerProperty("prop1", String.class, null); @@ -43,22 +57,20 @@ public class SerializationTest { @Test public void testMethodPropertyGetter() throws Exception { - MethodProperty<?> mp = new MethodProperty<Object>(new Data(), - "dummyGetter"); + MethodProperty<?> mp = new MethodProperty<>(new Data(), "dummyGetter"); serializeAndDeserialize(mp); } @Test public void testMethodPropertyGetterAndSetter() throws Exception { - MethodProperty<?> mp = new MethodProperty<Object>(new Data(), + MethodProperty<?> mp = new MethodProperty<>(new Data(), "dummyGetterAndSetter"); serializeAndDeserialize(mp); } @Test public void testMethodPropertyInt() throws Exception { - MethodProperty<?> mp = new MethodProperty<Object>(new Data(), - "dummyInt"); + MethodProperty<?> mp = new MethodProperty<>(new Data(), "dummyInt"); serializeAndDeserialize(mp); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java new file mode 100644 index 0000000000..0b30afbe0c --- /dev/null +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java @@ -0,0 +1,68 @@ +/* + * 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.v7.tests.server.component.form; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.v7.ui.Form; +import com.vaadin.v7.ui.TextField; + +/** + * Test for {@link Form}. + * + * @author Vaadin Ltd + */ +public class FormTest { + + @Test + public void testFocus() { + Form form = new Form(); + final boolean firstFieldIsFocused[] = new boolean[1]; + TextField field1 = new TextField() { + @Override + public boolean isConnectorEnabled() { + return false; + } + + @Override + public void focus() { + firstFieldIsFocused[0] = true; + } + }; + + final boolean secondFieldIsFocused[] = new boolean[1]; + TextField field2 = new TextField() { + @Override + public boolean isConnectorEnabled() { + return true; + } + + @Override + public void focus() { + secondFieldIsFocused[0] = true; + } + }; + form.addField("a", field1); + form.addField("b", field2); + form.focus(); + + Assert.assertTrue("Field with enabled connector is not focused", + secondFieldIsFocused[0]); + Assert.assertFalse("Field with disabled connector is focused", + firstFieldIsFocused[0]); + } +} |