1 /*
   2  * Copyright (c) 2010, 2014, 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  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javafx.scene.control;
  27 
  28 import com.sun.javafx.scene.control.infrastructure.StageLoader;
  29 import javafx.css.CssMetaData;
  30 import static com.sun.javafx.scene.control.infrastructure.ControlTestUtils.*;
  31 
  32 import com.sun.javafx.pgstub.StubToolkit;
  33 import javafx.scene.control.skin.SplitPaneSkin;
  34 import com.sun.javafx.tk.Toolkit;
  35 import javafx.application.Platform;
  36 import javafx.beans.property.DoubleProperty;
  37 import javafx.beans.property.ObjectProperty;
  38 import javafx.beans.property.SimpleDoubleProperty;
  39 import javafx.beans.property.SimpleObjectProperty;
  40 import javafx.css.StyleableProperty;
  41 import javafx.geometry.Orientation;
  42 import javafx.scene.Scene;
  43 import javafx.scene.layout.AnchorPane;
  44 import javafx.scene.layout.StackPane;
  45 import javafx.scene.layout.VBox;
  46 import javafx.stage.Stage;
  47 import static org.junit.Assert.*;
  48 
  49 
  50 import org.junit.Before;
  51 import org.junit.Test;
  52 
  53 /**
  54  *
  55  * @author srikalyc
  56  */
  57 public class SplitPaneTest {
  58     private SplitPane splitPane;//Empty string
  59     private SplitPane.Divider divider1;
  60     private SplitPane.Divider divider2;
  61     private Toolkit tk;
  62     private Scene scene;
  63     private Stage stage;
  64     private StackPane root;
  65 
  66     @Before public void setup() {
  67         tk = (StubToolkit)Toolkit.getToolkit();//This step is not needed (Just to make sure StubToolkit is loaded into VM)
  68         splitPane = new SplitPane();
  69         splitPane.setSkin(new SplitPaneSkin(splitPane));
  70         divider1 = new SplitPane.Divider();
  71         divider2 = new SplitPane.Divider();
  72 
  73         root = new StackPane();
  74         scene = new Scene(root);
  75         stage = new Stage();
  76         stage.setScene(scene);
  77     }
  78 
  79     /*********************************************************************
  80      * Helper methods (NOTE TESTS)                                       *
  81      ********************************************************************/
  82     private void add2NodesToSplitPane() {
  83         splitPane.getItems().add(new Button("Button One"));
  84         splitPane.getItems().add(new Button("Button Two"));
  85     }
  86     private void add3NodesToSplitPane() {
  87         add2NodesToSplitPane();
  88         splitPane.getItems().add(new Button("Button Three"));
  89     }
  90 
  91     private void add4NodesToSplitPane() {
  92         add3NodesToSplitPane();
  93         splitPane.getItems().add(new Button("Button Four"));
  94     }
  95 
  96     private void show() {
  97         stage.show();
  98     }
  99 
 100 
 101     private double convertDividerPostionToAbsolutePostion(double pos, double edge) {        
 102         return (Math.round(pos * edge)) - 3;  // 3 is half the divider width.
 103     }
 104     
 105     /*********************************************************************
 106      * Tests for default values                                         *
 107      ********************************************************************/
 108 
 109     @Test public void defaultConstructorShouldSetStyleClassTo_splitpane() {
 110         assertStyleClassContains(splitPane, "split-pane");
 111     }
 112 
 113     @Test public void defaultFocusTraversibleIsFalse() {
 114         assertFalse(splitPane.isFocusTraversable());
 115     }
 116 
 117     @Test public void defaultOrientation() {
 118         assertSame(splitPane.getOrientation(), Orientation.HORIZONTAL);
 119     }
 120 
 121     @Test public void defaultDividerPosition() {
 122         assertEquals(divider1.getPosition(), 0.5, 0.0);
 123     }
 124 
 125     @Test public void defaultPositionOf_N_DividersAddedToSplitPaneWhenNewNodeAreAdded() {
 126         add4NodesToSplitPane();
 127         assertEquals(splitPane.getDividers().get(0).getPosition(), 0.5, 0.0);
 128         assertEquals(splitPane.getDividers().get(1).getPosition(), 0.5, 0.0);
 129         assertEquals(splitPane.getDividers().get(1).getPosition(), 0.5, 0.0);
 130     }
 131 
 132     /*********************************************************************
 133      * Tests for property binding                                        *
 134      ********************************************************************/
 135 
 136     @Test public void checkHBarPolicyPropertyBind() {
 137         ObjectProperty objPr = new SimpleObjectProperty<Orientation>(Orientation.VERTICAL);
 138         splitPane.orientationProperty().bind(objPr);
 139         assertSame("orientationProperty cannot be bound", splitPane.orientationProperty().getValue(), Orientation.VERTICAL);
 140         objPr.setValue(Orientation.HORIZONTAL);
 141         assertSame("orientationProperty cannot be bound", splitPane.orientationProperty().getValue(), Orientation.HORIZONTAL);
 142     }
 143 
 144     @Test public void checkDividerPositionPropertyBind() {
 145         DoubleProperty objPr = new SimpleDoubleProperty(0.6);
 146         divider1.positionProperty().bind(objPr);
 147         assertEquals("positionProperty cannot be bound", divider1.positionProperty().getValue(), 0.6, 0.0);
 148         objPr.setValue(0.9);
 149         assertEquals("positionProperty cannot be bound", divider1.positionProperty().getValue(), 0.9, 0.0);
 150     }
 151 
 152     @Test public void checkOrientationPropertyBind() {
 153         ObjectProperty objPr = new SimpleObjectProperty<Orientation>(Orientation.HORIZONTAL);
 154         splitPane.orientationProperty().bind(objPr);
 155         assertSame("orientationProperty cannot be bound", splitPane.orientationProperty().getValue(), Orientation.HORIZONTAL);
 156         objPr.setValue(Orientation.VERTICAL);
 157         assertSame("orientationProperty cannot be bound", splitPane.orientationProperty().getValue(), Orientation.VERTICAL);
 158     }
 159 
 160     @Test public void orientationPropertyHasBeanReference() {
 161         assertSame(splitPane, splitPane.orientationProperty().getBean());
 162     }
 163 
 164     @Test public void orientationPropertyHasName() {
 165         assertEquals("orientation", splitPane.orientationProperty().getName());
 166     }
 167 
 168     @Test public void positionPropertyHasBeanReference() {
 169         assertSame(divider1, divider1.positionProperty().getBean());
 170     }
 171 
 172     @Test public void positionPropertyHasName() {
 173         assertEquals("position", divider1.positionProperty().getName());
 174     }
 175 
 176 
 177 
 178     /*********************************************************************
 179      * Check for Pseudo classes                                          *
 180      ********************************************************************/
 181     @Test public void settingVerticalOrientationSetsVerticalPseudoClass() {
 182         splitPane.setOrientation(Orientation.VERTICAL);
 183         assertPseudoClassExists(splitPane, "vertical");
 184         assertPseudoClassDoesNotExist(splitPane, "horizontal");
 185     }
 186 
 187     @Test public void clearingVerticalOrientationClearsVerticalPseudoClass() {
 188         splitPane.setOrientation(Orientation.VERTICAL);
 189         splitPane.setOrientation(Orientation.HORIZONTAL);
 190         assertPseudoClassDoesNotExist(splitPane, "vertical");
 191         assertPseudoClassExists(splitPane, "horizontal");
 192     }
 193 
 194     @Test public void settingHorizontalOrientationSetsHorizontalPseudoClass() {
 195         splitPane.setOrientation(Orientation.HORIZONTAL);
 196         assertPseudoClassExists(splitPane, "horizontal");
 197         assertPseudoClassDoesNotExist(splitPane, "vertical");
 198     }
 199 
 200     @Test public void clearingHorizontalOrientationClearsHorizontalPseudoClass() {
 201         splitPane.setOrientation(Orientation.HORIZONTAL);
 202         splitPane.setOrientation(Orientation.VERTICAL);
 203         assertPseudoClassDoesNotExist(splitPane, "horizontal");
 204         assertPseudoClassExists(splitPane, "vertical");
 205     }
 206 
 207 
 208 
 209     /*********************************************************************
 210      * CSS related Tests                                                 *
 211      ********************************************************************/
 212     @Test public void whenOrientationIsBound_impl_cssSettable_ReturnsFalse() {
 213         CssMetaData styleable = ((StyleableProperty)splitPane.orientationProperty()).getCssMetaData();
 214         assertTrue(styleable.isSettable(splitPane));
 215         ObjectProperty<Orientation> other = new SimpleObjectProperty<Orientation>(Orientation.VERTICAL);
 216         splitPane.orientationProperty().bind(other);
 217         assertFalse(styleable.isSettable(splitPane));
 218     }
 219 
 220     @Test public void whenOrientationIsSpecifiedViaCSSAndIsNotBound_impl_cssSettable_ReturnsTrue() {
 221         CssMetaData styleable = ((StyleableProperty)splitPane.orientationProperty()).getCssMetaData();
 222         assertTrue(styleable.isSettable(splitPane));
 223     }
 224 
 225     @Test public void canSpecifyOrientationViaCSS() {
 226         ((StyleableProperty)splitPane.orientationProperty()).applyStyle(null, Orientation.VERTICAL);
 227         assertSame(Orientation.VERTICAL, splitPane.getOrientation());
 228     }
 229 
 230     /*********************************************************************
 231      * Miscellaneous Tests                                         *
 232      ********************************************************************/
 233     @Test public void setOrientationAndSeeValueIsReflectedInModel() {
 234         splitPane.setOrientation(Orientation.HORIZONTAL);
 235         assertSame(splitPane.orientationProperty().getValue(), Orientation.HORIZONTAL);
 236     }
 237 
 238     @Test public void setOrientationAndSeeValue() {
 239         splitPane.setOrientation(Orientation.VERTICAL);
 240         assertSame(splitPane.getOrientation(), Orientation.VERTICAL);
 241     }
 242 
 243     @Test public void setPositionAndSeeValueIsReflectedInModel() {
 244         divider1.setPosition(0.2);
 245         assertEquals(divider1.positionProperty().getValue(), 0.2, 0.0);
 246     }
 247 
 248     @Test public void setPositionAndSeeValue() {
 249         divider1.setPosition(0.3);
 250         assertEquals(divider1.getPosition(), 0.3, 0.0);
 251     }
 252 
 253     @Test public void addingNnodesToSplitPaneCreatesNminus1Dividers() {
 254         add3NodesToSplitPane();
 255         assertNotNull(splitPane.getDividers());
 256         assertEquals(splitPane.getDividers().size(), 2, 0.0);
 257     }
 258 
 259     @Test public void setMultipleDividerPositionsAndValidate() {
 260         add3NodesToSplitPane();
 261         splitPane.setDividerPosition(0, 0.4);
 262         splitPane.setDividerPosition(1, 0.6);
 263         assertNotNull(splitPane.getDividers());
 264         assertEquals(splitPane.getDividers().size(), 2, 0.0);
 265         assertEquals(splitPane.getDividers().get(0).getPosition(), 0.4, 0.0);
 266         assertEquals(splitPane.getDividers().get(1).getPosition(), 0.6, 0.0);
 267     }
 268 
 269     @Test public void addingNonExistantDividerPositionToSplitPaneCachesItAndAppliesWhenNewNodeAreAdded() {
 270         add2NodesToSplitPane();
 271         splitPane.setDividerPosition(2, 0.4);//2 is a non existant divider position, but still position value 0.4 is cached
 272 
 273         splitPane.getItems().add(new Button("Button Three"));
 274         splitPane.getItems().add(new Button("Button Four"));
 275         assertNotNull(splitPane.getDividers());
 276         assertEquals(splitPane.getDividers().size(), 3, 0.0);
 277         assertEquals(splitPane.getDividers().get(2).getPosition(), 0.4, 0.0);
 278     }
 279 
 280     @Test public void zeroDivider() {
 281         StackPane spCenter = new StackPane();
 282         splitPane.getItems().addAll(spCenter);
 283 
 284         root.setPrefSize(400, 400);
 285         root.getChildren().add(splitPane);
 286         show();
 287 
 288         root.applyCss();
 289         root.autosize();
 290         root.layout();
 291 
 292         assertEquals(0, splitPane.getDividers().size());
 293         assertEquals(398, spCenter.getLayoutBounds().getWidth(), 1e-100);
 294     }
 295 
 296     @Test public void oneDividerPanelsAreEquallySized() {
 297         StackPane spLeft = new StackPane();
 298         StackPane spRight = new StackPane();
 299 
 300         splitPane.getItems().addAll(spLeft, spRight);
 301 
 302         root.setPrefSize(400, 400);
 303         root.getChildren().add(splitPane);
 304         show();
 305 
 306         root.applyCss();
 307         root.autosize();
 308         root.layout();
 309 
 310         double w = 398; // The width minus the insets.
 311         double pos[] = splitPane.getDividerPositions();
 312         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 313 
 314         assertEquals(196, p0, 1e-100);
 315         assertEquals(196, spLeft.getLayoutBounds().getWidth(), 1e-100);
 316         assertEquals(196, spRight.getLayoutBounds().getWidth(), 1e-100);
 317     }
 318     
 319     @Test public void twoDividersHaveTheSamePosition() {
 320         StackPane spLeft = new StackPane();
 321         StackPane spCenter = new StackPane();
 322         StackPane spRight = new StackPane();
 323 
 324         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 325 
 326         root.setPrefSize(400, 400);
 327         root.getChildren().add(splitPane);
 328         show();
 329 
 330         root.applyCss();
 331         root.autosize();
 332         root.layout();
 333 
 334         double w = 398; // The width minus the insets.
 335         double pos[] = splitPane.getDividerPositions();
 336         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 337         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 338 
 339         assertEquals(196, p0, 1e-100);
 340         assertEquals(202, p1, 1e-100);
 341         assertEquals(196, spLeft.getLayoutBounds().getWidth(), 1e-100);
 342         assertEquals(0, spCenter.getLayoutBounds().getWidth(), 1e-100);
 343         assertEquals(190, spRight.getLayoutBounds().getWidth(), 1e-100);
 344     }
 345         
 346     @Test public void twoDividersHaveTheDifferentPositions() {
 347         StackPane spLeft = new StackPane();
 348         StackPane spCenter = new StackPane();
 349         StackPane spRight = new StackPane();
 350 
 351         splitPane.setDividerPosition(0, 0.20);
 352         splitPane.setDividerPosition(1, 0.80);
 353         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 354 
 355         root.setPrefSize(400, 400);
 356         root.getChildren().add(splitPane);
 357         show();
 358 
 359         root.applyCss();
 360         root.autosize();
 361         root.layout();
 362 
 363         double w = 398; // The width minus the insets.
 364         double pos[] = splitPane.getDividerPositions();
 365         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 366         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 367 
 368         assertEquals(77, p0, 1e-100);
 369         assertEquals(315, p1, 1e-100);
 370         assertEquals(77, spLeft.getLayoutBounds().getWidth(), 1e-100);
 371         assertEquals(232, spCenter.getLayoutBounds().getWidth(), 1e-100);
 372         assertEquals(77, spRight.getLayoutBounds().getWidth(), 1e-100);
 373     }
 374 
 375     @Test public void threePanelsAllAreSetToMin() {
 376         StackPane spLeft = new StackPane();
 377         StackPane spCenter = new StackPane();
 378         StackPane spRight = new StackPane();
 379 
 380         spLeft.setMinWidth(28);
 381         spCenter.setMinWidth(29);
 382         spRight.setMinWidth(29);
 383         
 384         splitPane.setDividerPosition(0, 0.20);
 385         splitPane.setDividerPosition(1, 0.80);
 386         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 387 
 388         root.setPrefSize(100, 100);
 389         root.getChildren().add(splitPane);
 390         show();
 391 
 392         root.applyCss();
 393         root.autosize();
 394         root.layout();
 395 
 396         double w = 98; // The width minus the insets.
 397         double pos[] = splitPane.getDividerPositions();
 398         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 399         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 400 
 401         assertEquals(28, p0, 1e-100);
 402         assertEquals(63, p1, 1e-100);
 403         assertEquals(28, spLeft.getLayoutBounds().getWidth(), 1e-100);
 404         assertEquals(29, spCenter.getLayoutBounds().getWidth(), 1e-100);
 405         assertEquals(29, spRight.getLayoutBounds().getWidth(), 1e-100);
 406     }
 407 
 408     @Test public void threePanelsAllAreSetToMax() {
 409         StackPane spLeft = new StackPane();
 410         StackPane spCenter = new StackPane();
 411         StackPane spRight = new StackPane();
 412 
 413         spLeft.setMaxWidth(28);
 414         spCenter.setMaxWidth(29);
 415         spRight.setMaxWidth(29);
 416 
 417         splitPane.setDividerPosition(0, 0.20);
 418         splitPane.setDividerPosition(1, 0.80);
 419         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 420 
 421         root.setPrefSize(100, 100);
 422         root.getChildren().add(splitPane);
 423         show();
 424 
 425         root.applyCss();
 426         root.autosize();
 427         root.layout();
 428 
 429         double w = 98; // The width minus the insets.
 430         double pos[] = splitPane.getDividerPositions();
 431         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 432         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 433 
 434         assertEquals(28, p0, 1e-100);
 435         assertEquals(63, p1, 1e-100);
 436         assertEquals(28, spLeft.getLayoutBounds().getWidth(), 1e-100);
 437         assertEquals(29, spCenter.getLayoutBounds().getWidth(), 1e-100);
 438         assertEquals(29, spRight.getLayoutBounds().getWidth(), 1e-100);
 439     }
 440 
 441     @Test public void threePanelsSetToMinMaxMin() {
 442         StackPane spLeft = new StackPane();
 443         StackPane spCenter = new StackPane();
 444         StackPane spRight = new StackPane();
 445 
 446         spLeft.setMinWidth(28);
 447         spCenter.setMaxWidth(29);
 448         spRight.setMinWidth(29);
 449 
 450         splitPane.setDividerPosition(0, 0.20);
 451         splitPane.setDividerPosition(1, 0.80);
 452         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 453 
 454         root.setPrefSize(100, 100);
 455         root.getChildren().add(splitPane);
 456         show();
 457 
 458         root.applyCss();
 459         root.autosize();
 460         root.layout();
 461 
 462         double w = 98; // The width minus the insets.
 463         double pos[] = splitPane.getDividerPositions();
 464         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 465         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 466 
 467         assertEquals(28, p0, 1e-100);
 468         assertEquals(63, p1, 1e-100);
 469         assertEquals(28, spLeft.getLayoutBounds().getWidth(), 1e-100);
 470         assertEquals(29, spCenter.getLayoutBounds().getWidth(), 1e-100);
 471         assertEquals(29, spRight.getLayoutBounds().getWidth(), 1e-100);
 472     }
 473 
 474     @Test public void setDividerLessThanMin() {
 475         StackPane spLeft = new StackPane();
 476         StackPane spRight = new StackPane();
 477 
 478         spLeft.setMinWidth(80);
 479         splitPane.getItems().addAll(spLeft, spRight);
 480         splitPane.setDividerPositions(0);
 481         
 482         root.setPrefSize(100, 100);
 483         root.getChildren().add(splitPane);
 484         show();
 485 
 486         root.applyCss();
 487         root.autosize();
 488         root.layout();
 489 
 490         double w = 98; // The width minus the insets.
 491         double pos[] = splitPane.getDividerPositions();
 492         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 493 
 494         assertEquals(80, p0, 1e-100);
 495         assertEquals(80, spLeft.getLayoutBounds().getWidth(), 1e-100);
 496         assertEquals(12, spRight.getLayoutBounds().getWidth(), 1e-100);
 497     }
 498 
 499     @Test public void setDividerGreaterThanMax() {
 500         StackPane spLeft = new StackPane();
 501         StackPane spRight = new StackPane();
 502 
 503         spLeft.setMaxWidth(80);
 504         splitPane.getItems().addAll(spLeft, spRight);
 505         splitPane.setDividerPositions(1.5);
 506         
 507         root.setPrefSize(100, 100);
 508         root.getChildren().add(splitPane);
 509         show();
 510 
 511         root.applyCss();
 512         root.autosize();
 513         root.layout();
 514 
 515         double w = 98; // The width minus the insets.
 516         double pos[] = splitPane.getDividerPositions();
 517         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 518 
 519         assertEquals(80, p0, 1e-100);
 520         assertEquals(80, spLeft.getLayoutBounds().getWidth(), 1e-100);
 521         assertEquals(12, spRight.getLayoutBounds().getWidth(), 1e-100);
 522     }
 523 
 524     @Test public void setTwoDividerGreaterThanMax() {
 525         StackPane spLeft = new StackPane();
 526         StackPane spCenter = new StackPane();
 527         StackPane spRight = new StackPane();
 528 
 529         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 530         splitPane.setDividerPositions(1.5, 1.5);
 531 
 532         root.setPrefSize(100, 100);
 533         root.getChildren().add(splitPane);
 534         show();
 535 
 536         root.applyCss();
 537         root.autosize();
 538         root.layout();
 539 
 540         double w = 98; // The width minus the insets.
 541         double pos[] = splitPane.getDividerPositions();
 542         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 543         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 544 
 545         assertEquals(86, p0, 1e-100);
 546         assertEquals(92, p1, 1e-100);
 547         assertEquals(86, spLeft.getLayoutBounds().getWidth(), 1e-100);
 548         assertEquals(0, spCenter.getLayoutBounds().getWidth(), 1e-100);
 549         assertEquals(0, spRight.getLayoutBounds().getWidth(), 1e-100);
 550     }
 551     
 552     @Test public void checkDividerPositions_RT18805() {
 553         Button l = new Button("Left Button");
 554         Button c = new Button("Center Button");
 555         Button r = new Button("Left Button");
 556 
 557         StackPane spLeft = new StackPane();
 558         StackPane spCenter = new StackPane();
 559         StackPane spRight = new StackPane();
 560 
 561         spLeft.getChildren().add(l);
 562         spCenter.getChildren().add(c);
 563         spRight.getChildren().add(r);
 564 
 565         spLeft.setMinWidth(100);
 566         spLeft.setMaxWidth(150);
 567         spRight.setMaxWidth(100);
 568         spRight.setMaxWidth(150);
 569 
 570         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 571 
 572         root.setPrefSize(600, 400);
 573         root.getChildren().add(splitPane);
 574         show();
 575 
 576         root.applyCss();
 577         root.autosize();
 578         root.layout();
 579 
 580         double w = 598; // The width minus the insets.
 581         double pos[] = splitPane.getDividerPositions();
 582         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 583         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 584 
 585         assertEquals(150, p0, 1e-100);
 586         assertEquals(442, p1, 1e-100);
 587         assertEquals(150, spLeft.getLayoutBounds().getWidth(), 1e-100);
 588         assertEquals(286, spCenter.getLayoutBounds().getWidth(), 1e-100);
 589         assertEquals(150, spRight.getLayoutBounds().getWidth(), 1e-100);
 590     }
 591 
 592     @Test public void growSplitPaneBy5px_RT18855() {
 593         StackPane spLeft = new StackPane();
 594         StackPane spCenter = new StackPane();
 595         StackPane spRight = new StackPane();
 596 
 597         spLeft.setMinWidth(77);
 598         spRight.setMinWidth(77);
 599 
 600         splitPane.setDividerPosition(0, 0.20);
 601         splitPane.setDividerPosition(1, 0.80);
 602         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 603 
 604         root.setPrefSize(400, 400);
 605         root.getChildren().add(splitPane);
 606         show();
 607 
 608         root.applyCss();
 609         root.autosize();
 610         root.layout();
 611 
 612         double w = 398; // The width minus the insets.
 613         double pos[] = splitPane.getDividerPositions();
 614         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 615         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 616 
 617         assertEquals(77, p0, 1e-100);
 618         assertEquals(315, p1, 1e-100);
 619         assertEquals(77, spLeft.getLayoutBounds().getWidth(), 1e-100);
 620         assertEquals(232, spCenter.getLayoutBounds().getWidth(), 1e-100);
 621         assertEquals(77, spRight.getLayoutBounds().getWidth(), 1e-100);
 622 
 623         root.applyCss();
 624         root.resize(405, 400);
 625         root.layout();
 626 
 627         w = 403;
 628         pos = splitPane.getDividerPositions();
 629         p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 630         p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 631         
 632         assertEquals(78, p0, 1e-100);
 633         assertEquals(319, p1, 1e-100);
 634         assertEquals(78, spLeft.getLayoutBounds().getWidth(), 1e-100);
 635         assertEquals(235, spCenter.getLayoutBounds().getWidth(), 1e-100);
 636         assertEquals(78, spRight.getLayoutBounds().getWidth(), 1e-100);
 637     }
 638 
 639     @Test public void growSplitPaneBy5pxWithFixedDividers_RT18806() {
 640         StackPane spLeft = new StackPane();
 641         StackPane spCenter = new StackPane();
 642         StackPane spRight = new StackPane();
 643 
 644         spLeft.setMinWidth(77);
 645         spRight.setMinWidth(77);
 646 
 647         splitPane.setDividerPosition(0, 0.20);
 648         splitPane.setDividerPosition(1, 0.80);
 649         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 650 
 651         SplitPane.setResizableWithParent(spLeft, false);
 652         SplitPane.setResizableWithParent(spRight, false);
 653 
 654         root.setPrefSize(400, 400);
 655         root.getChildren().add(splitPane);
 656         show();
 657 
 658         root.applyCss();
 659         root.autosize();
 660         root.layout();
 661 
 662         double w = 398; // The width minus the insets.
 663         double pos[] = splitPane.getDividerPositions();
 664         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 665         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 666 
 667         assertEquals(77, p0, 1e-100);
 668         assertEquals(315, p1, 1e-100);
 669         assertEquals(77, spLeft.getLayoutBounds().getWidth(), 1e-100);
 670         assertEquals(232, spCenter.getLayoutBounds().getWidth(), 1e-100);
 671         assertEquals(77, spRight.getLayoutBounds().getWidth(), 1e-100);
 672 
 673         root.applyCss();
 674         root.resize(405, 400);
 675         root.layout();
 676 
 677         w = 403;
 678         pos = splitPane.getDividerPositions();
 679         p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 680         p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 681 
 682         assertEquals(77, p0, 1e-100);
 683         assertEquals(320, p1, 1e-100);
 684         assertEquals(77, spLeft.getLayoutBounds().getWidth(), 1e-100);
 685         assertEquals(237, spCenter.getLayoutBounds().getWidth(), 1e-100);
 686         assertEquals(77, spRight.getLayoutBounds().getWidth(), 1e-100);
 687     }
 688 
 689     @Test public void resizeSplitPaneAllPanesAreSetToMax() {
 690         StackPane spLeft = new StackPane();
 691         StackPane spCenter = new StackPane();
 692         StackPane spRight = new StackPane();
 693 
 694         spLeft.setMaxWidth(28);
 695         spCenter.setMaxWidth(29);
 696         spRight.setMaxWidth(29);
 697 
 698         splitPane.setDividerPosition(0, 0.20);
 699         splitPane.setDividerPosition(1, 0.80);
 700         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 701 
 702         root.setPrefSize(100, 100);
 703         root.getChildren().add(splitPane);
 704         show();
 705 
 706         root.applyCss();
 707         root.autosize();
 708         root.layout();
 709 
 710         double w = 98; // The width minus the insets.
 711         double pos[] = splitPane.getDividerPositions();
 712         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 713         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 714 
 715         assertEquals(28, p0, 1e-100);
 716         assertEquals(63, p1, 1e-100);
 717         assertEquals(28, spLeft.getLayoutBounds().getWidth(), 1e-100);
 718         assertEquals(29, spCenter.getLayoutBounds().getWidth(), 1e-100);
 719         assertEquals(29, spRight.getLayoutBounds().getWidth(), 1e-100);
 720 
 721         root.applyCss();
 722         root.resize(405, 400);
 723         root.layout();
 724 
 725         w = 403;
 726         pos = splitPane.getDividerPositions();
 727         p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
 728         p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
 729 
 730         assertEquals(28, p0, 1e-100);
 731         assertEquals(63, p1, 1e-100);
 732         assertEquals(28, spLeft.getLayoutBounds().getWidth(), 1e-100);
 733         assertEquals(29, spCenter.getLayoutBounds().getWidth(), 1e-100);
 734         assertEquals(29, spRight.getLayoutBounds().getWidth(), 1e-100);
 735     }
 736 
 737     /*
 738      * Vertical SplitPane
 739      */
 740     @Test public void oneDividerPanelsAreEquallySized_VerticalSplitPane() {
 741         StackPane spLeft = new StackPane();
 742         StackPane spRight = new StackPane();
 743 
 744         splitPane.setOrientation(Orientation.VERTICAL);
 745         splitPane.getItems().addAll(spLeft, spRight);
 746 
 747         root.setPrefSize(400, 400);
 748         root.getChildren().add(splitPane);
 749         show();
 750 
 751         root.applyCss();
 752         root.autosize();
 753         root.layout();
 754 
 755         double h = 398; // The width minus the insets.
 756         double pos[] = splitPane.getDividerPositions();
 757         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
 758 
 759         assertEquals(196, p0, 1e-100);
 760         assertEquals(196, spLeft.getLayoutBounds().getHeight(), 1e-100);
 761         assertEquals(196, spRight.getLayoutBounds().getHeight(), 1e-100);
 762     }
 763 
 764     @Test public void twoDividersHaveTheSamePosition_VerticalSplitPane() {
 765         StackPane spLeft = new StackPane();
 766         StackPane spCenter = new StackPane();
 767         StackPane spRight = new StackPane();
 768 
 769         splitPane.setOrientation(Orientation.VERTICAL);
 770         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 771 
 772         root.setPrefSize(400, 400);
 773         root.getChildren().add(splitPane);
 774         show();
 775 
 776         root.applyCss();
 777         root.autosize();
 778         root.layout();
 779 
 780         double h = 398; // The width minus the insets.
 781         double pos[] = splitPane.getDividerPositions();
 782         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
 783         double p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
 784 
 785         assertEquals(196, p0, 1e-100);
 786         assertEquals(202, p1, 1e-100);
 787         assertEquals(196, spLeft.getLayoutBounds().getHeight(), 1e-100);
 788         assertEquals(0, spCenter.getLayoutBounds().getHeight(), 1e-100);
 789         assertEquals(190, spRight.getLayoutBounds().getHeight(), 1e-100);
 790     }
 791 
 792     @Test public void twoDividersHaveTheDifferentPositions_VerticalSplitPane() {
 793         StackPane spLeft = new StackPane();
 794         StackPane spCenter = new StackPane();
 795         StackPane spRight = new StackPane();
 796 
 797         splitPane.setOrientation(Orientation.VERTICAL);
 798         splitPane.setDividerPosition(0, 0.20);
 799         splitPane.setDividerPosition(1, 0.80);
 800         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 801 
 802         root.setPrefSize(400, 400);
 803         root.getChildren().add(splitPane);
 804         show();
 805 
 806         root.applyCss();
 807         root.autosize();
 808         root.layout();
 809 
 810         double h = 398; // The width minus the insets.
 811         double pos[] = splitPane.getDividerPositions();
 812         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
 813         double p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
 814 
 815         assertEquals(77, p0, 1e-100);
 816         assertEquals(315, p1, 1e-100);
 817         assertEquals(77, spLeft.getLayoutBounds().getHeight(), 1e-100);
 818         assertEquals(232, spCenter.getLayoutBounds().getHeight(), 1e-100);
 819         assertEquals(77, spRight.getLayoutBounds().getHeight(), 1e-100);
 820     }
 821 
 822     @Test public void threePanelsAllAreSetToMin_VerticalSplitPane() {
 823         StackPane spLeft = new StackPane();
 824         StackPane spCenter = new StackPane();
 825         StackPane spRight = new StackPane();
 826 
 827         spLeft.setMinHeight(28);
 828         spCenter.setMinHeight(29);
 829         spRight.setMinHeight(29);
 830 
 831         splitPane.setOrientation(Orientation.VERTICAL);
 832         splitPane.setDividerPosition(0, 0.20);
 833         splitPane.setDividerPosition(1, 0.80);
 834         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 835 
 836         root.setPrefSize(100, 100);
 837         root.getChildren().add(splitPane);
 838         show();
 839 
 840         root.applyCss();
 841         root.autosize();
 842         root.layout();
 843 
 844         double h = 98; // The width minus the insets.
 845         double pos[] = splitPane.getDividerPositions();
 846         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
 847         double p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
 848 
 849         assertEquals(28, p0, 1e-100);
 850         assertEquals(63, p1, 1e-100);
 851         assertEquals(28, spLeft.getLayoutBounds().getHeight(), 1e-100);
 852         assertEquals(29, spCenter.getLayoutBounds().getHeight(), 1e-100);
 853         assertEquals(29, spRight.getLayoutBounds().getHeight(), 1e-100);
 854     }
 855 
 856     @Test public void threePanelsAllAreSetToMax_VerticalSplitPane() {
 857         StackPane spLeft = new StackPane();
 858         StackPane spCenter = new StackPane();
 859         StackPane spRight = new StackPane();
 860 
 861         spLeft.setMaxHeight(28);
 862         spCenter.setMaxHeight(29);
 863         spRight.setMaxHeight(29);
 864 
 865         splitPane.setOrientation(Orientation.VERTICAL);
 866         splitPane.setDividerPosition(0, 0.20);
 867         splitPane.setDividerPosition(1, 0.80);
 868         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 869 
 870         root.setPrefSize(100, 100);
 871         root.getChildren().add(splitPane);
 872         show();
 873 
 874         root.applyCss();
 875         root.autosize();
 876         root.layout();
 877 
 878         double h = 98; // The width minus the insets.
 879         double pos[] = splitPane.getDividerPositions();
 880         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
 881         double p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
 882 
 883         assertEquals(28, p0, 1e-100);
 884         assertEquals(63, p1, 1e-100);
 885         assertEquals(28, spLeft.getLayoutBounds().getHeight(), 1e-100);
 886         assertEquals(29, spCenter.getLayoutBounds().getHeight(), 1e-100);
 887         assertEquals(29, spRight.getLayoutBounds().getHeight(), 1e-100);
 888     }
 889 
 890     @Test public void threePanelsSetToMinMaxMin_VerticalSplitPane() {
 891         StackPane spLeft = new StackPane();
 892         StackPane spCenter = new StackPane();
 893         StackPane spRight = new StackPane();
 894 
 895         spLeft.setMinHeight(28);
 896         spCenter.setMaxHeight(29);
 897         spRight.setMinHeight(29);
 898 
 899         splitPane.setOrientation(Orientation.VERTICAL);
 900         splitPane.setDividerPosition(0, 0.20);
 901         splitPane.setDividerPosition(1, 0.80);
 902         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 903 
 904         root.setPrefSize(100, 100);
 905         root.getChildren().add(splitPane);
 906         show();
 907 
 908         root.applyCss();
 909         root.autosize();
 910         root.layout();
 911 
 912         double h = 98; // The width minus the insets.
 913         double pos[] = splitPane.getDividerPositions();
 914         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
 915         double p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
 916 
 917         assertEquals(28, p0, 1e-100);
 918         assertEquals(63, p1, 1e-100);
 919         assertEquals(28, spLeft.getLayoutBounds().getHeight(), 1e-100);
 920         assertEquals(29, spCenter.getLayoutBounds().getHeight(), 1e-100);
 921         assertEquals(29, spRight.getLayoutBounds().getHeight(), 1e-100);
 922     }
 923 
 924     @Test public void setDividerLessThanMin_VerticalSplitPane() {
 925         StackPane spLeft = new StackPane();
 926         StackPane spRight = new StackPane();
 927 
 928         spLeft.setMinHeight(80);
 929 
 930         splitPane.setOrientation(Orientation.VERTICAL);
 931         splitPane.getItems().addAll(spLeft, spRight);
 932         splitPane.setDividerPositions(0);
 933 
 934         root.setPrefSize(100, 100);
 935         root.getChildren().add(splitPane);
 936         show();
 937 
 938         root.applyCss();
 939         root.autosize();
 940         root.layout();
 941 
 942         double h = 98; // The width minus the insets.
 943         double pos[] = splitPane.getDividerPositions();
 944         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
 945 
 946         assertEquals(80, p0, 1e-100);
 947         assertEquals(80, spLeft.getLayoutBounds().getHeight(), 1e-100);
 948         assertEquals(12, spRight.getLayoutBounds().getHeight(), 1e-100);
 949     }
 950 
 951     @Test public void setDividerGreaterThanMax_VerticalSplitPane() {
 952         StackPane spLeft = new StackPane();
 953         StackPane spRight = new StackPane();
 954 
 955         spLeft.setMaxHeight(80);
 956 
 957         splitPane.setOrientation(Orientation.VERTICAL);
 958         splitPane.getItems().addAll(spLeft, spRight);
 959         splitPane.setDividerPositions(1.5);
 960 
 961         root.setPrefSize(100, 100);
 962         root.getChildren().add(splitPane);
 963         show();
 964 
 965         root.applyCss();
 966         root.autosize();
 967         root.layout();
 968 
 969         double h = 98; // The width minus the insets.
 970         double pos[] = splitPane.getDividerPositions();
 971         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
 972 
 973         assertEquals(80, p0, 1e-100);
 974         assertEquals(80, spLeft.getLayoutBounds().getHeight(), 1e-100);
 975         assertEquals(12, spRight.getLayoutBounds().getHeight(), 1e-100);
 976     }
 977 
 978     @Test public void setTwoDividerGreaterThanMax_VerticalSplitPane() {
 979         StackPane spLeft = new StackPane();
 980         StackPane spCenter = new StackPane();
 981         StackPane spRight = new StackPane();
 982 
 983         splitPane.setOrientation(Orientation.VERTICAL);
 984         splitPane.getItems().addAll(spLeft, spCenter, spRight);
 985         splitPane.setDividerPositions(1.5, 1.5);
 986 
 987         root.setPrefSize(100, 100);
 988         root.getChildren().add(splitPane);
 989         show();
 990 
 991         root.applyCss();
 992         root.autosize();
 993         root.layout();
 994 
 995         double h = 98; // The height minus the insets.
 996         double pos[] = splitPane.getDividerPositions();
 997         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
 998         double p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
 999 
1000         assertEquals(86, p0, 1e-100);
1001         assertEquals(92, p1, 1e-100);
1002         assertEquals(86, spLeft.getLayoutBounds().getHeight(), 1e-100);
1003         assertEquals(0, spCenter.getLayoutBounds().getHeight(), 1e-100);
1004         assertEquals(0, spRight.getLayoutBounds().getHeight(), 1e-100);
1005     }
1006 
1007     @Test public void checkDividerPositions_RT18805_VerticalSplitPane() {
1008         Button l = new Button("Left Button");
1009         Button c = new Button("Center Button");
1010         Button r = new Button("Left Button");
1011 
1012         StackPane spLeft = new StackPane();
1013         StackPane spCenter = new StackPane();
1014         StackPane spRight = new StackPane();
1015 
1016         spLeft.getChildren().add(l);
1017         spCenter.getChildren().add(c);
1018         spRight.getChildren().add(r);
1019 
1020         spLeft.setMinHeight(100);
1021         spLeft.setMaxHeight(150);
1022         spRight.setMaxHeight(100);
1023         spRight.setMaxHeight(150);
1024 
1025         splitPane.setOrientation(Orientation.VERTICAL);
1026         splitPane.getItems().addAll(spLeft, spCenter, spRight);
1027 
1028         root.setPrefSize(400, 600);
1029         root.getChildren().add(splitPane);
1030         show();
1031 
1032         root.applyCss();
1033         root.autosize();
1034         root.layout();
1035 
1036         double h = 598; // The height minus the insets.
1037         double pos[] = splitPane.getDividerPositions();
1038         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
1039         double p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
1040 
1041         assertEquals(150, p0, 1e-100);
1042         assertEquals(442, p1, 1e-100);
1043         assertEquals(150, spLeft.getLayoutBounds().getHeight(), 1e-100);
1044         assertEquals(286, spCenter.getLayoutBounds().getHeight(), 1e-100);
1045         assertEquals(150, spRight.getLayoutBounds().getHeight(), 1e-100);
1046     }
1047 
1048     @Test public void growSplitPaneBy5px_RT18855_VerticalSplitPane() {
1049         StackPane spLeft = new StackPane();
1050         StackPane spCenter = new StackPane();
1051         StackPane spRight = new StackPane();
1052 
1053         spLeft.setMinHeight(77);
1054         spRight.setMinHeight(77);
1055 
1056         splitPane.setOrientation(Orientation.VERTICAL);
1057         splitPane.setDividerPosition(0, 0.20);
1058         splitPane.setDividerPosition(1, 0.80);
1059         splitPane.getItems().addAll(spLeft, spCenter, spRight);
1060 
1061         root.setPrefSize(400, 400);
1062         root.getChildren().add(splitPane);
1063         show();
1064 
1065         root.applyCss();
1066         root.autosize();
1067         root.layout();
1068 
1069         double h = 398; // The height minus the insets.
1070         double pos[] = splitPane.getDividerPositions();
1071         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
1072         double p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
1073 
1074         assertEquals(77, p0, 1e-100);
1075         assertEquals(315, p1, 1e-100);
1076         assertEquals(77, spLeft.getLayoutBounds().getHeight(), 1e-100);
1077         assertEquals(232, spCenter.getLayoutBounds().getHeight(), 1e-100);
1078         assertEquals(77, spRight.getLayoutBounds().getHeight(), 1e-100);
1079 
1080         root.applyCss();
1081         root.resize(400, 405);
1082         root.layout();
1083 
1084         h = 403;
1085         pos = splitPane.getDividerPositions();
1086         p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
1087         p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
1088 
1089         assertEquals(78, p0, 1e-100);
1090         assertEquals(319, p1, 1e-100);
1091         assertEquals(78, spLeft.getLayoutBounds().getHeight(), 1e-100);
1092         assertEquals(235, spCenter.getLayoutBounds().getHeight(), 1e-100);
1093         assertEquals(78, spRight.getLayoutBounds().getHeight(), 1e-100);
1094     }
1095 
1096     @Test public void growSplitPaneBy5pxWithFixedDividers_RT18806_VerticalSplitPane() {
1097         StackPane spLeft = new StackPane();
1098         StackPane spCenter = new StackPane();
1099         StackPane spRight = new StackPane();
1100 
1101         spLeft.setMinHeight(77);
1102         spRight.setMinHeight(77);
1103 
1104         splitPane.setOrientation(Orientation.VERTICAL);
1105         splitPane.setDividerPosition(0, 0.20);
1106         splitPane.setDividerPosition(1, 0.80);
1107         splitPane.getItems().addAll(spLeft, spCenter, spRight);
1108 
1109         SplitPane.setResizableWithParent(spLeft, false);
1110         SplitPane.setResizableWithParent(spRight, false);
1111 
1112         root.setPrefSize(400, 400);
1113         root.getChildren().add(splitPane);
1114         show();
1115 
1116         root.applyCss();
1117         root.autosize();
1118         root.layout();
1119 
1120         double h = 398; // The height minus the insets.
1121         double pos[] = splitPane.getDividerPositions();
1122         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
1123         double p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
1124 
1125         assertEquals(77, p0, 1e-100);
1126         assertEquals(315, p1, 1e-100);
1127         assertEquals(77, spLeft.getLayoutBounds().getHeight(), 1e-100);
1128         assertEquals(232, spCenter.getLayoutBounds().getHeight(), 1e-100);
1129         assertEquals(77, spRight.getLayoutBounds().getHeight(), 1e-100);
1130 
1131         root.applyCss();
1132         root.resize(400, 405);
1133         root.layout();
1134 
1135         h = 403;
1136         pos = splitPane.getDividerPositions();
1137         p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
1138         p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
1139 
1140         assertEquals(77, p0, 1e-100);
1141         assertEquals(320, p1, 1e-100);
1142         assertEquals(77, spLeft.getLayoutBounds().getHeight(), 1e-100);
1143         assertEquals(237, spCenter.getLayoutBounds().getHeight(), 1e-100);
1144         assertEquals(77, spRight.getLayoutBounds().getHeight(), 1e-100);
1145     }
1146 
1147     @Test public void resizeSplitPaneAllPanesAreSetToMax_VerticalSplitPane() {
1148         StackPane spLeft = new StackPane();
1149         StackPane spCenter = new StackPane();
1150         StackPane spRight = new StackPane();
1151 
1152         spLeft.setMaxHeight(28);
1153         spCenter.setMaxHeight(29);
1154         spRight.setMaxHeight(29);
1155 
1156         splitPane.setOrientation(Orientation.VERTICAL);
1157         splitPane.setDividerPosition(0, 0.20);
1158         splitPane.setDividerPosition(1, 0.80);
1159         splitPane.getItems().addAll(spLeft, spCenter, spRight);
1160 
1161         root.setPrefSize(100, 100);
1162         root.getChildren().add(splitPane);
1163         show();
1164 
1165         root.applyCss();
1166         root.autosize();
1167         root.layout();
1168 
1169         double h = 98; // The height minus the insets.
1170         double pos[] = splitPane.getDividerPositions();
1171         double p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
1172         double p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
1173 
1174         assertEquals(28, p0, 1e-100);
1175         assertEquals(63, p1, 1e-100);
1176         assertEquals(28, spLeft.getLayoutBounds().getHeight(), 1e-100);
1177         assertEquals(29, spCenter.getLayoutBounds().getHeight(), 1e-100);
1178         assertEquals(29, spRight.getLayoutBounds().getHeight(), 1e-100);
1179 
1180         root.applyCss();
1181         root.resize(400, 405);
1182         root.layout();
1183 
1184         h = 403;
1185         pos = splitPane.getDividerPositions();
1186         p0 = convertDividerPostionToAbsolutePostion(pos[0], h);
1187         p1 = convertDividerPostionToAbsolutePostion(pos[1], h);
1188 
1189         assertEquals(28, p0, 1e-100);
1190         assertEquals(63, p1, 1e-100);
1191         assertEquals(28, spLeft.getLayoutBounds().getHeight(), 1e-100);
1192         assertEquals(29, spCenter.getLayoutBounds().getHeight(), 1e-100);
1193         assertEquals(29, spRight.getLayoutBounds().getHeight(), 1e-100);
1194     }    
1195     
1196     @Test public void positionDividersWithANonResizablePanel_RT22929() {
1197         StackPane spLeft = new StackPane();
1198         StackPane spCenter = new StackPane();
1199         StackPane spRight = new StackPane();
1200 
1201         spRight.setMinWidth(20);
1202         spRight.setPrefWidth(20);
1203         spRight.setMaxWidth(30);
1204 
1205         splitPane.setDividerPosition(0, 0.50);
1206         splitPane.setDividerPosition(1, 0.50);
1207         splitPane.getItems().addAll(spLeft, spCenter, spRight);
1208 
1209         root.setPrefSize(100, 100);
1210         root.getChildren().add(splitPane);
1211         show();
1212 
1213         root.applyCss();
1214         root.autosize();
1215         root.layout();
1216 
1217         double w = 98; // The width minus the insets.
1218         double pos[] = splitPane.getDividerPositions();
1219         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
1220         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
1221 
1222         assertEquals(46, p0, 1e-100);
1223         assertEquals(62, p1, 1e-100);
1224         assertEquals(46, spLeft.getLayoutBounds().getWidth(), 1e-100);
1225         assertEquals(10, spCenter.getLayoutBounds().getWidth(), 1e-100);
1226         assertEquals(30, spRight.getLayoutBounds().getWidth(), 1e-100);       
1227         
1228         splitPane.setDividerPosition(0, 0.20);
1229         root.layout();
1230 
1231         pos = splitPane.getDividerPositions();
1232         p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
1233         p1 = convertDividerPostionToAbsolutePostion(pos[1], w);       
1234         assertEquals(17, p0, 1e-100);
1235         assertEquals(62, p1, 1e-100);
1236         
1237         splitPane.setDividerPosition(1, 0.25);
1238         root.layout();
1239                 
1240         pos = splitPane.getDividerPositions();
1241         p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
1242         p1 = convertDividerPostionToAbsolutePostion(pos[1], w);       
1243         assertEquals(17, p0, 1e-100);
1244         assertEquals(62, p1, 1e-100);
1245     }
1246     
1247     @Test public void threeDividersHaveTheSamePosition() {
1248         StackPane sp1 = new StackPane();
1249         StackPane sp2 = new StackPane();
1250         StackPane sp3 = new StackPane();
1251         StackPane sp4 = new StackPane();
1252 
1253         splitPane.getItems().addAll(sp1, sp2, sp3, sp4);
1254 
1255         root.setPrefSize(400, 400);
1256         root.getChildren().add(splitPane);
1257         show();
1258 
1259         root.applyCss();
1260         root.autosize();
1261         root.layout();
1262 
1263         double w = 398; // The width minus the insets.
1264         double pos[] = splitPane.getDividerPositions();
1265         double p0 = convertDividerPostionToAbsolutePostion(pos[0], w);
1266         double p1 = convertDividerPostionToAbsolutePostion(pos[1], w);
1267         double p2 = convertDividerPostionToAbsolutePostion(pos[2], w);
1268 
1269         assertEquals(190, p0, 1e-100);
1270         assertEquals(196, p1, 1e-100);
1271         assertEquals(202, p2, 1e-100);
1272         assertEquals(190, sp1.getLayoutBounds().getWidth(), 1e-100);
1273         assertEquals(0, sp2.getLayoutBounds().getWidth(), 1e-100);
1274         assertEquals(0, sp3.getLayoutBounds().getWidth(), 1e-100);
1275         assertEquals(190, sp4.getLayoutBounds().getWidth(), 1e-100);
1276     }    
1277     
1278     @Test public void addItemsInRunLater_RT23063() {
1279         final SplitPane sp = new SplitPane();
1280         Stage st = new Stage();
1281         st.setScene(new Scene(sp, 2000, 2000));
1282         st.show();
1283            
1284         Runnable runnable = () -> {
1285             StackPane rightsp = new StackPane();
1286             Label right = new Label("right");
1287             rightsp.getChildren().add(right);
1288 
1289             StackPane leftsp = new StackPane();
1290             Label left = new Label("left");
1291             leftsp.getChildren().add(left);
1292 
1293             sp.getItems().addAll(rightsp, leftsp);
1294         };
1295         Platform.runLater(runnable);
1296                         
1297         sp.applyCss();
1298         sp.resize(400, 400);
1299         sp.layout();
1300         
1301         assertEquals(1, sp.getDividerPositions().length);
1302         
1303         double pos[] = sp.getDividerPositions();
1304         double p0 = convertDividerPostionToAbsolutePostion(pos[0], 398);
1305         assertEquals(196, p0, 1e-100);        
1306     }
1307 
1308     @Test public void test_rt_36392() {
1309         AnchorPane item0 = new AnchorPane();
1310         item0.setId("xxx");
1311 
1312         VBox item1 = new VBox();
1313         item1.setId("myvbox");
1314 
1315         SplitPane splitPane = new SplitPane();
1316         splitPane.getItems().addAll(item0, item1);
1317 
1318         AnchorPane page = new AnchorPane();
1319         page.setId("AnchorPane");
1320         page.getChildren().add(splitPane);
1321 
1322         StageLoader sl = new StageLoader(page);
1323 
1324         VBox myvbox = (VBox) page.lookup("#myvbox");
1325         myvbox.getChildren().add(new Button("Hello world !!!"));
1326 
1327         sl.dispose();
1328     }
1329 }