--- /dev/null
+package com.vaadin.tests.components.table;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class TableColumnResizeContentsWidthIE8Test extends MultiBrowserTest {
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ List<DesiredCapabilities> browsersToTest = new ArrayList<DesiredCapabilities>();
+
+ browsersToTest.add(Browser.IE8.getDesiredCapabilities());
+
+ return browsersToTest;
+ }
+
+ @Override
+ protected Class<?> getUIClass() {
+ return TableColumnResizeContentsWidth.class;
+ }
+
+ @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"));
+
+ // click the button for decreasing size
+ buttons.get(1).click();
+
+ assertEquals(60, textField.getSize().width);
+
+ // click the button for increasing size
+ buttons.get(0).click();
+
+ assertEquals(80, textField.getSize().width);
+ }
+}
*/
package com.vaadin.tests.components.table;
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
import org.junit.Test;
import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.ExpectedCondition;
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.testbench.elements.TableElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
/**
* Tests that components within table cells get resized when their column gets
*/
public class TableColumnResizeContentsWidthTest extends MultiBrowserTest {
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ List<DesiredCapabilities> browsersToTest = super.getBrowsersToTest();
+
+ //Can't get IE8 to hit the resizer, extracted IE8 to it's own test class.
+ browsersToTest.remove(Browser.IE8.getDesiredCapabilities());
+
+ return browsersToTest;
+ }
+
@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();
+ WebElement resizer = getTable().findElement(By.className("v-table-resizer"));
- assertEquals(80, textField.getSize().width);
+ assertEquals(100, getTextFieldWidth());
- // drag resizer to right
- new Actions(getDriver()).moveToElement(resizer).clickAndHold()
- .moveByOffset(40, 0).release().perform();
+ moveResizer(resizer, -20);
+ assertEquals(80, getTextFieldWidth());
- assertEquals(120, textField.getSize().width);
+ moveResizer(resizer, 40);
+ assertEquals(120, getTextFieldWidth());
// click the button for decreasing size
buttons.get(1).click();
- sleep(50);
-
- assertEquals(80, textField.getSize().width);
+ waitUntilTextFieldWidthIs(80);
// click the button for increasing size
buttons.get(0).click();
- sleep(50);
+ waitUntilTextFieldWidthIs(100);
+ }
+
+ private void waitUntilTextFieldWidthIs(final int width) {
+ waitUntil(new ExpectedCondition<Object>() {
+ @Override
+ public Object apply(WebDriver input) {
+ return getTextFieldWidth() == width;
+ }
+ });
+ }
+
+ private int getTextFieldWidth() {
+ TableElement table = getTable();
+ final WebElement textField = table.findElement(By.className("v-textfield"));
+
+ return textField.getSize().width;
+ }
- assertEquals(100, textField.getSize().width);
+ private TableElement getTable() {
+ return $(TableElement.class).first();
}
+ private void moveResizer(WebElement resizer, int offset) {
+ new Actions(driver).clickAndHold(resizer).moveByOffset(offset, 0).release().perform();
+ }
}
+
+