--- old/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/CheckBoxSkinTest.java 2017-02-27 14:41:29.691655000 +0530 +++ new/modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/CheckBoxSkinTest.java 2017-02-27 14:41:29.483551000 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,12 @@ import javafx.geometry.Insets; import javafx.scene.control.CheckBox; import javafx.scene.control.skin.CheckBoxSkin; +import com.sun.javafx.tk.Toolkit; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.stage.Stage; +import org.junit.BeforeClass; import org.junit.Before; import org.junit.Test; @@ -40,6 +45,13 @@ public class CheckBoxSkinTest { private CheckBox checkbox; private CheckBoxSkinMock skin; + private static Toolkit tk; + private Scene scene; + private Stage stage; + + @BeforeClass public static void initToolKit() { + tk = Toolkit.getToolkit(); + } @Before public void setup() { checkbox = new CheckBox("Test"); @@ -49,6 +61,11 @@ checkbox.setPadding(new Insets(10, 10, 10, 10)); checkbox.setSkin(skin); + scene = new Scene(new Group(checkbox)); + stage = new Stage(); + stage.setScene(scene); + stage.show(); + tk.firePulse(); } @Test public void maxWidthTracksPreferred() { @@ -61,6 +78,17 @@ assertEquals(500, checkbox.maxHeight(-1), 0); } + @Test public void testPadding() { + checkbox.setPadding(new Insets(10, 20, 30, 40)); + + tk.firePulse(); + + double expectedArea = checkbox.getHeight() * checkbox.getWidth(); + double actualArea = checkbox.getSkin().getNode().computeAreaInScreen(); + + assertEquals(expectedArea, actualArea, 0.001); + } + public static final class CheckBoxSkinMock extends CheckBoxSkin { boolean propertyChanged = false; int propertyChangeCount = 0;