]> source.dussan.org Git - vaadin-framework.git/commitdiff
ComboBox not always shows selected value (#10600)
authorAnna Miroshnik <anna.miroshnik@arcadia.spb.ru>
Fri, 5 Sep 2014 08:09:40 +0000 (12:09 +0400)
committerVaadin Code Review <review@vaadin.com>
Tue, 16 Sep 2014 12:58:13 +0000 (12:58 +0000)
Full name of defect: ComboBox doesn't show selected value beyond the first dropdown page.
Tests to be sure that this bug is not reproduced now.
Test were updated not to use Thread.sleep().

Change-Id: I12b0c9a1fbae5e934ebe0471b1b60a3ec7098da7

uitest/src/com/vaadin/tests/components/combobox/ComboSelectedValueBeyondTheFirstDropdownPage.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/combobox/ComboSelectedValueBeyondTheFirstDropdownPageTest.java [new file with mode: 0644]

diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboSelectedValueBeyondTheFirstDropdownPage.java b/uitest/src/com/vaadin/tests/components/combobox/ComboSelectedValueBeyondTheFirstDropdownPage.java
new file mode 100644 (file)
index 0000000..41b61c9
--- /dev/null
@@ -0,0 +1,61 @@
+package com.vaadin.tests.components.combobox;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Label;
+
+@SuppressWarnings("serial")
+public class ComboSelectedValueBeyondTheFirstDropdownPage extends AbstractTestUI {
+
+    protected static final int ITEM_COUNT = 21;
+    protected static final String ITEM_NAME_TEMPLATE = "Item %d";
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        Label value = getLabel();
+        ComboBox combobox = getComboBox(value);
+
+        addComponent(combobox);
+        addComponent(value);
+    }
+
+    private Label getLabel() {
+        final Label value = new Label();
+        value.setId("value");
+
+        return value;
+    }
+
+    private ComboBox getComboBox(final Label value) {
+        final ComboBox combobox = new ComboBox("MyCaption");
+        combobox.setDescription("ComboBox with more than 10 elements in it's dropdown list.");
+
+        combobox.setImmediate(true);
+
+        for (int i = 1; i <= ITEM_COUNT; i++) {
+            combobox.addItem(String.format(ITEM_NAME_TEMPLATE, i));
+        }
+
+        combobox.addValueChangeListener(new ValueChangeListener() {
+            @Override
+            public void valueChange(ValueChangeEvent event) {
+                value.setValue(String.valueOf(event.getProperty().getValue()));
+            }
+        });
+
+        return combobox;
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Test for ensuring that ComboBox shows selected value beyound the first dropdown page";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 10600;
+    }
+}
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboSelectedValueBeyondTheFirstDropdownPageTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboSelectedValueBeyondTheFirstDropdownPageTest.java
new file mode 100644 (file)
index 0000000..2803286
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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 com.vaadin.testbench.elements.ComboBoxElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+@SuppressWarnings("serial")
+public class ComboSelectedValueBeyondTheFirstDropdownPageTest extends
+        MultiBrowserTest {
+
+    @Test
+    public void valueOnSecondPageIsSelected() {
+        openTestURL();
+
+        ComboBoxElement comboBoxWebElement = $(ComboBoxElement.class).first();
+
+        comboBoxWebElement.openNextPage();
+        comboBoxWebElement.selectByText("Item 19");
+
+        assertThat($(LabelElement.class).id("value").getText(), is("Item 19"));
+    }
+}