author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 35987 | aea5d5d0ec6d |
child 39839 | 9c7500fae20a |
permissions | -rw-r--r-- |
35987
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
35987
diff
changeset
|
2 |
* Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. |
35987
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
4 |
* |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
8 |
* |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
13 |
* accompanied this code). |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
14 |
* |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
18 |
* |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
21 |
* questions. |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
22 |
*/ |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
23 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
24 |
/* |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
25 |
@test |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
35987
diff
changeset
|
26 |
@key headful |
35987
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
27 |
@bug 6180449 |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
28 |
@summary TextArea scrolls to its left when selecting the text from the end. |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
29 |
@run main TextAreaScrolling |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
30 |
*/ |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
31 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
32 |
import java.awt.Frame; |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
33 |
import java.awt.Point; |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
34 |
import java.awt.Rectangle; |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
35 |
import java.awt.Robot; |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
36 |
import java.awt.TextArea; |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
37 |
import java.awt.event.InputEvent; |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
38 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
39 |
public class TextAreaScrolling { |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
40 |
Frame mainFrame; |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
41 |
TextArea textArea; |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
42 |
Robot robot; |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
43 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
44 |
TextAreaScrolling() { |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
45 |
mainFrame = new Frame(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
46 |
mainFrame.setSize(200, 200); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
47 |
mainFrame.setLocation(200, 200); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
48 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
49 |
textArea = new TextArea(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
50 |
textArea.setText("1234 5678"); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
51 |
textArea.setSelectionStart(3); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
52 |
textArea.setSelectionStart(4); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
53 |
mainFrame.add(textArea); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
54 |
mainFrame.setVisible(true); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
55 |
textArea.requestFocusInWindow(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
56 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
57 |
try { |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
58 |
robot = new Robot(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
59 |
robot.setAutoWaitForIdle(true); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
60 |
} catch (Exception ex) { |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
61 |
dispose(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
62 |
System.exit(0); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
63 |
throw new RuntimeException("Robot Creation Failed"); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
64 |
} |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
65 |
} |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
66 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
67 |
public void dispose() { |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
68 |
if (mainFrame != null) { |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
69 |
mainFrame.dispose(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
70 |
} |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
71 |
} |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
72 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
73 |
public void performTest() { |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
74 |
Point loc = textArea.getLocationOnScreen(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
75 |
Rectangle textAreaBounds = new Rectangle(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
76 |
textArea.getBounds(textAreaBounds); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
77 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
78 |
// Move mouse at center in first row of TextArea. |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
79 |
robot.mouseMove(loc.x + textAreaBounds.width / 2, loc.y + 5); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
80 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
81 |
// Perform selection by scrolling to left from end of char sequence. |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
82 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
83 |
robot.mouseMove(textAreaBounds.x - 5, loc.y + 5); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
84 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
85 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
86 |
// Perform double click on beginning word of TextArea |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
87 |
robot.mouseMove(loc.x + 5, loc.y + 5); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
88 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
89 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
90 |
robot.delay(100); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
91 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
92 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
93 |
robot.delay(100); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
94 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
95 |
if (textArea.getSelectedText().contentEquals("5678")) { |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
96 |
dispose(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
97 |
throw new RuntimeException ("TextArea over scrolled towards left" |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
98 |
+ "Expected selected text: '1234 ' and for mac '1234'" |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
99 |
+ "Actual selected text: 5678"); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
100 |
} |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
101 |
} |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
102 |
|
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
103 |
public static void main(String argv[]) throws RuntimeException { |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
104 |
TextAreaScrolling test = new TextAreaScrolling(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
105 |
test.performTest(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
106 |
test.dispose(); |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
107 |
} |
aea5d5d0ec6d
6180449: PIT: Text in TextArea scrolls to its left one char when selecting the text from the end
arapte
parents:
diff
changeset
|
108 |
} |