1 /* 2 * Copyright (c) 2014, 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 23 * questions. 24 */ 25 package javafx.scene.control.test.ListView; 26 27 import client.test.ScreenshotCheck; 28 import client.test.Smoke; 29 import javafx.collections.ObservableList; 30 import javafx.commons.SortValidator; 31 import javafx.event.EventHandler; 32 import javafx.geometry.Orientation; 33 import javafx.scene.Node; 34 import javafx.scene.control.ListCell; 35 import javafx.scene.control.ListView; 36 import javafx.scene.control.ScrollBar; 37 import javafx.scene.control.SelectionMode; 38 import javafx.scene.control.test.util.MultipleSelectionHelper; 39 import javafx.scene.control.test.util.ScrollingChecker; 40 import javafx.scene.control.test.utils.ptables.AbstractPropertyController.SettingType; 41 import javafx.scene.input.KeyCode; 42 import javafx.scene.input.KeyEvent; 43 import javafx.scene.input.MouseEvent; 44 import javafx.scene.text.Text; 45 import javafx.util.StringConverter; 46 import org.jemmy.Rectangle; 47 import org.jemmy.action.GetAction; 48 import org.jemmy.control.Wrap; 49 import org.jemmy.fx.Root; 50 import org.jemmy.interfaces.Keyboard.KeyboardButtons; 51 import org.jemmy.interfaces.Keyboard.KeyboardModifiers; 52 import org.jemmy.interfaces.Mouse; 53 import org.jemmy.interfaces.Parent; 54 import org.jemmy.interfaces.Showable; 55 import org.jemmy.lookup.Lookup; 56 import org.jemmy.lookup.LookupCriteria; 57 import org.jemmy.timing.State; 58 import org.junit.After; 59 import static org.junit.Assert.assertFalse; 60 import static org.junit.Assert.assertTrue; 61 import org.junit.Before; 62 import org.junit.Test; 63 import org.junit.runner.RunWith; 64 import test.javaclient.shared.FilteredTestRunner; 65 import test.javaclient.shared.Utils; 66 67 /** 68 * @author Alexander Kirov 69 */ 70 @RunWith(FilteredTestRunner.class) 71 public class NewListViewTest extends TestBase { 72 73 static StringBuilder sb = new StringBuilder(); 74 75 @Before 76 @Override 77 public void setUp() { 78 super.setUp(); 79 80 new GetAction<Object>() { 81 @Override 82 public void run(Object... os) throws Exception { 83 ListView list = (ListView) testedControl.getControl(); 84 list.addEventFilter(KeyEvent.KEY_RELEASED, new EventHandler<javafx.scene.input.KeyEvent>() { 85 public void handle(javafx.scene.input.KeyEvent event) { 86 if (event.getCode() == KeyCode.CONTROL) return; 87 if (event.getCode() == KeyCode.ALT) return; 88 if (event.getCode() == KeyCode.SHIFT) return; 89 90 if (event.isAltDown()) sb.append("ALT + "); 91 if (event.isControlDown()) sb.append("CTRL + "); 92 if (event.isShiftDown()) sb.append("SHIFT + "); 93 94 sb.append(event.getCode()).append("\n"); 95 } 96 }); 97 } 98 }.dispatch(testedControl.getEnvironment()); 99 100 new GetAction<Object>() { 101 @Override 102 public void run(Object... os) throws Exception { 103 ListView list = (ListView) testedControl.getControl(); 104 list.addEventFilter(MouseEvent.ANY, new EventHandler<MouseEvent>() { 105 public void handle(MouseEvent event) { 106 sb.append("mouse ").append(event.getButton()).append("\n"); 107 } 108 }); 109 } 110 }.dispatch(testedControl.getEnvironment()); 111 } 112 113 @After 114 public void _after() { 115 String newLine = "\n"; 116 int currIndex = sb.indexOf(newLine); 117 int prevIndex = 0; 118 119 int counter = 1; 120 String prevLine = null; 121 122 StringBuilder rolledUpResult = new StringBuilder(); 123 while(currIndex > 0) { 124 String currLine = sb.substring(prevIndex, currIndex); 125 if (prevLine == null) { 126 prevLine = currLine; 127 } else if (prevLine.equals(currLine)) { 128 ++counter; 129 } else { 130 rolledUpResult.append(prevLine); 131 if (counter > 1) rolledUpResult.append(" x").append(counter); 132 rolledUpResult.append(newLine); 133 counter = 1; 134 prevLine = currLine; 135 } 136 prevIndex = currIndex + 1; 137 currIndex = sb.indexOf(newLine, prevIndex); 138 if (currIndex == sb.length() - 1) { 139 rolledUpResult.append(sb.substring(prevIndex)); 140 break; 141 } 142 } 143 System.out.println("Key sequence:"); 144 System.out.println(rolledUpResult.toString()); 145 sb = new StringBuilder(); 146 } 147 148 //SECTION OF TESTS ON PROPERTIES 149 @Smoke 150 @Test(timeout = 300000) 151 public void editablePropertyTest() { 152 setPropertyByToggleClick(SettingType.BIDIRECTIONAL, Properties.editable); 153 checkTextFieldText(Properties.editable, "true"); 154 155 clickToggleButton("BIDIR_EDITABLE_CONTROLLER_ID"); 156 checkTextFieldText(Properties.editable, "false"); 157 158 setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, Properties.editable); 159 checkTextFieldText(Properties.editable, "true"); 160 161 clickToggleButton("UNIDIR_EDITABLE_CONTROLLER_ID"); 162 checkTextFieldText(Properties.editable, "false"); 163 } 164 165 @Smoke 166 @Test(timeout = 300000) 167 public void orientationPropertyTest() { 168 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.VERTICAL, Properties.orientation); 169 checkTextFieldText(Properties.orientation, "VERTICAL"); 170 171 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation); 172 checkTextFieldText(Properties.orientation, "HORIZONTAL"); 173 174 setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, Orientation.VERTICAL, Properties.orientation); 175 checkTextFieldText(Properties.orientation, "VERTICAL"); 176 177 setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation); 178 checkTextFieldText(Properties.orientation, "HORIZONTAL"); 179 } 180 181 @Smoke 182 @Test(timeout = 300000) 183 public void selectionModePropertyTest() { 184 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 185 checkTextFieldText(Properties.selectionMode, "MULTIPLE"); 186 187 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.SINGLE, Properties.selectionMode); 188 checkTextFieldText(Properties.selectionMode, "SINGLE"); 189 190 setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 191 checkTextFieldText(Properties.selectionMode, "MULTIPLE"); 192 193 setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, SelectionMode.SINGLE, Properties.selectionMode); 194 checkTextFieldText(Properties.selectionMode, "SINGLE"); 195 } 196 197 @Smoke 198 @Test(timeout = 300000) 199 public void prefHeightPropertyTest() throws InterruptedException { 200 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 200); 201 checkTextFieldValue(Properties.prefHeight, 200); 202 203 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 100); 204 checkTextFieldValue(Properties.prefHeight, 100); 205 206 setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefHeight, 150); 207 checkTextFieldValue(Properties.prefHeight, 150); 208 209 setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefHeight, 50); 210 checkTextFieldValue(Properties.prefHeight, 50); 211 } 212 213 @Smoke 214 @Test(timeout = 300000) 215 public void prefWidthPropertyTest() throws InterruptedException { 216 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 200); 217 checkTextFieldValue(Properties.prefWidth, 200); 218 219 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 100); 220 checkTextFieldValue(Properties.prefWidth, 100); 221 222 setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefWidth, 150); 223 checkTextFieldValue(Properties.prefWidth, 150); 224 225 setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefWidth, 50); 226 checkTextFieldValue(Properties.prefWidth, 50); 227 } 228 229 // SITUATIONAL TESTS 230 @Smoke 231 @Test(timeout = 300000) 232 public void keyboardRangeMultipleSelection2Test() throws Throwable { 233 addElements(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); 234 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 235 KeyboardButtons CTRL_OS = Utils.isMacOS() ? KeyboardButtons.META : KeyboardButtons.CONTROL; 236 237 selectionHelper = new MultipleSelectionHelper(1, DATA_ITEMS_NUM); 238 selectionHelper.setMultiple(true); 239 240 requestFocusOnControl(testedControl); 241 242 testedControl.keyboard().pressKey(KeyboardButtons.SHIFT); 243 try { 244 for (int i = 1; i < 5; i++) { 245 testedControl.keyboard().pushKey(KeyboardButtons.DOWN); 246 selectionHelper.push(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 247 checkSelection(); 248 } 249 } finally { 250 testedControl.keyboard().releaseKey(KeyboardButtons.SHIFT); 251 } 252 253 testedControl.keyboard().pressKey(CTRL_OS); 254 try { 255 for (int i = 1; i < 5; i++) { 256 testedControl.keyboard().pushKey(KeyboardButtons.DOWN); 257 selectionHelper.push(KeyboardButtons.DOWN, CTRL_DOWN_MASK_OS); 258 checkSelection(); 259 } 260 } finally { 261 testedControl.keyboard().releaseKey(CTRL_OS); 262 } 263 264 testedControl.keyboard().pressKey(KeyboardButtons.SHIFT); 265 try { 266 for (int i = 1; i < 5; i++) { 267 testedControl.keyboard().pushKey(KeyboardButtons.UP); 268 selectionHelper.push(KeyboardButtons.UP, KeyboardModifiers.SHIFT_DOWN_MASK); 269 checkSelection(); 270 } 271 } finally { 272 testedControl.keyboard().releaseKey(KeyboardButtons.SHIFT); 273 } 274 275 testedControl.keyboard().pressKey(CTRL_OS); 276 try { 277 for (int i = 1; i < 5; i++) { 278 testedControl.keyboard().pushKey(KeyboardButtons.UP); 279 selectionHelper.push(KeyboardButtons.UP, CTRL_DOWN_MASK_OS); 280 checkSelection(); 281 } 282 } finally { 283 testedControl.keyboard().releaseKey(CTRL_OS); 284 } 285 } 286 287 @Smoke 288 @Test(timeout = 300000) 289 public void scrollToTest() throws InterruptedException { 290 int size = 10; 291 292 for (int i = 0; i <= size; i++) { 293 addElement(String.valueOf(i), i); 294 } 295 296 setSize(50, 50); 297 for (Orientation orientation : Orientation.values()) { 298 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, orientation, Properties.orientation); 299 300 scrollTo(size); 301 checkScrollingState(1, false, true, size, orientation); 302 303 scrollTo(0); 304 checkScrollingState(0, true, false, size, orientation); 305 306 scrollTo(size * 2); 307 checkScrollingState(1, false, true, size, orientation); 308 309 scrollTo(-size); 310 checkScrollingState(0, true, false, size, orientation); 311 } 312 } 313 314 private void checkScrollingState(final double scrollValue, boolean beginVisible, boolean endVisible, int size, final Orientation orientation) { 315 //assertEquals(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), orientation, true).getControl().getValue(), scrollValue, 0.01); 316 testedControl.waitState(new State() { 317 public Object reached() { 318 Wrap<? extends ScrollBar> sb = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), orientation, true); 319 if (Math.abs(sb.getControl().getValue() - scrollValue) < 0.01) { 320 return true; 321 } else { 322 return null; 323 } 324 } 325 }); 326 327 if (beginVisible) { 328 assertTrue(isCellShown(0, orientation)); 329 } 330 if (endVisible) { 331 assertTrue(isCellShown(size, orientation)); 332 } 333 } 334 335 private boolean isCellShown(final int item, Orientation orientation) { 336 Wrap<Text> cellWrap = getCellWrap(item); 337 Rectangle cellRect = cellWrap.getScreenBounds(); 338 Rectangle control = testedControl.getScreenBounds(); 339 340 // int epsilon = 0; 341 // 342 // if (orientation == Orientation.HORIZONTAL) { 343 // control.x = control.x - epsilon; 344 // control.width = control.width + 2 * epsilon; 345 // } else { 346 // control.y = control.y - epsilon; 347 // control.height = control.height + 2 * epsilon; 348 // } 349 350 return control.contains(cellRect); 351 } 352 353 @Smoke 354 @Test(timeout = 30000) 355 public void fixedCellSizePropertyTest() throws InterruptedException { 356 adjustControl(); 357 fixedCellSizePropertyTestCommon(testedControl, Properties.fixedCellSize, Utils.isCaspian() ? 19.4 : 21); 358 } 359 360 @Smoke 361 @Test(timeout = 30000) 362 public void fixedCellSizePropertyCSSTest() { 363 adjustControl(); 364 fixedCellSizePropertyCSSTestCommon(testedControl, Properties.fixedCellSize, Utils.isCaspian() ? 19.4 : 21); 365 } 366 367 @Smoke 368 @Test(timeout = 300000) 369 public void verticalScrollBarBehaviorOnAddingDeletingTest() throws InterruptedException { 370 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 50); 371 assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, false) == null); 372 addElements(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); 373 assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true) == null); 374 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 500); 375 assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, false) == null); 376 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 50); 377 for (int i = 0; i < 10; i++) { 378 removeFromPos(0); 379 } 380 assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, false) == null); 381 } 382 383 //Test//RT-17538//Test removed, as non actual (bug - is not a bug). 384 public void steadyScrollingTest() throws InterruptedException { 385 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 150); 386 387 addRectangleAtPos(0); 388 addTextFieldAtPos(1); 389 addRectangleAtPos(2); 390 391 Wrap<? extends ScrollBar> sb = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true); 392 ScrollingChecker sc = new ScrollingChecker(sb.getControl().valueProperty()); 393 testedControl.mouse().move(); 394 for (int i = 0; i < 8; i++) { 395 findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(+1); 396 sc.checkChanging(+1); 397 } 398 } 399 400 @Smoke 401 @Test(timeout = 300000) 402 public void scrollAppearingOnResizingTest() throws InterruptedException { 403 setSize(50, 50); 404 checkScrollbarsStates(false, false); 405 406 addRectangleAtPos(0); 407 408 checkScrollbarsStates(true, true); 409 410 setSize(230, 50); 411 checkScrollbarsStates(false, true); 412 413 setSize(50, 225); 414 checkScrollbarsStates(true, false); 415 416 setSize(230, 230); 417 checkScrollbarsStates(false, false); 418 419 setSize(50, 50); 420 checkScrollbarsStates(true, true); 421 422 removeFromPos(0); 423 424 checkScrollbarsStates(false, false); 425 } 426 427 @Smoke 428 @Test(timeout = 300000) 429 public void scrollBarAppearingSensitivityTest() throws InterruptedException { 430 addRectangleAtPos(0); 431 432 setSize(208, 208); 433 checkScrollbarsStates(true, true); 434 435 setSize(225, 225); 436 checkScrollbarsStates(false, false); 437 } 438 439 @Smoke 440 @Test(timeout = 300000)//RT-18293 441 public void eventsCommingTest() throws InterruptedException { 442 addFormAtPos(0); 443 444 setSize(200, 200); 445 446 clickFormButton(); 447 checkFormClickCounter(1); 448 scrollFormScrollBar(-1); 449 checkFormScrollCounter(1); 450 } 451 452 //Test//RT-17701// Test removed, because developers don't want to count size of content, to evaluate scrollBar size propertly. 453 public void scrollBarSize1Test() throws InterruptedException, Throwable { 454 setSize(150, 150); 455 addRectangleAtPos(0); 456 addRectangleAtPos(0); 457 addTextFieldAtPos(1); 458 459 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation); 460 461 checkScreenshot("ListView_scrollBarSize1Test_HorizontalScroll_1", findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true)); 462 checkScreenshot("ListView_scrollBarSize1Test_VerticalScroll_1", findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true)); 463 throwScreenshotError(); 464 } 465 466 @ScreenshotCheck 467 @Test(timeout = 300000) //RT-17460 468 public void scrollBarSize2Test() throws InterruptedException, Throwable { 469 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation); 470 setSize(200, 210); 471 472 addRectangleAtPos(0); 473 addRectangleAtPos(0); 474 checkScreenshot("ListView_HorizontalScroll_2", findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true)); 475 throwScreenshotError(); 476 } 477 478 @Smoke 479 @Test(timeout = 300000) //RT-17462 480 public void scrollBarDisappearTest() throws InterruptedException { 481 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation); 482 setSize(210, 210); 483 484 addRectangleAtPos(0); 485 addRectangleAtPos(0); 486 487 for (int i = 0; i < 100; i++) { 488 findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(+1); 489 } 490 491 assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true) == null); 492 } 493 494 @ScreenshotCheck 495 @Smoke 496 @Test(timeout = 300000)//RT-17465 497 public void selectionSavingTest() throws InterruptedException, Throwable { 498 setSize(100, 100); 499 addRectangleAtPos(0); 500 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation); 501 testedControl.mouse().click(); 502 503 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.VERTICAL, Properties.orientation); 504 checkScreenshot("ListView_SelectionSavingChecking", testedControl); 505 506 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation); 507 checkScreenshot("ListView_SelectionSavingChecking", testedControl); 508 509 throwScreenshotError(); 510 } 511 512 @ScreenshotCheck 513 @Test(timeout = 300000)//RT-17705 514 public void scrollingConfused1Test() throws InterruptedException, Throwable { 515 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation); 516 setSize(150, 150); 517 addRectangleAtPos(0); 518 int scroll_value = Utils.isMacOS() ? -20 : +20; 519 findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(scroll_value); 520 521 findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(scroll_value); 522 523 checkScreenshot("ListView_ScrollingIssue_1", testedControl); 524 throwScreenshotError(); 525 } 526 527 @ScreenshotCheck 528 @Test(timeout = 300000)//RT-17730 529 public void scrollingConfused2Test() throws InterruptedException, Throwable { 530 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.VERTICAL, Properties.orientation); 531 setSize(150, 150); 532 addRectangleAtPos(0); 533 Thread.sleep(500); 534 535 for (int i = 0; i < 20; i++) { 536 findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(+1); 537 } 538 539 for (int i = 0; i < 20; i++) { 540 findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(+1); 541 } 542 543 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation); 544 findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(+20); 545 checkScreenshot("ListView_ScrollingIssue_2", testedControl); 546 throwScreenshotError(); 547 } 548 549 @ScreenshotCheck 550 @Test(timeout = 300000)//RT-17733 551 public void scrollingConfused3Test() throws Throwable { 552 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.VERTICAL, Properties.orientation); 553 setSize(150, 150); 554 addRectangleAtPos(0); 555 556 findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(+20); 557 findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(+20); 558 checkScreenshot("ListView_ScrollingIssue_3", testedControl); 559 throwScreenshotError(); 560 } 561 562 @Smoke 563 @Test(timeout = 300000)//RT-17522 564 public void addingElementOnFocusPositionTest() { 565 addElements(1, 2, 3, 4, 5, 6, 7); 566 testedControl.mouse().click(); 567 568 testedControl.keyboard().pushKey(KeyboardButtons.DOWN); 569 testedControl.keyboard().pushKey(KeyboardButtons.DOWN); 570 571 checkListener(Listeners.focusedIndex, 2); 572 addElement("0", 0); 573 checkListener(Listeners.focusedIndex, 3); 574 addElement("0", 2); 575 checkListener(Listeners.focusedIndex, 4); 576 addElement("0", 4); 577 checkListener(Listeners.focusedIndex, 5); 578 } 579 580 //Test//RT-17539//Test removed because developers don't count size of content. 581 public void knobSizeChangingTest() throws InterruptedException, Throwable { 582 setSize(150, 150); 583 584 addTextFieldAtPos(0); 585 addRectangleAtPos(1); 586 addElement("0", 2); 587 588 checkScreenshot("ListView_ScrollBarKnobSizeIssue_1", testedControl); 589 590 for (int i = 0; i < 20; i++) { 591 findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(+1); 592 } 593 594 checkScreenshot("ListView_ScrollBarKnobSizeIssue_2", testedControl); 595 596 findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(+10); 597 598 checkScreenshot("ListView_ScrollBarKnobSizeIssue_3", testedControl); 599 throwScreenshotError(); 600 } 601 602 @Smoke 603 @Test(timeout = 300000)//RT-18234 - possible 604 public void singleSelectionOnKeyBoardTest() throws InterruptedException, Throwable { 605 addElements(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); 606 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 607 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.SINGLE, Properties.selectionMode); 608 setSize(130, 130); 609 610 selectionHelper = new MultipleSelectionHelper(1, DATA_ITEMS_NUM); 611 selectionHelper.setSingleCell(false); 612 selectionHelper.setMultiple(false); 613 614 requestFocusOnControl(testedControl); 615 616 //Testing section 617 try { 618 for (int i = 0; i < 5; i++) { 619 testedControl.keyboard().pushKey(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 620 selectionHelper.push(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 621 checkSelection(); 622 } 623 624 for (int i = 0; i < 3; i++) { 625 testedControl.keyboard().pushKey(KeyboardButtons.UP, CTRL_DOWN_MASK_OS); 626 selectionHelper.push(KeyboardButtons.UP, CTRL_DOWN_MASK_OS); 627 checkSelection(); 628 } 629 630 testedControl.keyboard().pushKey(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 631 testedControl.keyboard().releaseKey(KeyboardButtons.SHIFT); 632 selectionHelper.push(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 633 checkSelection(); 634 // End of testing section 635 } catch (Throwable error) { 636 throw error; 637 } 638 } 639 640 @Smoke 641 @Test(timeout = 300000) 642 public void multipleSelectionCommonLogicOnKeyBoardTest() throws InterruptedException, Throwable { 643 addElements(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); 644 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.SINGLE, Properties.selectionMode); 645 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 646 setSize(130, 130); 647 648 selectionHelper = new MultipleSelectionHelper(1, 10); 649 selectionHelper.setSingleCell(false); 650 selectionHelper.setMultiple(true); 651 652 requestFocusOnControl(testedControl); 653 654 //Testing section 655 try { 656 for (int i = 0; i < 2; i++) { 657 testedControl.keyboard().pushKey(KeyboardButtons.DOWN); 658 selectionHelper.push(KeyboardButtons.DOWN); 659 } 660 661 for (int i = 0; i < 5; i++) { 662 testedControl.keyboard().pushKey(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 663 selectionHelper.push(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 664 checkSelection(); 665 } 666 //Elements from 2 to 7 are selected 667 668 for (int i = 0; i < 2; i++) { 669 testedControl.keyboard().pushKey(KeyboardButtons.DOWN, CTRL_DOWN_MASK_OS); 670 selectionHelper.push(KeyboardButtons.DOWN, CTRL_DOWN_MASK_OS); 671 checkSelection(); 672 } 673 674 for (int i = 0; i < 5; i++) { 675 testedControl.keyboard().pushKey(KeyboardButtons.UP, KeyboardModifiers.SHIFT_DOWN_MASK); 676 selectionHelper.push(KeyboardButtons.UP, KeyboardModifiers.SHIFT_DOWN_MASK); 677 checkSelection(); 678 } 679 680 for (int i = 0; i < 4; i++) { 681 testedControl.keyboard().pushKey(KeyboardButtons.UP, CTRL_DOWN_MASK_OS); 682 selectionHelper.push(KeyboardButtons.UP, CTRL_DOWN_MASK_OS); 683 checkSelection(); 684 } 685 686 for (int i = 0; i < 6; i++) { 687 testedControl.keyboard().pushKey(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 688 selectionHelper.push(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 689 checkSelection(); //RT-18234 - possible 690 } 691 692 for (int i = 0; i < 2; i++) { 693 testedControl.keyboard().pushKey(KeyboardButtons.DOWN, CTRL_DOWN_MASK_OS); 694 selectionHelper.push(KeyboardButtons.DOWN, CTRL_DOWN_MASK_OS); 695 checkSelection(); 696 } 697 698 for (int i = 0; i < 15; i++) { 699 testedControl.keyboard().pushKey(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 700 selectionHelper.push(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 701 checkSelection(); 702 } 703 // End of testing section 704 } catch (Throwable error) { 705 throw error; 706 } 707 } 708 709 @Smoke 710 @Test(timeout = 300000) 711 public void ctrlAClickSingleTest() throws InterruptedException, Throwable { 712 addElements(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); 713 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 714 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.SINGLE, Properties.selectionMode); 715 setSize(130, 130); 716 717 selectionHelper = new MultipleSelectionHelper(1, DATA_ITEMS_NUM); 718 selectionHelper.setSingleCell(false); 719 selectionHelper.setMultiple(false); 720 721 requestFocusOnControl(testedControl); 722 723 //Testing section 724 try { 725 for (int i = 0; i < 2; i++) { 726 testedControl.keyboard().pushKey(KeyboardButtons.DOWN); 727 selectionHelper.push(KeyboardButtons.DOWN); 728 } 729 730 for (int i = 0; i < 4; i++) { 731 testedControl.keyboard().pushKey(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 732 selectionHelper.push(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 733 checkSelection(); 734 } 735 //Elements from 2 to 6 are selected 736 737 for (int i = 0; i < 2; i++) { 738 testedControl.keyboard().pushKey(KeyboardButtons.DOWN, CTRL_DOWN_MASK_OS); 739 selectionHelper.push(KeyboardButtons.DOWN, CTRL_DOWN_MASK_OS); 740 checkSelection(); 741 } 742 743 testedControl.keyboard().pushKey(KeyboardButtons.A, CTRL_DOWN_MASK_OS); 744 selectionHelper.ctrlA = true; 745 currentListContentSize = 10; 746 checkSelection(); 747 checkListener(Listeners.focusedIndex, 8); 748 checkListener(Listeners.selectedIndex, 6); 749 750 // End of testing section 751 } catch (Throwable error) { 752 throw error; 753 } 754 } 755 756 @Smoke 757 @Test(timeout = 300000) 758 public void ctrlAClickMultipleTest() throws InterruptedException, Throwable { 759 addElements(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); 760 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.SINGLE, Properties.selectionMode); 761 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 762 setSize(130, 130); 763 764 selectionHelper = new MultipleSelectionHelper(1, 10); 765 selectionHelper.setSingleCell(false); 766 selectionHelper.setMultiple(true); 767 768 requestFocusOnControl(testedControl); 769 770 //Testing section 771 try { 772 for (int i = 0; i < 2; i++) { 773 testedControl.keyboard().pushKey(KeyboardButtons.DOWN); 774 selectionHelper.push(KeyboardButtons.DOWN); 775 } 776 777 for (int i = 0; i < 4; i++) { 778 testedControl.keyboard().pushKey(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 779 selectionHelper.push(KeyboardButtons.DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 780 checkSelection(); 781 } 782 //Elements from 2 to 6 are selected 783 784 for (int i = 0; i < 2; i++) { 785 testedControl.keyboard().pushKey(KeyboardButtons.DOWN, CTRL_DOWN_MASK_OS); 786 selectionHelper.push(KeyboardButtons.DOWN, CTRL_DOWN_MASK_OS); 787 checkSelection(); 788 } 789 790 testedControl.keyboard().pushKey(KeyboardButtons.A, CTRL_DOWN_MASK_OS); 791 selectionHelper.ctrlA = true; 792 currentListContentSize = 10; 793 checkSelection(); 794 checkListener(Listeners.focusedIndex, 8); 795 checkListener(Listeners.selectedIndex, 8); 796 797 // End of testing section 798 } catch (Throwable error) { 799 throw error; 800 } 801 } 802 803 @Smoke 804 @Test(timeout = 300000) 805 public void mouseClickingVerticalMultipleTest() throws InterruptedException, Throwable { 806 commonClickingTest(Orientation.VERTICAL, SelectionMode.MULTIPLE); 807 } 808 809 @Smoke 810 @Test(timeout = 300000) 811 public void mouseClickingHorizontalMultipleTest() throws InterruptedException, Throwable { 812 commonClickingTest(Orientation.HORIZONTAL, SelectionMode.MULTIPLE); 813 } 814 815 @Smoke 816 @Test(timeout = 300000) 817 public void mouseClickingVerticalSingleTest() throws InterruptedException, Throwable { 818 commonClickingTest(Orientation.VERTICAL, SelectionMode.SINGLE); 819 } 820 821 @Smoke 822 @Test(timeout = 300000) 823 public void mouseClickingHorizontalSingleTest() throws InterruptedException, Throwable { 824 commonClickingTest(Orientation.HORIZONTAL, SelectionMode.SINGLE); 825 } 826 827 protected void commonClickingTest(Orientation orientation, SelectionMode selectionMode) throws InterruptedException, Throwable { 828 setSize(130, 130); 829 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 830 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.SINGLE, Properties.selectionMode); 831 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, selectionMode, Properties.selectionMode); 832 833 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, orientation, Properties.orientation); 834 for (int i = 1; i < listItems; i++) { 835 addElement(String.valueOf(Integer.valueOf((int) Math.round(Math.pow(i, i)))), i - 1); 836 } 837 838 selectionCycle(0, listItems - 1, null, selectionMode); 839 840 localReset(); 841 842 selectionCycle(0, listItems - 1, KeyboardButtons.SHIFT, selectionMode); 843 844 localReset(); 845 846 selectionCycle(0, listItems - 1, KeyboardButtons.CONTROL, selectionMode); 847 } 848 849 @Test(timeout = 300000) 850 /** 851 * Add big amount of elements in a list and select some of the according to 852 * some rule. After that checks, whether focus is correct. 853 */ 854 public void simpleSelectionScreenShotTest() throws InterruptedException, Throwable { 855 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 200); 856 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 200); 857 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 858 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation); 859 860 final int elementsCount = 15; 861 addAndSelectElements(elementsCount); 862 863 final int step = 6; 864 checkScreenshotsWithStep("SimpleTest", elementsCount, step); 865 } 866 867 @Test(timeout = 300000)//RT-18234 - possible 868 /** 869 * Add big amount of elements in a list and select some of the according to 870 * some rules. It tries to apply different combinations of keys pushing with 871 * modifiers. A few time in process it tries to check screenshots. 872 */ 873 public void complexSelectionScreenShotTest() throws InterruptedException, Throwable { 874 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 200); 875 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 200); 876 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 877 selectionHelper.setMultiple(true); 878 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.HORIZONTAL, Properties.orientation); 879 880 final int elementsCount = 50; 881 addAndSelectElements(elementsCount); 882 final int step = 5; 883 884 for (Orientation orientation : Orientation.values()) { 885 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, orientation, Properties.orientation); 886 Wrap<Text> cellWrap = getCellWrap((Integer) (0)); //mouse will be over the second item. 887 cellWrap.as(Showable.class).shower().show(); 888 cellWrap.mouse().click(1, cellWrap.getClickPoint(), Mouse.MouseButtons.BUTTON1, CTRL_DOWN_MASK_OS); 889 selectionHelper.click(0, 0, KeyboardButtons.CONTROL); 890 checkSelection(); 891 892 KeyboardButtons lessKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.LEFT : KeyboardButtons.UP); 893 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 894 895 applyKeysPushing(2, KeyboardButtons.PAGE_DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 896 applyKeysPushing(1, KeyboardButtons.PAGE_DOWN, CTRL_DOWN_MASK_OS); 897 applyKeysPushing(2, KeyboardButtons.PAGE_UP, KeyboardModifiers.SHIFT_DOWN_MASK); 898 applyKeysPushing(1, KeyboardButtons.PAGE_UP, CTRL_DOWN_MASK_OS); 899 900 applyKeysPushing(15, moreKey, CTRL_DOWN_MASK_OS); 901 for (int i = 0; i < 10; i++) { 902 if (Utils.isMacOS()) { 903 applyKeysPushing(i, KeyboardButtons.SPACE, CTRL_DOWN_MASK_OS, KeyboardModifiers.CTRL_DOWN_MASK); 904 } else { 905 applyKeysPushing(i, KeyboardButtons.SPACE, CTRL_DOWN_MASK_OS); 906 } 907 applyKeysPushing(2, lessKey, CTRL_DOWN_MASK_OS); 908 } 909 applyKeysPushing(5, lessKey, KeyboardModifiers.SHIFT_DOWN_MASK); 910 applyKeysPushing(1, KeyboardButtons.SPACE, KeyboardModifiers.SHIFT_DOWN_MASK); 911 applyKeysPushing(2, KeyboardButtons.PAGE_DOWN, CTRL_DOWN_MASK_OS); 912 checkScreenshotsWithStep("ComlexTests_" + orientation + "_1", elementsCount, step); 913 914 applyKeysPushing(1, KeyboardButtons.HOME, CTRL_DOWN_MASK_OS); 915 applyKeysPushing(1, KeyboardButtons.END, KeyboardModifiers.SHIFT_DOWN_MASK); 916 applyKeysPushing(1, KeyboardButtons.HOME, CTRL_DOWN_MASK_OS); 917 applyKeysPushing(1, KeyboardButtons.END, CTRL_DOWN_MASK_OS); 918 applyKeysPushing(1, KeyboardButtons.HOME, KeyboardModifiers.SHIFT_DOWN_MASK); 919 920 applyKeysPushing(20, lessKey, CTRL_DOWN_MASK_OS); 921 applyKeysPushing(5, moreKey, KeyboardModifiers.SHIFT_DOWN_MASK); 922 applyKeysPushing(3, moreKey, CTRL_DOWN_MASK_OS); 923 applyKeysPushing(2, KeyboardButtons.PAGE_UP, CTRL_DOWN_MASK_OS); 924 checkScreenshotsWithStep("ComlexTests_" + orientation + "_2", elementsCount, step); 925 } 926 } 927 928 @Test(timeout = 300000) 929 public void simpleSelectionUpTest() throws InterruptedException { 930 for (Orientation orientation : Orientation.values()) { 931 prepareSelectionHelper(orientation, 20); 932 933 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 934 935 applyKeysPushing(10, moreKey, CTRL_DOWN_MASK_OS); 936 937 moveSelectUp(5, orientation); 938 939 checkMainListeners(5, 5); 940 941 resetSceneByDefault(); 942 } 943 } 944 945 @Test(timeout = 300000) 946 public void simpleSelectionDownTest() throws InterruptedException { 947 for (Orientation orientation : Orientation.values()) { 948 prepareSelectionHelper(orientation, 20); 949 950 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 951 952 applyKeysPushing(10, moreKey, CTRL_DOWN_MASK_OS); 953 954 moveSelectDown(5, orientation); 955 956 checkMainListeners(15, 15); 957 958 resetSceneByDefault(); 959 } 960 } 961 962 @Test(timeout = 300000) 963 public void simpleMoveUpTest() throws InterruptedException { 964 for (Orientation orientation : Orientation.values()) { 965 prepareSelectionHelper(orientation, 20); 966 967 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 968 969 applyKeysPushing(10, moreKey, CTRL_DOWN_MASK_OS); 970 971 moveFocusUp(5, orientation); 972 973 checkMainListeners(5, 18); 974 975 resetSceneByDefault(); 976 } 977 } 978 979 @Test(timeout = 300000) 980 public void simpleMoveDownTest() throws InterruptedException { 981 for (Orientation orientation : Orientation.values()) { 982 prepareSelectionHelper(orientation, 20); 983 984 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 985 986 applyKeysPushing(10, moreKey, CTRL_DOWN_MASK_OS); 987 988 moveFocusDown(5, orientation); 989 990 checkMainListeners(15, 18); 991 992 resetSceneByDefault(); 993 } 994 } 995 996 @Test(timeout = 300000) 997 public void simpleMovePageUpTest() throws InterruptedException { 998 for (Orientation orientation : Orientation.values()) { 999 prepareSelectionHelper(orientation, 20); 1000 selectionHelper.setPageHeight(8); 1001 selectionHelper.setPageWidth(1); 1002 1003 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1004 1005 applyKeysPushing(15, moreKey, CTRL_DOWN_MASK_OS); 1006 1007 moveFocusPageUp(1); 1008 1009 resetSceneByDefault(); 1010 } 1011 } 1012 1013 @Test(timeout = 300000) 1014 public void simpleMovePageDownTest() throws InterruptedException { 1015 for (Orientation orientation : Orientation.values()) { 1016 prepareSelectionHelper(orientation, 20); 1017 selectionHelper.setPageHeight(8); 1018 selectionHelper.setPageWidth(1); 1019 1020 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1021 1022 applyKeysPushing(5, moreKey, CTRL_DOWN_MASK_OS); 1023 1024 moveFocusPageDown(1); 1025 1026 resetSceneByDefault(); 1027 } 1028 } 1029 1030 @Test(timeout = 300000) 1031 public void simpleSelectPageUpTest() throws InterruptedException { 1032 for (Orientation orientation : Orientation.values()) { 1033 prepareSelectionHelper(orientation, 20); 1034 selectionHelper.setPageHeight(8); 1035 selectionHelper.setPageWidth(1); 1036 1037 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1038 1039 applyKeysPushing(15, moreKey, CTRL_DOWN_MASK_OS); 1040 1041 moveSelectPageUp(1); 1042 1043 resetSceneByDefault(); 1044 } 1045 } 1046 1047 @Test(timeout = 300000) 1048 public void simpleSelectPageDownTest() throws InterruptedException { 1049 for (Orientation orientation : Orientation.values()) { 1050 prepareSelectionHelper(orientation, 20); 1051 selectionHelper.setPageHeight(8); 1052 selectionHelper.setPageWidth(1); 1053 1054 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1055 1056 applyKeysPushing(5, moreKey, CTRL_DOWN_MASK_OS); 1057 1058 moveSelectPageDown(1); 1059 1060 resetSceneByDefault(); 1061 } 1062 } 1063 1064 @Test(timeout = 300000) 1065 public void simpleMoveHomeTest() throws InterruptedException { 1066 for (Orientation orientation : Orientation.values()) { 1067 prepareSelectionHelper(orientation, 20); 1068 1069 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1070 1071 applyKeysPushing(15, moreKey, CTRL_DOWN_MASK_OS); 1072 1073 moveToHome(); 1074 1075 checkMainListeners(0, 18); 1076 1077 resetSceneByDefault(); 1078 } 1079 1080 } 1081 1082 @Test(timeout = 300000) 1083 public void simpleMoveEndTest() throws InterruptedException { 1084 for (Orientation orientation : Orientation.values()) { 1085 prepareSelectionHelper(orientation, 20); 1086 1087 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1088 1089 applyKeysPushing(5, moreKey, CTRL_DOWN_MASK_OS); 1090 1091 moveToEnd(); 1092 1093 checkMainListeners(19, 18); 1094 1095 resetSceneByDefault(); 1096 } 1097 } 1098 1099 @Test(timeout = 300000)//RT-18413 1100 public void simpleSelectHomeTest() throws InterruptedException { 1101 for (Orientation orientation : Orientation.values()) { 1102 prepareSelectionHelper(orientation, 20); 1103 1104 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1105 1106 applyKeysPushing(15, moreKey, CTRL_DOWN_MASK_OS); 1107 1108 selectToHome(); 1109 1110 checkMainListeners(0, 18); 1111 1112 resetSceneByDefault(); 1113 } 1114 } 1115 1116 @Test(timeout = 300000)//RT-18412 1117 public void simpleSelectEndTest() throws InterruptedException { 1118 for (Orientation orientation : Orientation.values()) { 1119 prepareSelectionHelper(orientation, 20); 1120 1121 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1122 1123 applyKeysPushing(5, moreKey, CTRL_DOWN_MASK_OS); 1124 1125 selectToEnd(); 1126 1127 checkMainListeners(19, 19); 1128 1129 resetSceneByDefault(); 1130 } 1131 } 1132 1133 @Test(timeout = 60000) 1134 public void compositeSelectionTest() throws InterruptedException, Throwable { 1135 for (Orientation orientation : Orientation.values()) { 1136 final int elementsCount = 20; 1137 prepareSelectionHelper(orientation, elementsCount); 1138 selectionHelper.setPageHeight(8); 1139 selectionHelper.setPageWidth(1); 1140 1141 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1142 1143 applyKeysPushing(10, moreKey, CTRL_DOWN_MASK_OS);//we are in center 1144 1145 final int stepForScreenShotMaking = 8; 1146 1147 moveSelectUp(5, orientation); 1148 moveFocusPageDown(1); 1149 moveSelectUp(3, orientation); 1150 moveSelectPageUp(1); 1151 moveFocusDown(4, orientation); 1152 moveSelectUp(6, orientation); 1153 selectToHome(); 1154 moveSelectDown(4, orientation); 1155 checkScreenshotsWithStep("ComplexSelectionTest_1_" + orientation, elementsCount, stepForScreenShotMaking); 1156 selectToEnd(); 1157 moveFocusUp(3, orientation); 1158 moveSelectUp(5, orientation); 1159 moveToHome(); 1160 moveSelectPageDown(1); 1161 moveSelectDown(4, orientation); 1162 moveToEnd(); 1163 moveSelectDown(4, orientation); 1164 moveSelectUp(5, orientation); 1165 moveFocusPageUp(2); 1166 moveSelectDown(4, orientation); 1167 checkScreenshotsWithStep("ComplexSelectionTest_2_" + orientation, elementsCount, stepForScreenShotMaking); 1168 1169 resetSceneByDefault(); 1170 } 1171 } 1172 1173 @Test(timeout = 300000) 1174 public void selectionCancelTest() throws InterruptedException { 1175 checkKeyboardButtonOnCancellingSelection(KeyboardButtons.HOME); 1176 checkKeyboardButtonOnCancellingSelection(KeyboardButtons.END); 1177 checkKeyboardButtonOnCancellingSelection(KeyboardButtons.UP); 1178 checkKeyboardButtonOnCancellingSelection(KeyboardButtons.DOWN); 1179 checkKeyboardButtonOnCancellingSelection(KeyboardButtons.LEFT); 1180 checkKeyboardButtonOnCancellingSelection(KeyboardButtons.RIGHT); 1181 checkKeyboardButtonOnCancellingSelection(KeyboardButtons.PAGE_UP); 1182 checkKeyboardButtonOnCancellingSelection(KeyboardButtons.PAGE_DOWN); 1183 } 1184 1185 @Test(timeout = 300000) 1186 public void focusTraversalSelectionSavingTest() throws InterruptedException { 1187 checkKeyboardButtonOnNonCancellingSelectionBecauseTraversal(Orientation.HORIZONTAL, KeyboardButtons.UP); 1188 checkKeyboardButtonOnNonCancellingSelectionBecauseTraversal(Orientation.HORIZONTAL, KeyboardButtons.DOWN); 1189 1190 checkKeyboardButtonOnNonCancellingSelectionBecauseTraversal(Orientation.VERTICAL, KeyboardButtons.RIGHT); 1191 checkKeyboardButtonOnNonCancellingSelectionBecauseTraversal(Orientation.VERTICAL, KeyboardButtons.LEFT); 1192 1193 checkKeyboardButtonOnNonCancellingSelectionBecauseTraversal(KeyboardButtons.TAB); 1194 checkKeyboardButtonOnNonCancellingSelectionBecauseTraversal(KeyboardButtons.TAB, KeyboardModifiers.SHIFT_DOWN_MASK); 1195 } 1196 1197 /** 1198 * Checks that when the sorting is applied to the underlying data collection 1199 * the cells are rendered in the right order. 1200 */ 1201 @Smoke 1202 @Test(timeout = 30000) 1203 public void renderingAfterSortingTest() { 1204 try { 1205 setSize(100, 218); 1206 } catch (InterruptedException ex) { 1207 System.out.println(ex); 1208 } 1209 1210 addElements(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 100500); 1211 1212 final int ITEMS_COUNT = 9; 1213 1214 StringConverter<String> conv = new StringConverter<String>() { 1215 @Override 1216 public String toString(String t) { 1217 return t; 1218 } 1219 1220 @Override 1221 public String fromString(String s) { 1222 return s; 1223 } 1224 }; 1225 1226 SortValidator<String, ListCell> validator = new SortValidator<String, ListCell>(ITEMS_COUNT, conv) { 1227 @Override 1228 protected void setControlData(final ObservableList<String> ls) { 1229 new GetAction<Object>() { 1230 @Override 1231 public void run(Object... os) throws Exception { 1232 ListView listView = (ListView) testedControl.getControl(); 1233 listView.setItems(ls); 1234 } 1235 }.dispatch(testedControl.getEnvironment()); 1236 } 1237 1238 @Override 1239 protected Lookup<? extends ListCell> getCellsLookup() { 1240 return testedControl.as(Parent.class, Node.class) 1241 .lookup(ListCell.class, new LookupCriteria<ListCell>() { 1242 public boolean check(ListCell cell) { 1243 return cell.isVisible(); 1244 } 1245 }); 1246 } 1247 1248 @Override 1249 protected String getTextFromCell(ListCell cell) { 1250 return cell.getText(); 1251 } 1252 }; 1253 1254 boolean result = validator.check(); 1255 String msg = validator.getFailureReason(); 1256 assertTrue(msg, result); 1257 } 1258 1259 protected void checkKeyboardButtonOnCancellingSelection(KeyboardButtons button) throws InterruptedException { 1260 for (Orientation orientation : Orientation.values()) { 1261 prepareSelectionHelper(orientation, 10); 1262 selectionHelper.setPageHeight(8); 1263 selectionHelper.setPageWidth(1); 1264 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1265 applyKeysPushing(5, moreKey, CTRL_DOWN_MASK_OS); 1266 if (!(orientation == Orientation.HORIZONTAL && (button == KeyboardButtons.UP || button == KeyboardButtons.DOWN)) 1267 && !(orientation == Orientation.VERTICAL && (button == KeyboardButtons.LEFT || button == KeyboardButtons.RIGHT))) //because it is focus traversal. 1268 { 1269 applyKeysPushing(1, button); 1270 } 1271 resetSceneByDefault(); 1272 } 1273 } 1274 1275 protected void checkKeyboardButtonOnNonCancellingSelectionBecauseTraversal(KeyboardButtons button, KeyboardModifiers... modifiers) throws InterruptedException { 1276 checkKeyboardButtonOnNonCancellingSelectionBecauseTraversal(Orientation.HORIZONTAL, button, modifiers); 1277 checkKeyboardButtonOnNonCancellingSelectionBecauseTraversal(Orientation.VERTICAL, button, modifiers); 1278 } 1279 1280 protected void checkKeyboardButtonOnNonCancellingSelectionBecauseTraversal(Orientation orientation, KeyboardButtons button, KeyboardModifiers... modifiers) throws InterruptedException { 1281 resetSceneByDefault(); 1282 requestFocusOnControl(testedControl); 1283 prepareSelectionHelper(orientation, 10); 1284 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1285 applyKeysPushing(5, moreKey, CTRL_DOWN_MASK_OS); 1286 1287 testedControl.keyboard().pushKey(button, modifiers); 1288 1289 checkSelection(); 1290 } 1291 1292 protected void checkMainListeners(int focusIndex, int selectedIndex) { 1293 checkListener(Listeners.focusedIndex, focusIndex); 1294 checkListener(Listeners.selectedIndex, selectedIndex); 1295 } 1296 1297 protected void checkMainListeners(int focusIndex, int editingIndex, int selectedIndex) { 1298 checkMainListeners(focusIndex, selectedIndex); 1299 checkListener(Listeners.editingIndex, editingIndex); 1300 } 1301 1302 protected void prepareSelectionHelper(Orientation orientation, int numberOfElements) throws InterruptedException { 1303 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 1304 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, orientation, Properties.orientation); 1305 setSize(195, 195); 1306 1307 KeyboardButtons lessKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.LEFT : KeyboardButtons.UP); 1308 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 1309 1310 selectionHelper = new MultipleSelectionHelper(1, numberOfElements); 1311 selectionHelper.setMultiple(true); 1312 1313 for (int i = 0; i < numberOfElements; i++) { 1314 addElement(String.valueOf(i * i), i); 1315 } 1316 1317 requestFocusOnControl(testedControl); 1318 1319 new GetAction() { 1320 @Override 1321 public void run(Object... os) throws Exception { 1322 ((ListView) testedControl.getControl()).getSelectionModel().clearSelection(); 1323 ((ListView) testedControl.getControl()).getFocusModel().focus(0); 1324 } 1325 }.dispatch(Root.ROOT.getEnvironment()); 1326 //testedControl.keyboard().pushKey(moreKey, CTRL_DOWN_MASK_OS); 1327 for (int i = 1; i < numberOfElements; i++) { 1328 applyKeysPushing(1, moreKey, CTRL_DOWN_MASK_OS); 1329 if (i % 2 == 0) { 1330 if (Utils.isMacOS()) { 1331 applyKeysPushing(1, KeyboardButtons.SPACE, CTRL_DOWN_MASK_OS, KeyboardModifiers.CTRL_DOWN_MASK); 1332 } else { 1333 applyKeysPushing(1, KeyboardButtons.SPACE, CTRL_DOWN_MASK_OS); 1334 } 1335 } 1336 } 1337 applyKeysPushing(numberOfElements, lessKey, CTRL_DOWN_MASK_OS); 1338 } 1339 }