--- old/modules/javafx.controls/src/test/java/test/javafx/scene/control/TabPaneTest.java 2018-01-13 04:04:18.869488712 +0530 +++ new/modules/javafx.controls/src/test/java/test/javafx/scene/control/TabPaneTest.java 2018-01-13 04:04:18.525488712 +0530 @@ -1,5 +1,5 @@ /* - * 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 @@ -1093,4 +1093,39 @@ 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()); + } + }