From cad11e69d203e303c7a7d2e329f044f319ecf72e Mon Sep 17 00:00:00 2001 From: Anthony Guerreiro Date: Mon, 28 Jul 2014 10:33:56 +0100 Subject: ComboBoxFiltering test rewrite to TB3 Change-Id: I9aead23bfe093517d0b964dbf9f0ccf38dec7da2 --- .../components/combobox/ComboBoxFiltering.html | 62 ------------ .../components/combobox/ComboBoxSlowTest.java | 108 +++++++++++++++++++++ 2 files changed, 108 insertions(+), 62 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/combobox/ComboBoxFiltering.html create mode 100644 uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxFiltering.html b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxFiltering.html deleted file mode 100644 index 3de221871d..0000000000 --- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxFiltering.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.combobox.ComboBoxSlow?restartApplication
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboBoxSlow::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[0]92,19
enterCharactervaadin=runcomvaadintestscomponentscomboboxComboBoxSlow::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[0]1
screenCapturefilter-no-match
enterCharactervaadin=runcomvaadintestscomponentscomboboxComboBoxSlow::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[0]Item 12
screenCapturefilter-11-matches-paging
screenCapturefilter-11-matches-page-2
enterCharactervaadin=runcomvaadintestscomponentscomboboxComboBoxSlow::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[0]Item 100
screenCapturefilter-2-matches-no-paging
- - diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java new file mode 100644 index 0000000000..f030c0f5a0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java @@ -0,0 +1,108 @@ +/* + * 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Verifies SlowComboBox filtering works when user inputs text. Also verifies + * pagination works when the matching results number more than those that can be + * displayed. + * + * @since + * @author Vaadin Ltd + */ +public class ComboBoxSlowTest extends MultiBrowserTest { + + @Before + public void init() { + openTestURL(); + } + + @Test + public void testZeroMatches() throws InterruptedException { + clickComboBoxTextArea(); + sleep(250); + typeString("1"); + assertEquals(0, getNumberOfSuggestions()); + } + + @Test + public void testElevenMatchesAndPaging() throws InterruptedException { + clickComboBoxTextArea(); + sleep(250); + typeString("Item 12"); + + assertEquals(10, getNumberOfSuggestions()); + assertTrue(isPagingActive()); + goToNextPage(); + + sleep(500); + assertEquals(1, getNumberOfSuggestions()); + + } + + @Test + public void testTwoMatchesNoPaging() { + clickComboBoxTextArea(); + typeString("Item 100"); + assertEquals(2, getNumberOfSuggestions()); + assertFalse(isPagingActive()); + } + + private void clickComboBoxTextArea() { + WebElement cb = getDriver().findElement( + By.className("v-filterselect-input")); + cb.click(); + } + + private void typeString(String s) { + Actions action = new Actions(getDriver()); + action.sendKeys(s); + action.build().perform(); + } + + private int getNumberOfSuggestions() { + + List elements = getDriver().findElements( + By.className("gwt-MenuItem")); + return elements.size(); + } + + private boolean isPagingActive() { + List elements = getDriver().findElements( + By.className("v-filterselect-nextpage")); + return elements.size() == 1; + } + + private void goToNextPage() { + WebElement nextPage = getDriver().findElement( + By.className("v-filterselect-nextpage")); + nextPage.click(); + } +} -- cgit v1.2.3