jdk/test/java/awt/TextArea/UsingWithMouse/SelectionAutoscrollTest.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 36871 62d3bb5aba7a
permissions -rw-r--r--
8159690: [TESTBUG] Mark headful tests with @key headful. Reviewed-by: simonis, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
     2
 * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4815
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4815
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4815
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    25
  @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 36871
diff changeset
    26
  @key headful
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    27
  @bug 6497109 6734341
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
  @summary TextArea must have selection expanding, and also be autoscrolled, if mouse is dragged from inside.
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    29
  @library ../../regtesthelpers
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    30
  @build Util
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
  @author Konstantin Voloshin: area=TextArea
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    32
  @run main SelectionAutoscrollTest
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * SelectionAutoscrollTest.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * summary: TextArea should be auto-scrolled and text should be selected to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *   the end, if mouse is dragged from inside box-for-text to outside it, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *   is hold pressed there.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.awt.Frame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.awt.Panel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.awt.GridLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.awt.TextArea;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.awt.Point;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.awt.Dimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.awt.event.MouseEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.awt.Robot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.awt.Toolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import test.java.awt.regtesthelpers.Util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    56
public class SelectionAutoscrollTest {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    TextArea textArea;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    Robot robot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    final int desiredSelectionEnd = ('z'-'a'+1)*2;  // 52
4815
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
    60
    final static int SCROLL_DELAY = 10; // ms
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    62
    public static void main(String[] args) {
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    63
        SelectionAutoscrollTest selectionAutoscrollTest
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    64
                = new SelectionAutoscrollTest();
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    65
        selectionAutoscrollTest.createObjects();
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    66
        selectionAutoscrollTest.manipulateMouse();
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
    67
        selectionAutoscrollTest.checkResults();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    void createObjects() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        textArea = new TextArea( bigString() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        robot = Util.createRobot();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        Panel panel = new Panel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        panel.setLayout( new GridLayout(3,3) );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        for( int y=0; y<3; ++y ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            for( int x=0; x<3; ++x ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                if( x==1 && y==1 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                    panel.add( textArea );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                    panel.add( new Panel() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        Frame frame = new Frame( "TextArea cursor icon test" );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        frame.setSize( 300, 300 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        frame.add( panel );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        frame.setVisible( true );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    static String bigString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        String s = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        for( char c='a'; c<='z'; ++c ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            s += c+"\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        return s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    void manipulateMouse() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        moveMouseToCenterOfTextArea();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        Util.waitForIdle( robot );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        robot.mousePress( MouseEvent.BUTTON1_MASK );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        Util.waitForIdle( robot );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   108
        for( int tremble=0; tremble < 10; ++tremble ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            // Mouse is moved repeatedly here (with conservatively chosen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            // ammount of times), to give some time/chance for TextArea to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            // autoscroll and for text-selection to expand to the end.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            // This is because:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            // - On Windows,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            //   autoscrolling and selection-expansion happens only once per
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            //   each mouse-dragged event received, and only for some ammount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            //   not to the end. So, we have to drag mouse repeatedly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            // - on X,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            //   only 1 mouse-dragged event is required for autoscrolling/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            //   selection-expanding to commence. Once commenced, it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            //   continue to the end of text (provided that mouse-button is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            //   hold pressed), but it may take hardly predictable ammount of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            //   time. However, repeatedly dragging mouse seems perfectly help
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            //   here, instead of having to use 'Thread.sleep( ??? )'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            // Note: It's required here to move mouse 2 times to receive the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            //   1-st drag-event. After 1-st movement, only mouse-exited event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            //   will be generated. If mouse was released after first movement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            //   here, we would even get mouse-clicked event (at least for now,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            //   and this is probably a bug). But, starting with 2nd iteration,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            //   all events received will be mouse-dragged events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   131
            moveMouseBelowTextArea( tremble );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            Util.waitForIdle( robot );
4815
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
   133
            // it is needed to add some small delay on Gnome
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
   134
            waitUntilScrollIsPerformed(robot);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        robot.mouseRelease( MouseEvent.BUTTON1_MASK );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        Util.waitForIdle( robot );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    void moveMouseToCenterOfTextArea() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        Dimension d = textArea.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        Point l = textArea.getLocationOnScreen();
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   144
        Util.mouseMove(robot, l, new Point((int) (l.x + d.width * .5),
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   145
                (int) (l.y + d.height * .5)));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   148
    void moveMouseBelowTextArea(int tremble) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        Dimension d = textArea.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        Point l = textArea.getLocationOnScreen();
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   151
        Point p1;
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   152
        if (tremble == 0) {
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   153
            p1 = new Point((int) (l.x + d.width * .5),
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   154
                    (int) (l.y + d.height * 0.5));
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   155
        } else {
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   156
            p1 = new Point((int) (l.x + d.width * .5),
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   157
                    (int) (l.y + d.height * 1.5));
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   158
        }
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   159
        Point p2 = new Point((int) (l.x + d.width * .5),
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   160
                (int) (l.y + d.height * 1.5) + 15);
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   161
        if (tremble % 2 == 0) {
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   162
            Util.mouseMove(robot, p1, p2);
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   163
        } else {
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   164
            Util.mouseMove(robot, p2, p1);
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   165
        }
4815
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
   166
    }
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
   167
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
   168
    void waitUntilScrollIsPerformed(Robot robot) {
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
   169
        try {
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
   170
            Thread.sleep( SCROLL_DELAY );
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
   171
        }
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
   172
        catch( Exception e ) {
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
   173
            throw new RuntimeException( e );
228652bbd0b9 6920143: test/java/awt/TestArea/UsingWithMouse.java needs realSync()
ptisnovs
parents: 2
diff changeset
   174
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    void checkResults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        final int currentSelectionEnd = textArea.getSelectionEnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        System.out.println(
36871
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   180
                "TEST: Selection range after test is: ( "
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   181
                + textArea.getSelectionStart() + ", "
62d3bb5aba7a 6734341: REGTEST fails: SelectionAutoscrollTest.html
kshefov
parents: 7668
diff changeset
   182
                + currentSelectionEnd + " )"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        boolean resultOk = ( currentSelectionEnd == desiredSelectionEnd );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        String desiredSelectionEndString = "" + desiredSelectionEnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        // On Windows, last empty line is surprisingly not selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        // Even if it's a bug, it's not for this test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        // So, we have 2 acceptable results in this case.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        String toolkitName = Toolkit.getDefaultToolkit().getClass().getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        if( toolkitName.equals("sun.awt.windows.WToolkit") ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            final int desiredSelectionEnd2 = desiredSelectionEnd-1;  // 51
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            resultOk |= ( currentSelectionEnd == desiredSelectionEnd2 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            desiredSelectionEndString += " or " + desiredSelectionEnd2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if( resultOk ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            System.out.println(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                "TEST: passed: Text is selected to the end"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                + " (expected selection range end is "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                + desiredSelectionEndString + ")."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            System.out.println(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                "TEST: FAILED: Text should be selected to the end"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                + " (selection range end should be "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                + desiredSelectionEndString + ")."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            throw new RuntimeException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                "TEST: FAILED: Text should be selected to the end, but it is not."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
}