@Test
  public void testSceneSizeSetWithClipOnRoot() {
    Group g = new Group();

    Rectangle clip = new Rectangle();
    clip.setX(20);
    clip.setY(20);
    clip.setWidth(150);
    clip.setHeight(150);

    g.setClip(clip);

    Rectangle r = new Rectangle();

    r.setX(20);
    r.setY(20);
    g.getChildren().add(r);
    r.setWidth(200);
    r.setHeight(200);

    Scene scene = new Scene(g);
    stage.setScene(scene);

    assertEquals(170, (int) scene.getWidth());
    assertEquals(170, (int) scene.getHeight());
  }
  @Test
  public void testSceneSizeSetWithRotationOnRoot() {
    Group g = new Group();
    g.setRotate(45);
    Rectangle r = new Rectangle();
    r.setX(-20);
    r.setY(-20);
    r.setWidth(200);
    r.setHeight(200);
    g.getChildren().add(r);

    Scene scene = new Scene(g);
    stage.setScene(scene);

    assertTrue(scene.getWidth() > 220.0f && scene.getWidth() < 222.0f);
    assertTrue(scene.getHeight() > 220.0f && scene.getHeight() < 222.0f);
  }
  @Test
  public void testSceneSizeWithContentBiasOnRoot() {
    Rectangle r1 = new Rectangle(20, 20);
    Rectangle r2 = new Rectangle(20, 20);
    Rectangle r3 = new Rectangle(100, 20);

    TilePane tilePane = new TilePane();
    tilePane.getChildren().addAll(r1, r2);

    final VBox root = new VBox();
    root.getChildren().addAll(tilePane, r3);
    Scene scene = new Scene(root);
    stage.setScene(scene);

    assertEquals(100, (int) scene.getWidth());
    assertEquals(40, (int) scene.getHeight());
  }
  @Test
  public void testSceneSizeOverridesResizableRootPrefSize() {
    StackPane s = new StackPane();

    Rectangle r = new Rectangle();
    r.setX(-20);
    r.setY(-20);
    r.setWidth(100);
    r.setHeight(100);
    s.getChildren().add(r);

    Scene scene = new Scene(s, 600, 600);
    stage.setScene(scene);

    assertEquals(600, (int) scene.getWidth());
    assertEquals(600, (int) scene.getHeight());
  }
  @Test
  public void testSceneSizeWhenWidthAndHeightInitialized() {
    Group g = new Group();

    Rectangle r = new Rectangle();
    r.setX(-20);
    r.setY(-20);
    r.setWidth(100);
    r.setHeight(100);
    g.getChildren().add(r);

    Scene scene = new Scene(g, 400, 400);
    stage.setScene(scene);

    assertEquals(400, (int) scene.getWidth());
    assertEquals(400, (int) scene.getHeight());
  }
  @Test
  public void testSceneSizeSetWithResizableAsRoot() {
    StackPane st = new StackPane();

    Rectangle r = new Rectangle();
    r.setX(-20);
    r.setY(-20);
    r.setWidth(200);
    r.setHeight(200);
    st.getChildren().add(r);

    Scene scene = new Scene(st);
    stage.setScene(scene);

    assertEquals(200, (int) scene.getWidth());
    assertEquals(200, (int) scene.getHeight());
  }
  @Test
  public void testSceneSizeSetWithTranslateOnRoot() {
    Group g = new Group();

    g.setTranslateX(10);
    g.setTranslateY(10);
    Rectangle r = new Rectangle();
    r.setX(-20);
    r.setY(-20);
    r.setWidth(200);
    r.setHeight(200);
    g.getChildren().add(r);
    Scene scene = new Scene(g);
    stage.setScene(scene);

    assertEquals(190, (int) scene.getWidth());
    assertEquals(190, (int) scene.getHeight());
  }
  @Test
  public void testSceneSizeSetWithEffectOnRoot() {
    Group g = new Group();

    g.setEffect(new javafx.scene.effect.DropShadow());

    Rectangle r = new Rectangle();
    r.setX(-20);
    r.setY(-20);
    g.getChildren().add(r);
    r.setWidth(200);
    r.setHeight(200);

    Scene scene = new Scene(g);
    stage.setScene(scene);

    assertEquals(189, (int) scene.getWidth());
    assertEquals(189, (int) scene.getHeight());
  }
  @Test
  public void testSceneSizeSetWithTransformOnRoot() {
    Group g = new Group();

    Scale s = new Scale();
    s.setX(2.0f);
    s.setY(2.0f);
    Rectangle r = new Rectangle();
    r.setX(-20);
    r.setY(-20);
    g.getChildren().add(r);
    r.setWidth(200);
    r.setHeight(200);

    g.getTransforms().add(s);
    Scene scene = new Scene(g);
    stage.setScene(scene);

    assertEquals(360, (int) scene.getWidth());
    assertEquals(360, (int) scene.getHeight());
  }