Skip to content
Permalink
Browse files
8088739: [TestBug] RegionBackgroundImageUITest fail with timeout error
Reviewed-by: kcr
  • Loading branch information
arapte committed Apr 18, 2021
1 parent 8e54757 commit 56f2e17f3bb4cdc2392e40ef17b7405f95a4d66d
@@ -29,10 +29,9 @@
import javafx.scene.paint.Color;
import org.junit.Ignore;
import org.junit.Test;
import com.sun.javafx.PlatformUtil;
import static org.junit.Assume.assumeTrue;

/**
*/
@Ignore("RT-33741")
public class RegionBackgroundImageUITest extends RegionUITestBase {
/**************************************************************************
* *
@@ -43,6 +42,7 @@

@Test(timeout = 20000)
public void alignedImage() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');");

@@ -51,6 +51,7 @@ public void alignedImage() {

@Test(timeout = 20000)
public void alignedImage_RepeatX() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-x");
@@ -60,6 +61,7 @@ public void alignedImage_RepeatX() {

@Test(timeout = 20000)
public void alignedImage_RepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-y");
@@ -69,6 +71,7 @@ public void alignedImage_RepeatY() {

@Test(timeout = 20000)
public void alignedImage_Space() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: space space");
@@ -78,6 +81,7 @@ public void alignedImage_Space() {

@Test(timeout = 20000)
public void alignedImage_Round() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: round");
@@ -87,6 +91,7 @@ public void alignedImage_Round() {

@Test(timeout = 20000)
public void alignedImage_RoundSpace() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: round space");
@@ -155,6 +160,7 @@ public void alignedImage_PositionCenterTop() {

@Test(timeout = 20000)
public void alignedImage_PositionCenterBottom() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: no-repeat;" +
@@ -168,6 +174,7 @@ public void alignedImage_PositionCenterBottom() {

@Test(timeout = 20000)
public void alignedImage_PositionBottomRight() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: no-repeat;" +
@@ -223,6 +230,7 @@ public void alignedImage_PositionCenterRightRepeatX() {

@Test(timeout = 20000)
public void alignedImage_PositionCenterTopRepeatX() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-x;" +
@@ -233,6 +241,7 @@ public void alignedImage_PositionCenterTopRepeatX() {

@Test(timeout = 20000)
public void alignedImage_PositionCenterBottomRepeatX() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-x;" +
@@ -243,6 +252,7 @@ public void alignedImage_PositionCenterBottomRepeatX() {

@Test(timeout = 20000)
public void alignedImage_PositionBottomRightRepeatX() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-x;" +
@@ -253,6 +263,7 @@ public void alignedImage_PositionBottomRightRepeatX() {

@Test(timeout = 20000)
public void alignedImage_PositionCenterRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -263,6 +274,7 @@ public void alignedImage_PositionCenterRepeatY() {

@Test(timeout = 20000)
public void alignedImage_PositionCenterFiftyPercentRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -273,6 +285,7 @@ public void alignedImage_PositionCenterFiftyPercentRepeatY() {

@Test(timeout = 20000)
public void alignedImage_PositionCenterLeftRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -283,6 +296,7 @@ public void alignedImage_PositionCenterLeftRepeatY() {

@Test(timeout = 20000)
public void alignedImage_PositionCenterRightRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -293,6 +307,7 @@ public void alignedImage_PositionCenterRightRepeatY() {

@Test(timeout = 20000)
public void alignedImage_PositionCenterTopRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -303,6 +318,7 @@ public void alignedImage_PositionCenterTopRepeatY() {

@Test(timeout = 20000)
public void alignedImage_PositionCenterBottomRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -313,6 +329,7 @@ public void alignedImage_PositionCenterBottomRepeatY() {

@Test(timeout = 20000)
public void alignedImage_PositionBottomRightRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -363,6 +380,7 @@ public void alignedImage_Cover() {
// TODO should test that contain causes other properties to be ignored
@Test(timeout = 20000)
public void alignedImage_Contain() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test20x20.png');" +
"-fx-background-size: contain;");
@@ -384,13 +402,15 @@ public void alignedImage_ContainNoRepeat() {

@Test(timeout = 20000)
public void unalignedImage() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');");
checkCompletelyFilled(48);
}

@Test(timeout = 20000)
public void unalignedImage_RepeatX() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-x");
@@ -400,6 +420,7 @@ public void unalignedImage_RepeatX() {

@Test(timeout = 20000)
public void unalignedImage_RepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-y");
@@ -419,6 +440,7 @@ public void unalignedImage_Space() {

@Test(timeout = 20000)
public void unalignedImage_Round() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: round");
@@ -542,6 +564,7 @@ public void unalignedImage_PositionCenterRightRepeatX() {

@Test(timeout = 20000)
public void unalignedImage_PositionCenterTopRepeatX() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-x;" +
@@ -552,6 +575,7 @@ public void unalignedImage_PositionCenterTopRepeatX() {

@Test(timeout = 20000)
public void unalignedImage_PositionCenterBottomRepeatX() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-x;" +
@@ -562,6 +586,7 @@ public void unalignedImage_PositionCenterBottomRepeatX() {

@Test(timeout = 20000)
public void unalignedImage_PositionBottomRightRepeatX() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-x;" +
@@ -572,6 +597,7 @@ public void unalignedImage_PositionBottomRightRepeatX() {

@Test(timeout = 20000)
public void unalignedImage_PositionCenterRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -582,6 +608,7 @@ public void unalignedImage_PositionCenterRepeatY() {

@Test(timeout = 20000)
public void unalignedImage_PositionCenterFiftyPercentRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -592,6 +619,7 @@ public void unalignedImage_PositionCenterFiftyPercentRepeatY() {

@Test(timeout = 20000)
public void unalignedImage_PositionCenterLeftRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -602,6 +630,7 @@ public void unalignedImage_PositionCenterLeftRepeatY() {

@Test(timeout = 20000)
public void unalignedImage_PositionCenterRightRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -612,6 +641,7 @@ public void unalignedImage_PositionCenterRightRepeatY() {

@Test(timeout = 20000)
public void unalignedImage_PositionCenterTopRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -622,6 +652,7 @@ public void unalignedImage_PositionCenterTopRepeatY() {

@Test(timeout = 20000)
public void unalignedImage_PositionCenterBottomRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -632,6 +663,7 @@ public void unalignedImage_PositionCenterBottomRepeatY() {

@Test(timeout = 20000)
public void unalignedImage_PositionBottomRightRepeatY() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-repeat: repeat-y;" +
@@ -672,6 +704,8 @@ public void unalignedImage_Position25PercentRight() {

@Test(timeout = 20000)
public void unalignedImage_Cover() {
assumeTrue(checkIntegralUIScale());
assumeTrue(!PlatformUtil.isMac()); // JDK-8255679
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-size: cover;");
@@ -683,6 +717,7 @@ public void unalignedImage_Cover() {
// TODO should test that contain causes other properties to be ignored
@Test(timeout = 20000)
public void unalignedImage_Contain() {
assumeTrue(checkIntegralUIScale());
setStyle("-fx-background-color: black;" +
"-fx-background-image: url('test/robot/javafx/scene/layout/test48x48.png');" +
"-fx-background-size: contain;");
@@ -35,11 +35,13 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import javafx.scene.image.WritableImage;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.Border;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.Region;
import javafx.scene.robot.Robot;
import test.robot.testharness.VisualTestBase;

/**
@@ -59,10 +61,12 @@
protected Scene scene;
protected Group root;
protected Region region;
private volatile WritableImage screenCapture;

@Override
public void doSetup() {
super.doSetup();
screenCapture = null;
runAndWait(() -> {
stage = getStage();
region = new Region();
@@ -71,6 +75,7 @@ public void doSetup() {
scene = new Scene(root = new Group(region), WIDTH, HEIGHT);
scene.setFill(SCENE_FILL);
stage.setScene(scene);
stage.setAlwaysOnTop(true);
stage.show();
});
}
@@ -98,11 +103,16 @@ protected boolean checkIntegralUIScale() {
}

protected void assertColorEquals(Color expected, int x, int y, double tolerance) {
Color actual = getColorThreadSafe(x, y);
Color actual = getColorFromScreenCapture(x, y);
try {
assertColorEquals(expected, actual, tolerance);
} catch (AssertionError error) {
throw new AssertionError(error.getMessage() + " at position x=" + x + ", y=" + y);
actual = getColorThreadSafe(x, y);
try {
assertColorEquals(expected, actual, tolerance);
} catch (AssertionError ex) {
throw new AssertionError(ex.getMessage() + " at position x=" + x + ", y=" + y);
}
}
}

@@ -111,6 +121,19 @@ protected void assertColorDoesNotEqual(Color notExpected, int x, int y, double t
assertColorDoesNotEqual(notExpected, actual, tolerance);
}

private Color getColorFromScreenCapture(int x, int y) {
if (screenCapture == null) {
runAndWait(() -> {
screenCapture = new WritableImage((int)scene.getWidth(), (int)scene.getHeight());
getRobot().getScreenCapture(screenCapture,
scene.getX() + scene.getWindow().getX(),
scene.getY() + scene.getWindow().getY(),
scene.getWidth(), scene.getHeight());
});
}
return screenCapture.getPixelReader().getColor(x, y);
}

private Color getColorThreadSafe(int x, int y) {
AtomicReference<Color> color = new AtomicReference<>();
runAndWait(() -> color.set(getColor(scene, x, y)));
@@ -63,6 +63,10 @@
// Glass Robot instance
Robot robot;

protected Robot getRobot() {
return robot;
}

// Application class. An instance is created and initialized before running
// the first test, and it lives through the execution of all tests.
public static class MyApp extends Application {

1 comment on commit 56f2e17

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 56f2e17 Apr 18, 2021

Please sign in to comment.