< prev index next >

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

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -1091,6 +1091,41 @@
         assertEquals(1, selectionChangeCount);
 
         tabPane.getTabs().remove(t2);
     }
 
+    // Test for JDK-8193495
+    @Test public void testQuickRemoveAddTab() {
+        int tabHeaderMinWidth = 200;
+        int tabHeaderMinHeight = 50;
+        tabPane.setMaxSize(400, 200);
+        tabPane.setTabMinWidth(tabHeaderMinWidth);
+        tabPane.setTabMinHeight(tabHeaderMinHeight);
+        tabPane.getTabs().addAll(tab1, tab2, tab3);
+        tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
+
+        root.getChildren().add(tabPane);
+        show();
+        tabPane.requestFocus();
+        tk.firePulse();
+        assertTrue(tabPane.isFocused());
+
+        tabPane.getTabs().add(1, tabPane.getTabs().remove(0));
+        tk.firePulse();
+        tabPane.getSelectionModel().select(tab1);
+        tk.firePulse();
+
+        double xval = (tabPane.localToScene(tabPane.getLayoutBounds())).getMinX();
+        double yval = (tabPane.localToScene(tabPane.getLayoutBounds())).getMinY();
+
+        SceneHelper.processMouseEvent(scene,
+            MouseEventGenerator.generateMouseEvent(MouseEvent.MOUSE_PRESSED, xval + 19, yval + 17));
+        tk.firePulse();
+        SceneHelper.processMouseEvent(scene,
+            MouseEventGenerator.generateMouseEvent(MouseEvent.MOUSE_PRESSED, xval + 19, yval + 17));
+        tk.firePulse();
+
+        assertEquals("Tabpane should have 3 tabs.", 3, tabPane.getTabs().size());
+        assertEquals("tab2 should be at index 0.", tab2, tabPane.getSelectionModel().getSelectedItem());
+    }
+
 }
< prev index next >