diff options
author | Matti Tahvonen <matti@vaadin.com> | 2015-05-29 16:22:26 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-06-08 07:19:26 +0000 |
commit | 5ae33b641eea02b647825b27c311d4116f3be838 (patch) | |
tree | cc731c84e62a14b7a3a621841cb7590ee3081f04 /uitest/src/com/vaadin/tests/components/combobox | |
parent | b0d5315e8ba95d099f93dc2d16339033a6525b59 (diff) | |
download | vaadin-framework-5ae33b641eea02b647825b27c311d4116f3be838.tar.gz vaadin-framework-5ae33b641eea02b647825b27c311d4116f3be838.zip |
Selection is now shown although scrollToSelectedItem is false (#16673)
If scrollToSelectedItem is set to false (which is needed to work
properly with
large datasets) the selected item caption is sent to client with a
special
attribute to avoid the field looking like unselected.
Change-Id: Ib80355c3b52faaaeaa9ab7195644701cc3bf0d15
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/combobox')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabled.java | 74 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabledTest.java | 44 |
2 files changed, 118 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabled.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabled.java new file mode 100644 index 0000000000..f94306d2fa --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabled.java @@ -0,0 +1,74 @@ +package com.vaadin.tests.components.combobox; + +import java.util.ArrayList; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.tests.components.ComponentTestCase; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Notification; + +public class ComboBoxScrollingToPageDisabled extends + ComponentTestCase<ComboBox> { + + private static final Object CAPTION = "caption"; + + @Override + protected Class<ComboBox> getTestClass() { + return ComboBox.class; + } + + @Override + protected void initializeComponents() { + ComboBox s = createSelect(null); + s.setScrollToSelectedItem(false); + populate(s, 100); + Object selection = new ArrayList<Object>(s.getItemIds()).get(50); + s.setValue(selection); + addTestComponent(s); + } + + private void populate(ComboBox s, int nr) { + for (int i = 0; i < nr; i++) { + addItem(s, "Item " + i); + } + } + + @SuppressWarnings("unchecked") + private void addItem(ComboBox s, String string) { + Object id = s.addItem(); + s.getItem(id).getItemProperty(CAPTION).setValue(string); + + } + + private ComboBox createSelect(String caption) { + final ComboBox cb = new ComboBox(); + cb.setImmediate(true); + cb.addContainerProperty(CAPTION, String.class, ""); + cb.setItemCaptionPropertyId(CAPTION); + cb.setCaption(caption); + cb.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + Notification.show("Value now:" + cb.getValue() + " " + + cb.getItemCaption(cb.getValue())); + + } + }); + return cb; + } + + @Override + protected String getDescription() { + return "Test that selected value appears on the client " + + "side even though setScrollToSelectedItem(false) " + + "has been called. Textbox should containe 'Item 50'."; + } + + @Override + protected Integer getTicketNumber() { + return 16673; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabledTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabledTest.java new file mode 100644 index 0000000000..8c09279b87 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabledTest.java @@ -0,0 +1,44 @@ +/* + * 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.components.combobox; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * When pressed down key, while positioned on the last item - should show next + * page and focus on the first item of the next page. + */ +public class ComboBoxScrollingToPageDisabledTest extends MultiBrowserTest { + + @Override + public void setup() throws Exception { + super.setup(); + openTestURL(); + } + + @Test + public void checkValueIsVidinlr() throws InterruptedException { + WebElement input = driver.findElement(By + .className("v-filterselect-input")); + String value = input.getAttribute("value"); + org.junit.Assert.assertEquals("Item 50", value); + } + +} |