1 /*
   2  * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  */
  24 
  25 package test.robot.javafx.scene.layout;
  26 
  27 import javafx.scene.layout.BackgroundFill;
  28 import javafx.scene.paint.Color;
  29 import org.junit.Ignore;
  30 import org.junit.Test;
  31 
  32 import static org.junit.Assume.assumeTrue;
  33 
  34 /**
  35  */
  36 public class RegionBackgroundFillUITest extends RegionUITestBase {
  37 
  38     static {
  39         System.setProperty("glass.win.uiScale", "100%");
  40     }
  41 
  42     /**************************************************************************
  43      *                                                                        *
  44      * Tests for background fills. We start with a series of simple tests     *
  45      * with a single solid fill, including exercising different insets and    *
  46      * corner radii.                                                          *
  47      *                                                                        *
  48      *************************************************************************/
  49 
  50     @Test(timeout=20000)
  51     public void basicFill() {
  52         setStyle("-fx-background-color: red;");
  53         checkRegionCornersAndBoundariesForFills();
  54     }
  55 
  56     @Test(timeout=20000)
  57     public void translucentFill() {
  58         setStyle("-fx-background-color: rgba(255, 0, 0, .2);");
  59         // multiply through the alpha
  60         checkRegionCornersAndBoundariesOfBackgroundFill(
  61                 region.getBackground().getFills().get(0), Color.rgb(255, 204, 204), SCENE_FILL);
  62     }
  63 
  64     @Test(timeout=20000)
  65     public void basicFill_Insets1() {
  66         setStyle(
  67                 "-fx-background-color: red;" +
  68                 "-fx-background-insets: 5");
  69         checkRegionCornersAndBoundariesForFills();
  70     }
  71 
  72     @Test(timeout=20000)
  73     public void basicFill_Insets2() {
  74         setStyle(
  75                 "-fx-background-color: red;" +
  76                 "-fx-background-insets: 5 10");
  77         checkRegionCornersAndBoundariesForFills();
  78     }
  79 
  80     @Test(timeout=20000)
  81     public void basicFill_Insets3() {
  82         setStyle(
  83                 "-fx-background-color: red;" +
  84                 "-fx-background-insets: 5 10 15");
  85         checkRegionCornersAndBoundariesForFills();
  86     }
  87 
  88     @Test(timeout=20000)
  89     public void basicFill_Insets4() {
  90         setStyle(
  91                 "-fx-background-color: red;" +
  92                 "-fx-background-insets: 5 10 15 20");
  93         checkRegionCornersAndBoundariesForFills();
  94     }
  95 
  96     @Test(timeout=20000)
  97     public void basicFill_NegativeInsets1() {
  98         setStyle(
  99                 "-fx-background-color: red;" +
 100                 "-fx-background-insets: -5");
 101         checkRegionCornersAndBoundariesForFills();
 102     }
 103 
 104     @Test(timeout=20000)
 105     public void basicFill_NegativeInsets2() {
 106         setStyle(
 107                 "-fx-background-color: red;" +
 108                 "-fx-background-insets: -5 -10");
 109         checkRegionCornersAndBoundariesForFills();
 110     }
 111 
 112     @Test(timeout=20000)
 113     public void basicFill_NegativeInsets3() {
 114         setStyle(
 115                 "-fx-background-color: red;" +
 116                 "-fx-background-insets: -5 -10 -15");
 117         checkRegionCornersAndBoundariesForFills();
 118     }
 119 
 120     @Test(timeout=20000)
 121     public void basicFill_NegativeInsets4() {
 122         setStyle(
 123                 "-fx-background-color: red;" +
 124                 "-fx-background-insets: -5 -10 -15 -20");
 125         checkRegionCornersAndBoundariesForFills();
 126     }
 127 
 128     @Test(timeout=20000)
 129     public void basicFill_MixedInsets() {
 130         setStyle(
 131                 "-fx-background-color: red;" +
 132                 "-fx-background-insets: 10 10 -10 10");
 133         checkRegionCornersAndBoundariesForFills();
 134     }
 135 
 136     @Test(timeout=20000)
 137     public void basicFill_Radius1() {
 138         assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
 139         setStyle(
 140                 "-fx-background-color: red;" +
 141                 "-fx-background-radius: 10");
 142         checkRegionCornersAndBoundariesForFills();
 143     }
 144 
 145     @Test(timeout=20000)
 146     public void basicFill_Radius2() {
 147         setStyle(
 148                 "-fx-background-color: red;" +
 149                 "-fx-background-radius: 10 20");
 150         checkRegionCornersAndBoundariesForFills();
 151     }
 152 
 153     @Test(timeout=20000)
 154     public void basicFill_Radius3() {
 155         setStyle(
 156                 "-fx-background-color: red;" +
 157                 "-fx-background-radius: 10 20 30");
 158         checkRegionCornersAndBoundariesForFills();
 159     }
 160 
 161     @Test(timeout=20000)
 162     public void basicFill_Radius4() {
 163         setStyle(
 164                 "-fx-background-color: red;" +
 165                 "-fx-background-radius: 10 20 30 40");
 166         checkRegionCornersAndBoundariesForFills();
 167     }
 168 
 169     // TODO need to write tests for percentage based radii
 170 //    public void basicFill_PercentageRadius() {
 171 //        setStyle(
 172 //                "-fx-background-color: red;" +
 173 //                "-fx-background-radius: 5% 10% 15% 20%");
 174 //    }
 175 
 176     // TODO need to check on the syntax for the 8 independent corner radii...
 177 //    public void basicFill_Radius8() {
 178 //        setStyle(
 179 //                "-fx-background-color: red;" +
 180 //                "-fx-background-radius: 10 20 30 40 50 60 70 80");
 181 //    }
 182 
 183     @Test(timeout=20000)
 184     public void basicFill_RadiusAndInsets() {
 185         assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
 186         setStyle(
 187                 "-fx-background-color: red;" +
 188                 "-fx-background-radius: 10 20 30 40;" +
 189                 "-fx-background-insets: 5 10 15 20");
 190         checkRegionCornersAndBoundariesForFills();
 191     }
 192 
 193     // NOTE: A negative radius from CSS is treated as 0.
 194     @Test(timeout=20000)
 195     public void basicFill_NegativeRadius1() {
 196         setStyle(
 197                 "-fx-background-color: red;" +
 198                 "-fx-background-radius: -10");
 199         checkRegionCornersAndBoundariesForFills();
 200     }
 201 
 202     // NOTE: A negative radius from CSS is treated as 0.
 203     @Test(timeout=20000)
 204     public void basicFill_NegativeRadius2() {
 205         setStyle(
 206                 "-fx-background-color: red;" +
 207                 "-fx-background-radius: -10 -20");
 208         checkRegionCornersAndBoundariesForFills();
 209     }
 210 
 211     // NOTE: A negative radius from CSS is treated as 0.
 212     @Test(timeout=20000)
 213     public void basicFill_NegativeRadius3() {
 214         setStyle(
 215                 "-fx-background-color: red;" +
 216                 "-fx-background-radius: -10 -20 -30");
 217         checkRegionCornersAndBoundariesForFills();
 218     }
 219 
 220     // NOTE: A negative radius from CSS is treated as 0.
 221     @Test(timeout=20000)
 222     public void basicFill_NegativeRadius4() {
 223         setStyle(
 224                 "-fx-background-color: red;" +
 225                 "-fx-background-radius: -10 -20 -30 -40");
 226         checkRegionCornersAndBoundariesForFills();
 227     }
 228 
 229     /**************************************************************************
 230      *                                                                        *
 231      * Tests for ImagePattern fills and gradient fills                        *
 232      *                                                                        *
 233      *************************************************************************/
 234 
 235     // NOTE: These tests could be even more precise with different images / gradients such that
 236     // I actually could predict the color under a point, rather than just asserting it isn't
 237     // the Scene's fill.
 238 
 239     @Test(timeout=20000)
 240     public void imageFill() {
 241         setStyle("-fx-background-color: repeating-image-pattern('test/robot/javafx/scene/layout/test20x20.png');");
 242         checkRegionCornersAndBoundariesForFills();
 243     }
 244 
 245     @Test(timeout=20000)
 246     public void imageFill_MixedInsets() {
 247         setStyle(
 248                 "-fx-background-color: repeating-image-pattern('test/robot/javafx/scene/layout/test20x20.png');" +
 249                 "-fx-background-insets: 5 10 -15 20");
 250         checkRegionCornersAndBoundariesForFills();
 251     }
 252 
 253     @Test(timeout=20000)
 254     public void imageFill_Radius4() {
 255         setStyle(
 256                 "-fx-background-color: repeating-image-pattern('test/robot/javafx/scene/layout/test20x20.png');" +
 257                 "-fx-background-radius: 10 20 30 40");
 258         checkRegionCornersAndBoundariesForFills();
 259     }
 260 
 261     @Test(timeout=20000)
 262     public void imageFill_MissingImage() {
 263         setStyle(
 264                 "-fx-background-color: repeating-image-pattern('test/robot/javafx/scene/layout/missing.png');" +
 265                 "-fx-background-radius: 10 20 30 40");
 266         assertColorEquals(SCENE_FILL, WIDTH / 2, HEIGHT / 2, TOLERANCE);
 267     }
 268 
 269     @Test(timeout=20000)
 270     public void imageFill_Stretched() {
 271         setStyle("-fx-background-color: image-pattern('test/robot/javafx/scene/layout/test20x20.png');");
 272         checkRegionCornersAndBoundariesForFills();
 273     }
 274 
 275     @Test(timeout=20000)
 276     public void imageFill_Stretched2() {
 277         setStyle("-fx-background-color: image-pattern('test/robot/javafx/scene/layout/test20x20.png', 0, 0, 1, 1);");
 278         checkRegionCornersAndBoundariesForFills();
 279     }
 280 
 281     @Test(timeout=20000)
 282     public void imageFill_Stretched3() {
 283         setStyle("-fx-background-color: image-pattern('test/robot/javafx/scene/layout/test20x20.png', 0, 0, 1, 1, true);");
 284         checkRegionCornersAndBoundariesForFills();
 285     }
 286 
 287     @Test(timeout=20000)
 288     public void imageFill_Tiled() {
 289         setStyle("-fx-background-color: image-pattern('test/robot/javafx/scene/layout/test20x20.png', 0, 0, 40, 40, false);");
 290         checkRegionCornersAndBoundariesForFills();
 291     }
 292 
 293     @Test(timeout=20000)
 294     public void linearFill() {
 295         setStyle("-fx-background-color: linear-gradient(to bottom, red 0%, blue 100%);");
 296         checkRegionCornersAndBoundariesForFills();
 297     }
 298 
 299     @Test(timeout=20000)
 300     public void linearFill2() {
 301         setStyle("-fx-background-color: linear-gradient(to right, red 0%, blue 100%);");
 302         checkRegionCornersAndBoundariesForFills();
 303     }
 304 
 305     @Test(timeout=20000)
 306     public void linearFill_MixedInsets() {
 307         setStyle(
 308                 "-fx-background-color: linear-gradient(to bottom, red 0%, blue 100%);" +
 309                 "-fx-background-insets: 5 10 -15 20");
 310         checkRegionCornersAndBoundariesForFills();
 311     }
 312 
 313     @Test(timeout=20000)
 314     public void linearFill_Radius4() {
 315         setStyle(
 316                 "-fx-background-color: linear-gradient(to bottom, red 0%, blue 100%);" +
 317                 "-fx-background-radius: 10 20 30 40");
 318         checkRegionCornersAndBoundariesForFills();
 319     }
 320 
 321     // TODO I could write more tests here for other linear fill options, like repeat etc, also radial fill
 322 
 323     /**************************************************************************
 324      *                                                                        *
 325      * Tests for stacking fills with different radii etc                      *
 326      *                                                                        *
 327      *************************************************************************/
 328 
 329     @Test(timeout=20000)
 330     public void testScenario1() {
 331         setStyle(
 332                 "-fx-background-color: red;" +
 333                 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
 334                 "-fx-background-radius: 10 20 30 40;" +
 335                 "-fx-padding: 10 20 30 40;");
 336         checkRegionCornersAndBoundariesForFills();
 337     }
 338 
 339     @Test(timeout=20000)
 340     public void testScenario2() {
 341         setStyle(
 342                 "-fx-background-color: red, green, blue, grey;" +
 343                 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
 344                 "-fx-background-radius: 5 10 15 20, 25, 30 35 40 45;" +
 345                 "-fx-padding: 10 20 30 40;");
 346 
 347         BackgroundFill red = region.getBackground().getFills().get(0);
 348         BackgroundFill green = region.getBackground().getFills().get(1);
 349         BackgroundFill blue = region.getBackground().getFills().get(2);
 350         BackgroundFill grey = region.getBackground().getFills().get(3);
 351 
 352         checkRegionLeftBoundary(red, Color.GREEN, SCENE_FILL);
 353         checkRegionTopLeftCorner(red, SCENE_FILL);
 354         checkRegionTopBoundary(red, Color.GREEN, SCENE_FILL);
 355         checkRegionTopRightCorner(red, SCENE_FILL);
 356         checkRegionRightBoundary(red, Color.GREEN, SCENE_FILL);
 357         checkRegionBottomRightCorner(red, SCENE_FILL);
 358         checkRegionBottomBoundary(red, SCENE_FILL);
 359         checkRegionBottomLeftCorner(red, SCENE_FILL);
 360 
 361         checkRegionLeftBoundary(green, SCENE_FILL);
 362         checkRegionTopLeftCorner(green, Color.RED);
 363         checkRegionTopBoundary(green, SCENE_FILL);
 364         checkRegionTopRightCorner(green, Color.RED);
 365         checkRegionRightBoundary(green, SCENE_FILL);
 366         checkRegionBottomRightCorner(green, Color.RED);
 367         checkRegionBottomBoundary(green, Color.RED);
 368         checkRegionBottomLeftCorner(green, Color.RED);
 369 
 370         checkRegionCornersAndBoundariesOfBackgroundFill(blue, Color.GREEN);
 371         checkRegionCornersAndBoundariesOfBackgroundFill(grey, Color.BLUE);
 372     }
 373 
 374     @Test(timeout=20000)
 375     public void testScenario3() {
 376         assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
 377         setStyle(
 378                 "-fx-background-color: red, green, blue, grey;" +
 379                 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
 380                 "-fx-background-radius: 10 20 30 40;" +
 381                 "-fx-padding: 10 20 30 40;");
 382 
 383         BackgroundFill red = region.getBackground().getFills().get(0);
 384         BackgroundFill green = region.getBackground().getFills().get(1);
 385         BackgroundFill blue = region.getBackground().getFills().get(2);
 386         BackgroundFill grey = region.getBackground().getFills().get(3);
 387 
 388         checkRegionLeftBoundary(red, Color.GREEN, SCENE_FILL);
 389         checkRegionTopLeftCorner(red, Color.GREEN, SCENE_FILL);
 390         checkRegionTopBoundary(red, Color.GREEN, SCENE_FILL);
 391         checkRegionTopRightCorner(red, Color.GREEN, SCENE_FILL);
 392         checkRegionRightBoundary(red, Color.GREEN, SCENE_FILL);
 393         checkRegionBottomRightCorner(red, SCENE_FILL);
 394         checkRegionBottomBoundary(red, SCENE_FILL);
 395         checkRegionBottomLeftCorner(red, SCENE_FILL);
 396 
 397         checkRegionLeftBoundary(green, SCENE_FILL);
 398         checkRegionTopLeftCorner(green, SCENE_FILL);
 399         checkRegionTopBoundary(green, SCENE_FILL);
 400         checkRegionTopRightCorner(green, SCENE_FILL);
 401         checkRegionRightBoundary(green, SCENE_FILL);
 402         checkRegionBottomRightCorner(green, Color.RED);
 403         checkRegionBottomBoundary(green, Color.RED);
 404         checkRegionBottomLeftCorner(green, Color.RED);
 405 
 406         checkRegionCornersAndBoundariesOfBackgroundFill(blue, Color.GREEN);
 407         checkRegionCornersAndBoundariesOfBackgroundFill(grey, Color.BLUE);
 408     }
 409 
 410     @Test(timeout=20000)
 411     public void testScenario4() {
 412         assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
 413         setStyle(
 414                 "-fx-background-color: red, green, blue, repeating-image-pattern('test/robot/javafx/scene/layout/test20x20.png');" +
 415                 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
 416                 "-fx-background-radius: 10 20 30 40;" +
 417                 "-fx-padding: 10 20 30 40;");
 418 
 419         BackgroundFill red = region.getBackground().getFills().get(0);
 420         BackgroundFill green = region.getBackground().getFills().get(1);
 421         BackgroundFill blue = region.getBackground().getFills().get(2);
 422         BackgroundFill image = region.getBackground().getFills().get(3);
 423 
 424         checkRegionLeftBoundary(red, Color.GREEN, SCENE_FILL);
 425         checkRegionTopLeftCorner(red, Color.GREEN, SCENE_FILL);
 426         checkRegionTopBoundary(red, Color.GREEN, SCENE_FILL);
 427         checkRegionTopRightCorner(red, Color.GREEN, SCENE_FILL);
 428         checkRegionRightBoundary(red, Color.GREEN, SCENE_FILL);
 429         checkRegionBottomRightCorner(red, SCENE_FILL);
 430         checkRegionBottomBoundary(red, SCENE_FILL);
 431         checkRegionBottomLeftCorner(red, SCENE_FILL);
 432 
 433         checkRegionLeftBoundary(green, SCENE_FILL);
 434         checkRegionTopLeftCorner(green, SCENE_FILL);
 435         checkRegionTopBoundary(green, SCENE_FILL);
 436         checkRegionTopRightCorner(green, SCENE_FILL);
 437         checkRegionRightBoundary(green, SCENE_FILL);
 438         checkRegionBottomRightCorner(green, Color.RED);
 439         checkRegionBottomBoundary(green, Color.RED);
 440         checkRegionBottomLeftCorner(green, Color.RED);
 441 
 442         checkRegionCornersAndBoundariesOfBackgroundFill(blue, Color.GREEN);
 443 //        checkRegionCornersAndBoundariesOfBackgroundFill(image, Color.BLUE);
 444     }
 445 
 446     @Test(timeout=20000)
 447     public void testScenario5() {
 448         setStyle(
 449                 "-fx-background-color: red, green, repeating-image-pattern('test/robot/javafx/scene/layout/test20x20.png'), blue;" +
 450                 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
 451                 "-fx-background-radius: 10 20 30 40;" +
 452                 "-fx-padding: 10 20 30 40;");
 453 
 454         BackgroundFill red = region.getBackground().getFills().get(0);
 455         BackgroundFill green = region.getBackground().getFills().get(1);
 456         BackgroundFill image = region.getBackground().getFills().get(2);
 457         BackgroundFill blue = region.getBackground().getFills().get(3);
 458 
 459         checkRegionLeftBoundary(red, Color.GREEN, SCENE_FILL);
 460         checkRegionTopLeftCorner(red, Color.GREEN, SCENE_FILL);
 461         checkRegionTopBoundary(red, Color.GREEN, SCENE_FILL);
 462         checkRegionTopRightCorner(red, Color.GREEN, SCENE_FILL);
 463         checkRegionRightBoundary(red, Color.GREEN, SCENE_FILL);
 464         checkRegionBottomRightCorner(red, SCENE_FILL);
 465         checkRegionBottomBoundary(red, SCENE_FILL);
 466         checkRegionBottomLeftCorner(red, SCENE_FILL);
 467 
 468         checkRegionLeftBoundary(green, SCENE_FILL);
 469         checkRegionTopLeftCorner(green, SCENE_FILL);
 470         checkRegionTopBoundary(green, SCENE_FILL);
 471         checkRegionTopRightCorner(green, SCENE_FILL);
 472         checkRegionRightBoundary(green, SCENE_FILL);
 473         checkRegionBottomRightCorner(green, Color.RED);
 474         checkRegionBottomBoundary(green, Color.RED);
 475         checkRegionBottomLeftCorner(green, Color.RED);
 476 
 477         checkRegionCornersAndBoundariesOfBackgroundFill(image, Color.GREEN);
 478 //        checkRegionCornersAndBoundariesOfBackgroundFill(blue, Color.BLUE, null);
 479     }
 480 
 481     @Test(timeout=20000)
 482     public void testExample1() {
 483         setStyle(
 484                 "-fx-background-color: red, green, blue;" +
 485                 "-fx-background-insets: 4, 8, 12, 16;" + // An extra value here, which should be ignored
 486                 "-fx-background-radius: 14;");
 487 
 488         checkRegionCornersAndBoundariesForFills();
 489     }
 490 
 491     /**************************************************************************
 492      *                                                                        *
 493      * Tests for odd edge cases                                               *
 494      *                                                                        *
 495      *************************************************************************/
 496 
 497     @Test(timeout=20000)
 498     public void testOnePixelTopInset() {
 499         assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
 500         setStyle(
 501                 "-fx-background-color: red, yellow;" +
 502                 "-fx-background-insets: 0, 1 0 0 0;");
 503 
 504         BackgroundFill red = region.getBackground().getFills().get(0);
 505         BackgroundFill yellow = region.getBackground().getFills().get(1);
 506 
 507         checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 508         checkRegionTopLeftCorner(red, Color.RED, SCENE_FILL, 0, .2);
 509         checkRegionTopBoundary(red, Color.RED, SCENE_FILL, 0, .2);
 510         checkRegionTopRightCorner(red, Color.RED, SCENE_FILL, 0, .2);
 511         checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 512         checkRegionBottomRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 513         checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 514         checkRegionBottomLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 515 
 516         checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 517         checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 518         checkRegionTopBoundary(yellow, Color.YELLOW, Color.RED, 0, .2);
 519         checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 520         checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 521         checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 522         checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 523         checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 524     }
 525 
 526     @Test(timeout=20000)
 527     public void testOnePixelRightInset() {
 528         assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
 529         setStyle(
 530                 "-fx-background-color: red, yellow;" +
 531                 "-fx-background-insets: 0, 0 1 0 0;");
 532 
 533         BackgroundFill red = region.getBackground().getFills().get(0);
 534         BackgroundFill yellow = region.getBackground().getFills().get(1);
 535 
 536         checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 537         checkRegionTopLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 538         checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 539         checkRegionTopRightCorner(red, Color.RED, SCENE_FILL, 0, .2);
 540         checkRegionRightBoundary(red, Color.RED, SCENE_FILL, 0, .2);
 541         checkRegionBottomRightCorner(red, Color.RED, SCENE_FILL, 0, .2);
 542         checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 543         checkRegionBottomLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 544 
 545         checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 546         checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 547         checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 548         checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 549         checkRegionRightBoundary(yellow, Color.YELLOW, Color.RED, 0, .2);
 550         checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 551         checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 552         checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 553     }
 554 
 555     @Test(timeout=20000)
 556     public void testOnePixelBottomInset() {
 557         assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
 558         setStyle(
 559                 "-fx-background-color: red, yellow;" +
 560                 "-fx-background-insets: 0, 0 0 1 0;");
 561 
 562         BackgroundFill red = region.getBackground().getFills().get(0);
 563         BackgroundFill yellow = region.getBackground().getFills().get(1);
 564 
 565         checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 566         checkRegionTopLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 567         checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 568         checkRegionTopRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 569         checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 570         checkRegionBottomRightCorner(red, Color.RED, SCENE_FILL, 0, .2);
 571         checkRegionBottomBoundary(red, Color.RED, SCENE_FILL, 0, .2);
 572         checkRegionBottomLeftCorner(red, Color.RED, SCENE_FILL, 0, .2);
 573 
 574         checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 575         checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 576         checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 577         checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 578         checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 579         checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 580         checkRegionBottomBoundary(yellow, Color.YELLOW, Color.RED, 0, .2);
 581         checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 582     }
 583 
 584     @Test(timeout=20000)
 585     public void testOnePixelLeftInset() {
 586         assumeTrue(Boolean.getBoolean("unstable.test")); // JDK-8170026
 587         setStyle(
 588                 "-fx-background-color: red, yellow;" +
 589                 "-fx-background-insets: 0, 0 0 0 1;");
 590 
 591         BackgroundFill red = region.getBackground().getFills().get(0);
 592         BackgroundFill yellow = region.getBackground().getFills().get(1);
 593 
 594         checkRegionLeftBoundary(red, Color.RED, SCENE_FILL, 0, .2);
 595         checkRegionTopLeftCorner(red, Color.RED, SCENE_FILL, 0, .2);
 596         checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 597         checkRegionTopRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 598         checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 599         checkRegionBottomRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 600         checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 601         checkRegionBottomLeftCorner(red, Color.RED, SCENE_FILL, 0, .2);
 602 
 603         checkRegionLeftBoundary(yellow, Color.YELLOW, Color.RED, 0, .2);
 604         checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 605         checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 606         checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 607         checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 608         checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 609         checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 610         checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 611     }
 612 
 613     @Ignore("RT-33446")
 614     @Test(timeout=20000)
 615     public void testHalfPixelTopInset() {
 616         setStyle(
 617                 "-fx-background-color: red, yellow;" +
 618                 "-fx-background-insets: 0, .5 0 0 0;");
 619 
 620         BackgroundFill red = region.getBackground().getFills().get(0);
 621         BackgroundFill yellow = region.getBackground().getFills().get(1);
 622         Color blended = Color.rgb(254, 127, 27);
 623 
 624         checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 625         checkRegionTopLeftCorner(red, blended, SCENE_FILL, 0, .2);
 626         checkRegionTopBoundary(red, blended, SCENE_FILL, 0, .2);
 627         checkRegionTopRightCorner(red, blended, SCENE_FILL, 0, .2);
 628         checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 629         checkRegionBottomRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 630         checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 631         checkRegionBottomLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 632 
 633         checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 634         checkRegionTopLeftCorner(yellow, blended, SCENE_FILL, 0, .2);
 635         checkRegionTopBoundary(yellow, blended, SCENE_FILL, 0, .2);
 636         checkRegionTopRightCorner(yellow, blended, SCENE_FILL, 0, .2);
 637         checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 638         checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 639         checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 640         checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 641     }
 642 
 643     @Ignore("RT-33446")
 644     @Test(timeout=20000)
 645     public void testHalfPixelRightInset() {
 646         setStyle(
 647                 "-fx-background-color: red, yellow;" +
 648                 "-fx-background-insets: 0, 0 .5 0 0;");
 649 
 650         BackgroundFill red = region.getBackground().getFills().get(0);
 651         BackgroundFill yellow = region.getBackground().getFills().get(1);
 652         Color blended = Color.rgb(254, 127, 27);
 653 
 654         checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 655         checkRegionTopLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 656         checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 657         checkRegionTopRightCorner(red, blended, SCENE_FILL, 0, .2);
 658         checkRegionRightBoundary(red, blended, SCENE_FILL, 0, .2);
 659         checkRegionBottomRightCorner(red, blended, SCENE_FILL, 0, .2);
 660         checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 661         checkRegionBottomLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 662 
 663         checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 664         checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 665         checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 666         checkRegionTopRightCorner(yellow, blended, SCENE_FILL, 0, .2);
 667         checkRegionRightBoundary(yellow, blended, SCENE_FILL, 0, .2);
 668         checkRegionBottomRightCorner(yellow, blended, SCENE_FILL, 0, .2);
 669         checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 670         checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 671     }
 672 
 673     @Ignore("RT-33446")
 674     @Test(timeout=20000)
 675     public void testHalfPixelBottomInset() {
 676         setStyle(
 677                 "-fx-background-color: red, yellow;" +
 678                 "-fx-background-insets: 0, 0 0 .5 0;");
 679 
 680         BackgroundFill red = region.getBackground().getFills().get(0);
 681         BackgroundFill yellow = region.getBackground().getFills().get(1);
 682         Color blended = Color.rgb(254, 127, 27);
 683 
 684         checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 685         checkRegionTopLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 686         checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 687         checkRegionTopRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 688         checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 689         checkRegionBottomRightCorner(red, blended, SCENE_FILL, 0, .2);
 690         checkRegionBottomBoundary(red, blended, SCENE_FILL, 0, .2);
 691         checkRegionBottomLeftCorner(red, blended, SCENE_FILL, 0, .2);
 692 
 693         checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 694         checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 695         checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 696         checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 697         checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 698         checkRegionBottomRightCorner(yellow, blended, SCENE_FILL, 0, .2);
 699         checkRegionBottomBoundary(yellow, blended, SCENE_FILL, 0, .2);
 700         checkRegionBottomLeftCorner(yellow, blended, SCENE_FILL, 0, .2);
 701     }
 702 
 703     @Ignore("RT-33446")
 704     @Test(timeout=20000)
 705     public void testHalfPixelLeftInset() {
 706         setStyle(
 707                 "-fx-background-color: red, yellow;" +
 708                 "-fx-background-insets: 0, 0 0 0 .5;");
 709 
 710         BackgroundFill red = region.getBackground().getFills().get(0);
 711         BackgroundFill yellow = region.getBackground().getFills().get(1);
 712         Color blended = Color.rgb(254, 127, 27);
 713 
 714         checkRegionLeftBoundary(red, blended, SCENE_FILL, 0, .2);
 715         checkRegionTopLeftCorner(red, blended, SCENE_FILL, 0, .2);
 716         checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 717         checkRegionTopRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 718         checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 719         checkRegionBottomRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 720         checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 721         checkRegionBottomLeftCorner(red, blended, SCENE_FILL, 0, .2);
 722 
 723         checkRegionLeftBoundary(yellow, blended, SCENE_FILL, 0, .2);
 724         checkRegionTopLeftCorner(yellow, blended, SCENE_FILL, 0, .2);
 725         checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 726         checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 727         checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 728         checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 729         checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 730         checkRegionBottomLeftCorner(yellow, blended, SCENE_FILL, 0, .2);
 731     }
 732 
 733     @Ignore("RT-33446")
 734     @Test(timeout=20000)
 735     public void testHalfPixelTopLeftInset() {
 736         setStyle(
 737                 "-fx-background-color: red, yellow;" +
 738                 "-fx-background-insets: 0, .5 0 0 .5;");
 739 
 740         BackgroundFill red = region.getBackground().getFills().get(0);
 741         BackgroundFill yellow = region.getBackground().getFills().get(1);
 742         Color blended = Color.rgb(254, 127, 27);
 743 
 744         checkRegionLeftBoundary(red, blended, SCENE_FILL, 0, .2);
 745         // I'm not sure about this one. We actually blend the top and left together,
 746         // which makes the corner darker than it really probably should be. I think this is a bug.
 747 //        checkRegionTopLeftCorner(red, blended, SCENE_FILL, 0, .2);
 748         checkRegionTopBoundary(red, blended, SCENE_FILL, 0, .2);
 749         checkRegionTopRightCorner(red, blended, SCENE_FILL, 0, .2);
 750         checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 751         checkRegionBottomRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2);
 752         checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2);
 753         checkRegionBottomLeftCorner(red, blended, SCENE_FILL, 0, .2);
 754 
 755         checkRegionLeftBoundary(yellow, blended, SCENE_FILL, 0, .2);
 756         // I'm not sure about this one. We actually blend the top and left together,
 757         // which makes the corner darker than it really probably should be. I think this is a bug.
 758 //        checkRegionTopLeftCorner(yellow, blended, SCENE_FILL, 0, .2);
 759         checkRegionTopBoundary(yellow, blended, SCENE_FILL, 0, .2);
 760         checkRegionTopRightCorner(yellow, blended, SCENE_FILL, 0, .2);
 761         checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 762         checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 763         checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2);
 764         checkRegionBottomLeftCorner(yellow, blended, SCENE_FILL, 0, .2);
 765     }
 766 
 767     @Test(timeout=20000)
 768     public void testNoInsets() {
 769         setStyle(
 770                 "-fx-background-color: red, yellow;" +
 771                 "-fx-background-insets: 0, 0;");
 772 
 773         BackgroundFill red = region.getBackground().getFills().get(0);
 774         BackgroundFill yellow = region.getBackground().getFills().get(1);
 775         checkRegionCornersAndBoundariesOfBackgroundFill(red, Color.YELLOW, SCENE_FILL);
 776         checkRegionCornersAndBoundariesOfBackgroundFill(yellow, SCENE_FILL);
 777     }
 778 
 779     @Test(timeout=20000)
 780     public void testYellowOnRed() {
 781         setStyle(
 782                 "-fx-background-color: red, yellow;" +
 783                 "-fx-background-insets: 0, 40;");
 784         checkRegionCornersAndBoundariesForFills();
 785     }
 786 
 787     // TODO to be thorough, I wonder if we can write a test where NaN or +/- Infinity can be passed via CSS to radii?
 788 
 789     // This just plain shouldn't work.
 790 //    public void testImageFill() {
 791 //        setStyle("-fx-background-color: url('test/robot/javafx/scene/layout/test20x20.png');");
 792 //    }
 793 }