diff options
author | Anthony Guerreiro <anthony@vaadin.com> | 2014-07-28 10:33:56 +0100 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-05 15:03:56 +0000 |
commit | cad11e69d203e303c7a7d2e329f044f319ecf72e (patch) | |
tree | e5f49e54eb61da9d350f9843b502e5b1a3ba31a9 /uitest | |
parent | 251f248f426df40808d65ad8aa1c7a5e6edc16a6 (diff) | |
download | vaadin-framework-cad11e69d203e303c7a7d2e329f044f319ecf72e.tar.gz vaadin-framework-cad11e69d203e303c7a7d2e329f044f319ecf72e.zip |
ComboBoxFiltering test rewrite to TB3
Change-Id: I9aead23bfe093517d0b964dbf9f0ccf38dec7da2
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/combobox/ComboBoxFiltering.html | 62 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java | 108 |
2 files changed, 108 insertions, 62 deletions
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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.combobox.ComboBoxSlow?restartApplication</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxSlow::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[0]</td> - <td>92,19</td> -</tr> -<tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxSlow::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[0]</td> - <td>1</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>filter-no-match</td> -</tr> -<tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxSlow::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[0]</td> - <td>Item 12</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>filter-11-matches-paging</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>filter-11-matches-page-2</td> -</tr> -<tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxSlow::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[0]</td> - <td>Item 100</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>filter-2-matches-no-paging</td> -</tr> - -</tbody></table> -</body> -</html> 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<WebElement> elements = getDriver().findElements( + By.className("gwt-MenuItem")); + return elements.size(); + } + + private boolean isPagingActive() { + List<WebElement> 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(); + } +} |