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