]> source.dussan.org Git - vaadin-framework.git/commitdiff
ComboBoxFiltering test rewrite to TB3
authorAnthony Guerreiro <anthony@vaadin.com>
Mon, 28 Jul 2014 09:33:56 +0000 (10:33 +0100)
committerVaadin Code Review <review@vaadin.com>
Tue, 5 Aug 2014 15:03:56 +0000 (15:03 +0000)
Change-Id: I9aead23bfe093517d0b964dbf9f0ccf38dec7da2

uitest/src/com/vaadin/tests/components/combobox/ComboBoxFiltering.html [deleted file]
uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java [new file with mode: 0644]

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 (file)
index 3de2218..0000000
+++ /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 (file)
index 0000000..f030c0f
--- /dev/null
@@ -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();
+    }
+}