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 java.util.Collection; 28 import java.util.HashSet; 29 import java.util.List; 30 import javafx.geometry.Orientation; 31 import javafx.scene.Node; 32 import javafx.scene.Scene; 33 import javafx.scene.control.*; 34 import static javafx.scene.control.test.ListView.NewListViewApp.*; 35 import javafx.scene.control.test.util.MultipleSelectionHelper; 36 import javafx.scene.control.test.util.MultipleSelectionHelper.Range; 37 import javafx.scene.control.test.util.TableListCommonTests; 38 import static javafx.scene.control.test.utils.ComponentsFactory.*; 39 import javafx.scene.control.test.utils.SelectionFormatter; 40 import javafx.scene.control.test.utils.ptables.AbstractPropertyController.SettingType; 41 import static javafx.scene.control.test.utils.ptables.NodesChoserFactory.*; 42 import javafx.scene.text.Text; 43 import org.jemmy.Point; 44 import org.jemmy.action.GetAction; 45 import org.jemmy.control.Wrap; 46 import org.jemmy.env.Environment; 47 import org.jemmy.fx.ByID; 48 import org.jemmy.fx.Root; 49 import org.jemmy.fx.control.ListItemWrap.ListItemByObjectLookup; 50 import org.jemmy.interfaces.Keyboard.KeyboardButtons; 51 import org.jemmy.interfaces.Keyboard.KeyboardModifiers; 52 import static org.jemmy.interfaces.Keyboard.KeyboardModifiers.META_DOWN_MASK; 53 import org.jemmy.interfaces.Mouse; 54 import org.jemmy.interfaces.Parent; 55 import org.jemmy.interfaces.Selectable; 56 import org.jemmy.interfaces.Showable; 57 import org.jemmy.lookup.Lookup; 58 import org.jemmy.lookup.LookupCriteria; 59 import org.jemmy.timing.State; 60 import org.junit.After; 61 import org.junit.Assert; 62 import org.junit.Before; 63 import org.junit.BeforeClass; 64 import test.javaclient.shared.Utils; 65 import static test.javaclient.shared.TestUtil.isEmbedded; 66 67 /** 68 * @author Alexander Kirov 69 */ 70 public class TestBase extends TableListCommonTests { 71 72 static Wrap<? extends Scene> scene; 73 protected boolean resetHardByDefault = false;//switcher of hard and soft reset mode. 74 protected boolean doNextResetHard = resetHardByDefault; 75 76 @BeforeClass 77 public static void setUpClass() throws Exception { 78 NewListViewApp.main(null); 79 } 80 81 @Before 82 public void setUp() { 83 initWrappers(); 84 setContentSize(1, 9); 85 selectionHelper.setPageWidth(1); 86 selectionHelper.setPageHeight(10); 87 scene.getEnvironment().setTimeout("wait.state", isEmbedded() ? 60000 : 2000); 88 scene.getEnvironment().setTimeout("wait.control", isEmbedded() ? 60000 : 1000); 89 scene.mouse().move(new Point(0, 0)); 90 } 91 92 @After 93 public void tearDown() { 94 //It is needed in cases, when in process of testing, fail happened when 95 //shift button was pressed and was not released because of test fail 96 //between press and release. 97 scene.keyboard().pushKey(KeyboardButtons.SHIFT); 98 99 if (doNextResetHard) { 100 resetSceneHard(); 101 } else { 102 resetSceneSoft(); 103 } 104 105 doNextResetHard = resetHardByDefault; 106 currentSettingOption = SettingOption.PROGRAM; 107 } 108 109 protected void initWrappers() { 110 scene = Root.ROOT.lookup().wrap(); 111 parent = scene.as(Parent.class, Node.class); 112 113 testedControl = parent.lookup(ListView.class, new ByID<ListView>(TESTED_LIST_VIEW_ID)).wrap(); 114 } 115 116 // Wraps for intellisence. 117 protected void checkCounter(Counters counter, int value) { 118 checkCounterValue(counter, value); 119 } 120 121 protected void checkListener(Listeners listener, int value) { 122 checkSimpleListenerValue(listener, value); 123 } 124 125 protected void checkListener(Listeners listener, String text) { 126 checkSimpleListenerValue(listener, text); 127 } 128 129 // SINGLE BUTTONS 130 protected void resetSceneHard() { 131 clickButtonForTestPurpose(HARD_RESET_BUTTON_ID); 132 initWrappers(); 133 } 134 135 protected void resetSceneSoft() { 136 clickButtonForTestPurpose(SOFT_RESET_BUTTON_ID); 137 //initWrappers(); 138 } 139 140 protected void resetSceneByDefault() { 141 if (resetHardByDefault) { 142 resetSceneHard(); 143 } else { 144 resetSceneSoft(); 145 } 146 } 147 148 protected void doNextResetHard() { 149 doNextResetHard = true; 150 } 151 152 protected void doNextResetSoft() { 153 doNextResetHard = false; 154 } 155 156 protected void addRectangleAtPos(int position) { 157 setText(findTextField(ADD_RECTANGLE_TEXT_FIELD_ID), position); 158 clickButtonForTestPurpose(ADD_RECTANGLE_BUTTON_ID); 159 } 160 161 protected void addTextFieldAtPos(int position) { 162 setText(findTextField(ADD_TEXT_FIELD_TEXT_FIELD_ID), position); 163 clickButtonForTestPurpose(ADD_TEXT_FIELD_BUTTON_ID); 164 } 165 166 protected void startMotion(int position) { 167 setText(findTextField(START_MOTION_TEXT_FIELD_ID), position); 168 clickButtonForTestPurpose(START_MOTION_BUTTON_ID); 169 } 170 171 protected void increaseScale(int position) { 172 setText(findTextField(INCREASE_SCALE_TEXT_FIELD_ID), position); 173 clickButtonForTestPurpose(INCREASE_SCALE_BUTTON_ID); 174 } 175 176 protected void decreaseScale(int position) { 177 setText(findTextField(DECREASE_SCALE_TEXT_FIELD_ID), position); 178 clickButtonForTestPurpose(DECREASE_SCALE_BUTTON_ID); 179 } 180 181 protected void addElement(String element, int position) { 182 setText(findTextField(ADD_ITEM_POSITION_TEXT_FIELD_ID), position); 183 setText(findTextField(ADD_ITEM_TEXT_FIELD_ID), element); 184 clickButtonForTestPurpose(ADD_ITEM_BUTTON_ID); 185 } 186 187 protected void addControlToPosition(int controlIndex, int position) { 188 setText(findTextField(LIST_VIEW_CONTROL_ADD_INDEX_TEXT_FIELD_ID), String.valueOf(position)); 189 selectControlFromFactory(controlIndex); 190 clickButtonForTestPurpose(NODE_CHOOSER_ACTION_BUTTON_ID); 191 } 192 193 protected void addElements(int... elements) { 194 for (int i = 0; i < elements.length; i++) { 195 addElement(String.valueOf(elements[i]), i); 196 } 197 } 198 199 protected void addFormAtPos(int position) { 200 setText(findTextField(ADD_FORM_TEXT_FIELD_ID), position); 201 clickButtonForTestPurpose(ADD_FORM_BUTTON_ID); 202 } 203 204 protected void clickFormButton() { 205 clickButtonForTestPurpose(FORM_BUTTON_ID); 206 } 207 208 protected void checkFormClickCounter(int expectedValue) { 209 parent.lookup(TextField.class, new ByID<TextField>(FORM_CLICK_TEXT_FIELD_ID)).wrap().waitProperty(Wrap.TEXT_PROP_NAME, String.valueOf(expectedValue)); 210 } 211 212 protected void scrollFormScrollBar(int move) { 213 parent.lookup(ScrollBar.class, new ByID<ScrollBar>(FORM_SCROLLBAR_ID)).wrap().mouse().move(); 214 parent.lookup(ScrollBar.class, new ByID<ScrollBar>(FORM_SCROLLBAR_ID)).wrap().mouse().turnWheel(move * (Utils.isMacOS() ? -1 : 1)); 215 } 216 217 protected void checkFormScrollCounter(int expectedValue) { 218 parent.lookup(TextField.class, new ByID<TextField>(FORM_SCROLL_TEXT_FIELD_ID)).wrap().waitProperty(Wrap.TEXT_PROP_NAME, String.valueOf(expectedValue)); 219 } 220 221 protected void removeFromPos(int position) { 222 setText(findTextField(REMOVE_ITEM_POS_TEXT_FIELD_ID), position); 223 clickButtonForTestPurpose(REMOVE_BUTTON_ID); 224 } 225 226 protected void scrollTo(int position) { 227 setText(findTextField(SCROLL_TO_TEXT_FIELD_ID), position); 228 clickButtonForTestPurpose(SCROLL_TO_BUTTON_ID); 229 } 230 231 protected void changeSelectionModel(int position) { 232 clickButtonForTestPurpose(CHANGE_SELECTION_MODEL_BUTTON_ID); 233 } 234 235 /** 236 * Checks visibility states of horizontal and vertical scrollBars. 237 */ 238 protected void checkScrollbarsStates(boolean horizontalVisibility, boolean verticalVisibility) { 239 Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, horizontalVisibility) == null); 240 Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, verticalVisibility) == null); 241 } 242 243 /** 244 * Set size if tested control using bidirectional bindings. 245 */ 246 protected void setSize(double width, double height) throws InterruptedException { 247 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, height); 248 setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, width); 249 } 250 251 /** 252 * Make chessboard focus. 253 * 254 * @param elemCount - length of list of added elements. 255 */ 256 protected void addAndSelectElements(final int elemCount) { 257 for (int i = 0; i < elemCount; i++) { 258 addElement(String.valueOf(i * i), i); 259 } 260 261 new GetAction() { 262 @Override 263 public void run(Object... os) throws Exception { 264 ListView lv = (ListView) os[0]; 265 selectionHelper.setRowsNum(elemCount); 266 for (int i = 0; i < elemCount; i++) { 267 if (Integer.valueOf((String) lv.getItems().get(i)) % 2 == 0) { 268 lv.getSelectionModel().select(i); 269 selectionHelper.push(KeyboardButtons.SPACE, KeyboardModifiers.CTRL_DOWN_MASK); 270 selectionHelper.push(KeyboardButtons.DOWN, KeyboardModifiers.CTRL_DOWN_MASK); 271 selectionHelper.push(KeyboardButtons.DOWN, KeyboardModifiers.CTRL_DOWN_MASK); 272 } 273 } 274 } 275 }.dispatch(Root.ROOT.getEnvironment(), (ListView) testedControl.getControl()); 276 } 277 278 protected void checkScreenshotsWithStep(String name, final int elementsCount, final int step) throws Throwable { 279 Wrap<Text> cellWrap = getCellWrap((Integer) (0)); //mouse will be over the second item. 280 cellWrap.as(Showable.class).shower().show(); 281 cellWrap.mouse().click(1, cellWrap.getClickPoint(), Mouse.MouseButtons.BUTTON1, Utils.isMacOS() ? META_DOWN_MASK : CTRL_DOWN_MASK_OS); 282 for (int i = 0; i < elementsCount / step; i++) { 283 for (int j = 0; j < step; j++) { 284 testedControl.keyboard().pushKey(KeyboardButtons.RIGHT, Utils.isMacOS() ? META_DOWN_MASK : CTRL_DOWN_MASK_OS); 285 } 286 checkScreenshot("ListView_" + name + "_" + i, testedControl); 287 } 288 289 throwScreenshotError(); 290 } 291 292 @Override 293 protected void checkSelection() { 294 testedControl.waitState(new State() { 295 public Object reached() { 296 Collection<Point> helper_selected = selectionHelper.getSelected(); 297 Collection<Point> selected = getSelected(); 298 Point helper_selection = selectionHelper.focus; 299 Point selection = getSelectedItem(); 300 301 System.out.println(SelectionFormatter.format("Helper selection: ", helper_selected, "Selection: ", selected)); 302 System.out.println("Helper focus : " + helper_selection); 303 System.out.println("Focus : " + selection); 304 System.out.println("Helper anchor : " + selectionHelper.anchor + "\n\n"); 305 System.out.println("Anchor : " + selectionHelper.anchor + "\n\n"); 306 307 if (((helper_selected.size() == selected.size()) 308 && helper_selected.containsAll(selected) 309 && selected.containsAll(helper_selected) 310 && selection.equals(helper_selection)) 311 || (selectionHelper.ctrlA && (selected.size() == currentListContentSize))) { 312 return true; 313 } else { 314 return null; 315 } 316 } 317 }); 318 } 319 320 /** 321 * @return hashSet of selected items in listView 322 */ 323 @Override 324 protected HashSet<Point> getSelected() { 325 return new GetAction<HashSet<Point>>() { 326 @Override 327 public void run(Object... parameters) throws Exception { 328 HashSet<Point> selected = new HashSet<Point>(); 329 MultipleSelectionModel model = ((Wrap<? extends ListView>) testedControl).getControl().getSelectionModel(); 330 for (Object obj : model.getSelectedIndices()) { 331 Integer pos = (Integer) obj; 332 selected.add(new Point(-1, pos)); 333 } 334 setResult(selected); 335 } 336 }.dispatch(Root.ROOT.getEnvironment()); 337 } 338 339 @Override 340 protected Point getSelectedItem() { 341 return new GetAction<Point>() { 342 @Override 343 public void run(Object... parameters) throws Exception { 344 Lookup lookup = testedControl.as(Parent.class, Node.class).lookup(new LookupCriteria<Node>() { 345 public boolean check(Node row) { 346 return ListCell.class.isAssignableFrom(row.getClass()) 347 && ((ListCell) row).isFocused() 348 && ((ListCell) row).isVisible(); 349 } 350 }); 351 if (lookup.size() > 0) { 352 setResult(new Point(-1, ((ListCell) lookup.get()).getIndex())); 353 return; 354 } 355 setResult(new Point(-1, -1)); 356 } 357 }.dispatch(Root.ROOT.getEnvironment()); 358 } 359 360 protected void localReset() { 361 clearList(); 362 addExponentialContent(); 363 testedControl.keyboard().pushKey(KeyboardButtons.HOME); 364 } 365 366 protected void clearList() { 367 for (int i = 1; i < listItems; i++) { 368 removeFromPos(0); 369 } 370 } 371 372 protected void addExponentialContent() { 373 for (int i = 1; i < listItems; i++) { 374 addElement(String.valueOf(Integer.valueOf((int) Math.round(Math.pow(i, i)))), i - 1); 375 } 376 } 377 378 protected void applyKeysPushing(int times, KeyboardButtons button, KeyboardModifiers... modifiers) { 379 for (int i = 0; i < times; i++) { 380 if (button == KeyboardButtons.PAGE_DOWN || button == KeyboardButtons.PAGE_UP) { 381 selectionHelper.setVisibleRange(getVisibleRange()); 382 } 383 testedControl.keyboard().pushKey(button, modifiers); 384 385 if (button == KeyboardButtons.RIGHT) { 386 selectionHelper.push(KeyboardButtons.DOWN, modifiers); 387 } else if (button == KeyboardButtons.LEFT) { 388 selectionHelper.push(KeyboardButtons.UP, modifiers); 389 } else { 390 selectionHelper.push(button, modifiers); 391 } 392 checkSelection(); 393 } 394 } 395 396 protected void selectionCycle(int firstLine, int lastLine, KeyboardButtons modifier, SelectionMode mode) throws Throwable { 397 if (isListControl()) { 398 selectionHelper = new MultipleSelectionHelper.ListViewMultipleSelectionHelper(1, 8); 399 } else { 400 selectionHelper = new MultipleSelectionHelper(1, 8); 401 } 402 selectionHelper.setSingleCell(false); 403 selectionHelper.setMultiple((mode == SelectionMode.MULTIPLE ? true : false)); 404 selectionHelper.push(KeyboardButtons.HOME); 405 406 if (modifier != null) { 407 testedControl.keyboard().pressKey(modifier); 408 } 409 try { 410 for (int j = firstLine; j < lastLine; j++) { 411 Wrap<Text> cellWrap = getCellWrap(Integer.valueOf((int) Math.round(Math.pow(j + 1, j + 1)))); 412 mouseCellClick(cellWrap, modifier); 413 selectionHelper.click(-1, j, modifier); 414 checkSelection(); 415 } 416 417 int j = firstLine + (lastLine - firstLine) / 2; 418 Wrap<Text> cellWrap = getCellWrap(Integer.valueOf((int) Math.round(Math.pow(j + 1, j + 1)))); 419 mouseCellClick(cellWrap, modifier); 420 selectionHelper.click(-1, j, modifier); 421 checkSelection(); 422 423 j = firstLine; 424 cellWrap = getCellWrap(Integer.valueOf((int) Math.round(Math.pow(j + 1, j + 1)))); 425 mouseCellClick(cellWrap, modifier); 426 selectionHelper.click(-1, j, modifier); 427 checkSelection(); 428 429 j = lastLine - 1; 430 cellWrap = getCellWrap(Integer.valueOf((int) Math.round(Math.pow(j + 1, j + 1)))); 431 mouseCellClick(cellWrap, modifier); 432 selectionHelper.click(-1, j, modifier); 433 checkSelection(); 434 435 } catch (Throwable error) { 436 throw error; 437 } finally { 438 if (modifier != null) { 439 testedControl.keyboard().releaseKey(modifier); 440 } 441 } 442 } 443 444 /** 445 * @return wrapper over required data item which can be used for mouse 446 * actions 447 */ 448 protected Wrap<Text> getCellWrap(final Integer item) { 449 return testedControl.as(Parent.class, String.class).lookup( 450 new LookupCriteria<String>() { 451 @Override 452 public boolean check(String cell_item) { 453 return cell_item.equals(String.valueOf(item)); 454 } 455 }).wrap(); 456 } 457 458 protected void mouseCellClick(Wrap<Text> cell, KeyboardButtons mod) { 459 cell.as(Showable.class).shower().show(); 460 Point cp = cell.getClickPoint(); 461 if (mod == null) { 462 cell.mouse().click(1, cp, Mouse.MouseButtons.BUTTON1); 463 } else { 464 switch (mod) { 465 case SHIFT: 466 cell.mouse().click(1, cp, Mouse.MouseButtons.BUTTON1, KeyboardModifiers.SHIFT_DOWN_MASK); 467 break; 468 case CONTROL: 469 cell.mouse().click(1, cp, Mouse.MouseButtons.BUTTON1, CTRL_DOWN_MASK_OS); 470 break; 471 } 472 } 473 } 474 475 protected void scrollTo(final int inXCoord, int inYCoord) { 476 if (inXCoord > 1) { 477 throw new IllegalArgumentException("Incorrect X coordinate!"); 478 } 479 480 new GetAction() { 481 @Override 482 public void run(Object... os) throws Exception { 483 ((ListView) testedControl.getControl()).scrollTo(inXCoord); 484 } 485 }.dispatch(Root.ROOT.getEnvironment()); 486 } 487 488 protected void switchOnMultiple() { 489 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, SelectionMode.MULTIPLE, Properties.selectionMode); 490 } 491 492 protected void showItem(int item) { 493 getCellWrap((Integer) (item)).as(Showable.class).shower().show(); 494 } 495 496 protected void moveSelectUp(int times, Orientation orientation) { 497 KeyboardButtons lessKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.LEFT : KeyboardButtons.UP); 498 applyKeysPushing(times, lessKey, KeyboardModifiers.SHIFT_DOWN_MASK); 499 } 500 501 protected void moveSelectDown(int times, Orientation orientation) { 502 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 503 applyKeysPushing(times, moreKey, KeyboardModifiers.SHIFT_DOWN_MASK); 504 } 505 506 protected void moveSelectPageUp(int times) { 507 applyKeysPushing(times, KeyboardButtons.PAGE_UP, KeyboardModifiers.SHIFT_DOWN_MASK); 508 } 509 510 protected void moveSelectPageDown(int times) { 511 applyKeysPushing(times, KeyboardButtons.PAGE_DOWN, KeyboardModifiers.SHIFT_DOWN_MASK); 512 } 513 514 protected void moveFocusUp(int times, Orientation orientation) { 515 KeyboardButtons lessKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.LEFT : KeyboardButtons.UP); 516 applyKeysPushing(times, lessKey, CTRL_DOWN_MASK_OS); 517 } 518 519 protected void moveFocusDown(int times, Orientation orientation) { 520 KeyboardButtons moreKey = (orientation == Orientation.HORIZONTAL ? KeyboardButtons.RIGHT : KeyboardButtons.DOWN); 521 applyKeysPushing(times, moreKey, CTRL_DOWN_MASK_OS); 522 } 523 524 protected void moveFocusPageUp(int times) { 525 applyKeysPushing(times, KeyboardButtons.PAGE_UP, CTRL_DOWN_MASK_OS); 526 } 527 528 protected void moveFocusPageDown(int times) { 529 applyKeysPushing(times, KeyboardButtons.PAGE_DOWN, CTRL_DOWN_MASK_OS); 530 } 531 532 protected void moveToEnd() { 533 applyKeysPushing(1, KeyboardButtons.END, CTRL_DOWN_MASK_OS); 534 } 535 536 protected void selectToEnd() { 537 applyKeysPushing(1, KeyboardButtons.END, KeyboardModifiers.SHIFT_DOWN_MASK); 538 } 539 540 protected void moveToHome() { 541 applyKeysPushing(1, KeyboardButtons.HOME, CTRL_DOWN_MASK_OS); 542 } 543 544 protected void selectToHome() { 545 applyKeysPushing(1, KeyboardButtons.HOME, KeyboardModifiers.SHIFT_DOWN_MASK); 546 } 547 548 @Override 549 protected void adjustControl() { 550 setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Orientation.VERTICAL, Properties.orientation); 551 try { 552 setSize(100, 218); 553 } catch (InterruptedException ex) { 554 System.out.println(ex); 555 } 556 for (int i = 0; i < DATA_ITEMS_NUM; i++) { 557 addElement(String.valueOf(i), i); 558 } 559 } 560 561 @Override 562 protected void clickOnFirstCell() { 563 String item = new GetAction<String>() { 564 @Override 565 public void run(Object... os) throws Exception { 566 setResult((String) ((ListView) testedControl.getControl()).getItems().get((Integer) os[1])); 567 } 568 }.dispatch(Root.ROOT.getEnvironment(), testedControl, 0); 569 Wrap<Text> cellWrap = getCellWrap(Integer.valueOf(item)); 570 cellWrap.as(Showable.class).shower().show(); 571 cellWrap.mouse().click(1, cellWrap.getClickPoint(), Mouse.MouseButtons.BUTTON1); 572 } 573 574 @Override 575 protected Wrap getCellWrap(int column, final int row) { 576 String item = new GetAction<String>() { 577 @Override 578 public void run(Object... os) throws Exception { 579 setResult((String) ((ListView) testedControl.getControl()).getItems().get(row)); 580 } 581 }.dispatch(Root.ROOT.getEnvironment()); 582 return getCellWrap(Integer.valueOf(item)); 583 } 584 //must be int in [3, 9] 585 static protected final int listItems = 9; 586 static protected int currentListContentSize = 10; 587 588 @Override 589 protected Range getVisibleRange() { 590 int top = -1; 591 int bottom = -1; 592 final List<Object> states = testedControl.as(Selectable.class).getStates(); 593 for (int i = 0; i < states.size(); i++) { 594 final Lookup lookup = testedControl.as(Parent.class, Node.class).lookup(ListCell.class, new ListItemByObjectLookup<Object>(states.get(i))); 595 boolean visible = lookup.size() > 0 && testedControl.getScreenBounds().contains(lookup.wrap().getScreenBounds()); 596 if (visible && top < 0) { 597 top = i; 598 } 599 if (visible) { 600 bottom = i; 601 } 602 if (!visible && top >= 0) { 603 bottom = i - 1; 604 break; 605 } 606 } 607 return new Range(top, bottom); 608 } 609 610 @Override 611 protected void setOrientation(Orientation orientation) { 612 setPropertyByChoiceBox(SettingType.SETTER, orientation, Properties.orientation); 613 } 614 615 // All controlled properties. 616 static protected enum Properties { 617 618 editable, orientation, prefWidth, prefHeight, selectionMode, fixedCellSize 619 }; 620 621 static protected enum Listeners { 622 623 selectedIndex, selectedItem, focusedIndex, focusedItem, editingIndex 624 }; 625 626 static protected enum Counters { 627 628 set_on_edit_cancel, set_on_edit_commit, set_on_edit_start, get_on_edit_cancel, get_on_edit_commit, get_on_edit_start 629 }; 630 }