From 34852cdb88c6c27b1341684204d78db0fdd061a6 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 18 Aug 2016 21:51:13 +0300 Subject: Move selects to compatibility package Change-Id: I7ee02d34b230e8752174a7f19824f81cbb616c33 --- server/src/main/java/com/vaadin/ui/ListSelect.java | 80 ------ .../src/main/java/com/vaadin/ui/NativeSelect.java | 108 -------- .../src/main/java/com/vaadin/ui/OptionGroup.java | 253 ----------------- server/src/main/java/com/vaadin/ui/Select.java | 60 ---- .../design/ParseAllSupportedComponentsTest.java | 45 --- .../vaadin/tests/design/ParseLegacyPrefixTest.java | 44 --- .../AbstractSelectDeclarativeTest.java | 306 --------------------- .../AbstractSelectListenersTest.java | 26 -- .../abstractselect/AbstractSelectStateTest.java | 60 ---- .../abstractselect/OptionGroupDeclarativeTest.java | 160 ----------- .../component/abstractselect/OptionGroupTest.java | 32 --- .../listselect/ListSelectDeclarativeTest.java | 71 ----- .../component/listselect/ListSelectStateTest.java | 45 --- .../nativeselect/NativeSelectDeclarativeTest.java | 69 ----- .../optiongroup/OptionGroupListenersTest.java | 25 -- .../optiongroup/OptionGroupStateTest.java | 60 ---- .../component/select/SelectListenersTest.java | 25 -- .../src/test/java/com/vaadin/ui/AbsSelectTest.java | 147 ---------- .../test/java/com/vaadin/ui/NativeSelectTest.java | 70 ----- .../vaadin/tests/design/all-components-legacy.html | 122 -------- .../com/vaadin/tests/design/all-components.html | 122 -------- 21 files changed, 1930 deletions(-) delete mode 100644 server/src/main/java/com/vaadin/ui/ListSelect.java delete mode 100644 server/src/main/java/com/vaadin/ui/NativeSelect.java delete mode 100644 server/src/main/java/com/vaadin/ui/OptionGroup.java delete mode 100644 server/src/main/java/com/vaadin/ui/Select.java delete mode 100644 server/src/test/java/com/vaadin/tests/design/ParseAllSupportedComponentsTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/design/ParseLegacyPrefixTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectStateTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectDeclarativeTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectStateTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupStateTest.java delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java delete mode 100644 server/src/test/java/com/vaadin/ui/AbsSelectTest.java delete mode 100644 server/src/test/java/com/vaadin/ui/NativeSelectTest.java delete mode 100644 server/src/test/resources/com/vaadin/tests/design/all-components-legacy.html delete mode 100644 server/src/test/resources/com/vaadin/tests/design/all-components.html (limited to 'server') diff --git a/server/src/main/java/com/vaadin/ui/ListSelect.java b/server/src/main/java/com/vaadin/ui/ListSelect.java deleted file mode 100644 index 9a720d1895..0000000000 --- a/server/src/main/java/com/vaadin/ui/ListSelect.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2000-2016 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.ui; - -import java.util.Collection; - -import com.vaadin.data.Container; -import com.vaadin.server.PaintException; -import com.vaadin.server.PaintTarget; - -/** - * This is a simple list select without, for instance, support for new items, - * lazyloading, and other advanced features. - */ -@SuppressWarnings("serial") -public class ListSelect extends AbstractSelect { - - private int rows = 0; - - public ListSelect() { - super(); - } - - public ListSelect(String caption, Collection options) { - super(caption, options); - } - - public ListSelect(String caption, Container dataSource) { - super(caption, dataSource); - } - - public ListSelect(String caption) { - super(caption); - } - - public int getRows() { - return rows; - } - - /** - * Sets the number of rows in the editor. If the number of rows is set 0, - * the actual number of displayed rows is determined implicitly by the - * adapter. - * - * @param rows - * the number of rows to set. - */ - public void setRows(int rows) { - if (rows < 0) { - rows = 0; - } - if (this.rows != rows) { - this.rows = rows; - markAsDirty(); - } - } - - @Override - public void paintContent(PaintTarget target) throws PaintException { - // Adds the number of rows - if (rows != 0) { - target.addAttribute("rows", rows); - } - super.paintContent(target); - } -} diff --git a/server/src/main/java/com/vaadin/ui/NativeSelect.java b/server/src/main/java/com/vaadin/ui/NativeSelect.java deleted file mode 100644 index 13556a0387..0000000000 --- a/server/src/main/java/com/vaadin/ui/NativeSelect.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2000-2016 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.ui; - -import java.util.Collection; - -import com.vaadin.data.Container; -import com.vaadin.event.FieldEvents; -import com.vaadin.event.FieldEvents.BlurEvent; -import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcImpl; -import com.vaadin.event.FieldEvents.FocusEvent; -import com.vaadin.event.FieldEvents.FocusListener; - -/** - * This is a simple drop-down select without, for instance, support for - * multiselect, new items, lazyloading, and other advanced features. Sometimes - * "native" select without all the bells-and-whistles of the ComboBox is a - * better choice. - */ -@SuppressWarnings("serial") -public class NativeSelect extends AbstractSelect - implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier { - - FocusAndBlurServerRpcImpl focusBlurRpc = new FocusAndBlurServerRpcImpl( - this) { - - @Override - protected void fireEvent(Event event) { - NativeSelect.this.fireEvent(event); - } - }; - - public NativeSelect() { - super(); - registerRpc(focusBlurRpc); - } - - public NativeSelect(String caption, Collection options) { - super(caption, options); - registerRpc(focusBlurRpc); - } - - public NativeSelect(String caption, Container dataSource) { - super(caption, dataSource); - registerRpc(focusBlurRpc); - } - - public NativeSelect(String caption) { - super(caption); - registerRpc(focusBlurRpc); - } - - @Override - public void setMultiSelect(boolean multiSelect) - throws UnsupportedOperationException { - if (multiSelect == true) { - throw new UnsupportedOperationException( - "Multiselect not supported"); - } - } - - @Override - public void setNewItemsAllowed(boolean allowNewOptions) - throws UnsupportedOperationException { - if (allowNewOptions == true) { - throw new UnsupportedOperationException( - "newItemsAllowed not supported"); - } - } - - @Override - public void addFocusListener(FocusListener listener) { - addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, - FocusListener.focusMethod); - } - - @Override - public void removeFocusListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - } - - @Override - public void addBlurListener(BlurListener listener) { - addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, - BlurListener.blurMethod); - } - - @Override - public void removeBlurListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - -} diff --git a/server/src/main/java/com/vaadin/ui/OptionGroup.java b/server/src/main/java/com/vaadin/ui/OptionGroup.java deleted file mode 100644 index 3e491906d5..0000000000 --- a/server/src/main/java/com/vaadin/ui/OptionGroup.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright 2000-2016 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.ui; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.jsoup.nodes.Element; - -import com.vaadin.data.Container; -import com.vaadin.event.FieldEvents; -import com.vaadin.event.FieldEvents.BlurEvent; -import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusEvent; -import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.server.PaintException; -import com.vaadin.server.PaintTarget; -import com.vaadin.shared.ui.optiongroup.OptionGroupConstants; -import com.vaadin.shared.ui.optiongroup.OptionGroupState; -import com.vaadin.ui.declarative.DesignContext; -import com.vaadin.ui.declarative.DesignFormatter; - -/** - * Configures select to be used as an option group. - */ -@SuppressWarnings("serial") -public class OptionGroup extends AbstractSelect - implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier { - - private Set disabledItemIds = new HashSet(); - - public OptionGroup() { - super(); - } - - public OptionGroup(String caption, Collection options) { - super(caption, options); - } - - public OptionGroup(String caption, Container dataSource) { - super(caption, dataSource); - } - - public OptionGroup(String caption) { - super(caption); - } - - @Override - protected void paintItem(PaintTarget target, Object itemId) - throws PaintException { - super.paintItem(target, itemId); - if (!isItemEnabled(itemId)) { - target.addAttribute(OptionGroupConstants.ATTRIBUTE_OPTION_DISABLED, - true); - } - } - - @Override - public void changeVariables(Object source, Map variables) { - super.changeVariables(source, variables); - - if (variables.containsKey(FocusEvent.EVENT_ID)) { - fireEvent(new FocusEvent(this)); - } - if (variables.containsKey(BlurEvent.EVENT_ID)) { - fireEvent(new BlurEvent(this)); - } - } - - @Override - public void addBlurListener(BlurListener listener) { - addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, - BlurListener.blurMethod); - } - - @Override - public void removeBlurListener(BlurListener listener) { - removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener); - } - - @Override - public void addFocusListener(FocusListener listener) { - addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener, - FocusListener.focusMethod); - } - - @Override - public void removeFocusListener(FocusListener listener) { - removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener); - - } - - @Override - protected void setValue(Object newValue, boolean repaintIsNotNeeded) { - if (repaintIsNotNeeded) { - /* - * Check that value from changeVariables() doesn't contain unallowed - * selections: In the multi select mode, the user has selected or - * deselected a disabled item. In the single select mode, the user - * has selected a disabled item. - */ - if (isMultiSelect()) { - Set currentValueSet = (Set) getValue(); - Set newValueSet = (Set) newValue; - for (Object itemId : currentValueSet) { - if (!isItemEnabled(itemId) - && !newValueSet.contains(itemId)) { - markAsDirty(); - return; - } - } - for (Object itemId : newValueSet) { - if (!isItemEnabled(itemId) - && !currentValueSet.contains(itemId)) { - markAsDirty(); - return; - } - } - } else { - if (newValue == null) { - newValue = getNullSelectionItemId(); - } - if (!isItemEnabled(newValue)) { - markAsDirty(); - return; - } - } - } - super.setValue(newValue, repaintIsNotNeeded); - } - - /** - * Sets an item disabled or enabled. In the multiselect mode, a disabled - * item cannot be selected or deselected by the user. In the single - * selection mode, a disable item cannot be selected. - * - * However, programmatical selection or deselection of an disable item is - * possible. By default, items are enabled. - * - * @param itemId - * the id of the item to be disabled or enabled - * @param enabled - * if true the item is enabled, otherwise the item is disabled - */ - public void setItemEnabled(Object itemId, boolean enabled) { - if (itemId != null) { - if (enabled) { - disabledItemIds.remove(itemId); - } else { - disabledItemIds.add(itemId); - } - markAsDirty(); - } - } - - /** - * Returns true if the item is enabled. - * - * @param itemId - * the id of the item to be checked - * @return true if the item is enabled, false otherwise - * @see #setItemEnabled(Object, boolean) - */ - public boolean isItemEnabled(Object itemId) { - if (itemId != null) { - return !disabledItemIds.contains(itemId); - } - return true; - } - - /** - * Sets whether html is allowed in the item captions. If set to true, the - * captions are passed to the browser as html and the developer is - * responsible for ensuring no harmful html is used. If set to false, the - * content is passed to the browser as plain text. - * - * @param htmlContentAllowed - * true if the captions are used as html, false if used as plain - * text - */ - public void setHtmlContentAllowed(boolean htmlContentAllowed) { - getState().htmlContentAllowed = htmlContentAllowed; - } - - /** - * Checks whether captions are interpreted as html or plain text. - * - * @return true if the captions are used as html, false if used as plain - * text - * @see #setHtmlContentAllowed(boolean) - */ - public boolean isHtmlContentAllowed() { - return getState(false).htmlContentAllowed; - } - - @Override - protected Object readItem(Element child, Set selected, - DesignContext context) { - Object itemId = super.readItem(child, selected, context); - - if (child.hasAttr("disabled")) { - setItemEnabled(itemId, false); - } - - return itemId; - } - - @Override - protected Element writeItem(Element design, Object itemId, - DesignContext context) { - Element elem = super.writeItem(design, itemId, context); - - if (!isItemEnabled(itemId)) { - elem.attr("disabled", ""); - } - if (isHtmlContentAllowed()) { - // need to unencode HTML entities. AbstractSelect.writeDesign can't - // check if HTML content is allowed, so it always encodes entities - // like '>', '<' and '&'; in case HTML content is allowed this is - // undesirable so we need to unencode entities. Entities other than - // '<' and '>' will be taken care by Jsoup. - elem.html(DesignFormatter.decodeFromTextNode(elem.html())); - } - - return elem; - } - - @Override - protected OptionGroupState getState() { - return (OptionGroupState) super.getState(); - } - - @Override - protected OptionGroupState getState(boolean markAsDirty) { - return (OptionGroupState) super.getState(markAsDirty); - } -} diff --git a/server/src/main/java/com/vaadin/ui/Select.java b/server/src/main/java/com/vaadin/ui/Select.java deleted file mode 100644 index 66b36f8ac2..0000000000 --- a/server/src/main/java/com/vaadin/ui/Select.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2000-2016 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.ui; - -import java.util.Collection; - -import com.vaadin.data.Container; - -/** - *

- * A class representing a selection of items the user has selected in a UI. The - * set of choices is presented as a set of {@link com.vaadin.data.Item}s in a - * {@link com.vaadin.data.Container}. - *

- * - *

- * A Select component may be in single- or multiselect mode. - * Multiselect mode means that more than one item can be selected - * simultaneously. - *

- * - * @author Vaadin Ltd. - * @since 3.0 - * @deprecated As of 7.0. Use {@link ComboBox} instead. - */ -@Deprecated -public class Select extends ComboBox { - /* Component methods */ - - public Select() { - super(); - } - - public Select(String caption, Collection options) { - super(caption, options); - } - - public Select(String caption, Container dataSource) { - super(caption, dataSource); - } - - public Select(String caption) { - super(caption); - } - -} diff --git a/server/src/test/java/com/vaadin/tests/design/ParseAllSupportedComponentsTest.java b/server/src/test/java/com/vaadin/tests/design/ParseAllSupportedComponentsTest.java deleted file mode 100644 index 6694372539..0000000000 --- a/server/src/test/java/com/vaadin/tests/design/ParseAllSupportedComponentsTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2000-2016 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.design; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; - -import java.io.FileNotFoundException; - -import org.junit.Test; - -import com.vaadin.ui.declarative.Design; -import com.vaadin.ui.declarative.DesignContext; - -/** - * Just top level test case that contains all synchronizable components - * - * @author Vaadin Ltd - */ -public class ParseAllSupportedComponentsTest { - - @Test - public void allComponentsAreParsed() throws FileNotFoundException { - DesignContext ctx = Design.read( - getClass().getResourceAsStream("all-components.html"), null); - - assertThat(ctx, is(not(nullValue()))); - assertThat(ctx.getRootComponent(), is(not(nullValue()))); - } -} diff --git a/server/src/test/java/com/vaadin/tests/design/ParseLegacyPrefixTest.java b/server/src/test/java/com/vaadin/tests/design/ParseLegacyPrefixTest.java deleted file mode 100644 index 5dd21b35f8..0000000000 --- a/server/src/test/java/com/vaadin/tests/design/ParseLegacyPrefixTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2000-2016 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.design; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; - -import java.io.FileNotFoundException; - -import org.junit.Test; - -import com.vaadin.ui.declarative.Design; -import com.vaadin.ui.declarative.DesignContext; - -/** - * Test reading a design with all components using the legacy prefix. - */ -public class ParseLegacyPrefixTest { - - @Test - public void allComponentsAreParsed() throws FileNotFoundException { - DesignContext ctx = Design.read( - getClass().getResourceAsStream("all-components-legacy.html"), - null); - - assertThat(ctx, is(not(nullValue()))); - assertThat(ctx.getRootComponent(), is(not(nullValue()))); - } -} diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java deleted file mode 100644 index 9a8777909f..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright 2000-2016 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.jsoup.nodes.Attributes; -import org.jsoup.nodes.Element; -import org.jsoup.parser.Tag; -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.data.Container; -import com.vaadin.data.util.IndexedContainer; -import com.vaadin.server.ExternalResource; -import com.vaadin.server.Resource; -import com.vaadin.tests.design.DeclarativeTestBase; -import com.vaadin.tests.design.DeclarativeTestBaseBase; -import com.vaadin.ui.AbstractSelect; -import com.vaadin.ui.AbstractSelect.ItemCaptionMode; -import com.vaadin.ui.ComboBox; -import com.vaadin.ui.ListSelect; -import com.vaadin.ui.declarative.DesignContext; -import com.vaadin.ui.declarative.DesignException; - -/** - * Test cases for reading the properties of selection components. - * - * @author Vaadin Ltd - */ -public class AbstractSelectDeclarativeTest - extends DeclarativeTestBase { - - public String getDesignSingleSelectNewItemsAllowed() { - return ""; - - } - - public AbstractSelect getExpectedSingleSelectNewItemsAllowed() { - ComboBox c = new ComboBox(); - c.setNewItemsAllowed(true); - c.setItemCaptionMode(ItemCaptionMode.ICON_ONLY); - c.setNullSelectionAllowed(true);// Default - c.setNullSelectionItemId("nullIid"); - return c; - } - - public String getDesignMultiSelect() { - return ""; - } - - public AbstractSelect getExpectedMultiSelect() { - ListSelect c = new ListSelect(); - c.setNewItemsAllowed(true); - c.setNullSelectionAllowed(false); - c.setItemCaptionMode(ItemCaptionMode.PROPERTY); - c.setMultiSelect(true); - return c; - } - - @Test - public void testReadSingleSelectNewItemsAllowed() { - testRead(getDesignSingleSelectNewItemsAllowed(), - getExpectedSingleSelectNewItemsAllowed()); - } - - @Test - public void testWriteSingleSelectNewItemsAllowed() { - testWrite(getDesignSingleSelectNewItemsAllowed(), - getExpectedSingleSelectNewItemsAllowed()); - } - - @Test - public void testReadMultiSelect() { - testRead(getDesignMultiSelect(), getExpectedMultiSelect()); - } - - @Test - public void testWriteMultiSelect() { - testWrite(getDesignMultiSelect(), getExpectedMultiSelect()); - } - - @Test - public void testReadInlineData() { - testRead(getDesignForInlineData(), getExpectedComponentForInlineData()); - } - - @Test(expected = DesignException.class) - public void testReadMultipleValuesForSingleSelect() { - testRead("" + "" - + "" + "", - null); - } - - @Test - public void testReadMultipleValuesForMultiSelect() { - ListSelect ls = new ListSelect(); - ls.setMultiSelect(true); - ls.addItem("1"); - ls.addItem("2"); - ls.select("1"); - ls.select("2"); - testRead("" - + "" + "" - + "", ls); - } - - @Test - public void testReadSingleValueForMultiSelect() { - ListSelect ls = new ListSelect(); - ls.setMultiSelect(true); - ls.addItem("1"); - ls.addItem("2"); - ls.select("1"); - testRead("" - + "" + "" - + "", ls); - } - - @Test - public void testReadSingleValueForSingleSelect() { - ListSelect ls = new ListSelect(); - ls.setMultiSelect(false); - ls.addItem("1"); - ls.addItem("2"); - ls.select("1"); - testRead("" + "" - + "" + "", ls); - } - - @Test - public void testWriteInlineDataIgnored() { - // No data is written by default - testWrite(stripOptionTags(getDesignForInlineData()), - getExpectedComponentForInlineData()); - } - - @Test - public void testWriteInlineData() { - testWrite(getDesignForInlineData(), getExpectedComponentForInlineData(), - true); - } - - private String getDesignForInlineData() { - return "\n" - + " \n" // - + " \n"// - + ""; - } - - private AbstractSelect getExpectedComponentForInlineData() { - AbstractSelect as = new ListSelect(); - as.addItem("Value 1"); - as.setItemIcon("Value 1", - new ExternalResource("http://some.url/icon.png")); - as.addItem("Value 2"); - as.setValue("Value 2"); - return as; - } - - @Test - public void testReadAttributesSingleSelect() { - Element design = createDesignWithAttributesSingleSelect(); - ComboBox cb = new ComboBox(); - IndexedContainer container = new IndexedContainer(); - container.addContainerProperty("icon", Resource.class, null); - container.addContainerProperty("name", String.class, null); - cb.setContainerDataSource(container); - cb.readDesign(design, new DesignContext()); - Assert.assertTrue("Adding new items should be allowed.", - cb.isNewItemsAllowed()); - assertEquals("Wrong item caption mode.", - AbstractSelect.ItemCaptionMode.PROPERTY, - cb.getItemCaptionMode()); - assertEquals("Wrong item caption property id.", "name", - cb.getItemCaptionPropertyId()); - assertEquals("Wrong item icon property id.", "icon", - cb.getItemIconPropertyId()); - Assert.assertTrue("Null selection should be allowed.", - cb.isNullSelectionAllowed()); - assertEquals("Wrong null selection item id.", "No items selected", - cb.getNullSelectionItemId()); - } - - @Test - public void testReadAttributesMultiSelect() { - Element design = createDesignWithAttributesMultiSelect(); - ListSelect ls = new ListSelect(); - ls.readDesign(design, new DesignContext()); - Assert.assertTrue("Multi select should be allowed.", - ls.isMultiSelect()); - assertEquals("Wrong caption mode.", - AbstractSelect.ItemCaptionMode.EXPLICIT, - ls.getItemCaptionMode()); - Assert.assertFalse("Null selection should not be allowed.", - ls.isNullSelectionAllowed()); - } - - private Element createDesignWithAttributesSingleSelect() { - Attributes attributes = new Attributes(); - attributes.put("new-items-allowed", true); - attributes.put("multi-select", "false"); - attributes.put("item-caption-mode", "property"); - attributes.put("item-caption-property-id", "name"); - attributes.put("item-icon-property-id", "icon"); - attributes.put("null-selection-allowed", true); - attributes.put("null-selection-item-id", "No items selected"); - return new Element(Tag.valueOf("vaadin-combo-box"), "", attributes); - } - - private Element createDesignWithAttributesMultiSelect() { - Attributes attributes = new Attributes(); - attributes.put("multi-select", true); - attributes.put("item-caption-mode", "EXPLICIT"); - attributes.put("null-selection-allowed", "false"); - return new Element(Tag.valueOf("vaadin-list-select"), "", attributes); - } - - @Test - public void testWriteAttributesSingleSelect() { - ComboBox cb = createSingleSelectWithOnlyAttributes(); - Element e = new Element(Tag.valueOf("vaadin-combo-box"), ""); - cb.writeDesign(e, new DesignContext()); - assertEquals("Wrong caption for the combo box.", "A combo box", - e.attr("caption")); - Assert.assertTrue("Adding new items should be allowed.", - "".equals(e.attr("new-items-allowed"))); - assertEquals("Wrong item caption mode.", "icon_only", - e.attr("item-caption-mode")); - assertEquals("Wrong item icon property id.", "icon", - e.attr("item-icon-property-id")); - Assert.assertTrue("Null selection should be allowed.", - "".equals(e.attr("null-selection-allowed")) - || "true".equals(e.attr("null-selection-allowed"))); - assertEquals("Wrong null selection item id.", "No item selected", - e.attr("null-selection-item-id")); - } - - @Test - public void testWriteMultiListSelect() { - ListSelect ls = createMultiSelect(); - Element e = new Element(Tag.valueOf("vaadin-list-select"), ""); - ls.writeDesign(e, new DesignContext()); - assertEquals("Null selection should not be allowed.", "false", - e.attr("null-selection-allowed")); - Assert.assertTrue("Multi select should be allowed.", - "".equals(e.attr("multi-select")) - || "true".equals(e.attr("multi-select"))); - } - - @Test - public void testHtmlEntities() { - String design = "" - + " " - + " " + ""; - AbstractSelect read = read(design); - - Assert.assertEquals("> One", read.getItemCaption("one")); - - AbstractSelect underTest = new ComboBox(); - underTest.addItem("> One"); - - Element root = new Element(Tag.valueOf("vaadin-combo-box"), ""); - DesignContext dc = new DesignContext(); - dc.setShouldWriteDataDelegate( - DeclarativeTestBaseBase.ALWAYS_WRITE_DATA); - underTest.writeDesign(root, dc); - - Assert.assertEquals("> One", - root.getElementsByTag("option").first().html()); - } - - public ComboBox createSingleSelectWithOnlyAttributes() { - ComboBox cb = new ComboBox(); - Container dataSource = new IndexedContainer(); - dataSource.addContainerProperty("icon", Resource.class, null); - cb.setContainerDataSource(dataSource); - cb.setCaption("A combo box"); - cb.setNewItemsAllowed(true); - cb.setItemCaptionMode(ItemCaptionMode.ICON_ONLY); - cb.setItemIconPropertyId("icon"); - cb.setNullSelectionAllowed(true); - cb.setNullSelectionItemId("No item selected"); - return cb; - } - - public ListSelect createMultiSelect() { - ListSelect ls = new ListSelect(); - ls.setNullSelectionAllowed(false); - ls.setMultiSelect(true); - return ls; - } - -} diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java deleted file mode 100644 index 7fc584e3d5..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectListenersTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.vaadin.tests.server.component.abstractselect; - -import org.junit.Test; - -import com.vaadin.data.Container.ItemSetChangeEvent; -import com.vaadin.data.Container.ItemSetChangeListener; -import com.vaadin.data.Container.PropertySetChangeEvent; -import com.vaadin.data.Container.PropertySetChangeListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; -import com.vaadin.ui.ComboBox; - -public class AbstractSelectListenersTest - extends AbstractListenerMethodsTestBase { - - @Test - public void testItemSetChangeListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(ComboBox.class, ItemSetChangeEvent.class, - ItemSetChangeListener.class); - } - - @Test - public void testPropertySetChangeListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(ComboBox.class, PropertySetChangeEvent.class, - PropertySetChangeListener.class); - } -} diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectStateTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectStateTest.java deleted file mode 100644 index c5ff297d7b..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/AbstractSelectStateTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2000-2016 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.Assert; -import org.junit.Test; - -import com.vaadin.shared.ui.select.AbstractSelectState; -import com.vaadin.ui.AbstractSelect; - -/** - * Tests for AbstractSelect state - * - */ -public class AbstractSelectStateTest { - - @Test - public void getState_selectHasCustomState() { - TestSelect select = new TestSelect(); - AbstractSelectState state = select.getState(); - Assert.assertEquals("Unexpected state class", AbstractSelectState.class, - state.getClass()); - } - - @Test - public void getPrimaryStyleName_selectHasCustomPrimaryStyleName() { - TestSelect combobox = new TestSelect(); - AbstractSelectState state = new AbstractSelectState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, combobox.getPrimaryStyleName()); - } - - @Test - public void selectStateHasCustomPrimaryStyleName() { - AbstractSelectState state = new AbstractSelectState(); - Assert.assertEquals("Unexpected primary style name", "v-select", - state.primaryStyleName); - } - - private static class TestSelect extends AbstractSelect { - - @Override - public AbstractSelectState getState() { - return super.getState(); - } - } -} diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java deleted file mode 100644 index 8bd253ab64..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2000-2016 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 OptionGroupDeclarativeTest - 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; - } - -} diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java deleted file mode 100644 index 9a20d2fd79..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractselect/OptionGroupTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.vaadin.tests.server.component.abstractselect; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.junit.Before; -import org.junit.Test; - -import com.vaadin.ui.OptionGroup; - -public class OptionGroupTest { - - private OptionGroup optionGroup; - - @Before - public void setup() { - optionGroup = new OptionGroup(); - } - - @Test - public void itemsAreAdded() { - optionGroup.addItems("foo", "bar"); - - Collection itemIds = optionGroup.getItemIds(); - - assertEquals(2, itemIds.size()); - assertTrue(itemIds.contains("foo")); - assertTrue(itemIds.contains("bar")); - } -} diff --git a/server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectDeclarativeTest.java deleted file mode 100644 index f0fa4aad55..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectDeclarativeTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2000-2016 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.listselect; - -import org.junit.Test; - -import com.vaadin.tests.design.DeclarativeTestBase; -import com.vaadin.ui.ListSelect; - -public class ListSelectDeclarativeTest extends DeclarativeTestBase { - - private ListSelect getWithOptionsExpected() { - ListSelect ls = new ListSelect(); - ls.setRows(10); - ls.addItem("Male"); - ls.addItem("Female"); - return ls; - } - - private String getWithOptionsDesign() { - return "\n" - + " \n" - + " \n" - + "\n" + ""; - } - - @Test - public void testReadWithOptions() { - testRead(getWithOptionsDesign(), getWithOptionsExpected()); - } - - @Test - public void testWriteWithOptions() { - testWrite(stripOptionTags(getWithOptionsDesign()), - getWithOptionsExpected()); - } - - private ListSelect getBasicExpected() { - ListSelect ls = new ListSelect(); - ls.setCaption("Hello"); - return ls; - } - - private String getBasicDesign() { - return ""; - } - - @Test - public void testReadBasic() { - testRead(getBasicDesign(), getBasicExpected()); - } - - @Test - public void testWriteBasic() { - testWrite(getBasicDesign(), getBasicExpected()); - } - -} diff --git a/server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectStateTest.java b/server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectStateTest.java deleted file mode 100644 index 595909aa69..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/listselect/ListSelectStateTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2000-2016 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.listselect; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.shared.ui.select.AbstractSelectState; -import com.vaadin.ui.ListSelect; - -/** - * Tests for ListSelect State. - * - */ -public class ListSelectStateTest { - - @Test - public void getState_listSelectHasCustomState() { - TestListSelect select = new TestListSelect(); - AbstractSelectState state = select.getState(); - Assert.assertEquals("Unexpected state class", AbstractSelectState.class, - state.getClass()); - } - - private static class TestListSelect extends ListSelect { - @Override - public AbstractSelectState getState() { - return super.getState(); - } - } - -} diff --git a/server/src/test/java/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java deleted file mode 100644 index 853f38c7d3..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/nativeselect/NativeSelectDeclarativeTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2000-2016 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.nativeselect; - -import org.junit.Test; - -import com.vaadin.tests.design.DeclarativeTestBase; -import com.vaadin.ui.NativeSelect; - -/** - * Test cases for reading the properties of selection components. - * - * @author Vaadin Ltd - */ -public class NativeSelectDeclarativeTest - extends DeclarativeTestBase { - - public String getBasicDesign() { - return ""; - - } - - public NativeSelect getBasicExpected() { - NativeSelect ns = new NativeSelect(); - ns.addItem("foo"); - ns.addItem("bar"); - return ns; - } - - @Test - public void testReadBasic() { - testRead(getBasicDesign(), getBasicExpected()); - } - - @Test - public void testWriteBasic() { - testWrite(stripOptionTags(getBasicDesign()), getBasicExpected()); - } - - @Test - public void testReadOnlyValue() { - String design = ""; - - NativeSelect ns = new NativeSelect(); - ns.addItems("foo", "bar"); - ns.setValue("foo"); - ns.setReadOnly(true); - - testRead(design, ns); - - // Selects items are not written out by default - String design2 = ""; - testWrite(design2, ns); - } - -} diff --git a/server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java deleted file mode 100644 index 2c2a8a81fb..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupListenersTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.vaadin.tests.server.component.optiongroup; - -import org.junit.Test; - -import com.vaadin.event.FieldEvents.BlurEvent; -import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusEvent; -import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; -import com.vaadin.ui.OptionGroup; - -public class OptionGroupListenersTest extends AbstractListenerMethodsTestBase { - - @Test - public void testFocusListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(OptionGroup.class, FocusEvent.class, - FocusListener.class); - } - - @Test - public void testBlurListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(OptionGroup.class, BlurEvent.class, - BlurListener.class); - } -} diff --git a/server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupStateTest.java b/server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupStateTest.java deleted file mode 100644 index a6d04576bc..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/optiongroup/OptionGroupStateTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2000-2016 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.optiongroup; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.shared.ui.optiongroup.OptionGroupState; -import com.vaadin.ui.OptionGroup; - -/** - * Tests for OptionGroup state. - * - */ -public class OptionGroupStateTest { - - @Test - public void getState_optionGroupHasCustomState() { - TestOptionGroup group = new TestOptionGroup(); - OptionGroupState state = group.getState(); - Assert.assertEquals("Unexpected state class", OptionGroupState.class, - state.getClass()); - } - - @Test - public void getPrimaryStyleName_optionGroupHasCustomPrimaryStyleName() { - OptionGroup layout = new OptionGroup(); - OptionGroupState state = new OptionGroupState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, layout.getPrimaryStyleName()); - } - - @Test - public void optionGroupStateHasCustomPrimaryStyleName() { - OptionGroupState state = new OptionGroupState(); - Assert.assertEquals("Unexpected primary style name", - "v-select-optiongroup", state.primaryStyleName); - } - - private static class TestOptionGroup extends OptionGroup { - - @Override - public OptionGroupState getState() { - return super.getState(); - } - } -} diff --git a/server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java deleted file mode 100644 index 1b0ff1caff..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/select/SelectListenersTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.vaadin.tests.server.component.select; - -import org.junit.Test; - -import com.vaadin.event.FieldEvents.BlurEvent; -import com.vaadin.event.FieldEvents.BlurListener; -import com.vaadin.event.FieldEvents.FocusEvent; -import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; -import com.vaadin.ui.Select; - -public class SelectListenersTest extends AbstractListenerMethodsTestBase { - - @Test - public void testFocusListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(Select.class, FocusEvent.class, - FocusListener.class); - } - - @Test - public void testBlurListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(Select.class, BlurEvent.class, - BlurListener.class); - } -} diff --git a/server/src/test/java/com/vaadin/ui/AbsSelectTest.java b/server/src/test/java/com/vaadin/ui/AbsSelectTest.java deleted file mode 100644 index 51556f9e1a..0000000000 --- a/server/src/test/java/com/vaadin/ui/AbsSelectTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2000-2016 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.ui; - -import java.util.ArrayList; -import java.util.HashSet; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.data.util.ObjectProperty; - -public class AbsSelectTest { - - @Test - public void addItemsStrings() { - NativeSelect ns = new NativeSelect(); - ns.addItems("Foo", "bar", "baz"); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { "Foo", "bar", "baz" }, - ns.getItemIds().toArray()); - } - - @Test - public void addItemsObjects() { - Object o1 = new Object(); - Object o2 = new Object(); - Object o3 = new Object(); - - NativeSelect ns = new NativeSelect(); - ns.addItems(o1, o2, o3); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, - ns.getItemIds().toArray()); - } - - @Test - public void addItemsStringList() { - ArrayList itemIds = new ArrayList(); - itemIds.add("foo"); - itemIds.add("bar"); - itemIds.add("baz"); - NativeSelect ns = new NativeSelect(); - ns.addItems(itemIds); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { "foo", "bar", "baz" }, - ns.getItemIds().toArray()); - } - - @Test - public void addItemsObjectList() { - Object o1 = new Object(); - Object o2 = new Object(); - Object o3 = new Object(); - ArrayList itemIds = new ArrayList(); - itemIds.add(o1); - itemIds.add(o2); - itemIds.add(o3); - NativeSelect ns = new NativeSelect(); - ns.addItems(itemIds); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, - ns.getItemIds().toArray()); - - } - - @Test - public void singleSelectInitiallyEmpty() { - AbstractSelect s = new ListSelect(); - Assert.assertTrue(s.isEmpty()); - } - - @Test - public void singleSelectEmptyAfterClearUsingPDS() { - AbstractSelect s = new ListSelect(); - s.addItem("foo"); - s.addItem("bar"); - s.setPropertyDataSource(new ObjectProperty("foo")); - - Assert.assertFalse(s.isEmpty()); - s.clear(); - Assert.assertTrue(s.isEmpty()); - } - - @Test - public void singleSelectEmptyAfterClear() { - AbstractSelect s = new ListSelect(); - s.addItem("foo"); - s.addItem("bar"); - s.setValue("bar"); - - Assert.assertFalse(s.isEmpty()); - s.clear(); - Assert.assertTrue(s.isEmpty()); - } - - @Test - public void multiSelectInitiallyEmpty() { - AbstractSelect s = new ListSelect(); - s.setMultiSelect(true); - Assert.assertTrue(s.isEmpty()); - } - - @Test - public void multiSelectEmptyAfterClearUsingPDS() { - AbstractSelect s = new ListSelect(); - s.setMultiSelect(true); - s.addItem("foo"); - s.addItem("bar"); - HashSet sel = new HashSet(); - sel.add("foo"); - sel.add("bar"); - s.setPropertyDataSource(new ObjectProperty(sel)); - - Assert.assertFalse(s.isEmpty()); - s.clear(); - Assert.assertTrue(s.isEmpty()); - } - - @Test - public void multiSelectEmptyAfterClear() { - AbstractSelect s = new ListSelect(); - s.setMultiSelect(true); - s.addItem("foo"); - s.addItem("bar"); - s.select("foo"); - s.select("bar"); - - Assert.assertFalse(s.isEmpty()); - s.clear(); - Assert.assertTrue(s.isEmpty()); - } - -} diff --git a/server/src/test/java/com/vaadin/ui/NativeSelectTest.java b/server/src/test/java/com/vaadin/ui/NativeSelectTest.java deleted file mode 100644 index 1a41fc1097..0000000000 --- a/server/src/test/java/com/vaadin/ui/NativeSelectTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2000-2016 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.ui; - -import java.util.Collections; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.data.util.IndexedContainer; -import com.vaadin.shared.ui.select.AbstractSelectState; - -public class NativeSelectTest { - - @Test - public void rpcRegisteredConstructorNoArg() { - assertFocusRpcRegistered(new NativeSelect()); - } - - @Test - public void rpcRegisteredConstructorString() { - assertFocusRpcRegistered(new NativeSelect("foo")); - } - - @Test - public void rpcRegisteredConstructorStringCollection() { - assertFocusRpcRegistered( - new NativeSelect("foo", Collections.singleton("Hello"))); - } - - @Test - public void rpcRegisteredConstructorStringContainer() { - assertFocusRpcRegistered( - new NativeSelect("foo", new IndexedContainer())); - } - - @Test - public void getState_listSelectHasCustomState() { - TestNativeSelect select = new TestNativeSelect(); - AbstractSelectState state = select.getState(); - Assert.assertEquals("Unexpected state class", AbstractSelectState.class, - state.getClass()); - } - - private static class TestNativeSelect extends NativeSelect { - @Override - public AbstractSelectState getState() { - return super.getState(); - } - } - - private void assertFocusRpcRegistered(NativeSelect s) { - Assert.assertNotNull("RPC is not correctly registered", s.getRpcManager( - "com.vaadin.shared.communication.FieldRpc$FocusAndBlurServerRpc")); - } - -} diff --git a/server/src/test/resources/com/vaadin/tests/design/all-components-legacy.html b/server/src/test/resources/com/vaadin/tests/design/all-components-legacy.html deleted file mode 100644 index 39aecb6db1..0000000000 --- a/server/src/test/resources/com/vaadin/tests/design/all-components-legacy.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - OK - Cancel - - - - - OK - - - - - - OK - - - - - - OK - - - - - - OK - - - - - - - - - - - - - - - - test value - - OK - - OK - - - - - - - - - - In disabled tab - can’t be shown by default - - - - - - - - - - - - - - - In disabled tab - can’t be shown by default - - - - - - - - - First slot - - - Second slot - - - First slot - Second slot - - - - Hello world! - This is Rich content! - This is only text and will contain visible tags - - - - - - - - - - - - - - - - diff --git a/server/src/test/resources/com/vaadin/tests/design/all-components.html b/server/src/test/resources/com/vaadin/tests/design/all-components.html deleted file mode 100644 index 6507188cd7..0000000000 --- a/server/src/test/resources/com/vaadin/tests/design/all-components.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - OK - Cancel - - - - - OK - - - - - - OK - - - - - - OK - - - - - - OK - - - - - - - - - - - - - - - - test value - - OK - - OK - - - - - - - - - - In disabled tab - can’t be shown by default - - - - - - - - - - - - - - - In disabled tab - can’t be shown by default - - - - - - - - - First slot - - - Second slot - - - First slot - Second slot - - - - Hello world! - This is Rich content! - This is only text and will contain visible tags - - - - - - - - - - - - - - - - -- cgit v1.2.3