< prev index next >

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

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

@@ -33,10 +33,11 @@
 import javafx.scene.input.KeyCode;
 import java.util.List;
 import com.sun.javafx.PlatformUtil;
 import com.sun.javafx.util.Utils;
 import com.sun.javafx.scene.control.behavior.TreeViewAnchorRetriever;
+import com.sun.javafx.scene.control.infrastructure.ControlTestUtils;
 import com.sun.javafx.scene.control.infrastructure.KeyEventFirer;
 import com.sun.javafx.scene.control.infrastructure.KeyModifier;
 import com.sun.javafx.scene.control.infrastructure.StageLoader;
 import com.sun.javafx.scene.control.infrastructure.VirtualFlowTestUtils;
 import com.sun.javafx.tk.Toolkit;

@@ -2190,15 +2191,10 @@
         assertTrue(sm.isSelected(4));
         assertFalse(sm.isSelected(5));
     }
 
     @Test public void test_rt36800() {
-        // get the current exception handler before replacing with our own,
-        // as ListListenerHelp intercepts the exception otherwise
-        final Thread.UncaughtExceptionHandler exceptionHandler = Thread.currentThread().getUncaughtExceptionHandler();
-        Thread.currentThread().setUncaughtExceptionHandler((t, e) -> fail("We don't expect any exceptions in this test!"));
-
         final int items = 10;
         root.getChildren().clear();
         root.setExpanded(true);
         for (int i = 0; i < items; i++) {
             root.getChildren().add(new TreeItem<>("Row " + i));

@@ -2214,23 +2210,26 @@
         keyboard.doKeyPress(KeyCode.UP, KeyModifier.SHIFT); // 4
         keyboard.doKeyPress(KeyCode.UP, KeyModifier.SHIFT); // 3
         keyboard.doKeyPress(KeyCode.UP, KeyModifier.SHIFT); // 2
         keyboard.doKeyPress(KeyCode.UP, KeyModifier.SHIFT); // 1
         keyboard.doKeyPress(KeyCode.UP, KeyModifier.SHIFT); // 0
+
+        final Thread.UncaughtExceptionHandler exceptionHandler = ControlTestUtils.setHandler();
+        try {
         keyboard.doKeyPress(KeyCode.UP, KeyModifier.SHIFT); // bug time?
+        } finally {
+            ControlTestUtils.resetHandler(exceptionHandler);
+        }
 
         assertEquals(0, getAnchor());
         assertTrue(fm.isFocused(0));
         assertTrue(sm.isSelected(0));
         assertFalse(sm.isSelected(1));
         assertFalse(sm.isSelected(2));
         assertFalse(sm.isSelected(3));
         assertFalse(sm.isSelected(4));
         assertFalse(sm.isSelected(5));
-
-        // reset the exception handler
-        Thread.currentThread().setUncaughtExceptionHandler(exceptionHandler);
     }
 
     @Test public void test_rt_37130_pageUpAtTop() {
         final int items = 100;
         root.getChildren().clear();
< prev index next >