equal
deleted
inserted
replaced
22 */ |
22 */ |
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @key headful |
26 * @key headful |
27 * @bug 4278839 |
27 * @bug 4278839 8233634 |
28 * @summary Incorrect cursor movement between words at the end of line |
28 * @summary Incorrect cursor movement between words at the end of line |
29 * @author Anton Nashatyrev |
29 * @author Anton Nashatyrev |
30 * @library ../../../regtesthelpers |
30 * @library ../../../regtesthelpers |
31 * @build Util |
31 * @build Util |
32 * @run main bug4278839 |
32 * @run main bug4278839 |
39 public class bug4278839 extends JFrame { |
39 public class bug4278839 extends JFrame { |
40 |
40 |
41 private static boolean passed = true; |
41 private static boolean passed = true; |
42 private static JTextArea area; |
42 private static JTextArea area; |
43 private static Robot robo; |
43 private static Robot robo; |
|
44 private static JFrame frame; |
44 |
45 |
45 public static void main(String[] args) { |
46 public static void main(String[] args) throws Exception { |
46 try { |
47 try { |
47 |
48 |
48 robo = new Robot(); |
49 robo = new Robot(); |
49 robo.setAutoDelay(100); |
50 robo.setAutoDelay(200); |
50 |
51 |
51 SwingUtilities.invokeAndWait(new Runnable() { |
52 SwingUtilities.invokeAndWait(new Runnable() { |
52 @Override |
53 @Override |
53 public void run() { |
54 public void run() { |
54 createAndShowGUI(); |
55 createAndShowGUI(); |
58 robo.waitForIdle(); |
59 robo.waitForIdle(); |
59 |
60 |
60 clickMouse(); |
61 clickMouse(); |
61 robo.waitForIdle(); |
62 robo.waitForIdle(); |
62 |
63 |
|
64 area.setCaretPosition(0); |
63 |
65 |
64 if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { |
66 if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { |
65 Util.hitKeys(robo, KeyEvent.VK_HOME); |
67 Util.hitKeys(robo, KeyEvent.VK_HOME); |
66 } else { |
68 } else { |
67 Util.hitKeys(robo, KeyEvent.VK_CONTROL, KeyEvent.VK_HOME); |
69 Util.hitKeys(robo, KeyEvent.VK_CONTROL, KeyEvent.VK_HOME); |
84 passed &= moveCaret(false) == 0; |
86 passed &= moveCaret(false) == 0; |
85 |
87 |
86 } catch (Exception e) { |
88 } catch (Exception e) { |
87 throw new RuntimeException("Test failed because of an exception:", |
89 throw new RuntimeException("Test failed because of an exception:", |
88 e); |
90 e); |
|
91 } finally { |
|
92 if (frame != null) { |
|
93 SwingUtilities.invokeAndWait(() -> frame.dispose()); |
|
94 } |
89 } |
95 } |
90 |
96 |
91 if (!passed) { |
97 if (!passed) { |
92 throw new RuntimeException("Test failed."); |
98 throw new RuntimeException("Test failed."); |
93 } |
99 } |
141 |
147 |
142 return KeyEvent.VK_CONTROL; |
148 return KeyEvent.VK_CONTROL; |
143 } |
149 } |
144 |
150 |
145 private static void createAndShowGUI() { |
151 private static void createAndShowGUI() { |
146 JFrame frame = new JFrame(); |
152 frame = new JFrame(); |
147 frame.setTitle("Bug# 4278839"); |
153 frame.setTitle("Bug# 4278839"); |
148 frame.setSize(200, 200); |
154 frame.setSize(200, 200); |
149 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
155 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
150 area = new JTextArea("\naaa bbb\nccc ddd\n"); |
156 area = new JTextArea("\naaa bbb\nccc ddd\n"); |
151 frame.getContentPane().add(new JScrollPane(area)); |
157 frame.getContentPane().add(new JScrollPane(area)); |