< prev index next >

test/java/awt/TextArea/UsingWithMouse/SelectionAutoscrollTest.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 20,34 **** * or visit www.oracle.com if you need additional information or have any * questions. */ /* ! test ! @bug 6497109 @summary TextArea must have selection expanding, and also be autoscrolled, if mouse is dragged from inside. @author Konstantin Voloshin: area=TextArea ! @run applet SelectionAutoscrollTest.html */ /** * SelectionAutoscrollTest.java * --- 20,36 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ /* ! @test ! @bug 6497109 6734341 @summary TextArea must have selection expanding, and also be autoscrolled, if mouse is dragged from inside. + @library ../../regtesthelpers + @build Util @author Konstantin Voloshin: area=TextArea ! @run main SelectionAutoscrollTest */ /** * SelectionAutoscrollTest.java *
*** 36,69 **** * the end, if mouse is dragged from inside box-for-text to outside it, and * is hold pressed there. */ - import java.applet.Applet; import java.awt.Frame; import java.awt.Panel; import java.awt.GridLayout; import java.awt.TextArea; - import java.awt.Point; import java.awt.Dimension; import java.awt.event.MouseEvent; import java.awt.Robot; import java.awt.Toolkit; import test.java.awt.regtesthelpers.Util; ! public class SelectionAutoscrollTest extends Applet { TextArea textArea; Robot robot; final int desiredSelectionEnd = ('z'-'a'+1)*2; // 52 final static int SCROLL_DELAY = 10; // ms ! public void start () { ! createObjects(); ! manipulateMouse(); ! checkResults(); } void createObjects() { textArea = new TextArea( bigString() ); robot = Util.createRobot(); --- 38,71 ---- * the end, if mouse is dragged from inside box-for-text to outside it, and * is hold pressed there. */ import java.awt.Frame; import java.awt.Panel; import java.awt.GridLayout; import java.awt.TextArea; import java.awt.Point; import java.awt.Dimension; import java.awt.event.MouseEvent; import java.awt.Robot; import java.awt.Toolkit; import test.java.awt.regtesthelpers.Util; ! public class SelectionAutoscrollTest { TextArea textArea; Robot robot; final int desiredSelectionEnd = ('z'-'a'+1)*2; // 52 final static int SCROLL_DELAY = 10; // ms ! public static void main(String[] args) { ! SelectionAutoscrollTest selectionAutoscrollTest ! = new SelectionAutoscrollTest(); ! selectionAutoscrollTest.createObjects(); ! selectionAutoscrollTest.manipulateMouse(); ! selectionAutoscrollTest.checkResults(); } void createObjects() { textArea = new TextArea( bigString() ); robot = Util.createRobot();
*** 123,133 **** // will be generated. If mouse was released after first movement // here, we would even get mouse-clicked event (at least for now, // and this is probably a bug). But, starting with 2nd iteration, // all events received will be mouse-dragged events. ! moveMouseBelowTextArea( tremble%2!=0 ); Util.waitForIdle( robot ); // it is needed to add some small delay on Gnome waitUntilScrollIsPerformed(robot); } --- 125,135 ---- // will be generated. If mouse was released after first movement // here, we would even get mouse-clicked event (at least for now, // and this is probably a bug). But, starting with 2nd iteration, // all events received will be mouse-dragged events. ! moveMouseBelowTextArea( tremble ); Util.waitForIdle( robot ); // it is needed to add some small delay on Gnome waitUntilScrollIsPerformed(robot); }
*** 136,155 **** } void moveMouseToCenterOfTextArea() { Dimension d = textArea.getSize(); Point l = textArea.getLocationOnScreen(); ! robot.mouseMove( (int)(l.x+d.width*.5), (int)(l.y+d.height*.5) ); } ! void moveMouseBelowTextArea( boolean shift ) { Dimension d = textArea.getSize(); Point l = textArea.getLocationOnScreen(); ! int x = (int)(l.x+d.width*.5); ! int y = (int)(l.y+d.height*1.5); ! if( shift ) y+=15; ! robot.mouseMove( x, y ); } void waitUntilScrollIsPerformed(Robot robot) { try { Thread.sleep( SCROLL_DELAY ); --- 138,169 ---- } void moveMouseToCenterOfTextArea() { Dimension d = textArea.getSize(); Point l = textArea.getLocationOnScreen(); ! Util.mouseMove(robot, l, new Point((int) (l.x + d.width * .5), ! (int) (l.y + d.height * .5))); } ! void moveMouseBelowTextArea(int tremble) { Dimension d = textArea.getSize(); Point l = textArea.getLocationOnScreen(); ! Point p1; ! if (tremble == 0) { ! p1 = new Point((int) (l.x + d.width * .5), ! (int) (l.y + d.height * 0.5)); ! } else { ! p1 = new Point((int) (l.x + d.width * .5), ! (int) (l.y + d.height * 1.5)); ! } ! Point p2 = new Point((int) (l.x + d.width * .5), ! (int) (l.y + d.height * 1.5) + 15); ! if (tremble % 2 == 0) { ! Util.mouseMove(robot, p1, p2); ! } else { ! Util.mouseMove(robot, p2, p1); ! } } void waitUntilScrollIsPerformed(Robot robot) { try { Thread.sleep( SCROLL_DELAY );
*** 158,172 **** throw new RuntimeException( e ); } } void checkResults() { - //try { Thread.sleep( 30*1000 ); } - //catch( Exception e ) { throw new RuntimeException( e ); } - final int currentSelectionEnd = textArea.getSelectionEnd(); - System.out.println( "TEST: Selection range after test is: ( " + textArea.getSelectionStart() + ", " + currentSelectionEnd + " )" ); --- 172,182 ----
< prev index next >