< prev index next >

functional/ControlsTests/test/javafx/scene/control/test/ScrollPane/ScrollPaneTest.java

Print this page




  60 import org.junit.runner.RunWith;
  61 import test.javaclient.shared.FilteredTestRunner;
  62 import test.javaclient.shared.Utils;
  63 
  64 /**
  65  * @author Alexander Kirov
  66  */
  67 @RunWith(FilteredTestRunner.class)
  68 public class ScrollPaneTest extends TestBase {
  69 
  70     @Before
  71     public void setUp() {
  72         initWrappers();
  73         scene.mouse().move(new Point(0, 0));
  74     }
  75 
  76     @Smoke
  77     @Test(timeout = 300000)
  78     @Covers(value = {"javafx.scene.control.ScrollPane.vmax.DEFAULT", "javafx.scene.control.ScrollPane.vmax.GET"}, level = Level.FULL)
  79     public void checkVMaxOptionTest() throws InterruptedException {



  80         Assert.assertEquals((new ScrollPane()).vmaxProperty().getValue(), 1, commonComparePrecision);
  81 
  82         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vmax, 200);
  83         checkTextFieldValue(Properties.vmax, 200);
  84 
  85         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vvalue, 200);
  86         checkTextFieldValue(Properties.vvalue, 200);
  87 
  88         Wrap<? extends ScrollBar> sb1 = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true);
  89         sb1.as(AbstractScroll.class).to(0);
  90         checkTextFieldValue(Properties.vvalue, 0);
  91 
  92         Wrap<? extends ScrollBar> sb2 = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true);
  93         sb2.as(AbstractScroll.class).to(200);
  94         checkTextFieldValue(Properties.vvalue, 200);
  95 
  96         findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(-1 * (Utils.isMacOS() ? -1 : 1));
  97 
  98         findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(+1 * (Utils.isMacOS() ? -1 : 1));
  99         checkTextFieldValue(Properties.vvalue, 200);
 100 
 101         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.vmax, 150);
 102         checkTextFieldValue(Properties.vmax, 150);
 103 
 104         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.vmax, -150);
 105         checkTextFieldValue(Properties.vmax, -100);
 106     }
 107 
 108     @Smoke
 109     @Test(timeout = 300000)
 110     @Covers(value = {"javafx.scene.control.ScrollPane.vmin.DEFAULT", "javafx.scene.control.ScrollPane.vmin.GET"}, level = Level.FULL)
 111     public void checkVMinOptionTest() throws InterruptedException {



 112         Assert.assertEquals((new ScrollPane()).vminProperty().getValue(), 0, commonComparePrecision);
 113 
 114         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vmin, -100);
 115         checkTextFieldValue(Properties.vmin, -100);
 116 
 117         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vvalue, -100);
 118         checkTextFieldValue(Properties.vvalue, -100);
 119 
 120         Wrap<? extends ScrollBar> sb1 = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true);
 121         sb1.as(AbstractScroll.class).to(1);
 122         checkTextFieldValue(Properties.vvalue, 1);
 123 
 124         Wrap<? extends ScrollBar> sb2 = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true);
 125         sb2.as(AbstractScroll.class).to(-100);
 126         checkTextFieldValue(Properties.vvalue, -100);
 127 
 128         findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(+1 * (Utils.isMacOS() ? -1 : 1));
 129 
 130         findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(-1 * (Utils.isMacOS() ? -1 : 1));
 131         checkTextFieldValue(Properties.vvalue, -100);
 132 
 133         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.vmin, -50);
 134         checkTextFieldValue(Properties.vmin, -50);
 135 
 136         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.vmin, +150);
 137         checkTextFieldValue(Properties.vmin, +150);
 138     }
 139 
 140     @Smoke
 141     @Test(timeout = 300000)
 142     @Covers(value = {"javafx.scene.control.ScrollPane.hmax.DEFAULT", "javafx.scene.control.ScrollPane.hmax.GET"}, level = Level.FULL)
 143     public void checkHMaxOptionTest() throws InterruptedException {



 144         Assert.assertEquals((new ScrollPane()).hmaxProperty().getValue(), 1, commonComparePrecision);
 145 
 146         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hmax, 200);
 147         checkTextFieldValue(Properties.hmax, 200);
 148 
 149         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hvalue, 200);
 150         checkTextFieldValue(Properties.hvalue, 200);
 151 
 152         Wrap<? extends ScrollBar> sb1 = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
 153         sb1.as(AbstractScroll.class).to(0);
 154         checkTextFieldValue(Properties.hvalue, 0);
 155 
 156         Wrap<? extends ScrollBar> sb2 = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
 157         sb2.as(AbstractScroll.class).to(200);
 158         checkTextFieldValue(Properties.hvalue, 200);
 159 
 160         findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(-1);
 161 
 162         findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(+1);
 163         checkTextFieldValue(Properties.hvalue, 200);
 164 
 165         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.hmax, 150);
 166         checkTextFieldValue(Properties.hmax, 150);
 167 
 168         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.hmax, -150);
 169         checkTextFieldValue(Properties.hmax, -100);
 170     }
 171 
 172     @Smoke
 173     @Test(timeout = 300000)
 174     @Covers(value = {"javafx.scene.control.ScrollPane.hmin.DEFAULT", "javafx.scene.control.ScrollPane.hmin.GET"}, level = Level.FULL)
 175     public void checkHMinOptionTest() throws InterruptedException {



 176         Assert.assertEquals((new ScrollPane()).vminProperty().getValue(), 0, commonComparePrecision);
 177 
 178         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hmin, -100);
 179         checkTextFieldValue(Properties.hmin, -100);
 180 
 181         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hvalue, -100);
 182         checkTextFieldValue(Properties.hvalue, -100);
 183 
 184         Wrap<? extends ScrollBar> sb1 = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
 185         sb1.as(AbstractScroll.class).to(1);
 186         checkTextFieldValue(Properties.hvalue, 1);
 187 
 188         Wrap<? extends ScrollBar> sb2 = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
 189         sb2.as(AbstractScroll.class).to(-100);
 190         checkTextFieldValue(Properties.hvalue, -100);
 191 
 192         findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(+1);
 193 
 194         findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(-1);
 195         checkTextFieldValue(Properties.hvalue, -100);
 196 
 197         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.hmin, -50);
 198         checkTextFieldValue(Properties.hmin, -50);
 199 
 200         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.hmin, +150);
 201         checkTextFieldValue(Properties.hmin, +150);
 202     }
 203 
 204     @ScreenshotCheck
 205     @Test(timeout = 300000)
 206     public void checkH_V_ValueOptionTest() throws InterruptedException, Throwable {
 207         Assert.assertEquals((new ScrollPane()).hvalueProperty().getValue(), 0, commonComparePrecision);
 208         Assert.assertEquals((new ScrollPane()).vvalueProperty().getValue(), 0, commonComparePrecision);
 209 



 210         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hvalue, 200);
 211         checkTextFieldValue(Properties.hvalue, 1);
 212 
 213         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vvalue, 200);
 214         checkTextFieldValue(Properties.vvalue, 1);
 215 
 216         checkScreenshot("ScrollPane_H_V_Values_test", testedControl);
 217         throwScreenshotError();
 218     }
 219 
 220     /**
 221      * Assume, that scrollPane contain rectangle 200X200 pixels
 222      */
 223     @Smoke
 224     @Test(timeout = 300000)
 225     @Covers(value = {"javafx.scene.control.ScrollPane.prefViewportHeight.GET", "javafx.scene.control.ScrollPane.prefViewportHeight.DEFAULT"}, level = Level.FULL)
 226     public void checkPrefViewPortHeightOptionTest() throws InterruptedException {
 227         Assert.assertEquals((new ScrollPane()).prefViewportHeightProperty().getValue(), 0, commonComparePrecision);
 228 
 229         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 150);
 230         checkTextFieldValue(Properties.prefViewportHeight, 150);
 231         Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true) == null);
 232 
 233         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefViewportHeight, 230);
 234         checkTextFieldValue(Properties.prefViewportHeight, 230);
 235         Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, false) == null);
 236     }
 237 
 238     /**
 239      * Assume, that scrollPane contain rectangle 200X200 pixels
 240      */
 241     @Smoke
 242     @Test(timeout = 300000)
 243     @Covers(value = {"javafx.scene.control.ScrollPane.prefViewportWidth.GET", "javafx.scene.control.ScrollPane.prefViewportWidth.DEFAULT"}, level = Level.FULL)
 244     public void checkPrefViewPortWidthOptionTest() throws InterruptedException {
 245         Assert.assertEquals((new ScrollPane()).prefViewportWidthProperty().getValue(), 0, commonComparePrecision);
 246 
 247         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 150);
 248         checkTextFieldValue(Properties.prefViewportWidth, 150);
 249         Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true) == null);
 250 
 251         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefViewportWidth, 230);
 252         checkTextFieldValue(Properties.prefViewportWidth, 230);
 253         Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, false) == null);
 254     }
 255 
 256     @Test(timeout = 300000)
 257     @Covers(value = {"javafx.scene.control.ScrollPane.prefViewportWidth.GET", "javafx.scene.control.ScrollPane.prefViewportWidth.DEFAULT"}, level = Level.FULL)
 258     public void checkMinViewPortWidthSetTest() throws InterruptedException {
 259         Assert.assertEquals((new ScrollPane()).prefViewportWidthProperty().getValue(), 0, commonComparePrecision);
 260         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.minViewportWidth, 600);
 261         checkTextFieldValue(Properties.width, 600, 20);
 262     }
 263 
 264     @Smoke
 265     @Test(timeout = 300000)//Property affecting is verified in other test.
 266     @Covers(value = {"javafx.scene.control.ScrollPane.pannable.GET", "javafx.scene.control.ScrollPane.pannable.DEFAULT"}, level = Level.FULL)
 267     public void checkPannableOptionTest() throws InterruptedException {
 268         Assert.assertFalse((new ScrollPane()).pannableProperty().getValue());
 269 
 270         setPropertyByToggleClick(SettingType.BIDIRECTIONAL, TestBase.Properties.pannable);
 271         checkTextFieldText(Properties.pannable, "true");
 272 
 273         setPropertyByToggleClick(SettingType.BIDIRECTIONAL, TestBase.Properties.pannable);


 304 
 305         setPropertyByToggleClick(SettingType.BIDIRECTIONAL, Properties.fitToHeight);
 306         checkTextFieldText(Properties.fitToHeight, "false");
 307 
 308         setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, Properties.fitToHeight);
 309         checkTextFieldText(Properties.fitToHeight, "true");
 310 
 311         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 200);
 312         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 200);
 313 
 314         checkScreenshot("ScrollPane_fitToSize", testedControl);
 315         throwScreenshotError();
 316     }
 317 
 318     private enum Influence {
 319 
 320         INSIDEOUT, OUTSIDEIN
 321     };
 322 
 323     private void checkScrollbarsVisibility(boolean horizontalVisible, boolean verticalVisible) {
 324         Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, horizontalVisible) == null);
 325         Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, verticalVisible) == null);
 326     }
 327 
 328     @Smoke
 329     @Test(timeout = 300000)//RT-17395
 330     @Covers(value = {"javafx.scene.control.ScrollPane.vbarPolicy.GET", "javafx.scene.control.ScrollPane.vbarPolicy.DEFAULT",
 331         "javafx.scene.control.ScrollPane.hbarPolicy.GET", "javafx.scene.control.ScrollPane.hbarPolicy.DEFAULT"}, level = Level.FULL)
 332     public void checkHVBarPolicyOptionTest() throws InterruptedException {
 333         Assert.assertTrue((new ScrollPane()).vbarPolicyProperty().getValue() == ScrollBarPolicy.AS_NEEDED);
 334         Assert.assertTrue((new ScrollPane()).hbarPolicyProperty().getValue() == ScrollBarPolicy.AS_NEEDED);
 335 
 336         for (SettingType btype : EnumSet.of(SettingType.BIDIRECTIONAL, SettingType.SETTER, SettingType.UNIDIRECTIONAL)) {
 337             for (Influence influence : EnumSet.of(Influence.INSIDEOUT, Influence.OUTSIDEIN)) {
 338                 for (ScrollPane.ScrollBarPolicy policy : EnumSet.of(ScrollPane.ScrollBarPolicy.ALWAYS, ScrollPane.ScrollBarPolicy.AS_NEEDED, ScrollPane.ScrollBarPolicy.NEVER)) {
 339                     //Content size == 100X100
 340                     setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 200);
 341                     setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 200);
 342 
 343                     setPropertyByChoiceBox(btype, policy, Properties.hbarPolicy);
 344                     setPropertyByChoiceBox(btype, policy, Properties.vbarPolicy);
 345                     checkTextFieldText(Properties.hbarPolicy, policy.name());


 355                         case NEVER:
 356                             checkScrollbarsVisibility(false, false);
 357                             break;
 358                     }
 359 
 360                     if (influence == Influence.INSIDEOUT) {
 361                         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 230);
 362                         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 230);
 363 
 364                     } else { // Influence.OUTSIDEIN
 365                         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 50);
 366                         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 50);
 367 
 368                     }
 369 
 370                     switch (policy) {
 371                         case ALWAYS:
 372                             checkScrollbarsVisibility(true, true);
 373                             break;
 374                         case AS_NEEDED:
 375                             checkScrollbarsVisibility(true, true);
 376                             break;
 377                         case NEVER:
 378                             checkScrollbarsVisibility(false, false);
 379                             break;
 380                     }
 381                 }
 382             }
 383         }
 384     }
 385 
 386     @ScreenshotCheck
 387     @Test(timeout = 300000)
 388     public void contentRotationTest() throws InterruptedException, Throwable {
 389         rotateContent();
 390         checkScreenshot("ScrollPaneRotatedContent", testedControl);
 391         throwScreenshotError();
 392     }
 393 
 394     @ScreenshotCheck
 395     @Test(timeout = 300000)
 396     public void contentScalingTest() throws InterruptedException, Throwable {
 397         increaseContentScale();
 398         checkScreenshot("ScrollPaneScaledContent", testedControl);
 399         throwScreenshotError();
 400     }
 401 
 402     @ScreenshotCheck
 403     @Test(timeout = 300000)
 404     public void dynamicContentChangingTest() throws Throwable {



 405         changeContent();
 406         //If content has really changed, button will be searchable.
 407         //If content didn't change, button won't be on scene.
 408         clickContentButton();
 409 
 410         checkScreenshot("ScrollPane_DynamicContentChanging", testedControl);
 411         throwScreenshotError();
 412     }
 413 
 414     @ScreenshotCheck
 415     @Test(timeout = 300000)//RT-17335
 416     public void resizingTest() throws InterruptedException, Throwable {
 417         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 200);
 418         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 200);
 419 
 420         currentSettingOption = SettingOption.MANUAL;
 421         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 20);
 422         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 20);
 423 
 424         currentSettingOption = SettingOption.PROGRAM;


 426         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 100);
 427 
 428         checkScreenshot("ScrollPaneAfterResizing", testedControl);
 429         throwScreenshotError();
 430     }
 431 
 432     @Smoke
 433     @Test(timeout = 300000)//RT-17368
 434     public void viewPortPrefSizeTest() throws InterruptedException {
 435         changeContentToResizable();
 436         double[] sizes = {100, 50, 40, 55};
 437 
 438         for (Double size : sizes) {
 439 
 440             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, size);
 441             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, size);
 442 
 443             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, size * 2);
 444             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, size * 2);
 445 
 446             Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true) == null);
 447             Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true) == null);
 448 
 449             Point controlSize = new GetAction<Point>() {
 450                 @Override
 451                 public void run(Object... os) throws Exception {
 452                     setResult(new Point(((ScrollPane) os[0]).getWidth(), ((ScrollPane) os[0]).getHeight()));
 453                 }
 454             }.dispatch(Root.ROOT.getEnvironment(), testedControl.getControl());
 455 
 456             Point viewPortSize = new GetAction<Point>() {
 457                 @Override
 458                 public void run(Object... os) throws Exception {
 459                     setResult(new Point(((ScrollPane) os[0]).getPrefViewportWidth(), ((ScrollPane) os[0]).getPrefViewportHeight()));
 460                 }
 461             }.dispatch(Root.ROOT.getEnvironment(), testedControl.getControl());
 462 
 463             double verticalScrollBarWidth = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).getScreenBounds().width;
 464             double horizontalScrollBarHeight = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).getScreenBounds().height;
 465 
 466             Assert.assertEquals(viewPortSize.x + verticalScrollBarWidth, controlSize.x, commonComparePrecision);
 467             Assert.assertEquals(viewPortSize.y + horizontalScrollBarHeight, controlSize.y, commonComparePrecision);
 468         }
 469     }
 470 
 471     @ScreenshotCheck
 472     @Test(timeout = 300000)
 473     public void whiteGapTest() throws InterruptedException, Throwable {



 474         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hmax, 200);
 475         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hmin, 50);
 476         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hvalue, 200);
 477 
 478         checkScreenshot("ScrollPane_WhiteGapTest", testedControl);
 479         throwScreenshotError();
 480     }
 481 
 482     @Smoke
 483     @Test(timeout = 300000)//(expected=java.lang.RuntimeException.class) //RT-17334
 484     public void unidirectionalBindingForVHValueTest() throws InterruptedException {
 485         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.vvalue, 200);
 486         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.hvalue, 200);
 487     }
 488 
 489     @ScreenshotCheck
 490     @Test(timeout = 300000)//RT-17350
 491     public void immediateHVBarPoliticApplyingTest() throws Throwable {



 492         setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, ScrollPane.ScrollBarPolicy.ALWAYS, Properties.hbarPolicy);
 493         setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, ScrollPane.ScrollBarPolicy.NEVER, Properties.hbarPolicy);
 494 
 495         //There must not be horizontal bar.
 496         checkScreenshot("ScrollPane_PoliticApplyingTest", testedControl);
 497         throwScreenshotError();
 498     }
 499 
 500     @ScreenshotCheck
 501     @Test(timeout = 300000) //RT-17365
 502     public void contentMovingTest() throws InterruptedException, Throwable {
 503         contentMotionStart();
 504 
 505         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 100);
 506         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 100);
 507 
 508         Thread.sleep(ContentMotion.motionDuration + 1000);
 509 
 510         checkScreenshot("ScrollPane_ContentMovingTest", testedControl);
 511         throwScreenshotError();


 514     @Smoke
 515     @Test(timeout = 300000)
 516     public void contentReceiveMouseEventsTest() {
 517         changeContent();
 518         clickContentButton();
 519 
 520         checkContentTextFieldValue(1);
 521     }
 522 
 523     @Smoke
 524     private void checkFocusStates(boolean buttonFocus, boolean textFieldFocus, boolean textAreaFocus, boolean emptyButtonFocus) {
 525         checkFocus(CONTENT_BUTTON, buttonFocus);
 526         checkFocus(CONTENT_TEXT_FIELD_ID, textFieldFocus);
 527         checkFocus(CONTENT_TEXT_AREA_ID, textAreaFocus);
 528         checkFocus(WITHOUT_ACTION_BUTTON, emptyButtonFocus);
 529     }
 530 
 531     @ScreenshotCheck
 532     @Test(timeout = 300000)
 533     public void insideTraversalCheckTest() throws Throwable {



 534         changeContent();
 535         clickContentButton();
 536 
 537         Wrap<? extends Button> buttonWrap = parent.lookup(Button.class, new ByID<Button>(CONTENT_BUTTON)).wrap();
 538         buttonWrap.mouse().click();
 539         checkFocusStates(true, false, false, false);
 540         checkScreenshot("ScrollPane_InnerTraversal_1_Test", testedControl);
 541 
 542         buttonWrap.keyboard().pushKey(KeyboardButtons.TAB);
 543         checkFocusStates(false, true, false, false);
 544         checkScreenshot("ScrollPane_InnerTraversal_2_Test", testedControl);
 545 
 546         parent.lookup(TextField.class, new ByID<TextField>(CONTENT_TEXT_FIELD_ID)).wrap().keyboard().pushKey(KeyboardButtons.TAB);
 547         checkFocusStates(false, false, true, false);
 548         checkScreenshot("ScrollPane_InnerTraversal_3_Test", testedControl);
 549 
 550         parent.lookup(TextArea.class, new ByID<TextArea>(CONTENT_TEXT_AREA_ID)).wrap().keyboard().pushKey(KeyboardButtons.TAB, KeyboardModifiers.CTRL_DOWN_MASK);
 551         checkFocusStates(false, false, false, true);
 552         checkScreenshot("ScrollPane_InnerTraversal_4_Test", testedControl);
 553 
 554         throwScreenshotError();
 555     }
 556 
 557     @Smoke
 558     @Test(timeout = 300000)//RT-17378
 559     public void contentSizeDetectionAndScrolls() throws InterruptedException, Throwable {
 560         SettingOption temp = currentSettingOption;
 561         currentSettingOption = SettingOption.PROGRAM;
 562         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 201);
 563         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 201);
 564 
 565         Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, false) == null);
 566         Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, false) == null);
 567 
 568         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 200);
 569         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 200);
 570 
 571         Assert.assertTrue(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true) != null);
 572         Assert.assertTrue(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true) != null);
 573 
 574         currentSettingOption = temp;
 575     }
 576 
 577     @Smoke
 578     @Test(timeout = 300000)//RT-17380
 579     public void focusFromOutsideTest() {
 580         changeContent();
 581         parent.lookup(Button.class, new ByID<Button>(CHANGE_CONTENT_BUTTON_ID)).wrap().keyboard().pushKey(KeyboardButtons.UP);
 582 
 583         parent.lookup(Button.class, new ByID<Button>(WITHOUT_ACTION_BUTTON)).wrap().waitProperty("isFocused", true);
 584     }
 585 
 586     private void makeDND(int initialDeltaX, int initialDeltaY, int deltaX, int deltaY) throws InterruptedException {
 587         Wrap<? extends Group> group = parent.lookup(Group.class, new ByID<Group>(CUSTOM_CONTENT_ID)).wrap();
 588         Point fromPoint = group.getClickPoint();
 589 
 590         fromPoint.x += initialDeltaX;
 591         fromPoint.y += initialDeltaY;
 592         Point toPoint = new Point(fromPoint.x + deltaX, fromPoint.y + deltaY);


 704     }
 705 
 706     @Smoke
 707     @Test(timeout = 300000)
 708     public void panningAndMouseMovementCompare() throws InterruptedException {
 709         setPropertyByToggleClick(SettingType.BIDIRECTIONAL, Properties.pannable);
 710         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 100);
 711         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 100);
 712 
 713         tryToMove(-75, -75, -50, -50);
 714         tryToMove(-25, -25, 50, -50);
 715         tryToMove(-75, 25, -50, 50);
 716         tryToMove(-25, -25, -50, -50);
 717     }
 718 
 719     //Test//Switched off, because developers don't fix such bugs.
 720     public void steadyScrollingTest() throws InterruptedException {
 721         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 100);
 722         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 100);
 723 
 724         Wrap<? extends ScrollBar> vertical = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true);
 725         Wrap<? extends ScrollBar> horizontal = findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
 726 
 727         ScrollingChecker scV = new ScrollingChecker(vertical.getControl().valueProperty());
 728         ScrollingChecker scH = new ScrollingChecker(horizontal.getControl().valueProperty());
 729         for (int i = 0; i < 10; i++) {
 730             vertical.mouse().turnWheel(+1);
 731             scV.checkChanging(+1);
 732 
 733             horizontal.mouse().turnWheel(+1);
 734             scH.checkChanging(+1);
 735         }
 736 
 737         vertical.mouse().turnWheel(-17);
 738         horizontal.mouse().turnWheel(-17);
 739 
 740         changeContent();
 741 
 742         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hvalue, 0);
 743         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vvalue, 0);
 744 
 745         ScrollingChecker sc = new ScrollingChecker(vertical.getControl().valueProperty());


 748             vertical.mouse().turnWheel(+1);
 749             sc.checkChanging(+1);
 750         }
 751     }
 752 
 753     @Smoke
 754     @Test(timeout = 300000)//RT-17368
 755     @Covers(value = "javafx.scene.control.ScrollPane.viewportBounds.GET", level = Level.FULL)
 756     public void boundsTest() throws InterruptedException {
 757         changeContentToResizable();
 758         double[] sizes = {100, 50, 40, 55};
 759 
 760         for (Double size : sizes) {
 761 
 762             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, size);
 763             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, size);
 764 
 765             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, size * 2);
 766             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, size * 2);
 767 
 768             Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true) == null);
 769             Assert.assertFalse(findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true) == null);
 770 
 771             Bounds bounds = new GetAction<Bounds>() {
 772                 @Override
 773                 public void run(Object... os) throws Exception {
 774                     setResult(((ScrollPane) os[0]).getViewportBounds());
 775                 }
 776             }.dispatch(Root.ROOT.getEnvironment(), testedControl.getControl());
 777 
 778             Point viewPortSize = new GetAction<Point>() {
 779                 @Override
 780                 public void run(Object... os) throws Exception {
 781                     setResult(new Point(((ScrollPane) os[0]).getPrefViewportWidth(), ((ScrollPane) os[0]).getPrefViewportHeight()));
 782                 }
 783             }.dispatch(Root.ROOT.getEnvironment(), testedControl.getControl());
 784 
 785             Assert.assertEquals(viewPortSize.x, bounds.getWidth() + findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).getScreenBounds().getWidth(), commonComparePrecision);
 786             Assert.assertEquals(viewPortSize.y, bounds.getHeight() + findScrollBar(testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).getScreenBounds().getHeight(), commonComparePrecision);
 787         }
 788     }
 789 
 790     @Ignore //due to http://javafx-jira.kenai.com/browse/RT-27467
 791     @Smoke
 792     @Test(timeout = 30000)
 793     /**
 794      * Test checks method scrollTo of the control.
 795      */
 796     public void scrollToTest() {
 797         addGrid(10);
 798         scrollToCommonTest("B-5-5");
 799         scrollToCommonTest("B-9-0");
 800         scrollToCommonTest("B-0-9");
 801         scrollToCommonTest("B-9-9");
 802         scrollToCommonTest("B-0-0");
 803     }
 804 
 805     private void scrollToCommonTest(String name) {
 806         scrollTo(name);


  60 import org.junit.runner.RunWith;
  61 import test.javaclient.shared.FilteredTestRunner;
  62 import test.javaclient.shared.Utils;
  63 
  64 /**
  65  * @author Alexander Kirov
  66  */
  67 @RunWith(FilteredTestRunner.class)
  68 public class ScrollPaneTest extends TestBase {
  69 
  70     @Before
  71     public void setUp() {
  72         initWrappers();
  73         scene.mouse().move(new Point(0, 0));
  74     }
  75 
  76     @Smoke
  77     @Test(timeout = 300000)
  78     @Covers(value = {"javafx.scene.control.ScrollPane.vmax.DEFAULT", "javafx.scene.control.ScrollPane.vmax.GET"}, level = Level.FULL)
  79     public void checkVMaxOptionTest() throws InterruptedException {
  80         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 100);
  81         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 100);
  82 
  83         Assert.assertEquals((new ScrollPane()).vmaxProperty().getValue(), 1, commonComparePrecision);
  84 
  85         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vmax, 200);
  86         checkTextFieldValue(Properties.vmax, 200);
  87 
  88         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vvalue, 200);
  89         checkTextFieldValue(Properties.vvalue, 200);
  90 
  91         Wrap<? extends ScrollBar> sb1 = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true);
  92         sb1.as(AbstractScroll.class).to(0);
  93         checkTextFieldValue(Properties.vvalue, 0);
  94 
  95         Wrap<? extends ScrollBar> sb2 = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true);
  96         sb2.as(AbstractScroll.class).to(200);
  97         checkTextFieldValue(Properties.vvalue, 200);
  98 
  99         findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(-1 * (Utils.isMacOS() ? -1 : 1));
 100 
 101         findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(+1 * (Utils.isMacOS() ? -1 : 1));
 102         checkTextFieldValue(Properties.vvalue, 200);
 103 
 104         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.vmax, 150);
 105         checkTextFieldValue(Properties.vmax, 150);
 106 
 107         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.vmax, -150);
 108         checkTextFieldValue(Properties.vmax, -100);
 109     }
 110 
 111     @Smoke
 112     @Test(timeout = 300000)
 113     @Covers(value = {"javafx.scene.control.ScrollPane.vmin.DEFAULT", "javafx.scene.control.ScrollPane.vmin.GET"}, level = Level.FULL)
 114     public void checkVMinOptionTest() throws InterruptedException {
 115         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 100);
 116         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 100);
 117 
 118         Assert.assertEquals((new ScrollPane()).vminProperty().getValue(), 0, commonComparePrecision);
 119 
 120         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vmin, -100);
 121         checkTextFieldValue(Properties.vmin, -100);
 122 
 123         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vvalue, -100);
 124         checkTextFieldValue(Properties.vvalue, -100);
 125 
 126         Wrap<? extends ScrollBar> sb1 = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true);
 127         sb1.as(AbstractScroll.class).to(1);
 128         checkTextFieldValue(Properties.vvalue, 1);
 129 
 130         Wrap<? extends ScrollBar> sb2 = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true);
 131         sb2.as(AbstractScroll.class).to(-100);
 132         checkTextFieldValue(Properties.vvalue, -100);
 133 
 134         findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(+1 * (Utils.isMacOS() ? -1 : 1));
 135 
 136         findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).mouse().turnWheel(-1 * (Utils.isMacOS() ? -1 : 1));
 137         checkTextFieldValue(Properties.vvalue, -100);
 138 
 139         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.vmin, -50);
 140         checkTextFieldValue(Properties.vmin, -50);
 141 
 142         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.vmin, +150);
 143         checkTextFieldValue(Properties.vmin, +150);
 144     }
 145 
 146     @Smoke
 147     @Test(timeout = 300000)
 148     @Covers(value = {"javafx.scene.control.ScrollPane.hmax.DEFAULT", "javafx.scene.control.ScrollPane.hmax.GET"}, level = Level.FULL)
 149     public void checkHMaxOptionTest() throws InterruptedException {
 150         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 100);
 151         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 100);
 152 
 153         Assert.assertEquals((new ScrollPane()).hmaxProperty().getValue(), 1, commonComparePrecision);
 154 
 155         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hmax, 200);
 156         checkTextFieldValue(Properties.hmax, 200);
 157 
 158         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hvalue, 200);
 159         checkTextFieldValue(Properties.hvalue, 200);
 160 
 161         Wrap<? extends ScrollBar> sb1 = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
 162         sb1.as(AbstractScroll.class).to(0);
 163         checkTextFieldValue(Properties.hvalue, 0);
 164 
 165         Wrap<? extends ScrollBar> sb2 = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
 166         sb2.as(AbstractScroll.class).to(200);
 167         checkTextFieldValue(Properties.hvalue, 200);
 168 
 169         findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(-1);
 170 
 171         findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(+1);
 172         checkTextFieldValue(Properties.hvalue, 200);
 173 
 174         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.hmax, 150);
 175         checkTextFieldValue(Properties.hmax, 150);
 176 
 177         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.hmax, -150);
 178         checkTextFieldValue(Properties.hmax, -100);
 179     }
 180 
 181     @Smoke
 182     @Test(timeout = 300000)
 183     @Covers(value = {"javafx.scene.control.ScrollPane.hmin.DEFAULT", "javafx.scene.control.ScrollPane.hmin.GET"}, level = Level.FULL)
 184     public void checkHMinOptionTest() throws InterruptedException {
 185         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 100);
 186         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 100);
 187 
 188         Assert.assertEquals((new ScrollPane()).vminProperty().getValue(), 0, commonComparePrecision);
 189 
 190         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hmin, -100);
 191         checkTextFieldValue(Properties.hmin, -100);
 192 
 193         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hvalue, -100);
 194         checkTextFieldValue(Properties.hvalue, -100);
 195 
 196         Wrap<? extends ScrollBar> sb1 = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
 197         sb1.as(AbstractScroll.class).to(1);
 198         checkTextFieldValue(Properties.hvalue, 1);
 199 
 200         Wrap<? extends ScrollBar> sb2 = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
 201         sb2.as(AbstractScroll.class).to(-100);
 202         checkTextFieldValue(Properties.hvalue, -100);
 203 
 204         findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(+1);
 205 
 206         findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).mouse().turnWheel(-1);
 207         checkTextFieldValue(Properties.hvalue, -100);
 208 
 209         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.hmin, -50);
 210         checkTextFieldValue(Properties.hmin, -50);
 211 
 212         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.hmin, +150);
 213         checkTextFieldValue(Properties.hmin, +150);
 214     }
 215 
 216     @ScreenshotCheck
 217     @Test(timeout = 300000)
 218     public void checkH_V_ValueOptionTest() throws InterruptedException, Throwable {
 219         Assert.assertEquals((new ScrollPane()).hvalueProperty().getValue(), 0, commonComparePrecision);
 220         Assert.assertEquals((new ScrollPane()).vvalueProperty().getValue(), 0, commonComparePrecision);
 221 
 222         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 100);
 223         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 100);
 224 
 225         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hvalue, 200);
 226         checkTextFieldValue(Properties.hvalue, 1);
 227 
 228         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vvalue, 200);
 229         checkTextFieldValue(Properties.vvalue, 1);
 230 
 231         checkScreenshot("ScrollPane_H_V_Values_test", testedControl);
 232         throwScreenshotError();
 233     }
 234 
 235     /**
 236      * Assume, that scrollPane contain rectangle 200X200 pixels
 237      */
 238     @Smoke
 239     @Test(timeout = 300000)
 240     @Covers(value = {"javafx.scene.control.ScrollPane.prefViewportHeight.GET", "javafx.scene.control.ScrollPane.prefViewportHeight.DEFAULT"}, level = Level.FULL)
 241     public void checkPrefViewPortHeightOptionTest() throws InterruptedException {
 242         Assert.assertEquals((new ScrollPane()).prefViewportHeightProperty().getValue(), 0, commonComparePrecision);
 243 
 244         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 150);
 245         checkTextFieldValue(Properties.prefViewportHeight, 150);
 246         Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true) == null);
 247 
 248         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefViewportHeight, 230);
 249         checkTextFieldValue(Properties.prefViewportHeight, 230);
 250         Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, false) == null);
 251     }
 252 
 253     /**
 254      * Assume, that scrollPane contain rectangle 200X200 pixels
 255      */
 256     @Smoke
 257     @Test(timeout = 300000)
 258     @Covers(value = {"javafx.scene.control.ScrollPane.prefViewportWidth.GET", "javafx.scene.control.ScrollPane.prefViewportWidth.DEFAULT"}, level = Level.FULL)
 259     public void checkPrefViewPortWidthOptionTest() throws InterruptedException {
 260         Assert.assertEquals((new ScrollPane()).prefViewportWidthProperty().getValue(), 0, commonComparePrecision);
 261 
 262         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 150);
 263         checkTextFieldValue(Properties.prefViewportWidth, 150);
 264         Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true) == null);
 265 
 266         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.prefViewportWidth, 230);
 267         checkTextFieldValue(Properties.prefViewportWidth, 230);
 268         Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, false) == null);
 269     }
 270 
 271     @Test(timeout = 300000)
 272     @Covers(value = {"javafx.scene.control.ScrollPane.prefViewportWidth.GET", "javafx.scene.control.ScrollPane.prefViewportWidth.DEFAULT"}, level = Level.FULL)
 273     public void checkMinViewPortWidthSetTest() throws InterruptedException {
 274         Assert.assertEquals((new ScrollPane()).prefViewportWidthProperty().getValue(), 0, commonComparePrecision);
 275         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.minViewportWidth, 600);
 276         checkTextFieldValue(Properties.width, 600, 20);
 277     }
 278 
 279     @Smoke
 280     @Test(timeout = 300000)//Property affecting is verified in other test.
 281     @Covers(value = {"javafx.scene.control.ScrollPane.pannable.GET", "javafx.scene.control.ScrollPane.pannable.DEFAULT"}, level = Level.FULL)
 282     public void checkPannableOptionTest() throws InterruptedException {
 283         Assert.assertFalse((new ScrollPane()).pannableProperty().getValue());
 284 
 285         setPropertyByToggleClick(SettingType.BIDIRECTIONAL, TestBase.Properties.pannable);
 286         checkTextFieldText(Properties.pannable, "true");
 287 
 288         setPropertyByToggleClick(SettingType.BIDIRECTIONAL, TestBase.Properties.pannable);


 319 
 320         setPropertyByToggleClick(SettingType.BIDIRECTIONAL, Properties.fitToHeight);
 321         checkTextFieldText(Properties.fitToHeight, "false");
 322 
 323         setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, Properties.fitToHeight);
 324         checkTextFieldText(Properties.fitToHeight, "true");
 325 
 326         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 200);
 327         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 200);
 328 
 329         checkScreenshot("ScrollPane_fitToSize", testedControl);
 330         throwScreenshotError();
 331     }
 332 
 333     private enum Influence {
 334 
 335         INSIDEOUT, OUTSIDEIN
 336     };
 337 
 338     private void checkScrollbarsVisibility(boolean horizontalVisible, boolean verticalVisible) {
 339         Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, horizontalVisible) == null);
 340         Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, verticalVisible) == null);
 341     }
 342 
 343     @Smoke
 344     @Test(timeout = 300000)//RT-17395
 345     @Covers(value = {"javafx.scene.control.ScrollPane.vbarPolicy.GET", "javafx.scene.control.ScrollPane.vbarPolicy.DEFAULT",
 346         "javafx.scene.control.ScrollPane.hbarPolicy.GET", "javafx.scene.control.ScrollPane.hbarPolicy.DEFAULT"}, level = Level.FULL)
 347     public void checkHVBarPolicyOptionTest() throws InterruptedException {
 348         Assert.assertTrue((new ScrollPane()).vbarPolicyProperty().getValue() == ScrollBarPolicy.AS_NEEDED);
 349         Assert.assertTrue((new ScrollPane()).hbarPolicyProperty().getValue() == ScrollBarPolicy.AS_NEEDED);
 350 
 351         for (SettingType btype : EnumSet.of(SettingType.BIDIRECTIONAL, SettingType.SETTER, SettingType.UNIDIRECTIONAL)) {
 352             for (Influence influence : EnumSet.of(Influence.INSIDEOUT, Influence.OUTSIDEIN)) {
 353                 for (ScrollPane.ScrollBarPolicy policy : EnumSet.of(ScrollPane.ScrollBarPolicy.ALWAYS, ScrollPane.ScrollBarPolicy.AS_NEEDED, ScrollPane.ScrollBarPolicy.NEVER)) {
 354                     //Content size == 100X100
 355                     setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 200);
 356                     setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 200);
 357 
 358                     setPropertyByChoiceBox(btype, policy, Properties.hbarPolicy);
 359                     setPropertyByChoiceBox(btype, policy, Properties.vbarPolicy);
 360                     checkTextFieldText(Properties.hbarPolicy, policy.name());


 370                         case NEVER:
 371                             checkScrollbarsVisibility(false, false);
 372                             break;
 373                     }
 374 
 375                     if (influence == Influence.INSIDEOUT) {
 376                         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 230);
 377                         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 230);
 378 
 379                     } else { // Influence.OUTSIDEIN
 380                         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 50);
 381                         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 50);
 382 
 383                     }
 384 
 385                     switch (policy) {
 386                         case ALWAYS:
 387                             checkScrollbarsVisibility(true, true);
 388                             break;
 389                         case AS_NEEDED:
 390                             checkScrollbarsVisibility(false, false);
 391                             break;
 392                         case NEVER:
 393                             checkScrollbarsVisibility(false, false);
 394                             break;
 395                     }
 396                 }
 397             }
 398         }
 399     }
 400 
 401     @ScreenshotCheck
 402     @Test(timeout = 300000)
 403     public void contentRotationTest() throws InterruptedException, Throwable {
 404         rotateContent();
 405         checkScreenshot("ScrollPaneRotatedContent", testedControl);
 406         throwScreenshotError();
 407     }
 408 
 409     @ScreenshotCheck
 410     @Test(timeout = 300000)
 411     public void contentScalingTest() throws InterruptedException, Throwable {
 412         increaseContentScale();
 413         checkScreenshot("ScrollPaneScaledContent", testedControl);
 414         throwScreenshotError();
 415     }
 416 
 417     @ScreenshotCheck
 418     @Test(timeout = 300000)
 419     public void dynamicContentChangingTest() throws Throwable {
 420         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 100);
 421         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 100);
 422 
 423         changeContent();
 424         //If content has really changed, button will be searchable.
 425         //If content didn't change, button won't be on scene.
 426         clickContentButton();
 427 
 428         checkScreenshot("ScrollPane_DynamicContentChanging", testedControl);
 429         throwScreenshotError();
 430     }
 431 
 432     @ScreenshotCheck
 433     @Test(timeout = 300000)//RT-17335
 434     public void resizingTest() throws InterruptedException, Throwable {
 435         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 200);
 436         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 200);
 437 
 438         currentSettingOption = SettingOption.MANUAL;
 439         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 20);
 440         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 20);
 441 
 442         currentSettingOption = SettingOption.PROGRAM;


 444         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 100);
 445 
 446         checkScreenshot("ScrollPaneAfterResizing", testedControl);
 447         throwScreenshotError();
 448     }
 449 
 450     @Smoke
 451     @Test(timeout = 300000)//RT-17368
 452     public void viewPortPrefSizeTest() throws InterruptedException {
 453         changeContentToResizable();
 454         double[] sizes = {100, 50, 40, 55};
 455 
 456         for (Double size : sizes) {
 457 
 458             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, size);
 459             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, size);
 460 
 461             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, size * 2);
 462             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, size * 2);
 463 
 464             Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true) == null);
 465             Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true) == null);
 466 
 467             Point controlSize = new GetAction<Point>() {
 468                 @Override
 469                 public void run(Object... os) throws Exception {
 470                     setResult(new Point(((ScrollPane) os[0]).getWidth(), ((ScrollPane) os[0]).getHeight()));
 471                 }
 472             }.dispatch(Root.ROOT.getEnvironment(), testedControl.getControl());
 473 
 474             Point viewPortSize = new GetAction<Point>() {
 475                 @Override
 476                 public void run(Object... os) throws Exception {
 477                     setResult(new Point(((ScrollPane) os[0]).getPrefViewportWidth(), ((ScrollPane) os[0]).getPrefViewportHeight()));
 478                 }
 479             }.dispatch(Root.ROOT.getEnvironment(), testedControl.getControl());
 480 
 481             double verticalScrollBarWidth = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).getScreenBounds().width;
 482             double horizontalScrollBarHeight = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).getScreenBounds().height;
 483 
 484             Assert.assertEquals(viewPortSize.x + verticalScrollBarWidth, controlSize.x, commonComparePrecision);
 485             Assert.assertEquals(viewPortSize.y + horizontalScrollBarHeight, controlSize.y, commonComparePrecision);
 486         }
 487     }
 488 
 489     @ScreenshotCheck
 490     @Test(timeout = 300000)
 491     public void whiteGapTest() throws InterruptedException, Throwable {
 492         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 100);
 493         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 100);
 494 
 495         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hmax, 200);
 496         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hmin, 50);
 497         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hvalue, 200);
 498 
 499         checkScreenshot("ScrollPane_WhiteGapTest", testedControl);
 500         throwScreenshotError();
 501     }
 502 
 503     @Smoke
 504     @Test(timeout = 300000)//(expected=java.lang.RuntimeException.class) //RT-17334
 505     public void unidirectionalBindingForVHValueTest() throws InterruptedException {
 506         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.vvalue, 200);
 507         setPropertyBySlider(SettingType.UNIDIRECTIONAL, Properties.hvalue, 200);
 508     }
 509 
 510     @ScreenshotCheck
 511     @Test(timeout = 300000)//RT-17350
 512     public void immediateHVBarPoliticApplyingTest() throws Throwable {
 513         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 100);
 514         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 100);
 515 
 516         setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, ScrollPane.ScrollBarPolicy.ALWAYS, Properties.hbarPolicy);
 517         setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, ScrollPane.ScrollBarPolicy.NEVER, Properties.hbarPolicy);
 518 
 519         //There must not be horizontal bar.
 520         checkScreenshot("ScrollPane_PoliticApplyingTest", testedControl);
 521         throwScreenshotError();
 522     }
 523 
 524     @ScreenshotCheck
 525     @Test(timeout = 300000) //RT-17365
 526     public void contentMovingTest() throws InterruptedException, Throwable {
 527         contentMotionStart();
 528 
 529         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 100);
 530         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 100);
 531 
 532         Thread.sleep(ContentMotion.motionDuration + 1000);
 533 
 534         checkScreenshot("ScrollPane_ContentMovingTest", testedControl);
 535         throwScreenshotError();


 538     @Smoke
 539     @Test(timeout = 300000)
 540     public void contentReceiveMouseEventsTest() {
 541         changeContent();
 542         clickContentButton();
 543 
 544         checkContentTextFieldValue(1);
 545     }
 546 
 547     @Smoke
 548     private void checkFocusStates(boolean buttonFocus, boolean textFieldFocus, boolean textAreaFocus, boolean emptyButtonFocus) {
 549         checkFocus(CONTENT_BUTTON, buttonFocus);
 550         checkFocus(CONTENT_TEXT_FIELD_ID, textFieldFocus);
 551         checkFocus(CONTENT_TEXT_AREA_ID, textAreaFocus);
 552         checkFocus(WITHOUT_ACTION_BUTTON, emptyButtonFocus);
 553     }
 554 
 555     @ScreenshotCheck
 556     @Test(timeout = 300000)
 557     public void insideTraversalCheckTest() throws Throwable {
 558         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, 100);
 559         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, 100);
 560 
 561         changeContent();
 562         clickContentButton();
 563 
 564         Wrap<? extends Button> buttonWrap = parent.lookup(Button.class, new ByID<Button>(CONTENT_BUTTON)).wrap();
 565         buttonWrap.mouse().click();
 566         checkFocusStates(true, false, false, false);
 567         checkScreenshot("ScrollPane_InnerTraversal_1_Test", testedControl);
 568 
 569         buttonWrap.keyboard().pushKey(KeyboardButtons.TAB);
 570         checkFocusStates(false, true, false, false);
 571         checkScreenshot("ScrollPane_InnerTraversal_2_Test", testedControl);
 572 
 573         parent.lookup(TextField.class, new ByID<TextField>(CONTENT_TEXT_FIELD_ID)).wrap().keyboard().pushKey(KeyboardButtons.TAB);
 574         checkFocusStates(false, false, true, false);
 575         checkScreenshot("ScrollPane_InnerTraversal_3_Test", testedControl);
 576 
 577         parent.lookup(TextArea.class, new ByID<TextArea>(CONTENT_TEXT_AREA_ID)).wrap().keyboard().pushKey(KeyboardButtons.TAB, KeyboardModifiers.CTRL_DOWN_MASK);
 578         checkFocusStates(false, false, false, true);
 579         checkScreenshot("ScrollPane_InnerTraversal_4_Test", testedControl);
 580 
 581         throwScreenshotError();
 582     }
 583 
 584     @Smoke
 585     @Test(timeout = 300000)//RT-17378
 586     public void contentSizeDetectionAndScrolls() throws InterruptedException, Throwable {
 587         SettingOption temp = currentSettingOption;
 588         currentSettingOption = SettingOption.PROGRAM;
 589         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 201);
 590         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 201);
 591 
 592         Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, false) == null);
 593         Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, false) == null);
 594 
 595         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 200);
 596         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 200);
 597 
 598         Assert.assertTrue(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true) != null);
 599         Assert.assertTrue(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true) != null);
 600 
 601         currentSettingOption = temp;
 602     }
 603 
 604     @Smoke
 605     @Test(timeout = 300000)//RT-17380
 606     public void focusFromOutsideTest() {
 607         changeContent();
 608         parent.lookup(Button.class, new ByID<Button>(CHANGE_CONTENT_BUTTON_ID)).wrap().keyboard().pushKey(KeyboardButtons.UP);
 609 
 610         parent.lookup(Button.class, new ByID<Button>(WITHOUT_ACTION_BUTTON)).wrap().waitProperty("isFocused", true);
 611     }
 612 
 613     private void makeDND(int initialDeltaX, int initialDeltaY, int deltaX, int deltaY) throws InterruptedException {
 614         Wrap<? extends Group> group = parent.lookup(Group.class, new ByID<Group>(CUSTOM_CONTENT_ID)).wrap();
 615         Point fromPoint = group.getClickPoint();
 616 
 617         fromPoint.x += initialDeltaX;
 618         fromPoint.y += initialDeltaY;
 619         Point toPoint = new Point(fromPoint.x + deltaX, fromPoint.y + deltaY);


 731     }
 732 
 733     @Smoke
 734     @Test(timeout = 300000)
 735     public void panningAndMouseMovementCompare() throws InterruptedException {
 736         setPropertyByToggleClick(SettingType.BIDIRECTIONAL, Properties.pannable);
 737         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 100);
 738         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 100);
 739 
 740         tryToMove(-75, -75, -50, -50);
 741         tryToMove(-25, -25, 50, -50);
 742         tryToMove(-75, 25, -50, 50);
 743         tryToMove(-25, -25, -50, -50);
 744     }
 745 
 746     //Test//Switched off, because developers don't fix such bugs.
 747     public void steadyScrollingTest() throws InterruptedException {
 748         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, 100);
 749         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, 100);
 750 
 751         Wrap<? extends ScrollBar> vertical = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true);
 752         Wrap<? extends ScrollBar> horizontal = findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true);
 753 
 754         ScrollingChecker scV = new ScrollingChecker(vertical.getControl().valueProperty());
 755         ScrollingChecker scH = new ScrollingChecker(horizontal.getControl().valueProperty());
 756         for (int i = 0; i < 10; i++) {
 757             vertical.mouse().turnWheel(+1);
 758             scV.checkChanging(+1);
 759 
 760             horizontal.mouse().turnWheel(+1);
 761             scH.checkChanging(+1);
 762         }
 763 
 764         vertical.mouse().turnWheel(-17);
 765         horizontal.mouse().turnWheel(-17);
 766 
 767         changeContent();
 768 
 769         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.hvalue, 0);
 770         setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.vvalue, 0);
 771 
 772         ScrollingChecker sc = new ScrollingChecker(vertical.getControl().valueProperty());


 775             vertical.mouse().turnWheel(+1);
 776             sc.checkChanging(+1);
 777         }
 778     }
 779 
 780     @Smoke
 781     @Test(timeout = 300000)//RT-17368
 782     @Covers(value = "javafx.scene.control.ScrollPane.viewportBounds.GET", level = Level.FULL)
 783     public void boundsTest() throws InterruptedException {
 784         changeContentToResizable();
 785         double[] sizes = {100, 50, 40, 55};
 786 
 787         for (Double size : sizes) {
 788 
 789             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportHeight, size);
 790             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefViewportWidth, size);
 791 
 792             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefHeight, size * 2);
 793             setPropertyBySlider(SettingType.BIDIRECTIONAL, Properties.prefWidth, size * 2);
 794 
 795             Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true) == null);
 796             Assert.assertFalse(findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true) == null);
 797 
 798             Bounds bounds = new GetAction<Bounds>() {
 799                 @Override
 800                 public void run(Object... os) throws Exception {
 801                     setResult(((ScrollPane) os[0]).getViewportBounds());
 802                 }
 803             }.dispatch(Root.ROOT.getEnvironment(), testedControl.getControl());
 804 
 805             Point viewPortSize = new GetAction<Point>() {
 806                 @Override
 807                 public void run(Object... os) throws Exception {
 808                     setResult(new Point(((ScrollPane) os[0]).getPrefViewportWidth(), ((ScrollPane) os[0]).getPrefViewportHeight()));
 809                 }
 810             }.dispatch(Root.ROOT.getEnvironment(), testedControl.getControl());
 811 
 812             Assert.assertEquals(viewPortSize.x, bounds.getWidth() + findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.VERTICAL, true).getScreenBounds().getWidth(), commonComparePrecision);
 813             Assert.assertEquals(viewPortSize.y, bounds.getHeight() + findScrollBar((Parent<Node>) testedControl.as(Parent.class, Node.class), Orientation.HORIZONTAL, true).getScreenBounds().getHeight(), commonComparePrecision);
 814         }
 815     }
 816 
 817     @Ignore //due to http://javafx-jira.kenai.com/browse/RT-27467
 818     @Smoke
 819     @Test(timeout = 30000)
 820     /**
 821      * Test checks method scrollTo of the control.
 822      */
 823     public void scrollToTest() {
 824         addGrid(10);
 825         scrollToCommonTest("B-5-5");
 826         scrollToCommonTest("B-9-0");
 827         scrollToCommonTest("B-0-9");
 828         scrollToCommonTest("B-9-9");
 829         scrollToCommonTest("B-0-0");
 830     }
 831 
 832     private void scrollToCommonTest(String name) {
 833         scrollTo(name);
< prev index next >