From 05ce7f4158231b9ddcea69ead3bc26681c6d77f8 Mon Sep 17 00:00:00 2001 From: patrik Date: Mon, 13 Apr 2015 12:23:04 +0300 Subject: Add declarative OptionGroup support (#15549) Change-Id: I5edb32ffb8282fa76fc21cf6e134eeb48fec04d1 --- .../OptionGroupDeclarativeTests.java | 160 +++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 server/tests/src/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java (limited to 'server/tests') diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java b/server/tests/src/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java new file mode 100644 index 0000000000..4d75e0b59f --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java @@ -0,0 +1,160 @@ +/* + * 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.abstractselect; + +import org.junit.Before; +import org.junit.Test; + +import com.vaadin.server.ThemeResource; +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.OptionGroup; + +public class OptionGroupDeclarativeTests extends + DeclarativeTestBase { + + private OptionGroup og; + + @Before + public void init() { + og = new OptionGroup(); + } + + @Test + public void testBasicSyntax() { + + String expected = ""; + testReadWrite(expected); + + } + + @Test + public void testOptionSyntax() { + + og.addItems("foo", "bar", "baz", "bang"); + + //@formatter:off + String expected = + "" + + "" + + "" + + "" + + "" + + ""; + //@formatter:on + + testReadWrite(expected); + + } + + @Test + public void testDisabledOptionSyntax() { + + og.addItems("foo", "bar", "baz", "bang"); + og.setItemEnabled("baz", false); + + //@formatter:off + String expected = + "" + + "" + + "" + + "" + + "" + + ""; + //@formatter:on + + testReadWrite(expected); + + } + + @Test + public void testIconSyntax() { + + og.addItems("foo", "bar", "baz", "bang"); + og.setItemIcon("bar", new ThemeResource("foobar.png")); + + //@formatter:off + String expected = + "" + + "" + + "" + + "" + + "" + + ""; + //@formatter:on + + testReadWrite(expected); + + } + + @Test + public void testHTMLCaption() { + + og.addItems("foo", "bar", "baz", "bang"); + + og.setHtmlContentAllowed(true); + + og.setItemCaption("foo", "True"); + og.setItemCaption("bar", "False"); + + //@formatter:off + String expected = + "" + + "" + + "" + + "" + + "" + + ""; + //@formatter:on + + testReadWrite(expected); + } + + @Test + public void testPlaintextCaption() { + + og.addItems("foo", "bar", "baz", "bang"); + + og.setItemCaption("foo", "True"); + og.setItemCaption("bar", "False"); + + //@formatter:off + String expected = + "" + + "" + + "" + + "" + + "" + + ""; + //@formatter:on + + testReadWrite(expected); + } + + private void testReadWrite(String design) { + testWrite(design, og, true); + testRead(design, og); + } + + @Override + public OptionGroup testRead(String design, OptionGroup expected) { + + OptionGroup read = super.testRead(design, expected); + testWrite(design, read, true); + + return read; + } + +} -- cgit v1.2.3