< prev index next >

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

Print this page
rev 8906 : RT-46083: TimelineClipCore exceptions handling improvent


   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 static org.junit.Assert.assertEquals;
  29 import static org.junit.Assert.assertFalse;
  30 import static org.junit.Assert.assertNotNull;
  31 import static org.junit.Assert.assertNull;
  32 import static org.junit.Assert.assertSame;
  33 import static org.junit.Assert.assertTrue;
  34 import static org.junit.Assert.fail;
  35 
  36 import java.util.*;
  37 
  38 import com.sun.javafx.scene.control.infrastructure.StageLoader;
  39 import javafx.collections.FXCollections;
  40 import javafx.collections.ListChangeListener;
  41 import javafx.collections.ObservableList;
  42 import javafx.scene.control.ListView.ListViewFocusModel;
  43 import javafx.scene.control.TableView.TableViewFocusModel;
  44 import javafx.scene.control.TableView.TableViewSelectionModel;
  45 import javafx.scene.control.TreeTableView.TreeTableViewFocusModel;
  46 import javafx.scene.control.TreeTableView.TreeTableViewSelectionModel;
  47 import javafx.scene.control.TreeView.TreeViewFocusModel;


1153     @Ignore
1154     @Test public void test_rt38884_invalidChange() {
1155         model.select(3);
1156         int removedSize = model.getSelectedItems().size();
1157         ListChangeListener l = (ListChangeListener.Change c) -> {
1158             c.next();
1159             assertEquals(removedSize, c.getRemovedSize());
1160         };
1161         model.getSelectedItems().addListener(l);
1162         clearModelData();
1163     }
1164 
1165     private void clearModelData() {
1166         listView.getItems().clear();
1167         tableView.getItems().clear();
1168         treeView.setRoot(null);
1169         treeTableView.setRoot(null);
1170     }
1171 
1172     @Test public void test_rt40804() {
1173         final Thread.UncaughtExceptionHandler exceptionHandler = Thread.currentThread().getUncaughtExceptionHandler();
1174         Thread.currentThread().setUncaughtExceptionHandler((t, e) -> {
1175             e.printStackTrace();
1176             fail("We don't expect any exceptions in this test!");
1177         });
1178 
1179         StageLoader sl = new StageLoader(currentControl);
1180         model.setSelectionMode(SelectionMode.MULTIPLE);
1181         model.select(0);
1182         model.select(1);
1183         model.clearSelection();


1184         model.select(3); // this is where the test failed



1185 
1186         sl.dispose();
1187 
1188         // reset the exception handler
1189         Thread.currentThread().setUncaughtExceptionHandler(exceptionHandler);
1190     }
1191 }


   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.ControlTestUtils;
  29 import static org.junit.Assert.assertEquals;
  30 import static org.junit.Assert.assertFalse;
  31 import static org.junit.Assert.assertNotNull;
  32 import static org.junit.Assert.assertNull;
  33 import static org.junit.Assert.assertSame;
  34 import static org.junit.Assert.assertTrue;
  35 import static org.junit.Assert.fail;
  36 
  37 import java.util.*;
  38 
  39 import com.sun.javafx.scene.control.infrastructure.StageLoader;
  40 import javafx.collections.FXCollections;
  41 import javafx.collections.ListChangeListener;
  42 import javafx.collections.ObservableList;
  43 import javafx.scene.control.ListView.ListViewFocusModel;
  44 import javafx.scene.control.TableView.TableViewFocusModel;
  45 import javafx.scene.control.TableView.TableViewSelectionModel;
  46 import javafx.scene.control.TreeTableView.TreeTableViewFocusModel;
  47 import javafx.scene.control.TreeTableView.TreeTableViewSelectionModel;
  48 import javafx.scene.control.TreeView.TreeViewFocusModel;


1154     @Ignore
1155     @Test public void test_rt38884_invalidChange() {
1156         model.select(3);
1157         int removedSize = model.getSelectedItems().size();
1158         ListChangeListener l = (ListChangeListener.Change c) -> {
1159             c.next();
1160             assertEquals(removedSize, c.getRemovedSize());
1161         };
1162         model.getSelectedItems().addListener(l);
1163         clearModelData();
1164     }
1165 
1166     private void clearModelData() {
1167         listView.getItems().clear();
1168         tableView.getItems().clear();
1169         treeView.setRoot(null);
1170         treeTableView.setRoot(null);
1171     }
1172 
1173     @Test public void test_rt40804() {






1174         StageLoader sl = new StageLoader(currentControl);
1175         model.setSelectionMode(SelectionMode.MULTIPLE);
1176         model.select(0);
1177         model.select(1);
1178         model.clearSelection();
1179         final Thread.UncaughtExceptionHandler exceptionHandler = ControlTestUtils.setHandler();
1180         try {
1181             model.select(3); // this is where the test failed
1182         } finally {
1183             ControlTestUtils.resetHandler(exceptionHandler);
1184         }
1185 
1186         sl.dispose();



1187     }
1188 }
< prev index next >