< prev index next >

modules/javafx.controls/src/test/java/test/javafx/scene/control/ListCellTest.java

Print this page
rev 10463 : 8089514: [TableView, TreeView, ListView, TreeTableView] Clicking outside of the edited cell, node, or entry should commit the value
   1 /*
   2  * Copyright (c) 2011, 2016, 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


 615         cell.updateIndex(1);
 616         cell.startEdit();
 617         final boolean[] called = new boolean[] { false };
 618         list.setOnEditCancel(event -> {
 619             called[0] = true;
 620         });
 621         cell.cancelEdit();
 622         assertTrue(called[0]);
 623     }
 624 
 625     @Test public void cancelSetsListViewEditingIndexToNegativeOne() {
 626         list.setEditable(true);
 627         cell.updateListView(list);
 628         cell.updateIndex(1);
 629         cell.startEdit();
 630         cell.cancelEdit();
 631         assertEquals(-1, list.getEditingIndex());
 632         assertFalse(cell.isEditing());
 633     }
 634 

 635     @Test public void movingListCellEditingIndexCausesCurrentlyInEditCellToCancel() {
 636         list.setEditable(true);
 637         cell.updateListView(list);
 638         cell.updateIndex(0);
 639         cell.startEdit();
 640 
 641         ListCell other = new ListCell();
 642         other.updateListView(list);
 643         other.updateIndex(1);
 644         list.edit(1);
 645 
 646         assertTrue(other.isEditing());
 647         assertFalse(cell.isEditing());
 648     }
 649 
 650     // When the list view item's change and affects a cell that is editing, then what?
 651     // When the list cell's index is changed while it is editing, then what?
 652 
 653 
 654     private final class SelectionModelMock extends MultipleSelectionModelBaseShim<String> {


   1 /*
   2  * Copyright (c) 2011, 2017, 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


 615         cell.updateIndex(1);
 616         cell.startEdit();
 617         final boolean[] called = new boolean[] { false };
 618         list.setOnEditCancel(event -> {
 619             called[0] = true;
 620         });
 621         cell.cancelEdit();
 622         assertTrue(called[0]);
 623     }
 624 
 625     @Test public void cancelSetsListViewEditingIndexToNegativeOne() {
 626         list.setEditable(true);
 627         cell.updateListView(list);
 628         cell.updateIndex(1);
 629         cell.startEdit();
 630         cell.cancelEdit();
 631         assertEquals(-1, list.getEditingIndex());
 632         assertFalse(cell.isEditing());
 633     }
 634 
 635     @Ignore
 636     @Test public void movingListCellEditingIndexCausesCurrentlyInEditCellToCancel() {
 637         list.setEditable(true);
 638         cell.updateListView(list);
 639         cell.updateIndex(0);
 640         cell.startEdit();
 641 
 642         ListCell other = new ListCell();
 643         other.updateListView(list);
 644         other.updateIndex(1);
 645         list.edit(1);
 646 
 647         assertTrue(other.isEditing());
 648         assertFalse(cell.isEditing());
 649     }
 650 
 651     // When the list view item's change and affects a cell that is editing, then what?
 652     // When the list cell's index is changed while it is editing, then what?
 653 
 654 
 655     private final class SelectionModelMock extends MultipleSelectionModelBaseShim<String> {


< prev index next >