1 /*
2 * Copyright (c) 2010, 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
1074 tk.firePulse();
1075 assertTrue(tabPane.isFocused());
1076
1077 tabPane.getSelectionModel().select(t1);
1078
1079 double xval = (tabPane.localToScene(tabPane.getLayoutBounds())).getMinX();
1080 double yval = (tabPane.localToScene(tabPane.getLayoutBounds())).getMinY();
1081
1082 SceneHelper.processMouseEvent(scene,
1083 MouseEventGenerator.generateMouseEvent(MouseEvent.MOUSE_PRESSED, xval + 19, yval + 17));
1084 tk.firePulse();
1085 SceneHelper.processMouseEvent(scene,
1086 MouseEventGenerator.generateMouseEvent(MouseEvent.MOUSE_RELEASED, xval + 19, yval + 17));
1087 tk.firePulse();
1088
1089 assertEquals(1, tabPane.getTabs().size());
1090 assertEquals(t2, tabPane.getSelectionModel().getSelectedItem());
1091 assertEquals(1, selectionChangeCount);
1092
1093 tabPane.getTabs().remove(t2);
1094 }
1095
1096 }
|
1 /*
2 * Copyright (c) 2010, 2018, 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
1074 tk.firePulse();
1075 assertTrue(tabPane.isFocused());
1076
1077 tabPane.getSelectionModel().select(t1);
1078
1079 double xval = (tabPane.localToScene(tabPane.getLayoutBounds())).getMinX();
1080 double yval = (tabPane.localToScene(tabPane.getLayoutBounds())).getMinY();
1081
1082 SceneHelper.processMouseEvent(scene,
1083 MouseEventGenerator.generateMouseEvent(MouseEvent.MOUSE_PRESSED, xval + 19, yval + 17));
1084 tk.firePulse();
1085 SceneHelper.processMouseEvent(scene,
1086 MouseEventGenerator.generateMouseEvent(MouseEvent.MOUSE_RELEASED, xval + 19, yval + 17));
1087 tk.firePulse();
1088
1089 assertEquals(1, tabPane.getTabs().size());
1090 assertEquals(t2, tabPane.getSelectionModel().getSelectedItem());
1091 assertEquals(1, selectionChangeCount);
1092
1093 tabPane.getTabs().remove(t2);
1094 }
1095
1096 // Test for JDK-8193495
1097 @Test public void testQuickRemoveAddTab() {
1098 int tabHeaderMinWidth = 200;
1099 int tabHeaderMinHeight = 50;
1100 tabPane.setMaxSize(400, 200);
1101 tabPane.setTabMinWidth(tabHeaderMinWidth);
1102 tabPane.setTabMinHeight(tabHeaderMinHeight);
1103 tabPane.getTabs().addAll(tab1, tab2, tab3);
1104 tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
1105
1106 root.getChildren().add(tabPane);
1107 show();
1108 tabPane.requestFocus();
1109 tk.firePulse();
1110 assertTrue(tabPane.isFocused());
1111
1112 tabPane.getTabs().add(1, tabPane.getTabs().remove(0));
1113 tk.firePulse();
1114 tabPane.getSelectionModel().select(tab1);
1115 tk.firePulse();
1116
1117 double xval = (tabPane.localToScene(tabPane.getLayoutBounds())).getMinX();
1118 double yval = (tabPane.localToScene(tabPane.getLayoutBounds())).getMinY();
1119
1120 SceneHelper.processMouseEvent(scene,
1121 MouseEventGenerator.generateMouseEvent(MouseEvent.MOUSE_PRESSED, xval + 19, yval + 17));
1122 tk.firePulse();
1123 SceneHelper.processMouseEvent(scene,
1124 MouseEventGenerator.generateMouseEvent(MouseEvent.MOUSE_PRESSED, xval + 19, yval + 17));
1125 tk.firePulse();
1126
1127 assertEquals("Tabpane should have 3 tabs.", 3, tabPane.getTabs().size());
1128 assertEquals("tab2 should be at index 0.", tab2, tabPane.getSelectionModel().getSelectedItem());
1129 }
1130
1131 }
|