changeset 10851:e321eebba79c

8170026: Some tests in RegionBackgroundFillUITest fail with fractional window scale Reviewed-by: kcr, mbilla
author rkamath
date Mon, 26 Feb 2018 14:58:11 +0530
parents bc506190c9c3
children 375aedc5702a
files tests/system/src/test/java/test/robot/javafx/scene/layout/RegionBackgroundFillUITest.java tests/system/src/test/java/test/robot/javafx/scene/layout/RegionUITestBase.java
diffstat 2 files changed, 32 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/tests/system/src/test/java/test/robot/javafx/scene/layout/RegionBackgroundFillUITest.java	Mon Feb 26 12:49:58 2018 +0530
+++ b/tests/system/src/test/java/test/robot/javafx/scene/layout/RegionBackgroundFillUITest.java	Mon Feb 26 14:58:11 2018 +0530
@@ -35,10 +35,6 @@
  */
 public class RegionBackgroundFillUITest extends RegionUITestBase {
 
-    static {
-        System.setProperty("glass.win.uiScale", "100%");
-    }
-
     /**************************************************************************
      *                                                                        *
      * Tests for background fills. We start with a series of simple tests     *
@@ -135,7 +131,7 @@
 
     @Test(timeout=20000)
     public void basicFill_Radius1() {
-        assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red;" +
                 "-fx-background-radius: 10");
@@ -144,6 +140,7 @@
 
     @Test(timeout=20000)
     public void basicFill_Radius2() {
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red;" +
                 "-fx-background-radius: 10 20");
@@ -152,6 +149,7 @@
 
     @Test(timeout=20000)
     public void basicFill_Radius3() {
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red;" +
                 "-fx-background-radius: 10 20 30");
@@ -160,6 +158,7 @@
 
     @Test(timeout=20000)
     public void basicFill_Radius4() {
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red;" +
                 "-fx-background-radius: 10 20 30 40");
@@ -182,7 +181,7 @@
 
     @Test(timeout=20000)
     public void basicFill_RadiusAndInsets() {
-        assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red;" +
                 "-fx-background-radius: 10 20 30 40;" +
@@ -328,6 +327,7 @@
 
     @Test(timeout=20000)
     public void testScenario1() {
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red;" +
                 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
@@ -338,6 +338,7 @@
 
     @Test(timeout=20000)
     public void testScenario2() {
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red, green, blue, grey;" +
                 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
@@ -373,7 +374,7 @@
 
     @Test(timeout=20000)
     public void testScenario3() {
-        assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red, green, blue, grey;" +
                 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
@@ -409,7 +410,7 @@
 
     @Test(timeout=20000)
     public void testScenario4() {
-        assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red, green, blue, repeating-image-pattern('test/robot/javafx/scene/layout/test20x20.png');" +
                 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
@@ -445,6 +446,7 @@
 
     @Test(timeout=20000)
     public void testScenario5() {
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red, green, repeating-image-pattern('test/robot/javafx/scene/layout/test20x20.png'), blue;" +
                 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
@@ -496,7 +498,7 @@
 
     @Test(timeout=20000)
     public void testOnePixelTopInset() {
-        assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red, yellow;" +
                 "-fx-background-insets: 0, 1 0 0 0;");
@@ -525,7 +527,7 @@
 
     @Test(timeout=20000)
     public void testOnePixelRightInset() {
-        assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red, yellow;" +
                 "-fx-background-insets: 0, 0 1 0 0;");
@@ -554,7 +556,7 @@
 
     @Test(timeout=20000)
     public void testOnePixelBottomInset() {
-        assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red, yellow;" +
                 "-fx-background-insets: 0, 0 0 1 0;");
@@ -583,7 +585,7 @@
 
     @Test(timeout=20000)
     public void testOnePixelLeftInset() {
-        assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
+        assumeTrue(checkIntegralUIScale());
         setStyle(
                 "-fx-background-color: red, yellow;" +
                 "-fx-background-insets: 0, 0 0 0 1;");
--- a/tests/system/src/test/java/test/robot/javafx/scene/layout/RegionUITestBase.java	Mon Feb 26 12:49:58 2018 +0530
+++ b/tests/system/src/test/java/test/robot/javafx/scene/layout/RegionUITestBase.java	Mon Feb 26 14:58:11 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,9 +29,11 @@
 import javafx.scene.paint.Color;
 import javafx.scene.paint.Paint;
 import javafx.stage.Stage;
+import javafx.stage.Window;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 import javafx.scene.layout.Background;
 import javafx.scene.layout.BackgroundFill;
@@ -80,6 +82,21 @@
 
     static final double TOLERANCE = 0.07;
 
+    protected boolean checkIntegralUIScale() {
+        AtomicBoolean integralUIScale = new AtomicBoolean(false);
+        runAndWait(() -> {
+            Window window = scene.getWindow();
+            double outScaleX = window.getOutputScaleX();
+            double outScaleY = window.getOutputScaleY();
+
+            if (outScaleX == Math.rint(outScaleX)
+                    && outScaleY == Math.rint(outScaleY)) {
+                integralUIScale.set(true);
+            }
+        });
+        return integralUIScale.get();
+    }
+
     protected void assertColorEquals(Color expected, int x, int y, double tolerance) {
         Color actual = getColorThreadSafe(x, y);
         try {