1 /*
   2  * Copyright (c) 2011, 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  *
  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 test.javafx.scene.layout;
  27 
  28 import test.javafx.scene.layout.MockBiased;
  29 import javafx.css.ParsedValue;
  30 import javafx.css.CssMetaData;
  31 import javafx.css.CssParser;
  32 import javafx.css.StyleableProperty;
  33 import static org.junit.Assert.assertEquals;
  34 import static org.junit.Assert.assertNull;
  35 import javafx.geometry.Insets;
  36 import javafx.geometry.Orientation;
  37 import javafx.geometry.Pos;
  38 import javafx.scene.Node;
  39 import javafx.scene.ParentShim;
  40 import javafx.scene.Scene;
  41 import javafx.scene.layout.Region;
  42 import javafx.scene.layout.TilePane;
  43 import javafx.scene.shape.Rectangle;
  44 import javafx.stage.Stage;
  45 import org.junit.Assert;
  46 
  47 import org.junit.Before;
  48 import org.junit.Test;
  49 
  50 
  51 public class TilePaneTest {
  52 
  53     TilePane tilepane;
  54     TilePane htilepane;
  55     TilePane vtilepane;
  56 
  57     @Before public void setUp() {
  58         tilepane = new TilePane(); // 12 children
  59         for(int i = 0; i < 6; i++) {
  60             MockResizable child1 = new MockResizable(50,60, 100,200, 500,600);
  61             Rectangle child2 = new Rectangle(100, 100);
  62             ParentShim.getChildren(tilepane).addAll(child1, child2);
  63         }
  64 
  65         htilepane = new TilePane(Orientation.HORIZONTAL); // 8 children
  66         for(int i = 0; i < 4; i++) {
  67             MockResizable child1 = new MockResizable(200,300);
  68             Rectangle child2 = new Rectangle(100, 100);
  69             ParentShim.getChildren(htilepane).addAll(child1, child2);
  70         }
  71 
  72         vtilepane = new TilePane(Orientation.VERTICAL); // 8 children
  73         for(int i = 0; i < 4; i++) {
  74             MockResizable child1 = new MockResizable(200,300);
  75             Rectangle child2 = new Rectangle(100, 100);
  76             ParentShim.getChildren(vtilepane).addAll(child1, child2);
  77         }
  78 
  79     }
  80 
  81     @Test public void testOrientationDefaultsToHorizontal() {
  82         assertEquals(Orientation.HORIZONTAL, tilepane.getOrientation());
  83     }
  84 
  85     @Test public void testPrefColumnsDefault() {
  86         assertEquals(5, tilepane.getPrefColumns());
  87     }
  88 
  89     @Test public void testPrefRowsDefault() {
  90         assertEquals(5, vtilepane.getPrefColumns());
  91     }
  92 
  93     @Test public void testPrefTileWidthDefaultsToUSE_COMPUTED_SIZE() {
  94         assertEquals(Region.USE_COMPUTED_SIZE, tilepane.getPrefTileWidth(), 0);
  95     }
  96 
  97     @Test public void testPrefTileHeightDefaultsToUSE_COMPUTED_SIZE() {
  98         assertEquals(Region.USE_COMPUTED_SIZE, tilepane.getPrefTileHeight(), 0);
  99     }
 100 
 101     @Test public void testAlignmentDefaultsToTopLeft() {
 102         assertEquals(Pos.TOP_LEFT, tilepane.getAlignment());
 103     }
 104 
 105     @Test public void testTileAlignmentDefaultsToCenter() {
 106         assertEquals(Pos.CENTER, tilepane.getTileAlignment());
 107     }
 108 
 109     @Test public void testTilePaneNulls() {
 110         tilepane.setAlignment(null);
 111         tilepane.setTileAlignment(null);
 112         tilepane.setOrientation(null);
 113 
 114         // this musn't throw NPE
 115         tilepane.autosize();
 116         tilepane.layout();
 117 
 118         assertNull(null, tilepane.getAlignment());
 119         assertNull(null, tilepane.getTileAlignment());
 120         assertNull(null, tilepane.getOrientation());
 121         assertNull(null, tilepane.alignmentProperty().get());
 122         assertNull(null, tilepane.tileAlignmentProperty().get());
 123         assertNull(null, tilepane.orientationProperty().get());
 124     }
 125 
 126     @Test public void testHorizontalTilePaneMinSize() {
 127         assertEquals(200, htilepane.minWidth(-1), 1e-100);
 128         assertEquals(2400, htilepane.minHeight(100), 1e-100);
 129     }
 130 
 131     @Test public void testHorizontalTilePanePrefSize() {
 132         assertEquals(1000, htilepane.prefWidth(-1), 1e-100);
 133         assertEquals(600, htilepane.prefHeight(-1), 1e-100);
 134     }
 135 
 136     @Test public void testVerticalTilePaneMinSize() {
 137         assertEquals(300, vtilepane.minHeight(-1), 1e-100);
 138         assertEquals(1600, vtilepane.minWidth(300), 1e-100);
 139     }
 140 
 141     @Test public void testVerticalTilePanePrefSize() {
 142         assertEquals(1500, vtilepane.prefHeight(-1), 1e-100);
 143         assertEquals(400, vtilepane.prefWidth(-1), 1e-100);
 144     }
 145 
 146 
 147     @Test public void testEmptyHorizontalTilePaneMinWidthIsZero() {
 148         TilePane Tilepane = new TilePane();
 149 
 150         assertEquals(0, Tilepane.minWidth(-1), 0);
 151     }
 152 
 153     @Test public void testEmptyHorizontalTilePaneMinHeightIsZero() {
 154         TilePane Tilepane = new TilePane();
 155 
 156         assertEquals(0, Tilepane.minHeight(-1), 0);
 157     }
 158 
 159     @Test public void testEmptyVerticalTilePaneMinWidthIsZero() {
 160         TilePane Tilepane = new TilePane(Orientation.VERTICAL);
 161 
 162         assertEquals(0, Tilepane.minWidth(-1), 0);
 163     }
 164 
 165     @Test public void testEmptyVerticalTilePaneMinHeightIsZero() {
 166         TilePane Tilepane = new TilePane(Orientation.VERTICAL);
 167 
 168         assertEquals(0, Tilepane.minHeight(-1), 0);
 169     }
 170 
 171     @Test public void testLayoutWithPrefSize() {
 172         tilepane.autosize();
 173         tilepane.layout();
 174 
 175         // test a handful
 176         Node first = ParentShim.getChildren(tilepane).get(0);
 177         Node last = ParentShim.getChildren(tilepane).get(11);
 178 
 179         assertEquals(0, first.getLayoutX(), 1e-100);
 180         assertEquals(0, first.getLayoutY(), 1e-100);
 181         assertEquals(100, first.getLayoutBounds().getWidth(), 1e-100);
 182         assertEquals(200, first.getLayoutBounds().getHeight(), 1e-100);
 183         assertEquals(100, last.getLayoutX(), 1e-100);
 184         assertEquals(450, last.getLayoutY(), 1e-100);
 185         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 186         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 187     }
 188 
 189     @Test public void testLayoutWithLargerThanPrefSize() {
 190         tilepane.resize(800,800);
 191         tilepane.layout();
 192 
 193         Node first = ParentShim.getChildren(tilepane).get(0);
 194         Node last = ParentShim.getChildren(tilepane).get(11);
 195 
 196         assertEquals(0, first.getLayoutX(), 1e-100);
 197         assertEquals(0, first.getLayoutY(), 1e-100);
 198         assertEquals(100, first.getLayoutBounds().getWidth(), 1e-100);
 199         assertEquals(200, first.getLayoutBounds().getHeight(), 1e-100);
 200         assertEquals(300, last.getLayoutX(), 1e-100);
 201         assertEquals(250, last.getLayoutY(), 1e-100);
 202         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 203         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 204     }
 205 
 206     @Test public void testHorizontalTilePaneAlignmentTopLeft() {
 207         htilepane.setAlignment(Pos.TOP_LEFT);
 208         htilepane.resize(700,1000);
 209         htilepane.layout();
 210 
 211         // test a handful
 212         Node first = ParentShim.getChildren(htilepane).get(0);
 213         Node last = ParentShim.getChildren(htilepane).get(7);
 214 
 215         assertEquals(0, first.getLayoutX(), 1e-100);
 216         assertEquals(0, first.getLayoutY(), 1e-100);
 217         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 218         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 219         assertEquals(250, last.getLayoutX(), 1e-100);
 220         assertEquals(700, last.getLayoutY(), 1e-100);
 221         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 222         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 223     }
 224 
 225     @Test public void testHorizontalTilePaneAlignmentTopCenter() {
 226         htilepane.setAlignment(Pos.TOP_CENTER);
 227         htilepane.resize(700,1000);
 228         htilepane.layout();
 229 
 230         // test a handful
 231         Node first = ParentShim.getChildren(htilepane).get(0);
 232         Node last = ParentShim.getChildren(htilepane).get(7);
 233 
 234         assertEquals(50, first.getLayoutX(), 1e-100);
 235         assertEquals(0, first.getLayoutY(), 1e-100);
 236         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 237         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 238         assertEquals(400, last.getLayoutX(), 1e-100);
 239         assertEquals(700, last.getLayoutY(), 1e-100);
 240         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 241         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 242     }
 243 
 244     @Test public void testHorizontalTilePaneAlignmentTopRight() {
 245         htilepane.setAlignment(Pos.TOP_RIGHT);
 246         htilepane.resize(700,1000);
 247         htilepane.layout();
 248 
 249         // test a handful
 250         Node first = ParentShim.getChildren(htilepane).get(0);
 251         Node last = ParentShim.getChildren(htilepane).get(7);
 252 
 253         assertEquals(100, first.getLayoutX(), 1e-100);
 254         assertEquals(0, first.getLayoutY(), 1e-100);
 255         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 256         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 257         assertEquals(550, last.getLayoutX(), 1e-100);
 258         assertEquals(700, last.getLayoutY(), 1e-100);
 259         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 260         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 261     }
 262 
 263     @Test public void testHorizontalTilePaneAlignmentCenterLeft() {
 264         htilepane.setAlignment(Pos.CENTER_LEFT);
 265         htilepane.resize(700,1000);
 266         htilepane.layout();
 267 
 268         // test a handful
 269         Node first = ParentShim.getChildren(htilepane).get(0);
 270         Node last = ParentShim.getChildren(htilepane).get(7);
 271 
 272         assertEquals(0, first.getLayoutX(), 1e-100);
 273         assertEquals(50, first.getLayoutY(), 1e-100);
 274         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 275         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 276         assertEquals(250, last.getLayoutX(), 1e-100);
 277         assertEquals(750, last.getLayoutY(), 1e-100);
 278         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 279         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 280     }
 281 
 282     @Test public void testHorizontalTilePaneAlignmentCenter() {
 283         htilepane.setAlignment(Pos.CENTER);
 284         htilepane.resize(700,1000);
 285         htilepane.layout();
 286 
 287         // test a handful
 288         Node first = ParentShim.getChildren(htilepane).get(0);
 289         Node last = ParentShim.getChildren(htilepane).get(7);
 290 
 291         assertEquals(50, first.getLayoutX(), 1e-100);
 292         assertEquals(50, first.getLayoutY(), 1e-100);
 293         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 294         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 295         assertEquals(400, last.getLayoutX(), 1e-100);
 296         assertEquals(750, last.getLayoutY(), 1e-100);
 297         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 298         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 299     }
 300 
 301     @Test public void testHorizontalTilePaneAlignmentCenterRight() {
 302         htilepane.setAlignment(Pos.CENTER_RIGHT);
 303         htilepane.resize(700,1000);
 304         htilepane.layout();
 305 
 306         // test a handful
 307         Node first = ParentShim.getChildren(htilepane).get(0);
 308         Node last = ParentShim.getChildren(htilepane).get(7);
 309 
 310         assertEquals(100, first.getLayoutX(), 1e-100);
 311         assertEquals(50, first.getLayoutY(), 1e-100);
 312         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 313         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 314         assertEquals(550, last.getLayoutX(), 1e-100);
 315         assertEquals(750, last.getLayoutY(), 1e-100);
 316         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 317         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 318     }
 319 
 320     @Test public void testHorizontalTilePaneAlignmentBottomLeft() {
 321         htilepane.setAlignment(Pos.BOTTOM_LEFT);
 322         htilepane.resize(700,1000);
 323         htilepane.layout();
 324 
 325         // test a handful
 326         Node first = ParentShim.getChildren(htilepane).get(0);
 327         Node last = ParentShim.getChildren(htilepane).get(7);
 328 
 329         assertEquals(0, first.getLayoutX(), 1e-100);
 330         assertEquals(100, first.getLayoutY(), 1e-100);
 331         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 332         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 333         assertEquals(250, last.getLayoutX(), 1e-100);
 334         assertEquals(800, last.getLayoutY(), 1e-100);
 335         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 336         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 337     }
 338 
 339     @Test public void testHorizontalTilePaneAlignmentBottomCenter() {
 340         htilepane.setAlignment(Pos.BOTTOM_CENTER);
 341         htilepane.resize(700,1000);
 342         htilepane.layout();
 343 
 344         // test a handful
 345         Node first = ParentShim.getChildren(htilepane).get(0);
 346         Node last = ParentShim.getChildren(htilepane).get(7);
 347 
 348         assertEquals(50, first.getLayoutX(), 1e-100);
 349         assertEquals(100, first.getLayoutY(), 1e-100);
 350         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 351         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 352         assertEquals(400, last.getLayoutX(), 1e-100);
 353         assertEquals(800, last.getLayoutY(), 1e-100);
 354         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 355         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 356     }
 357 
 358     @Test public void testHorizontalTilePaneAlignmentBottomRight() {
 359         htilepane.setAlignment(Pos.BOTTOM_RIGHT);
 360         htilepane.resize(700,1000);
 361         htilepane.layout();
 362 
 363         // test a handful
 364         Node first = ParentShim.getChildren(htilepane).get(0);
 365         Node last = ParentShim.getChildren(htilepane).get(7);
 366 
 367         assertEquals(100, first.getLayoutX(), 1e-100);
 368         assertEquals(100, first.getLayoutY(), 1e-100);
 369         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 370         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 371         assertEquals(550, last.getLayoutX(), 1e-100);
 372         assertEquals(800, last.getLayoutY(), 1e-100);
 373         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 374         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 375     }
 376 
 377     @Test public void testVerticalTilePaneAlignmentTopLeft() {
 378         vtilepane.setAlignment(Pos.TOP_LEFT);
 379         vtilepane.resize(700,1000);
 380         vtilepane.layout();
 381 
 382         // test a handful
 383         Node first = ParentShim.getChildren(vtilepane).get(0);
 384         Node last = ParentShim.getChildren(vtilepane).get(7);
 385 
 386         assertEquals(0, first.getLayoutX(), 1e-100);
 387         assertEquals(0, first.getLayoutY(), 1e-100);
 388         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 389         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 390         assertEquals(450, last.getLayoutX(), 1e-100);
 391         assertEquals(400, last.getLayoutY(), 1e-100);
 392         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 393         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 394     }
 395 
 396     @Test public void testVerticalTilePaneAlignmentTopCenter() {
 397         vtilepane.setAlignment(Pos.TOP_CENTER);
 398         vtilepane.resize(700,1000);
 399         vtilepane.layout();
 400 
 401         // test a handful
 402         Node first = ParentShim.getChildren(vtilepane).get(0);
 403         Node last = ParentShim.getChildren(vtilepane).get(7);
 404 
 405         assertEquals(50, first.getLayoutX(), 1e-100);
 406         assertEquals(0, first.getLayoutY(), 1e-100);
 407         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 408         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 409         assertEquals(500, last.getLayoutX(), 1e-100);
 410         assertEquals(400, last.getLayoutY(), 1e-100);
 411         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 412         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 413     }
 414 
 415     @Test public void testVerticalTilePaneAlignmentTopRight() {
 416         vtilepane.setAlignment(Pos.TOP_RIGHT);
 417         vtilepane.resize(700,1000);
 418         vtilepane.layout();
 419 
 420         // test a handful
 421         Node first = ParentShim.getChildren(vtilepane).get(0);
 422         Node last = ParentShim.getChildren(vtilepane).get(7);
 423 
 424         assertEquals(100, first.getLayoutX(), 1e-100);
 425         assertEquals(0, first.getLayoutY(), 1e-100);
 426         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 427         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 428         assertEquals(550, last.getLayoutX(), 1e-100);
 429         assertEquals(400, last.getLayoutY(), 1e-100);
 430         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 431         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 432     }
 433 
 434     @Test public void testVerticalTilePaneAlignmentCenterLeft() {
 435         vtilepane.setAlignment(Pos.CENTER_LEFT);
 436         vtilepane.resize(700,1000);
 437         vtilepane.layout();
 438 
 439         // test a handful
 440         Node first = ParentShim.getChildren(vtilepane).get(0);
 441         Node last = ParentShim.getChildren(vtilepane).get(7);
 442 
 443         assertEquals(0, first.getLayoutX(), 1e-100);
 444         assertEquals(50, first.getLayoutY(), 1e-100);
 445         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 446         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 447         assertEquals(450, last.getLayoutX(), 1e-100);
 448         assertEquals(600, last.getLayoutY(), 1e-100);
 449         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 450         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 451     }
 452 
 453     @Test public void testVerticalTilePaneAlignmentCenter() {
 454         vtilepane.setAlignment(Pos.CENTER);
 455         vtilepane.resize(700,1000);
 456         vtilepane.layout();
 457 
 458         // test a handful
 459         Node first = ParentShim.getChildren(vtilepane).get(0);
 460         Node last = ParentShim.getChildren(vtilepane).get(7);
 461 
 462         assertEquals(50, first.getLayoutX(), 1e-100);
 463         assertEquals(50, first.getLayoutY(), 1e-100);
 464         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 465         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 466         assertEquals(500, last.getLayoutX(), 1e-100);
 467         assertEquals(600, last.getLayoutY(), 1e-100);
 468         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 469         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 470     }
 471 
 472     @Test public void testVerticalTilePaneAlignmentCenterRight() {
 473         vtilepane.setAlignment(Pos.CENTER_RIGHT);
 474         vtilepane.resize(700,1000);
 475         vtilepane.layout();
 476 
 477         // test a handful
 478         Node first = ParentShim.getChildren(vtilepane).get(0);
 479         Node last = ParentShim.getChildren(vtilepane).get(7);
 480 
 481         assertEquals(100, first.getLayoutX(), 1e-100);
 482         assertEquals(50, first.getLayoutY(), 1e-100);
 483         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 484         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 485         assertEquals(550, last.getLayoutX(), 1e-100);
 486         assertEquals(600, last.getLayoutY(), 1e-100);
 487         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 488         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 489     }
 490 
 491     @Test public void testVerticalTilePaneAlignmentBottomLeft() {
 492         vtilepane.setAlignment(Pos.BOTTOM_LEFT);
 493         vtilepane.resize(700,1000);
 494         vtilepane.layout();
 495 
 496         // test a handful
 497         Node first = ParentShim.getChildren(vtilepane).get(0);
 498         Node last = ParentShim.getChildren(vtilepane).get(7);
 499 
 500         assertEquals(0, first.getLayoutX(), 1e-100);
 501         assertEquals(100, first.getLayoutY(), 1e-100);
 502         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 503         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 504         assertEquals(450, last.getLayoutX(), 1e-100);
 505         assertEquals(800, last.getLayoutY(), 1e-100);
 506         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 507         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 508     }
 509 
 510     @Test public void testVerticalTilePaneAlignmentBottomCenter() {
 511         vtilepane.setAlignment(Pos.BOTTOM_CENTER);
 512         vtilepane.resize(700,1000);
 513         vtilepane.layout();
 514 
 515         // test a handful
 516         Node first = ParentShim.getChildren(vtilepane).get(0);
 517         Node last = ParentShim.getChildren(vtilepane).get(7);
 518 
 519         assertEquals(50, first.getLayoutX(), 1e-100);
 520         assertEquals(100, first.getLayoutY(), 1e-100);
 521         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 522         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 523         assertEquals(500, last.getLayoutX(), 1e-100);
 524         assertEquals(800, last.getLayoutY(), 1e-100);
 525         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 526         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 527     }
 528 
 529     @Test public void testVerticalTilePaneAlignmentBottomRight() {
 530         vtilepane.setAlignment(Pos.BOTTOM_RIGHT);
 531         vtilepane.resize(700,1000);
 532         vtilepane.layout();
 533 
 534         // test a handful
 535         Node first = ParentShim.getChildren(vtilepane).get(0);
 536         Node last = ParentShim.getChildren(vtilepane).get(7);
 537 
 538         assertEquals(100, first.getLayoutX(), 1e-100);
 539         assertEquals(100, first.getLayoutY(), 1e-100);
 540         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 541         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 542         assertEquals(550, last.getLayoutX(), 1e-100);
 543         assertEquals(800, last.getLayoutY(), 1e-100);
 544         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 545         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 546     }
 547 
 548     @Test public void testTileAlignmentTopLeft() {
 549         htilepane.setTileAlignment(Pos.TOP_LEFT);
 550         htilepane.resize(700,1000);
 551         htilepane.layout();
 552 
 553         // test a handful
 554         Node first = ParentShim.getChildren(htilepane).get(0);
 555         Node last = ParentShim.getChildren(htilepane).get(7);
 556 
 557         assertEquals(0, first.getLayoutX(), 1e-100);
 558         assertEquals(0, first.getLayoutY(), 1e-100);
 559         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 560         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 561         assertEquals(200, last.getLayoutX(), 1e-100);
 562         assertEquals(600, last.getLayoutY(), 1e-100);
 563         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 564         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 565     }
 566 
 567     @Test public void testTileAlignmentTopCenter() {
 568         htilepane.setTileAlignment(Pos.TOP_CENTER);
 569         htilepane.resize(700,1000);
 570         htilepane.layout();
 571 
 572         // test a handful
 573         Node first = ParentShim.getChildren(htilepane).get(0);
 574         Node last = ParentShim.getChildren(htilepane).get(7);
 575 
 576         assertEquals(0, first.getLayoutX(), 1e-100);
 577         assertEquals(0, first.getLayoutY(), 1e-100);
 578         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 579         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 580         assertEquals(250, last.getLayoutX(), 1e-100);
 581         assertEquals(600, last.getLayoutY(), 1e-100);
 582         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 583         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 584     }
 585 
 586     @Test public void testTileAlignmentTopRight() {
 587         htilepane.setTileAlignment(Pos.TOP_RIGHT);
 588         htilepane.resize(700,1000);
 589         htilepane.layout();
 590 
 591         // test a handful
 592         Node first = ParentShim.getChildren(htilepane).get(0);
 593         Node last = ParentShim.getChildren(htilepane).get(7);
 594 
 595         assertEquals(0, first.getLayoutX(), 1e-100);
 596         assertEquals(0, first.getLayoutY(), 1e-100);
 597         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 598         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 599         assertEquals(300, last.getLayoutX(), 1e-100);
 600         assertEquals(600, last.getLayoutY(), 1e-100);
 601         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 602         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 603     }
 604 
 605     @Test public void testTileAlignmentCenterLeft() {
 606         htilepane.setTileAlignment(Pos.CENTER_LEFT);
 607         htilepane.resize(700,1000);
 608         htilepane.layout();
 609 
 610         // test a handful
 611         Node first = ParentShim.getChildren(htilepane).get(0);
 612         Node last = ParentShim.getChildren(htilepane).get(7);
 613 
 614         assertEquals(0, first.getLayoutX(), 1e-100);
 615         assertEquals(0, first.getLayoutY(), 1e-100);
 616         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 617         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 618         assertEquals(200, last.getLayoutX(), 1e-100);
 619         assertEquals(700, last.getLayoutY(), 1e-100);
 620         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 621         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 622     }
 623 
 624     @Test public void testTileAlignmentCenter() {
 625         htilepane.setTileAlignment(Pos.CENTER);
 626         htilepane.resize(700,1000);
 627         htilepane.layout();
 628 
 629         // test a handful
 630         Node first = ParentShim.getChildren(htilepane).get(0);
 631         Node last = ParentShim.getChildren(htilepane).get(7);
 632 
 633         assertEquals(0, first.getLayoutX(), 1e-100);
 634         assertEquals(0, first.getLayoutY(), 1e-100);
 635         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 636         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 637         assertEquals(250, last.getLayoutX(), 1e-100);
 638         assertEquals(700, last.getLayoutY(), 1e-100);
 639         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 640         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 641     }
 642 
 643     @Test public void testTileAlignmentCenterRight() {
 644         htilepane.setTileAlignment(Pos.CENTER_RIGHT);
 645         htilepane.resize(700,1000);
 646         htilepane.layout();
 647 
 648         // test a handful
 649         Node first = ParentShim.getChildren(htilepane).get(0);
 650         Node last = ParentShim.getChildren(htilepane).get(7);
 651 
 652         assertEquals(0, first.getLayoutX(), 1e-100);
 653         assertEquals(0, first.getLayoutY(), 1e-100);
 654         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 655         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 656         assertEquals(300, last.getLayoutX(), 1e-100);
 657         assertEquals(700, last.getLayoutY(), 1e-100);
 658         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 659         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 660     }
 661 
 662     @Test public void testTileAlignmentBottomLeft() {
 663         htilepane.setTileAlignment(Pos.BOTTOM_LEFT);
 664         htilepane.resize(700,1000);
 665         htilepane.layout();
 666 
 667         // test a handful
 668         Node first = ParentShim.getChildren(htilepane).get(0);
 669         Node last = ParentShim.getChildren(htilepane).get(7);
 670 
 671         assertEquals(0, first.getLayoutX(), 1e-100);
 672         assertEquals(0, first.getLayoutY(), 1e-100);
 673         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 674         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 675         assertEquals(200, last.getLayoutX(), 1e-100);
 676         assertEquals(800, last.getLayoutY(), 1e-100);
 677         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 678         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 679     }
 680 
 681     @Test public void testTileAlignmentBottomCenter() {
 682         htilepane.setTileAlignment(Pos.BOTTOM_CENTER);
 683         htilepane.resize(700,1000);
 684         htilepane.layout();
 685 
 686         // test a handful
 687         Node first = ParentShim.getChildren(htilepane).get(0);
 688         Node last = ParentShim.getChildren(htilepane).get(7);
 689 
 690         assertEquals(0, first.getLayoutX(), 1e-100);
 691         assertEquals(0, first.getLayoutY(), 1e-100);
 692         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 693         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 694         assertEquals(250, last.getLayoutX(), 1e-100);
 695         assertEquals(800, last.getLayoutY(), 1e-100);
 696         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 697         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 698     }
 699 
 700     @Test public void testTileAlignmentBottomRight() {
 701         htilepane.setTileAlignment(Pos.BOTTOM_RIGHT);
 702         htilepane.resize(700,1000);
 703         htilepane.layout();
 704 
 705         // test a handful
 706         Node first = ParentShim.getChildren(htilepane).get(0);
 707         Node last = ParentShim.getChildren(htilepane).get(7);
 708 
 709         assertEquals(0, first.getLayoutX(), 1e-100);
 710         assertEquals(0, first.getLayoutY(), 1e-100);
 711         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 712         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 713         assertEquals(300, last.getLayoutX(), 1e-100);
 714         assertEquals(800, last.getLayoutY(), 1e-100);
 715         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 716         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 717     }
 718 
 719     @Test public void testSetMarginConstraint() {
 720         MockResizable child1 = new MockResizable(100,200, 300,400, 500,600);
 721 
 722         assertNull(TilePane.getMargin(child1));
 723 
 724         Insets margin = new Insets(10,20,30,40);
 725         TilePane.setMargin(child1, margin);
 726         assertEquals(margin, TilePane.getMargin(child1));
 727 
 728         TilePane.setMargin(child1, null);
 729         assertNull(TilePane.getMargin(child1));
 730     }
 731 
 732     @Test public void testMarginConstraint() {
 733         TilePane tilepane = new TilePane();
 734 
 735         for(int i = 0; i < 6; i++) {
 736             MockResizable child1 = new MockResizable(50,60, 100,200, 500,600);
 737             Rectangle child2 = new Rectangle(100, 100);
 738             ParentShim.getChildren(tilepane).addAll(child1, child2);
 739         }
 740 
 741         // test a handful
 742         Node first = ParentShim.getChildren(tilepane).get(0);
 743         Node last = ParentShim.getChildren(tilepane).get(11);
 744 
 745         TilePane.setMargin(first, new Insets(10,20,30,40));
 746 
 747         assertEquals(160, tilepane.minWidth(-1), 1e-100);
 748         assertEquals(720, tilepane.minHeight(-1), 1e-100);
 749         assertEquals(800, tilepane.prefWidth(-1), 1e-100);
 750         assertEquals(720, tilepane.prefHeight(-1), 1e-100);
 751 
 752         tilepane.autosize();
 753         tilepane.layout();
 754 
 755         assertEquals(40, first.getLayoutX(), 1e-100);
 756         assertEquals(10, first.getLayoutY(), 1e-100);
 757         assertEquals(100, first.getLayoutBounds().getWidth(), 1e-100);
 758         assertEquals(200, first.getLayoutBounds().getHeight(), 1e-100);
 759         assertEquals(190, last.getLayoutX(), 1e-100);
 760         assertEquals(550, last.getLayoutY(), 1e-100);
 761         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 762         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 763 
 764 
 765     }
 766 
 767     @Test public void testSetAlignmentConstraint() {
 768         MockResizable child1 = new MockResizable(100,200, 300,400, 500,600);
 769 
 770         assertNull(TilePane.getAlignment(child1));
 771 
 772         TilePane.setAlignment(child1, Pos.TOP_LEFT);
 773         assertEquals(Pos.TOP_LEFT, TilePane.getAlignment(child1));
 774 
 775         TilePane.setAlignment(child1, null);
 776         assertNull(TilePane.getAlignment(child1));
 777     }
 778 
 779     @Test public void testHorizontalTilePaneAlignmentConstraint() {
 780         TilePane tilepane = new TilePane();
 781 
 782         for(int i = 0; i < 6; i++) {
 783             MockResizable child1 = new MockResizable(50,60, 100,200, 500,600);
 784             Rectangle child2 = new Rectangle(100, 100);
 785             ParentShim.getChildren(tilepane).addAll(child1, child2);
 786         }
 787 
 788         assertEquals(100, tilepane.minWidth(-1), 1e-100);
 789         assertEquals(600, tilepane.minHeight(-1), 1e-100);
 790         assertEquals(500, tilepane.prefWidth(-1), 1e-100);
 791         assertEquals(600, tilepane.prefHeight(-1), 1e-100);
 792 
 793         tilepane.autosize();
 794         tilepane.layout();
 795 
 796         // test a handful
 797         Node first = ParentShim.getChildren(tilepane).get(0);
 798         Node last = ParentShim.getChildren(tilepane).get(11);
 799 
 800         TilePane.setAlignment(last, Pos.TOP_LEFT);
 801 
 802         tilepane.autosize();
 803         tilepane.layout();
 804 
 805         assertEquals(0, first.getLayoutX(), 1e-100);
 806         assertEquals(0, first.getLayoutY(), 1e-100);
 807         assertEquals(100, first.getLayoutBounds().getWidth(), 1e-100);
 808         assertEquals(200, first.getLayoutBounds().getHeight(), 1e-100);
 809         assertEquals(100, last.getLayoutX(), 1e-100);
 810         assertEquals(400, last.getLayoutY(), 1e-100);
 811         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 812         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 813 
 814         tilepane.resize(800,800);
 815         tilepane.layout();
 816         assertEquals(0, first.getLayoutX(), 1e-100);
 817         assertEquals(0, first.getLayoutY(), 1e-100);
 818         assertEquals(100, first.getLayoutBounds().getWidth(), 1e-100);
 819         assertEquals(200, first.getLayoutBounds().getHeight(), 1e-100);
 820         assertEquals(300, last.getLayoutX(), 1e-100);
 821         assertEquals(200, last.getLayoutY(), 1e-100);
 822         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 823         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 824     }
 825 
 826     @Test public void testWithHorizontalBiasedChild() {
 827         TilePane tilepane = new TilePane();
 828 
 829         MockBiased biased = new MockBiased(Orientation.HORIZONTAL, 100,100);
 830         Rectangle rect = new Rectangle(150,50);
 831 
 832         ParentShim.getChildren(tilepane).addAll(biased,rect);
 833 
 834         assertEquals(750, tilepane.prefWidth(-1), 1e-100);
 835         assertEquals(67, tilepane.prefHeight(-1), 1e-100);
 836 
 837         tilepane.autosize();
 838         tilepane.layout();
 839         assertEquals(0, biased.getLayoutX(), 1e-100);
 840         assertEquals(0, biased.getLayoutY(), 1e-100);
 841         assertEquals(150, biased.getLayoutBounds().getWidth(), 1e-100);
 842         assertEquals(67, biased.getLayoutBounds().getHeight(), 1e-100);
 843         assertEquals(150, rect.getLayoutX(), 1e-100);
 844         assertEquals(9, rect.getLayoutY(), 1e-100);
 845         assertEquals(150, rect.getLayoutBounds().getWidth(), 1e-100);
 846         assertEquals(50, rect.getLayoutBounds().getHeight(), 1e-100);
 847 
 848     }
 849 
 850     @Test public void testWithVerticalBiasedChild() {
 851         TilePane tilepane = new TilePane();
 852 
 853         MockBiased biased = new MockBiased(Orientation.VERTICAL, 100,100);
 854         Rectangle rect = new Rectangle(50,150);
 855 
 856         ParentShim.getChildren(tilepane).addAll(biased,rect);
 857 
 858         assertEquals(335.00, tilepane.prefWidth(-1), 1e-100);
 859         assertEquals(150, tilepane.prefHeight(-1), 1e-100);
 860 
 861         tilepane.autosize();
 862         tilepane.layout();
 863         assertEquals(0, biased.getLayoutX(), 1e-100);
 864         assertEquals(0, biased.getLayoutY(), 1e-100);
 865         assertEquals(67, biased.getLayoutBounds().getWidth(), 1e-100);
 866         assertEquals(150, biased.getLayoutBounds().getHeight(), 1e-100);
 867         assertEquals(76, rect.getLayoutX(), 1e-100);
 868         assertEquals(0, rect.getLayoutY(), 1e-100);
 869         assertEquals(50, rect.getLayoutBounds().getWidth(), 1e-100);
 870         assertEquals(150, rect.getLayoutBounds().getHeight(), 1e-100);
 871     }
 872 
 873     @Test public void testHorizontalTilePaneWithFixedTileWidth() {
 874         TilePane tilepane = new TilePane();
 875         tilepane.setPrefColumns(3);
 876         tilepane.setPrefTileWidth(200);
 877 
 878         for(int i = 0; i < 4; i++) {
 879             MockResizable child1 = new MockResizable(150,300);
 880             Rectangle child2 = new Rectangle(100, 100);
 881             ParentShim.getChildren(tilepane).addAll(child1, child2);
 882         }
 883 
 884         assertEquals(200, tilepane.getTileWidth(), 0);
 885         assertEquals(300, tilepane.getTileHeight(), 0);
 886 
 887         assertEquals(600, tilepane.prefWidth(-1), 0);
 888         assertEquals(900, tilepane.prefHeight(-1), 0);
 889 
 890         tilepane.autosize();
 891         tilepane.layout();
 892 
 893         assertEquals(200, tilepane.getTileWidth(), 0);
 894         assertEquals(300, tilepane.getTileHeight(), 0);
 895 
 896         // test a handful
 897         Node first = ParentShim.getChildren(tilepane).get(0);
 898         Node last = ParentShim.getChildren(tilepane).get(7);
 899 
 900         assertEquals(0, first.getLayoutX(), 1e-100);
 901         assertEquals(0, first.getLayoutY(), 1e-100);
 902         assertEquals(200, first.getLayoutBounds().getWidth(), 1e-100);
 903         assertEquals(300, first.getLayoutBounds().getHeight(), 1e-100);
 904         assertEquals(250, last.getLayoutX(), 1e-100);
 905         assertEquals(700, last.getLayoutY(), 1e-100);
 906         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 907         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 908     }
 909 
 910     @Test public void testHorizontalTilePaneWithFixedTileHeight() {
 911         TilePane tilepane = new TilePane();
 912         tilepane.setPrefColumns(3);
 913         tilepane.setPrefTileHeight(200);
 914 
 915         for(int i = 0; i < 4; i++) {
 916             MockResizable child1 = new MockResizable(300,150);
 917             Rectangle child2 = new Rectangle(100, 100);
 918             ParentShim.getChildren(tilepane).addAll(child1, child2);
 919         }
 920 
 921 
 922         assertEquals(300, tilepane.getTileWidth(), 0);
 923         assertEquals(200, tilepane.getTileHeight(), 0);
 924 
 925         assertEquals(900, tilepane.prefWidth(-1), 0);
 926         assertEquals(600, tilepane.prefHeight(-1), 0);
 927 
 928         tilepane.autosize();
 929         tilepane.layout();
 930 
 931         assertEquals(300, tilepane.getTileWidth(), 0);
 932         assertEquals(200, tilepane.getTileHeight(), 0);
 933 
 934         // test a handful
 935         Node first = ParentShim.getChildren(tilepane).get(0);
 936         Node last = ParentShim.getChildren(tilepane).get(7);
 937 
 938         assertEquals(0, first.getLayoutX(), 1e-100);
 939         assertEquals(0, first.getLayoutY(), 1e-100);
 940         assertEquals(300, first.getLayoutBounds().getWidth(), 1e-100);
 941         assertEquals(200, first.getLayoutBounds().getHeight(), 1e-100);
 942         assertEquals(400, last.getLayoutX(), 1e-100);
 943         assertEquals(450, last.getLayoutY(), 1e-100);
 944         assertEquals(100, last.getLayoutBounds().getWidth(), 1e-100);
 945         assertEquals(100, last.getLayoutBounds().getHeight(), 1e-100);
 946     }
 947 
 948     @Test public void testHorizontalTilePaneWithPrefSize() {
 949         TilePane tilepane = new TilePane(Orientation.HORIZONTAL);
 950         tilepane.setPrefSize(100,100);
 951 
 952         for(int i = 0; i < 8; i++) {
 953             Rectangle child = new Rectangle(40, 40);
 954             ParentShim.getChildren(tilepane).add(child);
 955         }
 956 
 957 
 958         assertEquals(40, tilepane.getTileWidth(), 0);
 959         assertEquals(40, tilepane.getTileHeight(), 0);
 960 
 961         assertEquals(100, tilepane.prefWidth(-1), 0);
 962         assertEquals(100, tilepane.prefHeight(-1), 0);
 963 
 964         tilepane.autosize();
 965         tilepane.layout();
 966 
 967         assertEquals(40, tilepane.getTileWidth(), 0);
 968         assertEquals(40, tilepane.getTileHeight(), 0);
 969 
 970         Node first = ParentShim.getChildren(tilepane).get(0);
 971 
 972         assertEquals(0, first.getLayoutX(), 1e-100);
 973         assertEquals(0, first.getLayoutY(), 1e-100);
 974         assertEquals(100, tilepane.getLayoutBounds().getWidth(), 1e-100);
 975         assertEquals(160, tilepane.getLayoutBounds().getHeight(), 1e-100);
 976     }
 977 
 978     @Test public void testVerticalTilePaneWithPrefSize() {
 979         TilePane tilepane = new TilePane(Orientation.VERTICAL);
 980         tilepane.setPrefSize(100,100);
 981 
 982         for(int i = 0; i < 8; i++) {
 983             Rectangle child = new Rectangle(40, 40);
 984             ParentShim.getChildren(tilepane).add(child);
 985         }
 986 
 987         assertEquals(40, tilepane.getTileWidth(), 0);
 988         assertEquals(40, tilepane.getTileHeight(), 0);
 989 
 990         assertEquals(100, tilepane.prefWidth(-1), 0);
 991         assertEquals(100, tilepane.prefHeight(-1), 0);
 992         tilepane.autosize();
 993         tilepane.layout();
 994 
 995         assertEquals(40, tilepane.getTileWidth(), 0);
 996         assertEquals(40, tilepane.getTileHeight(), 0);
 997 
 998         Node first = ParentShim.getChildren(tilepane).get(0);
 999 
1000         assertEquals(0, first.getLayoutX(), 1e-100);
1001         assertEquals(0, first.getLayoutY(), 1e-100);
1002         assertEquals(160, tilepane.getLayoutBounds().getWidth(), 1e-100);
1003         assertEquals(100, tilepane.getLayoutBounds().getHeight(), 1e-100);
1004     }
1005 
1006     @Test public void testTilePaneWithBaselineAlignment() {
1007         TilePane tilepane = new TilePane(Orientation.HORIZONTAL);
1008         tilepane.setPrefSize(100,100);
1009         tilepane.setTileAlignment(Pos.BASELINE_CENTER);
1010 
1011         for(int i = 0; i < 8; i++) {
1012             Rectangle child = new Rectangle(40, 40);
1013             ParentShim.getChildren(tilepane).add(child);
1014         }
1015 
1016         tilepane.autosize();
1017         tilepane.layout();
1018 
1019         Node first = ParentShim.getChildren(tilepane).get(0);
1020 
1021         assertEquals(0, first.getLayoutX(), 1e-100);
1022         assertEquals(0, first.getLayoutY(), 1e-100);
1023         assertEquals(100, tilepane.getLayoutBounds().getWidth(), 1e-100);
1024         assertEquals(160, tilepane.getLayoutBounds().getHeight(), 1e-100);
1025     }
1026 
1027     @Test public void testCSSsetPrefTileWidthAndHeight_RT20388() {
1028         Scene scene = new Scene(tilepane);
1029         Stage stage = new Stage();
1030         stage.setScene(scene);
1031         stage.show();
1032 
1033         ParsedValue pv = new CssParser().parseExpr("-fx-perf-tile-width","67.0");
1034         Object val = pv.convert(null);
1035         try {
1036             ((StyleableProperty)tilepane.prefTileWidthProperty()).applyStyle(null, val);
1037             assertEquals(67.0, tilepane.getPrefTileWidth(), 0.00001);
1038         } catch (Exception e) {
1039             Assert.fail(e.toString());
1040         }
1041     }
1042 
1043     @Test public void testCSSsetPrefRow_RT20437() {
1044         Scene scene = new Scene(tilepane);
1045         Stage stage = new Stage();
1046         stage.setScene(scene);
1047         stage.show();
1048 
1049         ParsedValue pv = new CssParser().parseExpr("-fx-perf-rows","2");
1050         Object val = pv.convert(null);
1051         try {
1052             ((StyleableProperty)tilepane.prefRowsProperty()).applyStyle(null, val);
1053             assertEquals(2, tilepane.getPrefRows(), 0.00001);
1054         } catch (Exception e) {
1055             Assert.fail(e.toString());
1056         }
1057     }
1058 
1059 
1060     @Test public void testCSSsetPrefColumns_RT22929() {
1061         Scene scene = new Scene(tilepane);
1062         Stage stage = new Stage();
1063         stage.setScene(scene);
1064         stage.show();
1065 
1066         ParsedValue pv = new CssParser().parseExpr("-fx-pref-columns","2");
1067         Object val = pv.convert(null);
1068         CssMetaData prop = ((StyleableProperty)tilepane.prefColumnsProperty()).getCssMetaData();
1069         try {
1070             ((StyleableProperty)tilepane.prefColumnsProperty()).applyStyle(null,val);
1071             assertEquals(2, tilepane.getPrefColumns(), 0.00001);
1072         } catch (Exception e) {
1073             Assert.fail(e.toString());
1074         }
1075     }
1076 }