1 /* 2 * Copyright (c) 2012, 2015, 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 /** 33 */ 34 public class RegionBackgroundFillUITest extends RegionUITestBase { 35 36 static { 37 System.setProperty("glass.win.uiScale", "100%"); 38 } 39 40 /************************************************************************** 41 * * 42 * Tests for background fills. We start with a series of simple tests * 43 * with a single solid fill, including exercising different insets and * 44 * corner radii. * 45 * * 46 *************************************************************************/ 47 48 @Test(timeout=20000) 49 public void basicFill() { 50 setStyle("-fx-background-color: red;"); 51 checkRegionCornersAndBoundariesForFills(); 52 } 53 54 @Test(timeout=20000) 55 public void translucentFill() { 56 setStyle("-fx-background-color: rgba(255, 0, 0, .2);"); 57 // multiply through the alpha 58 checkRegionCornersAndBoundariesOfBackgroundFill( 59 region.getBackground().getFills().get(0), Color.rgb(255, 204, 204), SCENE_FILL); 60 } 61 62 @Test(timeout=20000) 63 public void basicFill_Insets1() { 64 setStyle( 65 "-fx-background-color: red;" + 66 "-fx-background-insets: 5"); 67 checkRegionCornersAndBoundariesForFills(); 68 } 69 70 @Test(timeout=20000) 71 public void basicFill_Insets2() { 72 setStyle( 73 "-fx-background-color: red;" + 74 "-fx-background-insets: 5 10"); 75 checkRegionCornersAndBoundariesForFills(); 76 } 77 78 @Test(timeout=20000) 79 public void basicFill_Insets3() { 80 setStyle( 81 "-fx-background-color: red;" + 82 "-fx-background-insets: 5 10 15"); 83 checkRegionCornersAndBoundariesForFills(); 84 } 85 86 @Test(timeout=20000) 87 public void basicFill_Insets4() { 88 setStyle( 89 "-fx-background-color: red;" + 90 "-fx-background-insets: 5 10 15 20"); 91 checkRegionCornersAndBoundariesForFills(); 92 } 93 94 @Test(timeout=20000) 95 public void basicFill_NegativeInsets1() { 96 setStyle( 97 "-fx-background-color: red;" + 98 "-fx-background-insets: -5"); 99 checkRegionCornersAndBoundariesForFills(); 100 } 101 102 @Test(timeout=20000) 103 public void basicFill_NegativeInsets2() { 104 setStyle( 105 "-fx-background-color: red;" + 106 "-fx-background-insets: -5 -10"); 107 checkRegionCornersAndBoundariesForFills(); 108 } 109 110 @Test(timeout=20000) 111 public void basicFill_NegativeInsets3() { 112 setStyle( 113 "-fx-background-color: red;" + 114 "-fx-background-insets: -5 -10 -15"); 115 checkRegionCornersAndBoundariesForFills(); 116 } 117 118 @Test(timeout=20000) 119 public void basicFill_NegativeInsets4() { 120 setStyle( 121 "-fx-background-color: red;" + 122 "-fx-background-insets: -5 -10 -15 -20"); 123 checkRegionCornersAndBoundariesForFills(); 124 } 125 126 @Test(timeout=20000) 127 public void basicFill_MixedInsets() { 128 setStyle( 129 "-fx-background-color: red;" + 130 "-fx-background-insets: 10 10 -10 10"); 131 checkRegionCornersAndBoundariesForFills(); 132 } 133 134 @Test(timeout=20000) 135 public void basicFill_Radius1() { 136 setStyle( 137 "-fx-background-color: red;" + 138 "-fx-background-radius: 10"); 139 checkRegionCornersAndBoundariesForFills(); 140 } 141 142 @Test(timeout=20000) 143 public void basicFill_Radius2() { 144 setStyle( 145 "-fx-background-color: red;" + 146 "-fx-background-radius: 10 20"); 147 checkRegionCornersAndBoundariesForFills(); 148 } 149 150 @Test(timeout=20000) 151 public void basicFill_Radius3() { 152 setStyle( 153 "-fx-background-color: red;" + 154 "-fx-background-radius: 10 20 30"); 155 checkRegionCornersAndBoundariesForFills(); 156 } 157 158 @Test(timeout=20000) 159 public void basicFill_Radius4() { 160 setStyle( 161 "-fx-background-color: red;" + 162 "-fx-background-radius: 10 20 30 40"); 163 checkRegionCornersAndBoundariesForFills(); 164 } 165 166 // TODO need to write tests for percentage based radii 167 // public void basicFill_PercentageRadius() { 168 // setStyle( 169 // "-fx-background-color: red;" + 170 // "-fx-background-radius: 5% 10% 15% 20%"); 171 // } 172 173 // TODO need to check on the syntax for the 8 independent corner radii... 174 // public void basicFill_Radius8() { 175 // setStyle( 176 // "-fx-background-color: red;" + 177 // "-fx-background-radius: 10 20 30 40 50 60 70 80"); 178 // } 179 180 @Test(timeout=20000) 181 public void basicFill_RadiusAndInsets() { 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 setStyle( 373 "-fx-background-color: red, green, blue, grey;" + 374 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" + 375 "-fx-background-radius: 10 20 30 40;" + 376 "-fx-padding: 10 20 30 40;"); 377 378 BackgroundFill red = region.getBackground().getFills().get(0); 379 BackgroundFill green = region.getBackground().getFills().get(1); 380 BackgroundFill blue = region.getBackground().getFills().get(2); 381 BackgroundFill grey = region.getBackground().getFills().get(3); 382 383 checkRegionLeftBoundary(red, Color.GREEN, SCENE_FILL); 384 checkRegionTopLeftCorner(red, Color.GREEN, SCENE_FILL); 385 checkRegionTopBoundary(red, Color.GREEN, SCENE_FILL); 386 checkRegionTopRightCorner(red, Color.GREEN, SCENE_FILL); 387 checkRegionRightBoundary(red, Color.GREEN, SCENE_FILL); 388 checkRegionBottomRightCorner(red, SCENE_FILL); 389 checkRegionBottomBoundary(red, SCENE_FILL); 390 checkRegionBottomLeftCorner(red, SCENE_FILL); 391 392 checkRegionLeftBoundary(green, SCENE_FILL); 393 checkRegionTopLeftCorner(green, SCENE_FILL); 394 checkRegionTopBoundary(green, SCENE_FILL); 395 checkRegionTopRightCorner(green, SCENE_FILL); 396 checkRegionRightBoundary(green, SCENE_FILL); 397 checkRegionBottomRightCorner(green, Color.RED); 398 checkRegionBottomBoundary(green, Color.RED); 399 checkRegionBottomLeftCorner(green, Color.RED); 400 401 checkRegionCornersAndBoundariesOfBackgroundFill(blue, Color.GREEN); 402 checkRegionCornersAndBoundariesOfBackgroundFill(grey, Color.BLUE); 403 } 404 405 @Test(timeout=20000) 406 public void testScenario4() { 407 setStyle( 408 "-fx-background-color: red, green, blue, repeating-image-pattern('test/robot/javafx/scene/layout/test20x20.png');" + 409 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" + 410 "-fx-background-radius: 10 20 30 40;" + 411 "-fx-padding: 10 20 30 40;"); 412 413 BackgroundFill red = region.getBackground().getFills().get(0); 414 BackgroundFill green = region.getBackground().getFills().get(1); 415 BackgroundFill blue = region.getBackground().getFills().get(2); 416 BackgroundFill image = region.getBackground().getFills().get(3); 417 418 checkRegionLeftBoundary(red, Color.GREEN, SCENE_FILL); 419 checkRegionTopLeftCorner(red, Color.GREEN, SCENE_FILL); 420 checkRegionTopBoundary(red, Color.GREEN, SCENE_FILL); 421 checkRegionTopRightCorner(red, Color.GREEN, SCENE_FILL); 422 checkRegionRightBoundary(red, Color.GREEN, SCENE_FILL); 423 checkRegionBottomRightCorner(red, SCENE_FILL); 424 checkRegionBottomBoundary(red, SCENE_FILL); 425 checkRegionBottomLeftCorner(red, SCENE_FILL); 426 427 checkRegionLeftBoundary(green, SCENE_FILL); 428 checkRegionTopLeftCorner(green, SCENE_FILL); 429 checkRegionTopBoundary(green, SCENE_FILL); 430 checkRegionTopRightCorner(green, SCENE_FILL); 431 checkRegionRightBoundary(green, SCENE_FILL); 432 checkRegionBottomRightCorner(green, Color.RED); 433 checkRegionBottomBoundary(green, Color.RED); 434 checkRegionBottomLeftCorner(green, Color.RED); 435 436 checkRegionCornersAndBoundariesOfBackgroundFill(blue, Color.GREEN); 437 // checkRegionCornersAndBoundariesOfBackgroundFill(image, Color.BLUE); 438 } 439 440 @Test(timeout=20000) 441 public void testScenario5() { 442 setStyle( 443 "-fx-background-color: red, green, repeating-image-pattern('test/robot/javafx/scene/layout/test20x20.png'), blue;" + 444 "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" + 445 "-fx-background-radius: 10 20 30 40;" + 446 "-fx-padding: 10 20 30 40;"); 447 448 BackgroundFill red = region.getBackground().getFills().get(0); 449 BackgroundFill green = region.getBackground().getFills().get(1); 450 BackgroundFill image = region.getBackground().getFills().get(2); 451 BackgroundFill blue = region.getBackground().getFills().get(3); 452 453 checkRegionLeftBoundary(red, Color.GREEN, SCENE_FILL); 454 checkRegionTopLeftCorner(red, Color.GREEN, SCENE_FILL); 455 checkRegionTopBoundary(red, Color.GREEN, SCENE_FILL); 456 checkRegionTopRightCorner(red, Color.GREEN, SCENE_FILL); 457 checkRegionRightBoundary(red, Color.GREEN, SCENE_FILL); 458 checkRegionBottomRightCorner(red, SCENE_FILL); 459 checkRegionBottomBoundary(red, SCENE_FILL); 460 checkRegionBottomLeftCorner(red, SCENE_FILL); 461 462 checkRegionLeftBoundary(green, SCENE_FILL); 463 checkRegionTopLeftCorner(green, SCENE_FILL); 464 checkRegionTopBoundary(green, SCENE_FILL); 465 checkRegionTopRightCorner(green, SCENE_FILL); 466 checkRegionRightBoundary(green, SCENE_FILL); 467 checkRegionBottomRightCorner(green, Color.RED); 468 checkRegionBottomBoundary(green, Color.RED); 469 checkRegionBottomLeftCorner(green, Color.RED); 470 471 checkRegionCornersAndBoundariesOfBackgroundFill(image, Color.GREEN); 472 // checkRegionCornersAndBoundariesOfBackgroundFill(blue, Color.BLUE, null); 473 } 474 475 @Test(timeout=20000) 476 public void testExample1() { 477 setStyle( 478 "-fx-background-color: red, green, blue;" + 479 "-fx-background-insets: 4, 8, 12, 16;" + // An extra value here, which should be ignored 480 "-fx-background-radius: 14;"); 481 482 checkRegionCornersAndBoundariesForFills(); 483 } 484 485 /************************************************************************** 486 * * 487 * Tests for odd edge cases * 488 * * 489 *************************************************************************/ 490 491 @Test(timeout=20000) 492 public void testOnePixelTopInset() { 493 setStyle( 494 "-fx-background-color: red, yellow;" + 495 "-fx-background-insets: 0, 1 0 0 0;"); 496 497 BackgroundFill red = region.getBackground().getFills().get(0); 498 BackgroundFill yellow = region.getBackground().getFills().get(1); 499 500 checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 501 checkRegionTopLeftCorner(red, Color.RED, SCENE_FILL, 0, .2); 502 checkRegionTopBoundary(red, Color.RED, SCENE_FILL, 0, .2); 503 checkRegionTopRightCorner(red, Color.RED, SCENE_FILL, 0, .2); 504 checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 505 checkRegionBottomRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 506 checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 507 checkRegionBottomLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 508 509 checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 510 checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 511 checkRegionTopBoundary(yellow, Color.YELLOW, Color.RED, 0, .2); 512 checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 513 checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 514 checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 515 checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 516 checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 517 } 518 519 @Test(timeout=20000) 520 public void testOnePixelRightInset() { 521 setStyle( 522 "-fx-background-color: red, yellow;" + 523 "-fx-background-insets: 0, 0 1 0 0;"); 524 525 BackgroundFill red = region.getBackground().getFills().get(0); 526 BackgroundFill yellow = region.getBackground().getFills().get(1); 527 528 checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 529 checkRegionTopLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 530 checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 531 checkRegionTopRightCorner(red, Color.RED, SCENE_FILL, 0, .2); 532 checkRegionRightBoundary(red, Color.RED, SCENE_FILL, 0, .2); 533 checkRegionBottomRightCorner(red, Color.RED, SCENE_FILL, 0, .2); 534 checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 535 checkRegionBottomLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 536 537 checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 538 checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 539 checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 540 checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 541 checkRegionRightBoundary(yellow, Color.YELLOW, Color.RED, 0, .2); 542 checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 543 checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 544 checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 545 } 546 547 @Test(timeout=20000) 548 public void testOnePixelBottomInset() { 549 setStyle( 550 "-fx-background-color: red, yellow;" + 551 "-fx-background-insets: 0, 0 0 1 0;"); 552 553 BackgroundFill red = region.getBackground().getFills().get(0); 554 BackgroundFill yellow = region.getBackground().getFills().get(1); 555 556 checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 557 checkRegionTopLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 558 checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 559 checkRegionTopRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 560 checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 561 checkRegionBottomRightCorner(red, Color.RED, SCENE_FILL, 0, .2); 562 checkRegionBottomBoundary(red, Color.RED, SCENE_FILL, 0, .2); 563 checkRegionBottomLeftCorner(red, Color.RED, SCENE_FILL, 0, .2); 564 565 checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 566 checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 567 checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 568 checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 569 checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 570 checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 571 checkRegionBottomBoundary(yellow, Color.YELLOW, Color.RED, 0, .2); 572 checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 573 } 574 575 @Test(timeout=20000) 576 public void testOnePixelLeftInset() { 577 setStyle( 578 "-fx-background-color: red, yellow;" + 579 "-fx-background-insets: 0, 0 0 0 1;"); 580 581 BackgroundFill red = region.getBackground().getFills().get(0); 582 BackgroundFill yellow = region.getBackground().getFills().get(1); 583 584 checkRegionLeftBoundary(red, Color.RED, SCENE_FILL, 0, .2); 585 checkRegionTopLeftCorner(red, Color.RED, SCENE_FILL, 0, .2); 586 checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 587 checkRegionTopRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 588 checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 589 checkRegionBottomRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 590 checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 591 checkRegionBottomLeftCorner(red, Color.RED, SCENE_FILL, 0, .2); 592 593 checkRegionLeftBoundary(yellow, Color.YELLOW, Color.RED, 0, .2); 594 checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 595 checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 596 checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 597 checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 598 checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 599 checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 600 checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 601 } 602 603 @Ignore("RT-33446") 604 @Test(timeout=20000) 605 public void testHalfPixelTopInset() { 606 setStyle( 607 "-fx-background-color: red, yellow;" + 608 "-fx-background-insets: 0, .5 0 0 0;"); 609 610 BackgroundFill red = region.getBackground().getFills().get(0); 611 BackgroundFill yellow = region.getBackground().getFills().get(1); 612 Color blended = Color.rgb(254, 127, 27); 613 614 checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 615 checkRegionTopLeftCorner(red, blended, SCENE_FILL, 0, .2); 616 checkRegionTopBoundary(red, blended, SCENE_FILL, 0, .2); 617 checkRegionTopRightCorner(red, blended, SCENE_FILL, 0, .2); 618 checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 619 checkRegionBottomRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 620 checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 621 checkRegionBottomLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 622 623 checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 624 checkRegionTopLeftCorner(yellow, blended, SCENE_FILL, 0, .2); 625 checkRegionTopBoundary(yellow, blended, SCENE_FILL, 0, .2); 626 checkRegionTopRightCorner(yellow, blended, SCENE_FILL, 0, .2); 627 checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 628 checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 629 checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 630 checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 631 } 632 633 @Ignore("RT-33446") 634 @Test(timeout=20000) 635 public void testHalfPixelRightInset() { 636 setStyle( 637 "-fx-background-color: red, yellow;" + 638 "-fx-background-insets: 0, 0 .5 0 0;"); 639 640 BackgroundFill red = region.getBackground().getFills().get(0); 641 BackgroundFill yellow = region.getBackground().getFills().get(1); 642 Color blended = Color.rgb(254, 127, 27); 643 644 checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 645 checkRegionTopLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 646 checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 647 checkRegionTopRightCorner(red, blended, SCENE_FILL, 0, .2); 648 checkRegionRightBoundary(red, blended, SCENE_FILL, 0, .2); 649 checkRegionBottomRightCorner(red, blended, SCENE_FILL, 0, .2); 650 checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 651 checkRegionBottomLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 652 653 checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 654 checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 655 checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 656 checkRegionTopRightCorner(yellow, blended, SCENE_FILL, 0, .2); 657 checkRegionRightBoundary(yellow, blended, SCENE_FILL, 0, .2); 658 checkRegionBottomRightCorner(yellow, blended, SCENE_FILL, 0, .2); 659 checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 660 checkRegionBottomLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 661 } 662 663 @Ignore("RT-33446") 664 @Test(timeout=20000) 665 public void testHalfPixelBottomInset() { 666 setStyle( 667 "-fx-background-color: red, yellow;" + 668 "-fx-background-insets: 0, 0 0 .5 0;"); 669 670 BackgroundFill red = region.getBackground().getFills().get(0); 671 BackgroundFill yellow = region.getBackground().getFills().get(1); 672 Color blended = Color.rgb(254, 127, 27); 673 674 checkRegionLeftBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 675 checkRegionTopLeftCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 676 checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 677 checkRegionTopRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 678 checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 679 checkRegionBottomRightCorner(red, blended, SCENE_FILL, 0, .2); 680 checkRegionBottomBoundary(red, blended, SCENE_FILL, 0, .2); 681 checkRegionBottomLeftCorner(red, blended, SCENE_FILL, 0, .2); 682 683 checkRegionLeftBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 684 checkRegionTopLeftCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 685 checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 686 checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 687 checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 688 checkRegionBottomRightCorner(yellow, blended, SCENE_FILL, 0, .2); 689 checkRegionBottomBoundary(yellow, blended, SCENE_FILL, 0, .2); 690 checkRegionBottomLeftCorner(yellow, blended, SCENE_FILL, 0, .2); 691 } 692 693 @Ignore("RT-33446") 694 @Test(timeout=20000) 695 public void testHalfPixelLeftInset() { 696 setStyle( 697 "-fx-background-color: red, yellow;" + 698 "-fx-background-insets: 0, 0 0 0 .5;"); 699 700 BackgroundFill red = region.getBackground().getFills().get(0); 701 BackgroundFill yellow = region.getBackground().getFills().get(1); 702 Color blended = Color.rgb(254, 127, 27); 703 704 checkRegionLeftBoundary(red, blended, SCENE_FILL, 0, .2); 705 checkRegionTopLeftCorner(red, blended, SCENE_FILL, 0, .2); 706 checkRegionTopBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 707 checkRegionTopRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 708 checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 709 checkRegionBottomRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 710 checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 711 checkRegionBottomLeftCorner(red, blended, SCENE_FILL, 0, .2); 712 713 checkRegionLeftBoundary(yellow, blended, SCENE_FILL, 0, .2); 714 checkRegionTopLeftCorner(yellow, blended, SCENE_FILL, 0, .2); 715 checkRegionTopBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 716 checkRegionTopRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 717 checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 718 checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 719 checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 720 checkRegionBottomLeftCorner(yellow, blended, SCENE_FILL, 0, .2); 721 } 722 723 @Ignore("RT-33446") 724 @Test(timeout=20000) 725 public void testHalfPixelTopLeftInset() { 726 setStyle( 727 "-fx-background-color: red, yellow;" + 728 "-fx-background-insets: 0, .5 0 0 .5;"); 729 730 BackgroundFill red = region.getBackground().getFills().get(0); 731 BackgroundFill yellow = region.getBackground().getFills().get(1); 732 Color blended = Color.rgb(254, 127, 27); 733 734 checkRegionLeftBoundary(red, blended, SCENE_FILL, 0, .2); 735 // I'm not sure about this one. We actually blend the top and left together, 736 // which makes the corner darker than it really probably should be. I think this is a bug. 737 // checkRegionTopLeftCorner(red, blended, SCENE_FILL, 0, .2); 738 checkRegionTopBoundary(red, blended, SCENE_FILL, 0, .2); 739 checkRegionTopRightCorner(red, blended, SCENE_FILL, 0, .2); 740 checkRegionRightBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 741 checkRegionBottomRightCorner(red, Color.YELLOW, SCENE_FILL, 0, .2); 742 checkRegionBottomBoundary(red, Color.YELLOW, SCENE_FILL, 0, .2); 743 checkRegionBottomLeftCorner(red, blended, SCENE_FILL, 0, .2); 744 745 checkRegionLeftBoundary(yellow, blended, SCENE_FILL, 0, .2); 746 // I'm not sure about this one. We actually blend the top and left together, 747 // which makes the corner darker than it really probably should be. I think this is a bug. 748 // checkRegionTopLeftCorner(yellow, blended, SCENE_FILL, 0, .2); 749 checkRegionTopBoundary(yellow, blended, SCENE_FILL, 0, .2); 750 checkRegionTopRightCorner(yellow, blended, SCENE_FILL, 0, .2); 751 checkRegionRightBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 752 checkRegionBottomRightCorner(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 753 checkRegionBottomBoundary(yellow, Color.YELLOW, SCENE_FILL, 0, .2); 754 checkRegionBottomLeftCorner(yellow, blended, SCENE_FILL, 0, .2); 755 } 756 757 @Test(timeout=20000) 758 public void testNoInsets() { 759 setStyle( 760 "-fx-background-color: red, yellow;" + 761 "-fx-background-insets: 0, 0;"); 762 763 BackgroundFill red = region.getBackground().getFills().get(0); 764 BackgroundFill yellow = region.getBackground().getFills().get(1); 765 checkRegionCornersAndBoundariesOfBackgroundFill(red, Color.YELLOW, SCENE_FILL); 766 checkRegionCornersAndBoundariesOfBackgroundFill(yellow, SCENE_FILL); 767 } 768 769 @Test(timeout=20000) 770 public void testYellowOnRed() { 771 setStyle( 772 "-fx-background-color: red, yellow;" + 773 "-fx-background-insets: 0, 40;"); 774 checkRegionCornersAndBoundariesForFills(); 775 } 776 777 // TODO to be thorough, I wonder if we can write a test where NaN or +/- Infinity can be passed via CSS to radii? 778 779 // This just plain shouldn't work. 780 // public void testImageFill() { 781 // setStyle("-fx-background-color: url('test/robot/javafx/scene/layout/test20x20.png');"); 782 // } 783 }