aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-08-20 13:55:11 +0300
committerArtur Signell <artur@vaadin.com>2014-08-20 13:55:11 +0300
commit4bbf0565b92c4168273b2bb74ded05911cbdf2bf (patch)
treec977b1cc34b0d95a05fb8feb8d7dbc0513829018
parent8cec1704ae7625ba630d895ce673d9c2784db84e (diff)
parent1dc8c5c28c5d8990f15a69ea466cdf5178305a78 (diff)
downloadvaadin-framework-4bbf0565b92c4168273b2bb74ded05911cbdf2bf.tar.gz
vaadin-framework-4bbf0565b92c4168273b2bb74ded05911cbdf2bf.zip
Merge remote-tracking branch 'origin/master' into 7.3
-rw-r--r--server/src/com/vaadin/server/communication/ServerRpcHandler.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlow.java11
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java43
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.html292
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java9
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInputTest.java392
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html61
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java9
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java76
9 files changed, 524 insertions, 373 deletions
diff --git a/server/src/com/vaadin/server/communication/ServerRpcHandler.java b/server/src/com/vaadin/server/communication/ServerRpcHandler.java
index 9107a4e049..ae076e0856 100644
--- a/server/src/com/vaadin/server/communication/ServerRpcHandler.java
+++ b/server/src/com/vaadin/server/communication/ServerRpcHandler.java
@@ -91,8 +91,8 @@ public class ServerRpcHandler implements Serializable {
} else {
syncId = -1;
}
- invocations = new JSONArray(
- json.getString(ApplicationConstants.RPC_INVOCATIONS));
+ invocations = json
+ .getJSONArray(ApplicationConstants.RPC_INVOCATIONS);
}
/**
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlow.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlow.java
index 13066854bf..3668637846 100644
--- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlow.java
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlow.java
@@ -2,10 +2,11 @@ package com.vaadin.tests.components.combobox;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.tests.components.TestBase;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.util.Log;
-public class ComboBoxSlow extends TestBase {
+public class ComboBoxSlow extends AbstractTestUI {
private Log log = new Log(5);
@@ -15,19 +16,19 @@ public class ComboBoxSlow extends TestBase {
}
@Override
- protected String getDescription() {
+ protected String getTestDescription() {
return "The ComboBox artificially introduces a server delay to more easily spot problems";
}
@Override
- protected void setup() {
+ protected void setup(VaadinRequest request) {
addComponent(log);
final SlowComboBox cb = new SlowComboBox();
cb.setImmediate(true);
for (int i = 0; i <= 1000; i++) {
cb.addItem("Item " + i);
}
- cb.addListener(new ValueChangeListener() {
+ cb.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
log.log("Value changed to " + cb.getValue());
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java
index f030c0f5a0..e547e68fc1 100644
--- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java
@@ -23,8 +23,10 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
+import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedCondition;
import com.vaadin.testbench.By;
import com.vaadin.tests.tb3.MultiBrowserTest;
@@ -58,21 +60,44 @@ public class ComboBoxSlowTest extends MultiBrowserTest {
sleep(250);
typeString("Item 12");
- assertEquals(10, getNumberOfSuggestions());
+ final WebElement popup = driver.findElement(By
+ .className("v-filterselect-suggestpopup"));
+ List<WebElement> filteredItems = getFilteredItems(popup);
+ assertEquals("unexpected amount of suggestions found on first page",
+ 10, filteredItems.size());
+ assertEquals("wrong filtering result", "Item 12", filteredItems.get(0)
+ .getText());
+ assertEquals("wrong filtering result", "Item 128", filteredItems.get(9)
+ .getText());
+
assertTrue(isPagingActive());
goToNextPage();
- sleep(500);
- assertEquals(1, getNumberOfSuggestions());
-
+ waitUntil(new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver input) {
+ List<WebElement> filteredItems = getFilteredItems(popup);
+ return filteredItems.size() == 1
+ && "Item 129".equals(filteredItems.get(0).getText());
+ }
+ });
}
@Test
public void testTwoMatchesNoPaging() {
clickComboBoxTextArea();
typeString("Item 100");
- assertEquals(2, getNumberOfSuggestions());
assertFalse(isPagingActive());
+
+ WebElement popup = driver.findElement(By
+ .className("v-filterselect-suggestpopup"));
+ List<WebElement> filteredItems = getFilteredItems(popup);
+ assertEquals("unexpected amount of suggestions found", 2,
+ filteredItems.size());
+ assertEquals("wrong filtering result", "Item 100", filteredItems.get(0)
+ .getText());
+ assertEquals("wrong filtering result", "Item 1000", filteredItems
+ .get(1).getText());
}
private void clickComboBoxTextArea() {
@@ -105,4 +130,12 @@ public class ComboBoxSlowTest extends MultiBrowserTest {
By.className("v-filterselect-nextpage"));
nextPage.click();
}
+
+ /*
+ * Gets the list of filtered items from the combobox popup.
+ */
+ private List<WebElement> getFilteredItems(final WebElement popup) {
+ return popup.findElement(By.className("v-filterselect-suggestmenu"))
+ .findElements(By.className("gwt-MenuItem"));
+ }
}
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.html b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.html
deleted file mode 100644
index 2aab40f13f..0000000000
--- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.html
+++ /dev/null
@@ -1,292 +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>ComboBoxValueInput</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">ComboBoxValueInput</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.components.combobox.ComboBoxValueInput</td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[3]/td</td>
- <td>58,6</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[0]</td>
- <td>96,14</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[4]/td/span</td>
- <td>29,6</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[3]/td</td>
- <td>99,13</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[1]/td</td>
- <td>97,14</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[0]</td>
- <td>68,17</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>enterCharacter</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[0]</td>
- <td>value</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[0]</td>
- <td>down</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[0]</td>
- <td>down</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[0]</td>
- <td>down</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>pressSpecialKey</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[0]</td>
- <td>enter</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VFilterSelect[0]/domChild[0]</td>
- <td>76,17</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VFilterSelect[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[2]/td</td>
- <td>71,11</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VFilterSelect[0]/domChild[1]</td>
- <td></td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>screenCapture</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[1]/td</td>
- <td>58,9</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VFilterSelect[0]/domChild[0]</td>
- <td>73,12</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>mouseClick</td>
- <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxValueInput::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VFilterSelect[0]/domChild[0]</td>
- <td>43,7</td>
-</tr>
-<tr>
- <td>waitForVaadin</td>
- <td></td>
- <td></td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java
index 356181238e..b0c1acb421 100644
--- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java
@@ -1,13 +1,14 @@
package com.vaadin.tests.components.combobox;
+import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.combobox.FilteringMode;
-import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.ComboBox;
-public class ComboBoxValueInput extends TestBase {
+public class ComboBoxValueInput extends AbstractTestUI {
@Override
- protected void setup() {
+ protected void setup(VaadinRequest request) {
(getLayout()).setSpacing(true);
ComboBox cb = getComboBox("A combobox", false);
@@ -38,7 +39,7 @@ public class ComboBoxValueInput extends TestBase {
}
@Override
- protected String getDescription() {
+ protected String getTestDescription() {
return "A combobox should always show the selected value when it is not focused. Entering a text when nothing is selected and blurring the combobox should reset the value. The same should happen when a value is selected";
}
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInputTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInputTest.java
new file mode 100644
index 0000000000..74879f66e8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxValueInputTest.java
@@ -0,0 +1,392 @@
+/*
+ * 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.Keys;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.ComboBoxElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests ComboBox inputs and selections.
+ *
+ * @author Vaadin Ltd
+ */
+public class ComboBoxValueInputTest extends MultiBrowserTest {
+
+ @Override
+ @Before
+ public void setup() throws Exception {
+ super.setup();
+ openTestURL();
+ };
+
+ @Test
+ public void testOverall() {
+ List<ComboBoxElement> comboBoxes = $(ComboBoxElement.class).all();
+ assertEquals("unexpected amount of comboboxes found", 6,
+ comboBoxes.size());
+ }
+
+ @Test
+ public void testFirstComboBoxInputs() {
+ ComboBoxElement comboBox = $(ComboBoxElement.class).all().get(0);
+
+ // check the initial selection
+ assertEquals("correct selection not found", "",
+ comboBox.findElement(By.tagName("input")).getAttribute("value"));
+
+ // ensure the combobox has suggested values
+ assertFalse("suggestions not found even if there should be several",
+ comboBox.getPopupSuggestions().isEmpty());
+
+ // check that the found items were correct ones
+ WebElement popup = driver.findElement(By
+ .className("v-filterselect-suggestpopup"));
+ List<WebElement> filteredItems = popup.findElement(
+ By.className("v-filterselect-suggestmenu")).findElements(
+ By.className("gwt-MenuItem"));
+ assertEquals("unexpected amount of suggestions found", 4,
+ filteredItems.size());
+ assertEquals("wrong filtering result", " ", filteredItems.get(0)
+ .getText());
+ assertEquals("wrong filtering result", "Value 1", filteredItems.get(1)
+ .getText());
+ assertEquals("wrong filtering result", "Value 3", filteredItems.get(3)
+ .getText());
+
+ // select the second last item
+ filteredItems.get(2).click();
+
+ // ensure there's no more popup
+ assertFalse("popup found when there should be none",
+ comboBox.isElementPresent(By.vaadin("#popup")));
+
+ // check the updated selection
+ assertEquals("correct selection not found", "Value 2", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+ }
+
+ @Test
+ public void testSecondComboBoxInputs() {
+ ComboBoxElement comboBox = $(ComboBoxElement.class).all().get(1);
+
+ // check the input prompt
+ assertEquals("correct input prompt not found", "Please select",
+ comboBox.findElement(By.tagName("input")).getAttribute("value"));
+
+ // focus the combobox
+ comboBox.findElement(By.tagName("input")).click();
+
+ // check the input prompt has disappeared
+ assertEquals("correct input prompt not found", "", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+
+ // ensure the combobox has suggested values
+ assertFalse("suggestions not found even if there should be several",
+ comboBox.getPopupSuggestions().isEmpty());
+
+ // check that the found items were correct ones
+ WebElement popup = driver.findElement(By
+ .className("v-filterselect-suggestpopup"));
+ List<WebElement> filteredItems = popup.findElement(
+ By.className("v-filterselect-suggestmenu")).findElements(
+ By.className("gwt-MenuItem"));
+ assertEquals("unexpected amount of suggestions found", 4,
+ filteredItems.size());
+ assertEquals("wrong filtering result", " ", filteredItems.get(0)
+ .getText());
+ assertEquals("wrong filtering result", "Value 1", filteredItems.get(1)
+ .getText());
+ assertEquals("wrong filtering result", "Value 3", filteredItems.get(3)
+ .getText());
+
+ // select the last item
+ filteredItems.get(3).click();
+
+ // ensure there's no more popup
+ assertFalse("popup found when there should be none",
+ comboBox.isElementPresent(By.vaadin("#popup")));
+
+ // check the updated selection
+ assertEquals("correct selection not found", "Value 3", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+ }
+
+ @Test
+ public void testThirdComboBoxInputs() {
+ ComboBoxElement comboBox = $(ComboBoxElement.class).all().get(2);
+
+ // check the null selection
+ assertEquals("correct selection not found", "Null item", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+
+ // ensure the combobox has suggested values
+ assertFalse("suggestions not found even if there should be several",
+ comboBox.getPopupSuggestions().isEmpty());
+
+ // check that the found items were correct ones
+ WebElement popup = driver.findElement(By
+ .className("v-filterselect-suggestpopup"));
+ List<WebElement> filteredItems = popup.findElement(
+ By.className("v-filterselect-suggestmenu")).findElements(
+ By.className("gwt-MenuItem"));
+ assertEquals("unexpected amount of suggestions found", 4,
+ filteredItems.size());
+ assertEquals("wrong filtering result", "Null item", filteredItems
+ .get(0).getText());
+ assertEquals("wrong filtering result", "Value 1", filteredItems.get(1)
+ .getText());
+ assertEquals("wrong filtering result", "Value 3", filteredItems.get(3)
+ .getText());
+
+ // ensure the null item is marked as selected
+ assertEquals("wrong selection", "Null item",
+ popup.findElement(By.className("v-filterselect-suggestmenu"))
+ .findElement(By.className("gwt-MenuItem-selected"))
+ .getText());
+
+ // select the second last item
+ filteredItems.get(2).click();
+
+ // ensure there's no more popup
+ assertFalse("popup found when there should be none",
+ comboBox.isElementPresent(By.vaadin("#popup")));
+
+ // check the updated selection
+ assertEquals("correct selection not found", "Value 2", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+
+ // open the popup again
+ comboBox.openPopup();
+
+ // check that the found items were correct ones
+ popup = driver.findElement(By.className("v-filterselect-suggestpopup"));
+ filteredItems = popup.findElement(
+ By.className("v-filterselect-suggestmenu")).findElements(
+ By.className("gwt-MenuItem"));
+ assertEquals("unexpected amount of suggestions found", 4,
+ filteredItems.size());
+ assertEquals("wrong filtering result", "Null item", filteredItems
+ .get(0).getText());
+ assertEquals("wrong filtering result", "Value 1", filteredItems.get(1)
+ .getText());
+ assertEquals("wrong filtering result", "Value 3", filteredItems.get(3)
+ .getText());
+
+ // ensure the selected item is marked as selected
+ assertEquals("wrong selection", "Value 2",
+ popup.findElement(By.className("v-filterselect-suggestmenu"))
+ .findElement(By.className("gwt-MenuItem-selected"))
+ .getText());
+
+ // select the first item again
+ filteredItems.get(0).click();
+
+ // ensure there's no more popup
+ assertFalse("popup found when there should be none",
+ comboBox.isElementPresent(By.vaadin("#popup")));
+
+ // check the displayed value didn't change
+ assertEquals("correct selection not found", "Null item", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+
+ // enter a new filtering value
+ comboBox.findElement(By.tagName("input")).clear();
+ comboBox.findElement(By.tagName("input")).sendKeys("value");
+
+ // ensure there's a popup again
+ assertTrue("popup not found when there should be one",
+ comboBox.isElementPresent(By.vaadin("#popup")));
+
+ // check that the found items were correct ones
+ popup = driver.findElement(By.className("v-filterselect-suggestpopup"));
+ filteredItems = popup.findElement(
+ By.className("v-filterselect-suggestmenu")).findElements(
+ By.className("gwt-MenuItem"));
+ assertEquals("unexpected amount of suggestions found", 3,
+ filteredItems.size());
+ assertEquals("wrong filtering result", "Value 1", filteredItems.get(0)
+ .getText());
+ assertEquals("wrong filtering result", "Value 3", filteredItems.get(2)
+ .getText());
+
+ // check the displayed value updated
+ assertEquals("correct selection not found", "value", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+
+ comboBox.findElement(By.tagName("input")).sendKeys(Keys.ARROW_DOWN);
+
+ // ensure the first item is marked as selected
+ assertEquals("wrong selection", "Value 1",
+ popup.findElement(By.className("v-filterselect-suggestmenu"))
+ .findElement(By.className("gwt-MenuItem-selected"))
+ .getText());
+
+ // navigate with keys to the last item
+ comboBox.findElement(By.tagName("input")).sendKeys(Keys.ARROW_DOWN);
+ comboBox.findElement(By.tagName("input")).sendKeys(Keys.ARROW_DOWN);
+
+ // TODO: remove this limit once #14402 has been fixed
+ if (getBrowsersExcludingIE().contains(getDesiredCapabilities())) {
+ // ensure the last item is marked as selected
+ assertEquals(
+ "wrong selection",
+ "Value 3",
+ popup.findElement(
+ By.className("v-filterselect-suggestmenu"))
+ .findElement(By.className("gwt-MenuItem-selected"))
+ .getText());
+ }
+
+ // select the last item
+ comboBox.findElement(By.tagName("input")).sendKeys(Keys.RETURN);
+
+ // TODO: remove this limit once #14402 has been fixed
+ if (getBrowsersExcludingIE().contains(getDesiredCapabilities())) {
+ // check the updated selection
+ assertEquals("correct selection not found", "Value 3", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+ }
+
+ // TODO: remove this altogether once #14402 has been fixed
+ if (Browser.PHANTOMJS.getDesiredCapabilities().equals(
+ getDesiredCapabilities())) {
+ // toggle popup closed since the RETURN didn't do it
+ comboBox.openPopup();
+ }
+
+ // ensure there's no more popup
+ assertFalse("popup found when there should be none",
+ comboBox.isElementPresent(By.vaadin("#popup")));
+ }
+
+ @Test
+ public void testFourthComboBoxInputs() {
+ ComboBoxElement comboBox = $(ComboBoxElement.class).all().get(3);
+
+ // check the combobox displays the null selection instead of the input
+ // prompt
+ assertEquals("correct value not displayed", "Null item", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+
+ // ensure the combobox has suggested values
+ assertFalse("suggestions not found even if there should be several",
+ comboBox.getPopupSuggestions().isEmpty());
+
+ // check that the found items were correct ones
+ WebElement popup = driver.findElement(By
+ .className("v-filterselect-suggestpopup"));
+ List<WebElement> filteredItems = popup.findElement(
+ By.className("v-filterselect-suggestmenu")).findElements(
+ By.className("gwt-MenuItem"));
+ assertEquals("unexpected amount of suggestions found", 4,
+ filteredItems.size());
+ assertEquals("wrong filtering result", "Null item", filteredItems
+ .get(0).getText());
+ assertEquals("wrong filtering result", "Value 1", filteredItems.get(1)
+ .getText());
+ assertEquals("wrong filtering result", "Value 3", filteredItems.get(3)
+ .getText());
+
+ // ensure the null item is marked as selected
+ assertEquals("wrong selection", "Null item",
+ popup.findElement(By.className("v-filterselect-suggestmenu"))
+ .findElement(By.className("gwt-MenuItem-selected"))
+ .getText());
+
+ // select the second item
+ filteredItems.get(1).click();
+
+ // ensure there's no more popup
+ assertFalse("popup found when there should be none",
+ comboBox.isElementPresent(By.vaadin("#popup")));
+
+ // check the updated selection
+ assertEquals("correct selection not found", "Value 1", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+
+ // open the popup again
+ comboBox.openPopup();
+ waitForElementPresent(By.className("v-filterselect-suggestmenu"));
+ popup = driver.findElement(By.className("v-filterselect-suggestpopup"));
+
+ // ensure the full selection remains
+ filteredItems = popup.findElement(
+ By.className("v-filterselect-suggestmenu")).findElements(
+ By.className("gwt-MenuItem"));
+ assertEquals("unexpected amount of suggestions found", 4,
+ filteredItems.size());
+
+ // ensure the selected item is marked as selected
+ assertEquals("wrong selection", "Value 1",
+ popup.findElement(By.className("v-filterselect-suggestmenu"))
+ .findElement(By.className("gwt-MenuItem-selected"))
+ .getText());
+
+ // select the null selection item
+ filteredItems.get(0).click();
+
+ // ensure there's no more popup
+ assertFalse("popup found when there should be none",
+ comboBox.isElementPresent(By.vaadin("#popup")));
+ }
+
+ @Test
+ public void testFifthComboBoxInputs() {
+ ComboBoxElement comboBox = $(ComboBoxElement.class).all().get(4);
+
+ // check the initial selection
+ assertEquals("correct selection not found", "Null item", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+
+ // check the disabled status
+ assertEquals("correct selection not found", "true", comboBox
+ .findElement(By.tagName("input")).getAttribute("disabled"));
+
+ comboBox.openPopup();
+
+ // ensure there's no popup
+ assertFalse("popup found when there should be none",
+ comboBox.isElementPresent(By.vaadin("#popup")));
+ }
+
+ @Test
+ public void testSixthComboBoxInputs() {
+ ComboBoxElement comboBox = $(ComboBoxElement.class).all().get(5);
+
+ // check the initial selection
+ assertEquals("correct selection not found", "Null item", comboBox
+ .findElement(By.tagName("input")).getAttribute("value"));
+
+ // check the readonly status
+ assertEquals("correct selection not found", "true", comboBox
+ .findElement(By.tagName("input")).getAttribute("readonly"));
+
+ assertFalse("button visible on readonly combobox", comboBox
+ .findElement(By.vaadin("#button")).isDisplayed());
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html b/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html
deleted file mode 100644
index f2a3a06254..0000000000
--- a/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html
+++ /dev/null
@@ -1,61 +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></title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3"></td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.components.table.TableColumnResizeContentsWidth?restartApplication&amp;debug</td>
- <td></td>
-</tr>
-<tr>
- <td>dragAndDrop</td>
- <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>-20,+0</td>
-</tr>
-<tr>
- <td>assertElementWidth</td>
- <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]</td>
- <td>80</td>
-</tr>
-<tr>
- <td>dragAndDrop</td>
- <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>+40,+0</td>
-</tr>
-<tr>
- <td>assertElementWidth</td>
- <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]</td>
- <td>120</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementWidth</td>
- <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]</td>
- <td>80</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>assertElementWidth</td>
- <td>vaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]</td>
- <td>100</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java b/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java
index 0b695b41c7..b785f439ea 100644
--- a/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java
+++ b/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java
@@ -1,18 +1,19 @@
package com.vaadin.tests.components.table;
-import com.vaadin.tests.components.TestBase;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Table;
import com.vaadin.ui.Table.ColumnGenerator;
import com.vaadin.ui.TextField;
-public class TableColumnResizeContentsWidth extends TestBase {
+public class TableColumnResizeContentsWidth extends AbstractTestUI {
private static final String COL1 = "COL1";
@Override
- protected void setup() {
+ protected void setup(VaadinRequest request) {
final Table table = new Table();
table.addGeneratedColumn(COL1, new ColumnGenerator() {
@Override
@@ -47,7 +48,7 @@ public class TableColumnResizeContentsWidth extends TestBase {
}
@Override
- protected String getDescription() {
+ protected String getTestDescription() {
return "When a column is resized, it's contents should update to match the new size";
}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java b/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java
new file mode 100644
index 0000000000..0e98e7ddec
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.table;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests that components within table cells get resized when their column gets
+ * resized.
+ *
+ * @author Vaadin Ltd
+ */
+public class TableColumnResizeContentsWidthTest extends MultiBrowserTest {
+
+ @Test
+ public void testResizing() throws InterruptedException {
+ openTestURL();
+
+ TableElement table = $(TableElement.class).first();
+ List<ButtonElement> buttons = $(ButtonElement.class).all();
+
+ WebElement textField = table.findElement(By.className("v-textfield"));
+ WebElement resizer = table.findElement(By.className("v-table-resizer"));
+
+ assertEquals(100, textField.getSize().width);
+
+ // drag resizer to left
+ new Actions(getDriver()).moveToElement(resizer).clickAndHold()
+ .moveByOffset(-20, 0).release().perform();
+
+ assertEquals(80, textField.getSize().width);
+
+ // drag resizer to right
+ new Actions(getDriver()).moveToElement(resizer).clickAndHold()
+ .moveByOffset(40, 0).release().perform();
+
+ assertEquals(120, textField.getSize().width);
+
+ // click the button for decreasing size
+ buttons.get(1).click();
+ sleep(50);
+
+ assertEquals(80, textField.getSize().width);
+
+ // click the button for increasing size
+ buttons.get(0).click();
+ sleep(50);
+
+ assertEquals(100, textField.getSize().width);
+ }
+
+}