1 /*
   2  * Copyright (c) 2011, 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 com.sun.javafx.scene.control.infrastructure.VirtualFlowTestUtils;
  30 import com.sun.javafx.scene.control.skin.TableColumnHeader;
  31 import com.sun.javafx.scene.control.skin.TableViewSkin;
  32 import com.sun.javafx.scene.control.skin.TreeTableViewSkin;
  33 import com.sun.javafx.scene.control.skin.VirtualFlow;
  34 import com.sun.javafx.scene.control.test.Person;
  35 import com.sun.javafx.tk.Toolkit;
  36 import javafx.beans.property.DoubleProperty;
  37 import javafx.beans.property.ObjectProperty;
  38 import javafx.beans.property.SimpleBooleanProperty;
  39 import javafx.beans.property.SimpleDoubleProperty;
  40 import javafx.beans.property.SimpleObjectProperty;
  41 import javafx.beans.property.SimpleStringProperty;
  42 import javafx.beans.property.StringProperty;
  43 import javafx.beans.value.ObservableValue;
  44 import javafx.event.EventHandler;
  45 import javafx.event.EventType;
  46 import javafx.scene.Node;
  47 import javafx.scene.shape.Rectangle;
  48 import javafx.util.Callback;
  49 
  50 import java.util.Arrays;
  51 import java.util.Collections;
  52 import java.util.Comparator;
  53 import java.util.List;
  54 import javafx.beans.property.BooleanProperty;
  55 import javafx.collections.FXCollections;
  56 import javafx.scene.Group;
  57 import javafx.scene.Scene;
  58 import javafx.scene.control.cell.PropertyValueFactory;
  59 import javafx.scene.layout.Region;
  60 import javafx.stage.Stage;
  61 
  62 import org.junit.Before;
  63 import org.junit.Ignore;
  64 import org.junit.Test;
  65 
  66 import static org.junit.Assert.*;
  67 import static org.junit.Assert.assertEquals;
  68 
  69 /**
  70  */
  71 public class TreeTableColumnTest {
  72     private static final double MIN_WIDTH = 35;
  73     private static final double MAX_WIDTH = 2000;
  74     private static final double PREF_WIDTH = 100;
  75 
  76     private TreeTableColumn<Person,String> column;
  77     private TreeTableView<Person> table;
  78     private TreeItem<Person> root;
  79     
  80     @Before public void setup() {
  81         root = new TreeItem<Person>(null);
  82         root.setExpanded(true);
  83         
  84         root.getChildren().setAll(
  85                 new TreeItem(new Person("Humphrey McPhee", 76)),
  86                 new TreeItem(new Person("Justice Caldwell", 30)),
  87                 new TreeItem(new Person("Orrin Davies", 30)),
  88                 new TreeItem(new Person("Emma Wilson", 8)));
  89         
  90         column = new TreeTableColumn<Person,String>("");
  91         table = new TreeTableView<Person>(root);
  92     }
  93     
  94 
  95     /*********************************************************************
  96      * Tests for the constructors                                        *
  97      ********************************************************************/
  98 
  99     @Test public void defaultConstructorHasDefaultCellFactory() {
 100         assertSame(TreeTableColumn.DEFAULT_CELL_FACTORY, column.getCellFactory());
 101         assertSame(TreeTableColumn.DEFAULT_CELL_FACTORY, column.cellFactoryProperty().get());
 102     }
 103 
 104     @Test public void defaultConstructorHasDefaultComparator() {
 105         assertSame(TreeTableColumn.DEFAULT_COMPARATOR, column.getComparator());
 106         assertSame(TreeTableColumn.DEFAULT_COMPARATOR, column.comparatorProperty().get());
 107     }
 108 
 109     @Test public void defaultConstructorHasEmptyStringText() {
 110         assertEquals("", column.getText());
 111         assertEquals("", column.textProperty().get());
 112     }
 113 
 114 //    @Test public void defaultConstructorHasNonNullEditCommitHandler() {
 115 //        // This is questionable
 116 //    }
 117 
 118     /*********************************************************************
 119      * Tests for the tableView property                                  *
 120      ********************************************************************/
 121 
 122     @Test public void tableViewIsNullByDefault() {
 123         assertNull(column.getTreeTableView());
 124         assertNull(column.treeTableViewProperty().get());
 125     }
 126 
 127     @Test public void tableViewCanBeSpecified() {
 128         column.setTreeTableView(table);
 129         assertSame(table, column.getTreeTableView());
 130         assertSame(table, column.treeTableViewProperty().get());
 131     }
 132 
 133     @Test public void tableViewCanBeResetToNull() {
 134         column.setTreeTableView(table);
 135         column.setTreeTableView(null);
 136         assertNull(column.getTreeTableView());
 137         assertNull(column.treeTableViewProperty().get());
 138     }
 139 
 140     @Test public void treeTableViewPropertyBeanIsCorrect() {
 141         assertSame(column, column.treeTableViewProperty().getBean());
 142     }
 143 
 144     @Test public void treeTableViewPropertyNameIsCorrect() {
 145         assertEquals("treeTableView", column.treeTableViewProperty().getName());
 146     }
 147 
 148     @Test public void whenTableViewIsChangedChildColumnsAreUpdated() {
 149         TreeTableColumn<Person,String> child = new TreeTableColumn<Person,String>();
 150         column.getColumns().add(child);
 151         table.getColumns().add(column);
 152 
 153         TreeTableView<Person> other = new TreeTableView<Person>();
 154         table.getColumns().clear();
 155         other.getColumns().add(column);
 156 
 157         assertSame(other, child.getTreeTableView());
 158     }
 159 
 160     /*********************************************************************
 161      * Tests for the text property                                       *
 162      ********************************************************************/
 163 
 164     @Test public void textIsEmptyByDefault() {
 165         assertEquals("", column.getText());
 166         assertEquals("", column.textProperty().get());
 167     }
 168 
 169     @Test public void textCanBeSpecified() {
 170         column.setText("Name");
 171         assertEquals("Name", column.getText());
 172         assertEquals("Name", column.textProperty().get());
 173     }
 174 
 175     @Test public void textCanBeSetToNull() {
 176         column.setText(null);
 177         assertNull(column.getText());
 178         assertNull(column.textProperty().get());
 179     }
 180 
 181     @Test public void textPropertyBeanIsCorrect() {
 182         assertSame(column, column.textProperty().getBean());
 183     }
 184 
 185     @Test public void textPropertyNameIsCorrect() {
 186         assertEquals("text", column.textProperty().getName());
 187     }
 188 
 189     @Test public void textCanBeBound() {
 190         StringProperty other = new SimpleStringProperty("Name");
 191         column.textProperty().bind(other);
 192         assertEquals("Name", column.getText());
 193         assertEquals("Name", column.textProperty().get());
 194         other.set("Age");
 195         assertEquals("Age", column.getText());
 196         assertEquals("Age", column.textProperty().get());
 197     }
 198 
 199     /*********************************************************************
 200      * Tests for the visible property                                    *
 201      ********************************************************************/
 202 
 203     @Test public void visibleIsTrueByDefault() {
 204         assertTrue(column.isVisible());
 205         assertTrue(column.visibleProperty().get());
 206     }
 207 
 208     @Test public void visibleCanBeSpecified() {
 209         column.setVisible(false);
 210         assertFalse(column.isVisible());
 211         assertFalse(column.visibleProperty().get());
 212     }
 213 
 214     @Test public void visiblePropertyBeanIsCorrect() {
 215         assertSame(column, column.visibleProperty().getBean());
 216     }
 217 
 218     @Test public void visiblePropertyNameIsCorrect() {
 219         assertEquals("visible", column.visibleProperty().getName());
 220     }
 221 
 222     @Test public void visibleCanBeBound() {
 223         BooleanProperty other = new SimpleBooleanProperty(false);
 224         column.visibleProperty().bind(other);
 225         assertFalse(column.isVisible());
 226         assertFalse(column.visibleProperty().get());
 227         other.set(true);
 228         assertTrue(column.isVisible());
 229         assertTrue(column.visibleProperty().get());
 230     }
 231 
 232     /*********************************************************************
 233      * Tests for the parentColumn property                               *
 234      ********************************************************************/
 235 
 236     @Test public void parentColumnIsNullByDefault() {
 237         TreeTableColumn child = new TreeTableColumn();
 238         assertNull(child.getParentColumn());
 239         assertNull(child.parentColumnProperty().get());
 240     }
 241 
 242     @Test public void parentColumnIsUpdatedWhenAddedToParent() {
 243         TreeTableColumn child = new TreeTableColumn();
 244         column.getColumns().add(child);
 245         assertSame(column, child.getParentColumn());
 246         assertSame(column, child.parentColumnProperty().get());
 247     }
 248 
 249     @Test public void parentColumnIsClearedWhenRemovedFromParent() {
 250         TreeTableColumn child = new TreeTableColumn();
 251         column.getColumns().add(child);
 252         column.getColumns().remove(child);
 253         assertNull(child.getParentColumn());
 254         assertNull(child.parentColumnProperty().get());
 255     }
 256 
 257     @Test public void parentColumnIsClearedWhenParentColumnsIsCleared() {
 258         TreeTableColumn child = new TreeTableColumn();
 259         column.getColumns().add(child);
 260         column.getColumns().clear();
 261         assertNull(child.getParentColumn());
 262         assertNull(child.parentColumnProperty().get());
 263     }
 264 
 265     @Test public void tableViewReferenceIsUpdatedWhenAddedToParent() {
 266         table.getColumns().add(column);
 267         TreeTableColumn child = new TreeTableColumn();
 268         column.getColumns().add(child);
 269         assertSame(table, child.getTreeTableView());
 270         assertSame(table, child.treeTableViewProperty().get());
 271     }
 272 
 273     @Test public void tableViewReferenceIsClearedWhenRemovedFromParent() {
 274         table.getColumns().add(column);
 275         TreeTableColumn child = new TreeTableColumn();
 276         column.getColumns().add(child);
 277         column.getColumns().remove(child);
 278         assertNull(child.getTreeTableView());
 279         assertNull(child.treeTableViewProperty().get());
 280     }
 281 
 282     @Test public void tableViewReferenceIsClearedWhenParentColumnsIsCleared() {
 283         table.getColumns().add(column);
 284         TreeTableColumn child = new TreeTableColumn();
 285         column.getColumns().add(child);
 286         column.getColumns().clear();
 287         assertNull(child.getTreeTableView());
 288         assertNull(child.treeTableViewProperty().get());
 289     }
 290 
 291     @Test public void visibleIsUpdatedWhenParentColumnVisibleChanges() {
 292         TreeTableColumn child = new TreeTableColumn();
 293         column.getColumns().add(child);
 294         column.setVisible(true);
 295         assertTrue(child.visibleProperty().get());
 296         column.setVisible(false);
 297         assertFalse(child.isVisible());
 298     }
 299 
 300     @Test public void visibleIsTrueWhenAddedToParentColumnWithVisibleTrue() {
 301         TreeTableColumn child = new TreeTableColumn();
 302         column.setVisible(true);
 303         column.getColumns().add(child);
 304         assertTrue(child.isVisible());
 305         assertTrue(child.visibleProperty().get());
 306     }
 307 
 308     @Test public void visibleIsNotChangedWhenAddedToParentColumnWithVisibleFalse() {
 309         TreeTableColumn child = new TreeTableColumn();
 310         child.setVisible(true);
 311         column.setVisible(false);
 312         column.getColumns().add(child);
 313         assertTrue(child.isVisible());
 314         assertFalse(column.isVisible());
 315     }
 316 
 317     @Test public void visibleIsNotChangedWhenRemovedFromParentColumn() {
 318         TreeTableColumn child = new TreeTableColumn();
 319         column.getColumns().add(child);
 320         column.setVisible(false);
 321         column.getColumns().clear();
 322         assertFalse(child.isVisible());
 323         assertFalse(child.visibleProperty().get());
 324     }
 325 
 326     @Test public void childVisibleChangesAccordingToParentVisibleWhenParentVisibleIsBound() {
 327         TreeTableColumn<Person,String> child = new TreeTableColumn<Person,String>();
 328         column.getColumns().add(child);
 329         BooleanProperty other = new SimpleBooleanProperty(false);
 330         column.visibleProperty().bind(other);
 331         assertFalse(child.isVisible());
 332         assertFalse(child.visibleProperty().get());
 333         other.set(true);
 334         assertTrue(child.isVisible());
 335         assertTrue(child.visibleProperty().get());
 336     }
 337 
 338     /*********************************************************************
 339      * Tests for the contextMenu property                                *
 340      ********************************************************************/
 341 
 342     @Test public void contextMenuIsNullByDefault() {
 343         assertNull(column.getContextMenu());
 344         assertNull(column.contextMenuProperty().get());
 345     }
 346 
 347     @Test public void contextMenuCanBeSpecified() {
 348         ContextMenu ctx = new ContextMenu();
 349         column.setContextMenu(ctx);
 350         assertSame(ctx, column.getContextMenu());
 351         assertSame(ctx, column.contextMenuProperty().get());
 352     }
 353 
 354     @Test public void contextMenuCanBeSetBackToNull() {
 355         ContextMenu ctx = new ContextMenu();
 356         column.setContextMenu(ctx);
 357         column.setContextMenu(null);
 358         assertNull(column.getContextMenu());
 359         assertNull(column.contextMenuProperty().get());
 360     }
 361 
 362     @Test public void contextMenuPropertyBeanIsCorrect() {
 363         assertSame(column, column.contextMenuProperty().getBean());
 364     }
 365 
 366     @Test public void contextMenuPropertyNameIsCorrect() {
 367         assertEquals("contextMenu", column.contextMenuProperty().getName());
 368     }
 369 
 370     @Test public void contextMenuCanBeBound() {
 371         ContextMenu ctx = new ContextMenu();
 372         ObjectProperty<ContextMenu> other = new SimpleObjectProperty<ContextMenu>(ctx);
 373         column.contextMenuProperty().bind(other);
 374         assertSame(ctx, column.getContextMenu());
 375         assertSame(ctx, column.contextMenuProperty().get());
 376         other.set(null);
 377         assertNull(column.getContextMenu());
 378         assertNull(column.contextMenuProperty().get());
 379     }
 380 
 381     /*********************************************************************
 382      * Tests for the cellValueFactory property                           *
 383      ********************************************************************/
 384 
 385     @Test public void cellValueFactoryIsNullByDefault() {
 386         assertNull(column.getCellValueFactory());
 387         assertNull(column.cellValueFactoryProperty().get());
 388     }
 389 
 390     @Test public void cellValueFactoryCanBeSpecified() {
 391         CellValueFactory<Person,String> factory = param -> param.getValue().getValue().firstNameProperty();
 392 
 393         column.setCellValueFactory(factory);
 394         assertSame(factory, column.getCellValueFactory());
 395         assertSame(factory, column.cellValueFactoryProperty().get());
 396     }
 397 
 398     @Test public void cellValueFactoryCanBeResetToNull() {
 399         CellValueFactory<Person,String> factory = param -> param.getValue().getValue().firstNameProperty();
 400 
 401         column.setCellValueFactory(factory);
 402         column.setCellValueFactory(null);
 403         assertNull(column.getCellValueFactory());
 404         assertNull(column.cellValueFactoryProperty().get());
 405     }
 406 
 407     @Test public void cellValueFactoryPropertyBeanIsCorrect() {
 408         assertSame(column, column.cellValueFactoryProperty().getBean());
 409     }
 410 
 411     @Test public void cellValueFactoryPropertyNameIsCorrect() {
 412         assertEquals("cellValueFactory", column.cellValueFactoryProperty().getName());
 413     }
 414 
 415     @Test public void cellValueFactoryCanBeBound() {
 416         CellValueFactory<Person,String> factory = param -> param.getValue().getValue().firstNameProperty();
 417         ObjectProperty<CellValueFactory<Person,String>> other =
 418                 new SimpleObjectProperty<CellValueFactory<Person, String>>(factory);
 419         column.cellValueFactoryProperty().bind(other);
 420         assertSame(factory, column.getCellValueFactory());
 421         assertSame(factory, column.cellValueFactoryProperty().get());
 422         other.set(null);
 423         assertNull(column.getCellValueFactory());
 424         assertNull(column.cellValueFactoryProperty().get());
 425     }
 426 
 427     /*********************************************************************
 428      * Tests for the cellFactory property                                *
 429      ********************************************************************/
 430 
 431     @Test public void cellFactoryCanBeSpecified() {
 432         CellFactory<Person,String> factory = param -> null;
 433         column.setCellFactory(factory);
 434         assertSame(factory, column.getCellFactory());
 435         assertSame(factory, column.cellFactoryProperty().get());
 436     }
 437 
 438     @Test public void cellFactoryCanBeResetToNull() {
 439         CellFactory<Person,String> factory = param -> null;
 440         column.setCellFactory(factory);
 441         column.setCellFactory(null);
 442         assertNull(column.getCellFactory());
 443         assertNull(column.cellFactoryProperty().get());
 444     }
 445 
 446     @Test public void cellFactoryPropertyBeanIsCorrect() {
 447         assertSame(column, column.cellFactoryProperty().getBean());
 448     }
 449 
 450     @Test public void cellFactoryPropertyNameIsCorrect() {
 451         assertEquals("cellFactory", column.cellFactoryProperty().getName());
 452     }
 453 
 454     @Test public void cellFactoryCanBeBound() {
 455         CellFactory<Person,String> factory = param -> null;
 456         ObjectProperty<CellFactory<Person,String>> other =
 457                 new SimpleObjectProperty<CellFactory<Person, String>>(factory);
 458         column.cellFactoryProperty().bind(other);
 459         assertSame(factory, column.getCellFactory());
 460         assertSame(factory, column.cellFactoryProperty().get());
 461         other.set(null);
 462         assertNull(column.getCellFactory());
 463         assertNull(column.cellFactoryProperty().get());
 464     }
 465 
 466     /****************************************************************************
 467      * minWidth Tests                                                           *
 468      ***************************************************************************/
 469 
 470     @Ignore ("Fails with hardcoded value of 10")
 471     @Test public void minWidthIs_USE_COMPUTED_SIZE_ByDefault() {
 472         assertEquals(Control.USE_COMPUTED_SIZE, column.getMinWidth(), 0);
 473         assertEquals(Control.USE_COMPUTED_SIZE, column.minWidthProperty().get(), 0);
 474     }
 475 
 476     @Test public void minWidthCanBeSet() {
 477         column.setMinWidth(234);
 478         assertEquals(234, column.getMinWidth(), 0);
 479         assertEquals(234, column.minWidthProperty().get(), 0);
 480     }
 481 
 482     @Test public void minWidthCanBeBound() {
 483         DoubleProperty other = new SimpleDoubleProperty(939);
 484         column.minWidthProperty().bind(other);
 485         assertEquals(939, column.getMinWidth(), 0);
 486         other.set(332);
 487         assertEquals(332, column.getMinWidth(), 0);
 488     }
 489 
 490     @Test public void minWidthPropertyHasBeanReference() {
 491         assertSame(column, column.minWidthProperty().getBean());
 492     }
 493 
 494     @Test public void minWidthPropertyHasName() {
 495         assertEquals("minWidth", column.minWidthProperty().getName());
 496     }
 497 
 498     /****************************************************************************
 499      * maxWidth Tests                                                           *
 500      ***************************************************************************/
 501 
 502     @Ignore ("Fails with hardcoded value of 5000")
 503     @Test public void maxWidthIs_USE_COMPUTED_SIZE_ByDefault() {
 504         assertEquals(Control.USE_COMPUTED_SIZE, column.getMaxWidth(), 0);
 505         assertEquals(Control.USE_COMPUTED_SIZE, column.maxWidthProperty().get(), 0);
 506     }
 507 
 508     @Test public void maxWidthCanBeSet() {
 509         column.setMaxWidth(500);
 510         assertEquals(500, column.getMaxWidth(), 0);
 511         assertEquals(500, column.maxWidthProperty().get(), 0);
 512     }
 513 
 514     @Test public void maxWidthCanBeBound() {
 515         DoubleProperty other = new SimpleDoubleProperty(939);
 516         column.maxWidthProperty().bind(other);
 517         assertEquals(939, column.getMaxWidth(), 0);
 518         other.set(332);
 519         assertEquals(332, column.getMaxWidth(), 0);
 520     }
 521 
 522     @Test public void maxWidthPropertyHasBeanReference() {
 523         assertSame(column, column.maxWidthProperty().getBean());
 524     }
 525 
 526     @Test public void maxWidthPropertyHasName() {
 527         assertEquals("maxWidth", column.maxWidthProperty().getName());
 528     }
 529 
 530     /****************************************************************************
 531      * prefWidth Tests                                                          *
 532      ***************************************************************************/
 533 
 534     @Ignore ("Fails with hardcoded value of 80")
 535     @Test public void prefWidthIs_USE_COMPUTED_SIZE_ByDefault() {
 536         assertEquals(Control.USE_COMPUTED_SIZE, column.getPrefWidth(), 0);
 537         assertEquals(Control.USE_COMPUTED_SIZE, column.prefWidthProperty().get(), 0);
 538     }
 539 
 540     @Test public void prefWidthCanBeSet() {
 541         column.setPrefWidth(80);
 542         assertEquals(80, column.getPrefWidth(), 0);
 543         assertEquals(80, column.prefWidthProperty().get(), 0);
 544     }
 545 
 546     @Test public void prefWidthCanBeBound() {
 547         DoubleProperty other = new SimpleDoubleProperty(939);
 548         column.prefWidthProperty().bind(other);
 549         assertEquals(939, column.getPrefWidth(), 0);
 550         other.set(332);
 551         assertEquals(332, column.getPrefWidth(), 0);
 552     }
 553 
 554     @Test public void prefWidthPropertyHasBeanReference() {
 555         assertSame(column, column.prefWidthProperty().getBean());
 556     }
 557 
 558     @Test public void prefWidthPropertyHasName() {
 559         assertEquals("prefWidth", column.prefWidthProperty().getName());
 560     }
 561 
 562     /*********************************************************************
 563      * Tests for the resizable property                                  *
 564      ********************************************************************/
 565 
 566     @Test public void resizableIsTrueByDefault() {
 567         assertTrue(column.isResizable());
 568         assertTrue(column.resizableProperty().get());
 569     }
 570 
 571     @Test public void resizableCanBeSpecified() {
 572         column.setResizable(false);
 573         assertFalse(column.isResizable());
 574         assertFalse(column.resizableProperty().get());
 575     }
 576 
 577     @Test public void resizablePropertyBeanIsCorrect() {
 578         assertSame(column, column.resizableProperty().getBean());
 579     }
 580 
 581     @Test public void resizablePropertyNameIsCorrect() {
 582         assertEquals("resizable", column.resizableProperty().getName());
 583     }
 584 
 585     @Test public void resizableCanBeBound() {
 586         BooleanProperty other = new SimpleBooleanProperty(false);
 587         column.resizableProperty().bind(other);
 588         assertFalse(column.isResizable());
 589         assertFalse(column.resizableProperty().get());
 590         other.set(true);
 591         assertTrue(column.isResizable());
 592         assertTrue(column.resizableProperty().get());
 593     }
 594 
 595     /*********************************************************************
 596      * Tests for the sortable property                                   *
 597      ********************************************************************/
 598 
 599     @Test public void sortableIsTrueByDefault() {
 600         assertTrue(column.isSortable());
 601         assertTrue(column.sortableProperty().get());
 602     }
 603 
 604     @Test public void sortableCanBeSpecified() {
 605         column.setSortable(false);
 606         assertFalse(column.isSortable());
 607         assertFalse(column.sortableProperty().get());
 608     }
 609 
 610     @Test public void sortablePropertyBeanIsCorrect() {
 611         assertSame(column, column.sortableProperty().getBean());
 612     }
 613 
 614     @Test public void sortablePropertyNameIsCorrect() {
 615         assertEquals("sortable", column.sortableProperty().getName());
 616     }
 617 
 618     @Test public void sortableCanBeBound() {
 619         BooleanProperty other = new SimpleBooleanProperty(false);
 620         column.sortableProperty().bind(other);
 621         assertFalse(column.isSortable());
 622         assertFalse(column.sortableProperty().get());
 623         other.set(true);
 624         assertTrue(column.isSortable());
 625         assertTrue(column.sortableProperty().get());
 626     }
 627 
 628     /*********************************************************************
 629      * Tests for the sortType property                                   *
 630      ********************************************************************/
 631 
 632     @Test public void sortTypeIsASCENDINGByDefault() {
 633         assertSame(TreeTableColumn.SortType.ASCENDING, column.getSortType());
 634         assertSame(TreeTableColumn.SortType.ASCENDING, column.sortTypeProperty().get());
 635     }
 636 
 637     @Test public void sortTypeCanBeSpecified() {
 638         column.setSortType(TreeTableColumn.SortType.DESCENDING);
 639         assertSame(TreeTableColumn.SortType.DESCENDING, column.getSortType());
 640         assertSame(TreeTableColumn.SortType.DESCENDING, column.sortTypeProperty().get());
 641     }
 642 
 643     @Test public void sortTypeCanBeNull() {
 644         column.setSortType(null);
 645         assertNull(column.getSortType());
 646         assertNull(column.sortTypeProperty().get());
 647     }
 648 
 649     @Test public void sortTypePropertyBeanIsCorrect() {
 650         assertSame(column, column.sortTypeProperty().getBean());
 651     }
 652 
 653     @Test public void sortTypePropertyNameIsCorrect() {
 654         assertEquals("sortType", column.sortTypeProperty().getName());
 655     }
 656 
 657     @Test public void sortTypeCanBeBound() {
 658         ObjectProperty<TreeTableColumn.SortType> other =
 659                 new SimpleObjectProperty<TreeTableColumn.SortType>(TreeTableColumn.SortType.DESCENDING);
 660         column.sortTypeProperty().bind(other);
 661         assertSame(TreeTableColumn.SortType.DESCENDING, column.getSortType());
 662         assertSame(TreeTableColumn.SortType.DESCENDING, column.sortTypeProperty().get());
 663         other.set(null);
 664         assertNull(column.getSortType());
 665         assertNull(column.sortTypeProperty().get());
 666     }
 667 
 668     /*********************************************************************
 669      * Tests for the editable property                                   *
 670      ********************************************************************/
 671 
 672     @Test public void editableIsTrueByDefault() {
 673         assertTrue(column.isEditable());
 674         assertTrue(column.editableProperty().get());
 675     }
 676 
 677     @Test public void editableCanBeSpecified() {
 678         column.setEditable(false);
 679         assertFalse(column.isEditable());
 680         assertFalse(column.editableProperty().get());
 681     }
 682 
 683     @Test public void editablePropertyBeanIsCorrect() {
 684         assertSame(column, column.editableProperty().getBean());
 685     }
 686 
 687     @Test public void editablePropertyNameIsCorrect() {
 688         assertEquals("editable", column.editableProperty().getName());
 689     }
 690 
 691     @Test public void editableCanBeBound() {
 692         BooleanProperty other = new SimpleBooleanProperty(false);
 693         column.editableProperty().bind(other);
 694         assertFalse(column.isEditable());
 695         assertFalse(column.editableProperty().get());
 696         other.set(true);
 697         assertTrue(column.isEditable());
 698         assertTrue(column.editableProperty().get());
 699     }
 700 
 701     /*********************************************************************
 702      * Tests for the reorderable property                                *
 703      ********************************************************************/
 704 
 705     @Test public void reorderableIsTrueByDefault() {
 706         assertTrue(column.impl_isReorderable());
 707         assertTrue(column.impl_reorderableProperty().get());
 708     }
 709 
 710     @Test public void reorderableCanBeSpecified() {
 711         column.impl_setReorderable(false);
 712         assertFalse(column.impl_isReorderable());
 713         assertFalse(column.impl_reorderableProperty().get());
 714     }
 715 
 716     @Test public void reorderablePropertyBeanIsCorrect() {
 717         assertSame(column, column.impl_reorderableProperty().getBean());
 718     }
 719 
 720     @Test public void reorderablePropertyNameIsCorrect() {
 721         assertEquals("reorderable", column.impl_reorderableProperty().getName());
 722     }
 723 
 724     @Test public void reorderableCanBeBound() {
 725         BooleanProperty other = new SimpleBooleanProperty(false);
 726         column.impl_reorderableProperty().bind(other);
 727         assertFalse(column.impl_isReorderable());
 728         assertFalse(column.impl_reorderableProperty().get());
 729         other.set(true);
 730         assertTrue(column.impl_isReorderable());
 731         assertTrue(column.impl_reorderableProperty().get());
 732     }
 733 
 734     /*********************************************************************
 735      * Tests for the comparator property                                 *
 736      ********************************************************************/
 737 
 738     @Test public void comparatorCanBeSpecified() {
 739         Comparator<String> comparator = (o1, o2) -> o1.compareTo(o2);
 740         column.setComparator(comparator);
 741         assertSame(comparator, column.getComparator());
 742         assertSame(comparator, column.comparatorProperty().get());
 743     }
 744 
 745     @Test public void comparatorCanBeResetToNull() {
 746         Comparator<String> comparator = (o1, o2) -> o1.compareTo(o2);
 747         column.setComparator(comparator);
 748         column.setComparator(null);
 749         assertNull(column.getComparator());
 750         assertNull(column.comparatorProperty().get());
 751     }
 752 
 753     @Test public void comparatorPropertyBeanIsCorrect() {
 754         assertSame(column, column.comparatorProperty().getBean());
 755     }
 756 
 757     @Test public void comparatorPropertyNameIsCorrect() {
 758         assertEquals("comparator", column.comparatorProperty().getName());
 759     }
 760 
 761     @Test public void comparatorCanBeBound() {
 762         Comparator<String> comparator = (o1, o2) -> o1.compareTo(o2);
 763         ObjectProperty<Comparator<String>> other =
 764                 new SimpleObjectProperty<Comparator<String>>(comparator);
 765         column.comparatorProperty().bind(other);
 766         assertSame(comparator, column.getComparator());
 767         assertSame(comparator, column.comparatorProperty().get());
 768         other.set(null);
 769         assertNull(column.getComparator());
 770         assertNull(column.comparatorProperty().get());
 771     }
 772 
 773     /*********************************************************************
 774      * Tests for the onEditStart property                                *
 775      ********************************************************************/
 776 
 777     @Test public void onEditStartIsNullByDefault() {
 778         assertNull(column.getOnEditStart());
 779         assertNull(column.onEditStartProperty().get());
 780     }
 781 
 782     @Test public void onEditStartCanBeSpecified() {
 783         EventHandler<TreeTableColumn.CellEditEvent<Person,String>> handler =
 784                 event -> {
 785                 };
 786         column.setOnEditStart(handler);
 787         assertSame(handler, column.getOnEditStart());
 788         assertSame(handler, column.onEditStartProperty().get());
 789     }
 790 
 791     @Test public void onEditStartCanBeResetToNull() {
 792         EventHandler<TreeTableColumn.CellEditEvent<Person,String>> handler =
 793                 event -> {
 794                 };
 795         column.setOnEditStart(handler);
 796         column.setOnEditStart(null);
 797         assertNull(column.getOnEditStart());
 798         assertNull(column.onEditStartProperty().get());
 799     }
 800 
 801     @Test public void onEditStartPropertyBeanIsCorrect() {
 802         assertSame(column, column.onEditStartProperty().getBean());
 803     }
 804 
 805     @Test public void onEditStartPropertyNameIsCorrect() {
 806         assertEquals("onEditStart", column.onEditStartProperty().getName());
 807     }
 808 
 809     @Test public void onEditStartCanBeBound() {
 810         EventHandler<TreeTableColumn.CellEditEvent<Person,String>> handler =
 811                 event -> {
 812                 };
 813         ObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<Person,String>>> other =
 814                 new SimpleObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<Person, String>>>(handler);
 815         column.onEditStartProperty().bind(other);
 816         assertSame(handler, column.getOnEditStart());
 817         assertSame(handler, column.onEditStartProperty().get());
 818         other.set(null);
 819         assertNull(column.getOnEditStart());
 820         assertNull(column.onEditStartProperty().get());
 821     }
 822 
 823     /*********************************************************************
 824      * Tests for the onEditCancel property                               *
 825      ********************************************************************/
 826 
 827     @Test public void onEditCancelIsNullByDefault() {
 828         assertNull(column.getOnEditCancel());
 829         assertNull(column.onEditCancelProperty().get());
 830     }
 831 
 832     @Test public void onEditCancelCanBeSpecified() {
 833         EventHandler<TreeTableColumn.CellEditEvent<Person,String>> handler =
 834                 event -> {
 835                 };
 836         column.setOnEditCancel(handler);
 837         assertSame(handler, column.getOnEditCancel());
 838         assertSame(handler, column.onEditCancelProperty().get());
 839     }
 840 
 841     @Test public void onEditCancelCanBeResetToNull() {
 842         EventHandler<TreeTableColumn.CellEditEvent<Person,String>> handler =
 843                 event -> {
 844                 };
 845         column.setOnEditCancel(handler);
 846         column.setOnEditCancel(null);
 847         assertNull(column.getOnEditCancel());
 848         assertNull(column.onEditCancelProperty().get());
 849     }
 850 
 851     @Test public void onEditCancelPropertyBeanIsCorrect() {
 852         assertSame(column, column.onEditCancelProperty().getBean());
 853     }
 854 
 855     @Test public void onEditCancelPropertyNameIsCorrect() {
 856         assertEquals("onEditCancel", column.onEditCancelProperty().getName());
 857     }
 858 
 859     @Test public void onEditCancelCanBeBound() {
 860         EventHandler<TreeTableColumn.CellEditEvent<Person,String>> handler =
 861                 event -> {
 862                 };
 863         ObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<Person,String>>> other =
 864                 new SimpleObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<Person, String>>>(handler);
 865         column.onEditCancelProperty().bind(other);
 866         assertSame(handler, column.getOnEditCancel());
 867         assertSame(handler, column.onEditCancelProperty().get());
 868         other.set(null);
 869         assertNull(column.getOnEditCancel());
 870         assertNull(column.onEditCancelProperty().get());
 871     }
 872 
 873     /*********************************************************************
 874      * Tests for the onEditCommit property                               *
 875      ********************************************************************/
 876 
 877 //    @Test public void onEditCommitIsNullByDefault() {
 878 //        assertNull(column.getOnEditCommit());
 879 //        assertNull(column.onEditCommitProperty().get());
 880 //    }
 881 
 882     @Test public void onEditCommitCanBeSpecified() {
 883         EventHandler<TreeTableColumn.CellEditEvent<Person,String>> handler =
 884                 event -> {
 885                 };
 886         column.setOnEditCommit(handler);
 887         assertSame(handler, column.getOnEditCommit());
 888         assertSame(handler, column.onEditCommitProperty().get());
 889     }
 890 
 891     @Test public void onEditCommitCanBeResetToNull() {
 892         EventHandler<TreeTableColumn.CellEditEvent<Person,String>> handler =
 893                 event -> {
 894                 };
 895         column.setOnEditCommit(handler);
 896         column.setOnEditCommit(null);
 897         assertNull(column.getOnEditCommit());
 898         assertNull(column.onEditCommitProperty().get());
 899     }
 900 
 901     @Test public void onEditCommitPropertyBeanIsCorrect() {
 902         assertSame(column, column.onEditCommitProperty().getBean());
 903     }
 904 
 905     @Test public void onEditCommitPropertyNameIsCorrect() {
 906         assertEquals("onEditCommit", column.onEditCommitProperty().getName());
 907     }
 908 
 909     @Test public void onEditCommitCanBeBound() {
 910         EventHandler<TreeTableColumn.CellEditEvent<Person,String>> handler =
 911                 event -> {
 912                 };
 913         ObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<Person,String>>> other =
 914                 new SimpleObjectProperty<EventHandler<TreeTableColumn.CellEditEvent<Person, String>>>(handler);
 915         column.onEditCommitProperty().bind(other);
 916         assertSame(handler, column.getOnEditCommit());
 917         assertSame(handler, column.onEditCommitProperty().get());
 918         other.set(null);
 919         assertNull(column.getOnEditCommit());
 920         assertNull(column.onEditCommitProperty().get());
 921     }
 922 
 923     /*********************************************************************
 924      * Tests for getCellData                                             *
 925      ********************************************************************/
 926 
 927     @Test public void getCellDataReturnsNullWhenTableViewIsNull() {
 928         assertNull(column.getCellData(0));
 929     }
 930 
 931 //    @Test public void getCellDataReturnsNullWhenTableViewIsNull2() {
 932 //        assertNull(column.getCellData(table.getItems().get(1)));
 933 //    }
 934 //
 935 //    @Test public void getCellDataReturnsNullWhenTableViewItemsIsNull() {
 936 //        table.getColumns().add(column);
 937 //        table.setItems(null);
 938 //        assertNull(column.getCellData(0));
 939 //    }
 940 //
 941 //    @Test public void getCellDataReturnsNullWhenTableViewItemsIsNull2() {
 942 //        final Person person = table.getItems().get(1);
 943 //        table.getColumns().add(column);
 944 //        table.setItems(null);
 945 //        assertNull(column.getCellData(person));
 946 //    }
 947 //
 948 //    @Test public void getCellDataReturnsNullWhenRowDataIsNullByDefault() {
 949 //        table.getColumns().add(column);
 950 //        table.getItems().set(0, null);
 951 //        assertNull(column.getCellData(0));
 952 //    }
 953 
 954     @Test public void getCellDataReturnsNullWhenRowDataIsNullByDefault2() {
 955         table.getColumns().add(column);
 956         assertNull(column.getCellData(null));
 957     }
 958 
 959     @Test public void getCellDataReturnsNullWhenIndexIsNegative() {
 960         table.getColumns().add(column);
 961         assertNull(column.getCellData(-1));
 962     }
 963 
 964 //    @Test public void getCellDataReturnsNullWhenIndexIsTooLarge() {
 965 //        table.getColumns().add(column);
 966 //        assertNull(column.getCellData(table.getItems().size()));
 967 //    }
 968 
 969     @Test public void getCellDataReturnsNullWhenCellValueFactoryIsNull() {
 970         table.getColumns().add(column);
 971         assertNull(column.getCellData(0));
 972     }
 973 
 974 //    @Test public void getCellDataReturnsNullWhenCellValueFactoryIsNull2() {
 975 //        table.getColumns().add(column);
 976 //        assertNull(column.getCellData(table.getItems().get(1)));
 977 //    }
 978 
 979     @Test public void getCellDataReturnsValue() {
 980         table.getColumns().add(column);
 981         column.setCellValueFactory(param -> param.getValue().getValue().firstNameProperty());
 982         assertEquals("Humphrey McPhee", column.getCellData(1));
 983     }
 984 
 985 //    @Test public void getCellDataReturnsValue2() {
 986 //        table.getColumns().add(column);
 987 //        column.setCellValueFactory(new CellValueFactory<Person, String>() {
 988 //            @Override public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<Person, String> param) {
 989 //                return param.getValue().getValue().firstNameProperty();
 990 //            }
 991 //        });
 992 //        assertEquals("Humphrey McPhee", column.getCellData(table.getItems().get(0)));
 993 //    }
 994 //
 995 //    @Test public void cellDataFeaturesHasTableViewSpecified() {
 996 //        final boolean[] passed = new boolean[] { false };
 997 //        table.getColumns().add(column);
 998 //        column.setCellValueFactory(new CellValueFactory<Person, String>() {
 999 //            @Override public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<Person, String> param) {
1000 //                passed[0] = param.getTreeTableView() == table;
1001 //                return param.getValue().getValue().firstNameProperty();
1002 //            }
1003 //        });
1004 //        column.getCellData(table.getItems().get(0));
1005 //        assertTrue(passed[0]);
1006 //    }
1007 //
1008 //    @Test public void cellDataFeaturesHasTreeTableColumnSpecified() {
1009 //        final boolean[] passed = new boolean[] { false };
1010 //        table.getColumns().add(column);
1011 //        column.setCellValueFactory(new CellValueFactory<Person, String>() {
1012 //            @Override public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<Person, String> param) {
1013 //                passed[0] = param.getTreeTableColumn() == column;
1014 //                return param.getValue().getValue().firstNameProperty();
1015 //            }
1016 //        });
1017 //        column.getCellData(table.getItems().get(0));
1018 //        assertTrue(passed[0]);
1019 //    }
1020 //
1021 //    @Test public void cellDataFeaturesHasRowItemSpecified() {
1022 //        final boolean[] passed = new boolean[] { false };
1023 //        table.getColumns().add(column);
1024 //        column.setCellValueFactory(new CellValueFactory<Person,String>() {
1025 //            @Override public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<Person, String> param) {
1026 //                passed[0] = param.getValue() == table.getItems().get(0);
1027 //                return param.getValue().firstNameProperty();
1028 //            }
1029 //        });
1030 //        column.getCellData(table.getItems().get(0));
1031 //        assertTrue(passed[0]);
1032 //    }
1033 
1034     /*********************************************************************
1035      * Tests for the DEFAULT_EDIT_COMMIT_HANDLER. By default each        *
1036      * TreeTableColumn has a DEFAULT_EDIT_COMMIT_HANDLER installed which     *
1037      * will, if the value returned by cellValueFactory is a              *
1038      * WritableValue, commit. If not, then nothing happens.              *
1039      ********************************************************************/
1040 
1041     @Test public void onEditCommitHandlerInstalledByDefault() {
1042         assertNotNull(column.getOnEditCommit());
1043     }
1044 
1045 //    @Test public void defaultOnEditCommitHandlerWillSaveToWritableValue() {
1046 //        table.getColumns().add(column);
1047 //        column.setCellValueFactory(new CellValueFactory<Person, String>() {
1048 //            @Override public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<Person, String> param) {
1049 //                return param.getValue().getValue().firstNameProperty();
1050 //            }
1051 //        });
1052 //        TreeTablePosition<Person,String> pos = new TreeTablePosition<Person, String>(table, 0, column);
1053 //        EventType<TreeTableColumn.CellEditEvent<Person,String>> eventType = TreeTableColumn.editCommitEvent();
1054 //        column.getOnEditCommit().handle(new TreeTableColumn.CellEditEvent<Person,String>(
1055 //                table, pos, (EventType)eventType, "Richard Bair"));
1056 //        assertEquals("Richard Bair", table.getItems().get(0).getName());
1057 //    }
1058 //
1059 //    @Test public void defaultOnEditCommitHandlerWillIgnoreReadOnlyValue() {
1060 //        TreeTableColumn<Person,Number> ageColumn = new TreeTableColumn<Person,Number>();
1061 //        table.getColumns().add(ageColumn);
1062 //        ageColumn.setCellValueFactory(new CellValueFactory<Person, Number>() {
1063 //            @Override public ObservableValue<Number> call(TreeTableColumn.CellDataFeatures<Person, Number> param) {
1064 //                return param.getValue().getValue().ageProperty();
1065 //            }
1066 //        });
1067 //        TreeTablePosition<Person,Number> pos = new TreeTablePosition<Person, Number>(table, 0, ageColumn);
1068 //        EventType<TreeTableColumn.CellEditEvent<Person,Number>> eventType = TreeTableColumn.editCommitEvent();
1069 //        ageColumn.getOnEditCommit().handle(new TreeTableColumn.CellEditEvent<Person,Number>(
1070 //                table, pos, (EventType)eventType, 109));
1071 //        assertEquals(76, table.getItems().get(0).getAge());
1072 //    }
1073 
1074     @Test(expected=NullPointerException.class)
1075     public void defaultOnEditCommitHandlerDealsWithNullTableView() {
1076         table.getColumns().add(column);
1077         column.setCellValueFactory(param -> param.getValue().getValue().firstNameProperty());
1078         TreeTablePosition<Person,String> pos = new TreeTablePosition<Person, String>(table, 0, column);
1079         EventType<TreeTableColumn.CellEditEvent<Person,String>> eventType = TreeTableColumn.editCommitEvent();
1080         column.getOnEditCommit().handle(new TreeTableColumn.CellEditEvent<Person, String>(
1081                 null, pos, (EventType) eventType, "Richard Bair"));
1082     }
1083 
1084     @Test(expected=NullPointerException.class)
1085     public void defaultOnEditCommitHandlerDealsWithNullTablePosition() {
1086         table.getColumns().add(column);
1087         column.setCellValueFactory(param -> param.getValue().getValue().firstNameProperty());
1088         TreeTablePosition<Person,String> pos = new TreeTablePosition<Person, String>(table, 0, column);
1089         EventType<TreeTableColumn.CellEditEvent<Person,String>> eventType = TreeTableColumn.editCommitEvent();
1090         column.getOnEditCommit().handle(new TreeTableColumn.CellEditEvent<Person, String>(
1091                 table, null, (EventType) eventType, "Richard Bair"));
1092     }
1093 //
1094 //    @Test public void defaultOnEditCommitHandlerDealsWithInvalidTablePosition_indexIsNegative() {
1095 //        table.getColumns().add(column);
1096 //        column.setCellValueFactory(new CellValueFactory<Person, String>() {
1097 //            @Override public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<Person, String> param) {
1098 //                return param.getValue().getValue().firstNameProperty();
1099 //            }
1100 //        });
1101 //        TreeTablePosition<Person,String> pos = new TreeTablePosition<Person, String>(table, -1, column);
1102 //        EventType<TreeTableColumn.CellEditEvent<Person,String>> eventType = TreeTableColumn.editCommitEvent();
1103 //        column.getOnEditCommit().handle(new TreeTableColumn.CellEditEvent<Person,String>(
1104 //                table, pos, (EventType)eventType, "Richard Bair"));
1105 //        assertEquals("Humphrey McPhee", table.getItems().get(0).getName());
1106 //    }
1107 //
1108 //    @Test public void defaultOnEditCommitHandlerDealsWithInvalidTablePosition_indexIsTooLarge() {
1109 //        table.getColumns().add(column);
1110 //        column.setCellValueFactory(new CellValueFactory<Person, String>() {
1111 //            @Override public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<Person, String> param) {
1112 //                return param.getValue().getValue().firstNameProperty();
1113 //            }
1114 //        });
1115 //        TreeTablePosition<Person,String> pos = new TreeTablePosition<Person, String>(table, 100, column);
1116 //        EventType<TreeTableColumn.CellEditEvent<Person,String>> eventType = TreeTableColumn.editCommitEvent();
1117 //        column.getOnEditCommit().handle(new TreeTableColumn.CellEditEvent<Person, String>(
1118 //                table, pos, (EventType) eventType, "Richard Bair"));
1119 //        assertEquals("Humphrey McPhee", table.getItems().get(0).getName());
1120 //    }
1121 
1122     /*********************************************************************
1123      * Tests for the default comparator                                  *
1124      ********************************************************************/
1125 
1126     @Test public void sortingWithNullItems() {
1127         List<String> items = Arrays.asList("Hippo", null, "Fish", "Eagle", null);
1128         Collections.sort(items, TreeTableColumn.DEFAULT_COMPARATOR);
1129         assertNull(items.get(0));
1130         assertNull(items.get(1));
1131         assertEquals("Eagle", items.get(2));
1132         assertEquals("Fish", items.get(3));
1133         assertEquals("Hippo", items.get(4));
1134     }
1135 
1136     @Test public void sortingWithSameItems() {
1137         List<String> items = Arrays.asList("Hippo", "Hippo", "Fish", "Eagle", "Fish");
1138         Collections.sort(items, TreeTableColumn.DEFAULT_COMPARATOR);
1139         assertEquals("Eagle", items.get(0));
1140         assertEquals("Fish", items.get(1));
1141         assertEquals("Fish", items.get(2));
1142         assertEquals("Hippo", items.get(3));
1143         assertEquals("Hippo", items.get(4));
1144     }
1145 
1146     @Test public void sortingWithNonComparableItemsSortsByToString() {
1147         Person fred = new Person("Fred", 36);
1148         Person wilma = new Person("Wilma", 34);
1149         Person barney = new Person("Barney", 34);
1150         List<Person> items = Arrays.asList(fred, wilma, barney);
1151         Collections.sort(items, TreeTableColumn.DEFAULT_COMPARATOR);
1152         assertSame(barney, items.get(0));
1153         assertSame(fred, items.get(1));
1154         assertSame(wilma, items.get(2));
1155     }
1156 
1157     @Ignore("This started failing when I upgraded to Java 7")
1158     @Test public void sortingMixOfComparableAndNonComparable() {
1159         Person fred = new Person("Fred", 36);
1160         Person wilma = new Person("Wilma", 34);
1161         Person barney = new Person("Barney", 34);
1162         List<Object> items = Arrays.asList(fred, wilma, barney, "Pebbles");
1163         Collections.sort(items, TreeTableColumn.DEFAULT_COMPARATOR);
1164         assertSame(barney, items.get(0));
1165         assertSame(fred, items.get(1));
1166         assertEquals("Pebbles", items.get(2));
1167         assertSame(wilma, items.get(3));
1168     }
1169 
1170     /*********************************************************************
1171      * Tests for the default cell factory                                *
1172      ********************************************************************/
1173 
1174     @Test public void defaultCellFactoryHasNullTextByDefault() {
1175         table.getColumns().add(column);
1176         TreeTableCell<Person,String> cell = column.getCellFactory().call(column);
1177         assertNull(cell.getText());
1178     }
1179 
1180     @Test public void defaultCellFactoryHasNullGraphicByDefault() {
1181         table.getColumns().add(column);
1182         TreeTableCell<Person,String> cell = column.getCellFactory().call(column);
1183         assertNull(cell.getGraphic());
1184     }
1185 
1186 //    @Test public void defaultCellFactorySetsTextToNameWhenItemIsPerson() {
1187 //        table.getColumns().add(column);
1188 //        TreeTableCell<Person,String> cell = column.getCellFactory().call(column);
1189 //        cell.updateIndex(0);
1190 //        cell.updateItem(table.getItems().get(0).getName(), false);
1191 //        assertEquals(table.getItems().get(0).getName(), cell.getText());
1192 //    }
1193 //
1194 //    @Test public void defaultCellFactorySetsTextToNullWhenItemIsNull() {
1195 //        table.getColumns().add(column);
1196 //        TreeTableCell<Person,String> cell = column.getCellFactory().call(column);
1197 //        // First have to set to a value, or it short-cuts
1198 //        cell.updateIndex(0);
1199 //        cell.updateItem(table.getItems().get(0).getName(), false);
1200 //        // Now we're good to go
1201 //        table.getItems().set(0, null);
1202 //        cell.updateItem(null, false);
1203 //        assertNull(cell.getText());
1204 //    }
1205 //
1206 //    @Test public void defaultCellFactorySetsGraphicToNullWhenItemIsPerson() {
1207 //        table.getColumns().add(column);
1208 //        TreeTableCell<Person,String> cell = column.getCellFactory().call(column);
1209 //        cell.updateIndex(0);
1210 //        cell.updateItem(table.getItems().get(0).getName(), false);
1211 //        assertNull(cell.getGraphic());
1212 //    }
1213 //
1214 //    @Test public void defaultCellFactorySetsGraphicToNullWhenItemIsNull() {
1215 //        table.getColumns().add(column);
1216 //        TreeTableCell<Person,String> cell = column.getCellFactory().call(column);
1217 //        table.getItems().set(0, null);
1218 //        cell.updateIndex(0);
1219 //        cell.updateItem(null, false);
1220 //        assertNull(cell.getGraphic());
1221 //    }
1222 
1223     @Test public void defaultCellFactorySetsGraphicToItemWhenItemIsNode() {
1224         TreeTableView<Node> nodeTable = new TreeTableView<Node>();
1225         Rectangle rect = new Rectangle();
1226         nodeTable.setRoot(new TreeItem<Node>(rect));
1227         TreeTableColumn<Node,Node> nodeColumn = new TreeTableColumn<Node,Node>();
1228         nodeTable.getColumns().add(nodeColumn);
1229         TreeTableCell<Node,Node> cell = nodeColumn.getCellFactory().call(nodeColumn);
1230         cell.updateIndex(0);
1231         cell.updateItem(rect, false);
1232         assertSame(rect, cell.getGraphic());
1233     }
1234 
1235     @Test public void defaultCellFactorySetsTextToNullWhenItemIsNode() {
1236         TreeTableView<Node> nodeTable = new TreeTableView<Node>();
1237         Rectangle rect = new Rectangle();
1238         nodeTable.setRoot(new TreeItem<Node>(rect));
1239         TreeTableColumn<Node,Node> nodeColumn = new TreeTableColumn<Node,Node>();
1240         nodeTable.getColumns().add(nodeColumn);
1241         TreeTableCell<Node,Node> cell = nodeColumn.getCellFactory().call(nodeColumn);
1242         cell.updateIndex(0);
1243         cell.updateItem(rect, false);
1244         assertNull(cell.getText());
1245     }
1246 
1247     @Test public void test_rt36715_idIsNullAtStartup() {
1248         assertNull(column.getId());
1249     }
1250 
1251     @Test public void test_rt36715_idIsSettable() {
1252         column.setId("test-id");
1253         assertEquals("test-id", column.getId());
1254     }
1255 
1256     @Test public void test_rt36715_columnHeaderIdMirrorsTableColumnId_setIdBeforeHeaderInstantiation() {
1257         test_rt36715_columnHeaderPropertiesMirrorTableColumnProperties(true, true, false, false);
1258     }
1259 
1260     @Test public void test_rt36715_columnHeaderIdMirrorsTableColumnId_setIdAfterHeaderInstantiation() {
1261         test_rt36715_columnHeaderPropertiesMirrorTableColumnProperties(true, false, false, false);
1262     }
1263 
1264     @Test public void test_rt36715_styleIsEmptyStringAtStartup() {
1265         assertEquals("", column.getStyle());
1266     }
1267 
1268     @Test public void test_rt36715_styleIsSettable() {
1269         column.setStyle("-fx-border-color: red");
1270         assertEquals("-fx-border-color: red", column.getStyle());
1271     }
1272 
1273     @Test public void test_rt36715_columnHeaderStyleMirrorsTableColumnStyle_setStyleBeforeHeaderInstantiation() {
1274         test_rt36715_columnHeaderPropertiesMirrorTableColumnProperties(false, false, true, true);
1275     }
1276 
1277     @Test public void test_rt36715_columnHeaderStyleMirrorsTableColumnStyle_setStyleAfterHeaderInstantiation() {
1278         test_rt36715_columnHeaderPropertiesMirrorTableColumnProperties(false, false, true, false);
1279     }
1280 
1281     private void test_rt36715_columnHeaderPropertiesMirrorTableColumnProperties(
1282             boolean setId, boolean setIdBeforeHeaderInstantiation,
1283             boolean setStyle, boolean setStyleBeforeHeaderInstantiation) {
1284         table.getColumns().add(column);
1285 
1286         if (setId && setIdBeforeHeaderInstantiation) {
1287             column.setId("test-id");
1288         }
1289         if (setStyle && setStyleBeforeHeaderInstantiation) {
1290             column.setStyle("-fx-border-color: red");
1291         }
1292 
1293         StageLoader sl = new StageLoader(table);
1294         TableColumnHeader header = VirtualFlowTestUtils.getTableColumnHeader(table, column);
1295 
1296         if (setId && ! setIdBeforeHeaderInstantiation) {
1297             column.setId("test-id");
1298         }
1299         if (setStyle && ! setStyleBeforeHeaderInstantiation) {
1300             column.setStyle("-fx-border-color: red");
1301         }
1302 
1303         if (setId) {
1304             assertEquals("test-id", header.getId());
1305         }
1306         if (setStyle) {
1307             assertEquals("-fx-border-color: red", header.getStyle());
1308         }
1309 
1310         sl.dispose();
1311     }
1312     
1313 
1314 
1315 
1316     public interface CellValueFactory<S,T> extends Callback<TreeTableColumn.CellDataFeatures<S,T>, ObservableValue<T>> {
1317     }
1318 
1319     public interface CellFactory<S,T> extends Callback<TreeTableColumn<S,T>, TreeTableCell<S,T>> {
1320     }
1321 }