Browse Source

Test tweaks (#12287)

tags/8.14.0.alpha1
Anna Koskinen 3 years ago
parent
commit
b119eaf351
No account linked to committer's email address
20 changed files with 61 additions and 35 deletions
  1. BIN
      uitest/reference-screenshots/chrome/GridLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png
  2. BIN
      uitest/reference-screenshots/chrome/HIconTest-LayoutIcon_ANY_Chrome__icon-scrolled.png
  3. BIN
      uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-End.png
  4. BIN
      uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-Middle.png
  5. BIN
      uitest/reference-screenshots/chrome/VAlignmentTest-layoutAlignment_ANY_Chrome__alignment-scrolled.png
  6. BIN
      uitest/reference-screenshots/chrome/VLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png
  7. 3
    1
      uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutClickListeners.java
  8. 2
    3
      uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldEventOrderTest.java
  9. 3
    2
      uitest/src/test/java/com/vaadin/tests/components/grid/GridEditRowTest.java
  10. 3
    2
      uitest/src/test/java/com/vaadin/tests/layouts/UpdateComponentWithinExpandRatioTest.java
  11. 4
    2
      uitest/src/test/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java
  12. 7
    4
      uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java
  13. 15
    8
      uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java
  14. 4
    2
      uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java
  15. 4
    2
      uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java
  16. 2
    1
      uitest/src/test/java/com/vaadin/tests/themes/valo/ResponsiveStylesTest.java
  17. 4
    4
      uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridClientRenderers.java
  18. 4
    2
      uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java
  19. 4
    1
      uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java
  20. 2
    1
      uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeItemDoubleClickTest.java

BIN
uitest/reference-screenshots/chrome/GridLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png View File


BIN
uitest/reference-screenshots/chrome/HIconTest-LayoutIcon_ANY_Chrome__icon-scrolled.png View File


BIN
uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-End.png View File


BIN
uitest/reference-screenshots/chrome/HLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled-Middle.png View File


BIN
uitest/reference-screenshots/chrome/VAlignmentTest-layoutAlignment_ANY_Chrome__alignment-scrolled.png View File


BIN
uitest/reference-screenshots/chrome/VLayoutRegErrorTest-LayoutRegError_ANY_Chrome__RegError-Scrolled.png View File


+ 3
- 1
uitest/src/main/java/com/vaadin/tests/layouts/TestLayoutClickListeners.java View File

@@ -125,7 +125,9 @@ public class TestLayoutClickListeners extends AbstractReindeerTestUIWithLog {
gl.addComponent(l);
}
for (int i = nr; i < nr * 2; i++) {
gl.addComponent(new TextField("This is tf" + i, "this is tf " + i));
TextField tf = new TextField("This is tf" + i, "this is tf " + i);
tf.setWidth("130px");
gl.addComponent(tf);
}
}


+ 2
- 3
uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldEventOrderTest.java View File

@@ -29,10 +29,9 @@ public class DateTimeFieldEventOrderTest extends SingleBrowserTest {
.findElements(By.tagName("select"));

Select select = new Select(timeSelects.get(0));
// select two different times to ensure a value change happens
select.selectByValue("09");
// selecting is flaky, try index selection too to ensure selection
// actually happens
select.selectByIndex(9);
select.selectByValue("08");

findElement(By.id("test-button")).click();
waitUntil(new ExpectedCondition<Boolean>() {

+ 3
- 2
uitest/src/test/java/com/vaadin/tests/components/grid/GridEditRowTest.java View File

@@ -52,8 +52,9 @@ public class GridEditRowTest extends MultiBrowserTest {

private void assertEditorWithinGrid() {
GridEditorElement editor = grid.getEditor();
assertThat(editor.getLocation().y + editor.getSize().height,
not(greaterThan(grid.getLocation().y + grid.getSize().height)));
// allow 1px leeway
assertThat(editor.getLocation().y + editor.getSize().height, not(
greaterThan(grid.getLocation().y + grid.getSize().height + 1)));
}

@Test

+ 3
- 2
uitest/src/test/java/com/vaadin/tests/layouts/UpdateComponentWithinExpandRatioTest.java View File

@@ -23,9 +23,10 @@ public class UpdateComponentWithinExpandRatioTest extends MultiBrowserTest {
button.click();
waitUntilLoadingIndicatorNotVisible();

// allow small discrepancies
assertEquals("Button's position changed unexpectedly", initialX,
button.getLocation().getX());
button.getLocation().getX(), 5);
assertEquals("ProgressBar's width changed unexpectedly", initialWidth,
pb.getSize().getWidth());
pb.getSize().getWidth(), 5);
}
}

+ 4
- 2
uitest/src/test/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java View File

@@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.List;

import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.JavascriptExecutor;

import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest;
@@ -23,7 +23,9 @@ public class GridLayoutRegErrorTest extends BaseLayoutRegErrorTest {
assertEquals(3, checkBoxes.size());
CheckBoxElement lastCheckBox = checkBoxes.get(2);

new Actions(driver).moveToElement(lastCheckBox).build().perform();
// moveToElement fails on Firefox since the component is out of viewport
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", lastCheckBox);

compareScreen("RegError-Scrolled");
}

+ 7
- 4
uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java View File

@@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.List;

import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.JavascriptExecutor;

import com.vaadin.testbench.elements.HorizontalLayoutElement;
import com.vaadin.tests.layouts.layouttester.BaseIconTest;
@@ -25,9 +25,12 @@ public class HIconTest extends BaseIconTest {
HorizontalLayoutElement lastOfRow1 = layouts.get(3);
HorizontalLayoutElement lastOfRow2 = layouts.get(7);

// scroll to both to ensure both contents are fully in view
new Actions(driver).moveToElement(lastOfRow1).build().perform();
new Actions(driver).moveToElement(lastOfRow2).build().perform();
// scroll to both to ensure both contents are fully in view,
// moveToElement fails on Firefox since the component is out of viewport
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", lastOfRow1);
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", lastOfRow2);

compareScreen("icon-scrolled");
}

+ 15
- 8
uitest/src/test/java/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java View File

@@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.List;

import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.JavascriptExecutor;

import com.vaadin.testbench.elements.HorizontalLayoutElement;
import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest;
@@ -29,18 +29,25 @@ public class HLayoutRegErrorTest extends BaseLayoutRegErrorTest {
HorizontalLayoutElement lastOfRow1 = layouts.get(4);
HorizontalLayoutElement lastOfRow2 = layouts.get(9);

// scroll to both to ensure both contents are fully in view
new Actions(driver).moveToElement(group3row1).build().perform();
new Actions(driver).moveToElement(group3row2).build().perform();
// scroll to both to ensure both contents are fully in view,
// moveToElement fails on Firefox since the component is out of viewport
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", group3row1);
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", group3row2);
// scroll back to get the previous group at the left edge
new Actions(driver).moveToElement(group2row1).build().perform();
new Actions(driver).moveToElement(group2row2).build().perform();
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", group2row1);
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", group2row2);

compareScreen("RegError-Scrolled-Middle");

// scroll to last ones
new Actions(driver).moveToElement(lastOfRow1).build().perform();
new Actions(driver).moveToElement(lastOfRow2).build().perform();
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", lastOfRow1);
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", lastOfRow2);

compareScreen("RegError-Scrolled-End");
}

+ 4
- 2
uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java View File

@@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.List;

import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.JavascriptExecutor;

import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest;
@@ -23,7 +23,9 @@ public class VAlignmentTest extends BaseAlignmentTest {
assertEquals(9, textFields.size());
TextFieldElement lastTextField = textFields.get(8);

new Actions(driver).moveToElement(lastTextField).build().perform();
// moveToElement fails on Firefox since the component is out of viewport
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", lastTextField);

compareScreen("alignment-scrolled");
}

+ 4
- 2
uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java View File

@@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.List;

import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.JavascriptExecutor;

import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest;
@@ -23,7 +23,9 @@ public class VLayoutRegErrorTest extends BaseLayoutRegErrorTest {
assertEquals(3, checkBoxes.size());
CheckBoxElement lastCheckBox = checkBoxes.get(2);

new Actions(driver).moveToElement(lastCheckBox).build().perform();
// moveToElement fails on Firefox since the component is out of viewport
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", lastCheckBox);

compareScreen("RegError-Scrolled");
}

+ 2
- 1
uitest/src/test/java/com/vaadin/tests/themes/valo/ResponsiveStylesTest.java View File

@@ -1,6 +1,7 @@
package com.vaadin.tests.themes.valo;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.equalTo;

import java.util.List;
@@ -51,7 +52,7 @@ public class ResponsiveStylesTest extends MultiBrowserTest {

WebElement wideMenu = menus.get(WIDE_ELEMENT_INDEX);
int wideWidth = wideMenu.getSize().width;
assertThat(wideWidth, equalTo(WIDE_WIDTH));
assertThat((double) wideWidth, closeTo(WIDE_WIDTH, 1));
sleep(300);

compareScreen("defaultMenuWidths");

+ 4
- 4
uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridClientRenderers.java View File

@@ -147,7 +147,7 @@ public class GridClientRenderers extends MultiBrowserTest {

// Test initial renderering with contentVisible = False
TestBenchElement cell = getGrid().getCell(51, 1);
String backgroundColor = cell.getCssValue("backgroundColor");
String backgroundColor = cell.getCssValue("background-color");
assertEquals("Background color was not red.", colorRed,
backgroundColor);

@@ -156,7 +156,7 @@ public class GridClientRenderers extends MultiBrowserTest {

// Content becomes visible
cell = getGrid().getCell(51, 1);
backgroundColor = cell.getCssValue("backgroundColor");
backgroundColor = cell.getCssValue("background-color");
assertNotEquals("Background color was red.", colorRed, backgroundColor);

// scroll down, new cells becomes contentVisible = False
@@ -164,7 +164,7 @@ public class GridClientRenderers extends MultiBrowserTest {

// Cell should be red (setContentVisible set cell red)
cell = getGrid().getCell(55, 1);
backgroundColor = cell.getCssValue("backgroundColor");
backgroundColor = cell.getCssValue("background-color");
assertEquals("Background color was not red.", colorRed,
backgroundColor);

@@ -172,7 +172,7 @@ public class GridClientRenderers extends MultiBrowserTest {
sleep((int) (latency * SLEEP_MULTIPLIER));

// Cell should no longer be red
backgroundColor = cell.getCssValue("backgroundColor");
backgroundColor = cell.getCssValue("background-color");
assertTrue("Background color was not reset: " + backgroundColor,
backgroundColor.equals(colorWhite)
|| backgroundColor.equals(colorDark));

+ 4
- 2
uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java View File

@@ -223,7 +223,8 @@ public abstract class GridBasicFeaturesTest extends MultiBrowserTest {
if (dragHeaderCell.findElements(By.className("gwt-HTML")).isEmpty()) {
// no selectable header caption, drag freely
new Actions(getDriver()).clickAndHold(dragHeaderCell)
.moveToElement(targetHeaderCell, horizontalOffset, 0)
.moveToElement(targetHeaderCell,
getXOffset(targetHeaderCell, horizontalOffset), 0)
.release().perform();
} else {
// avoid clicking on the caption or the text gets selected and the
@@ -234,7 +235,8 @@ public abstract class GridBasicFeaturesTest extends MultiBrowserTest {
.moveToElement(dragHeaderCaption,
dragHeaderCaption.getSize().getWidth() + 5, 5)
.clickAndHold()
.moveToElement(targetHeaderCell, horizontalOffset, 0)
.moveToElement(targetHeaderCell,
getXOffset(targetHeaderCell, horizontalOffset), 0)
.release().perform();
}
}

+ 4
- 1
uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java View File

@@ -342,7 +342,10 @@ public class GridColumnReorderTest extends GridBasicFeaturesTest {
GridCellElement draggedHeaderCell = getGridElement().getHeaderCell(0,
1);
final int xOffset = 500;
new Actions(getDriver()).moveToElement(draggedHeaderCell, 20, 10)
new Actions(getDriver())
.moveToElement(draggedHeaderCell,
getXOffset(draggedHeaderCell, 20),
getYOffset(draggedHeaderCell, 10))
.clickAndHold().moveByOffset(xOffset, 0).build().perform();

WebElement floatingDragElement = findElement(

+ 2
- 1
uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeItemDoubleClickTest.java View File

@@ -49,7 +49,8 @@ public class TreeItemDoubleClickTest extends MultiBrowserTest {
}

private void doubleClick(WebElement element) {
new Actions(getDriver()).doubleClick(element).build().perform();
new Actions(getDriver()).moveToElement(element).doubleClick().build()
.perform();
sleep(100);
}


Loading…
Cancel
Save