|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
70 | 70 | * 3.2 tab[1] is the first tab in tab header.
|
71 | 71 | * 3.3 Pressing RIGHT key should select tabs in order: tab 4,3,2,0
|
72 | 72 | *
|
| 73 | + * b1. testPermuteGetTabsWithMoreTabs1() |
| 74 | + * 1. Add tabs 0,1 |
| 75 | + * 2. Permute tabs to tab 0,1,2,3 using TabPane.getTabs().setAll(). |
| 76 | + * 3. Verify that, |
| 77 | + * 3.1 tab[1] should remain selected tab. |
| 78 | + * 3.2 tab[0] is the first tab in tab header. |
| 79 | + * 3.3 Pressing RIGHT key should select tabs in order: tab 1,2,3 |
| 80 | + * |
73 | 81 | * c. testPermuteGetTabsWithLessTabs()
|
74 | 82 | * 1. Add tab 3,1 and some(6) more tabs, and select tab 1.
|
75 | 83 | * 2. Permute tabs to, tab 1,4,3,2 using TabPane.getTabs().setAll().
|
@@ -181,6 +189,59 @@ public void testPermuteGetTabsWithMoreTabs() {
|
181 | 189 | }
|
182 | 190 | }
|
183 | 191 |
|
| 192 | + // Test for JDK-8237602 |
| 193 | + @Test |
| 194 | + public void testAddingNewTabsWithExistingTabsAtSameIndex() { |
| 195 | + // Step #1 |
| 196 | + Util.runAndWait(() -> { |
| 197 | + tabPane.getTabs().setAll(tab[0], tab[1]); |
| 198 | + tabPane.getSelectionModel().select(tab[1]); |
| 199 | + }); |
| 200 | + delay(); |
| 201 | + |
| 202 | + Assert.assertSame("Sanity: tab[1] should be the selected tab.", |
| 203 | + tab[1], tabPane.getSelectionModel().getSelectedItem()); |
| 204 | + |
| 205 | + // Step #2 |
| 206 | + Util.runAndWait(() -> { |
| 207 | + tabPane.getTabs().setAll(tab[0], tab[1], tab[2], tab[3]); |
| 208 | + }); |
| 209 | + delay(); |
| 210 | + |
| 211 | + // Step #3.1 |
| 212 | + Assert.assertSame("Sanity: tab[1] should remain selected tab after permuting.", |
| 213 | + tab[1], tabPane.getSelectionModel().getSelectedItem()); |
| 214 | + |
| 215 | + // Step #3.2 |
| 216 | + // Click on first tab header |
| 217 | + selectionLatch[0] = new CountDownLatch(1); |
| 218 | + Util.runAndWait(() -> { |
| 219 | + robot.mouseMove((int) (scene.getWindow().getX() + scene.getX() + firstTabdXY), |
| 220 | + (int) (scene.getWindow().getY() + scene.getY() + firstTabdXY)); |
| 221 | + robot.mousePress(MouseButton.PRIMARY); |
| 222 | + robot.mouseRelease(MouseButton.PRIMARY); |
| 223 | + }); |
| 224 | + delay(); |
| 225 | + |
| 226 | + waitForLatch(selectionLatch[0], 5, |
| 227 | + "Timeout: Waiting for tab[" + 0 + "] to get selected."); |
| 228 | + Assert.assertSame("tab[0] should be first tab after permuting.", |
| 229 | + tab[0], tabPane.getSelectionModel().getSelectedItem()); |
| 230 | + |
| 231 | + // step #3.3 |
| 232 | + selectionLatch[1] = new CountDownLatch(1); |
| 233 | + for (int i = 1; i <= 3; i++) { |
| 234 | + Util.runAndWait(() -> { |
| 235 | + robot.keyPress(KeyCode.RIGHT); |
| 236 | + robot.keyRelease(KeyCode.RIGHT); |
| 237 | + }); |
| 238 | + waitForLatch(selectionLatch[i], 5, |
| 239 | + "Timeout: Waiting for tab[" + i + "] to get selected."); |
| 240 | + Assert.assertSame("tab[" + i + "] should get selected on RIGHT key press.", |
| 241 | + tab[i], tabPane.getSelectionModel().getSelectedItem()); |
| 242 | + } |
| 243 | + } |
| 244 | + |
184 | 245 | @Test
|
185 | 246 | public void testPermutGetTabsWithLessTabs() {
|
186 | 247 | // Step #1
|
|
0 commit comments