|
27 | 27 |
|
28 | 28 | import static javafx.concurrent.Worker.State.FAILED;
|
29 | 29 | import static javafx.concurrent.Worker.State.SUCCEEDED;
|
| 30 | + |
| 31 | +import com.sun.webkit.WebPage; |
| 32 | +import com.sun.webkit.WebPageShim; |
| 33 | + |
| 34 | +import java.awt.image.BufferedImage; |
| 35 | +import java.awt.Color; |
30 | 36 | import java.io.File;
|
31 | 37 | import javafx.concurrent.Worker.State;
|
32 | 38 | import javafx.scene.Scene;
|
33 | 39 | import javafx.scene.text.FontSmoothingType;
|
| 40 | +import javafx.scene.web.WebEngineShim; |
34 | 41 |
|
35 | 42 | import org.junit.Test;
|
36 | 43 |
|
37 | 44 | import static org.junit.Assert.assertEquals;
|
| 45 | +import static org.junit.Assert.assertFalse; |
| 46 | +import static org.junit.Assert.assertTrue; |
| 47 | +import static org.junit.Assert.assertNotNull; |
38 | 48 |
|
39 | 49 | public class CSSTest extends TestBase {
|
40 | 50 |
|
@@ -284,4 +294,68 @@ private void testMaxHeight(double expected) {
|
284 | 294 | load(new File(FILE));
|
285 | 295 | assertEquals("Loading Long SelectorList completed successfully", SUCCEEDED, getLoadState());
|
286 | 296 | }
|
| 297 | + |
| 298 | + @Test public void testBorderRadiusPropertyRendering() { |
| 299 | + loadContent( |
| 300 | + "<!DOCTYPE html>\n" + |
| 301 | + "<html>\n" + |
| 302 | + " <head>\n" + |
| 303 | + " <style>\n" + |
| 304 | + " button {\n" + |
| 305 | + " background-color: black; color: white; display: block; font-size: 32px;\n" + |
| 306 | + " width: 200px; height: 100px; padding: 0; border: none;\n" + |
| 307 | + " border-radius: 32px;\n" + |
| 308 | + " }\n" + |
| 309 | + " .bad0 {\n" + |
| 310 | + " background-color: red;\n" + |
| 311 | + " }\n" + |
| 312 | + " .bad1 {\n" + |
| 313 | + " border-bottom-left-radius: 0;\n" + |
| 314 | + " background-color: blue;\n" + |
| 315 | + " }\n" + |
| 316 | + " .bad2 {\n" + |
| 317 | + " border-bottom-left-radius: 0;\n" + |
| 318 | + " border-bottom-right-radius: 0;\n" + |
| 319 | + " background-color: green;\n" + |
| 320 | + " }\n" + |
| 321 | + " .bad3 {\n" + |
| 322 | + " border-bottom-left-radius: 0;\n" + |
| 323 | + " border-bottom-right-radius: 0;\n" + |
| 324 | + " border-top-right-radius: 0;\n" + |
| 325 | + " }\n" + |
| 326 | + " </style>\n" + |
| 327 | + " </head>\n" + |
| 328 | + " <body style='margin: 0px 0px;'>\n" + |
| 329 | + " <button class=\"bad0\">A</button>\n" + |
| 330 | + " <button class=\"bad1\">B</button>\n" + |
| 331 | + " <button class=\"bad2\">C</button>\n" + |
| 332 | + " <button class=\"bad3\">D</button>\n" + |
| 333 | + " </body>\n" + |
| 334 | + "</html>" |
| 335 | + ); |
| 336 | + submit(() -> { |
| 337 | + final WebPage webPage = WebEngineShim.getPage(getEngine()); |
| 338 | + assertNotNull(webPage); |
| 339 | + final BufferedImage img = WebPageShim.paint(webPage, 0, 0, 800, 600); |
| 340 | + assertNotNull(img); |
| 341 | + |
| 342 | + final Color pixelAt0x0 = new Color(img.getRGB(0, 0), true); |
| 343 | + assertFalse("Color should not be red:" + pixelAt0x0, isColorsSimilar(Color.RED, pixelAt0x0, 1)); |
| 344 | + final Color pixelAt199x0 = new Color(img.getRGB(199, 0), true); |
| 345 | + assertFalse("Color should not be red:" + pixelAt199x0, isColorsSimilar(Color.RED, pixelAt199x0, 1)); |
| 346 | + final Color pixelAt0x99 = new Color(img.getRGB(0, 99), true); |
| 347 | + assertFalse("Color should not be red:" + pixelAt0x99, isColorsSimilar(Color.RED, pixelAt0x99, 1)); |
| 348 | + final Color pixelAt199x99 = new Color(img.getRGB(199, 99), true); |
| 349 | + assertFalse("Color should not be red:" + pixelAt199x99, isColorsSimilar(Color.RED, pixelAt199x99, 1)); |
| 350 | + |
| 351 | + final Color pixelAt0x100 = new Color(img.getRGB(0, 100), true); |
| 352 | + assertFalse("Color should not be blue:" + pixelAt0x100, isColorsSimilar(Color.BLUE, pixelAt0x100, 1)); |
| 353 | + final Color pixelAt199x100 = new Color(img.getRGB(199, 100), true); |
| 354 | + assertFalse("Color should not be blue:" + pixelAt199x100, isColorsSimilar(Color.BLUE, pixelAt199x100, 1)); |
| 355 | + final Color pixel0x199 = new Color(img.getRGB(0, 199), true); |
| 356 | + assertTrue("Color should be opaque blue:" + pixel0x199, isColorsSimilar(Color.BLUE, pixel0x199, 1)); |
| 357 | + final Color pixelAt199x199 = new Color(img.getRGB(199, 199), true); |
| 358 | + assertFalse("Color should not be blue:" + pixelAt199x199, isColorsSimilar(Color.BLUE, pixelAt199x199, 1)); |
| 359 | + }); |
| 360 | + } |
287 | 361 | }
|
0 commit comments