67 |
67 |
68 public static void main(String[] args) { |
68 public static void main(String[] args) { |
69 bug6427244 t = new bug6427244(); |
69 bug6427244 t = new bug6427244(); |
70 for (String space: SPACES) { |
70 for (String space: SPACES) { |
71 t.init(space); |
71 t.init(space); |
72 t.runAllTests(); |
72 t.testCaretPosition(); |
73 } |
73 } |
74 |
74 |
75 System.out.println("OK"); |
75 System.out.println("OK"); |
|
76 // Dispose the test interface upon completion |
|
77 t.destroyTestInterface(); |
76 } |
78 } |
77 |
79 |
78 void init(final String space) { |
80 void init(final String space) { |
79 try { |
81 try { |
80 SwingUtilities.invokeAndWait(new Runnable() { |
82 SwingUtilities.invokeAndWait(new Runnable() { |
111 } catch (Exception ex) { |
113 } catch (Exception ex) { |
112 throw new RuntimeException(ex); |
114 throw new RuntimeException(ex); |
113 } |
115 } |
114 } |
116 } |
115 |
117 |
116 void blockTillDisplayed(JComponent comp) { |
118 void destroyTestInterface() { |
117 if(comp != null) { |
119 try { |
118 while (!comp.isVisible()) { |
120 SwingUtilities.invokeAndWait(new Runnable() { |
119 try { |
121 @Override |
|
122 public void run() { |
|
123 // Dispose the frame |
|
124 jf.dispose(); |
|
125 } |
|
126 }); |
|
127 } catch (Exception ex) { |
|
128 // No-op |
|
129 } |
|
130 } |
|
131 |
|
132 void blockTillDisplayed(JComponent comp) throws Exception { |
|
133 while (comp != null && isCompVisible == false) { |
|
134 try { |
|
135 SwingUtilities.invokeAndWait(new Runnable() { |
|
136 @Override |
|
137 public void run() { |
|
138 isCompVisible = comp.isVisible(); |
|
139 } |
|
140 }); |
|
141 |
|
142 if (isCompVisible == false) { |
|
143 // A short wait for component to be visible |
120 Thread.sleep(1000); |
144 Thread.sleep(1000); |
121 } catch (InterruptedException ie) { |
145 } |
122 /* No-op */ |
146 } catch (InterruptedException ex) { |
123 } |
147 // No-op. Thread resumed from sleep |
|
148 } catch (Exception ex) { |
|
149 throw new RuntimeException(ex); |
124 } |
150 } |
125 } |
151 } |
126 } |
152 } |
127 |
153 |
128 public void testCaretPosition() { |
154 public void testCaretPosition() { |
129 Point p = tp.getLocationOnScreen(); |
155 final Point p[] = new Point[1]; |
130 // the right-top corner position |
156 try { |
131 p.x += (dim.width - 5); |
157 SwingUtilities.invokeAndWait(new Runnable() { |
132 p.y += 5; |
158 public void run() { |
133 ROBOT.mouseMove(p.x, p.y); |
159 p[0] = tp.getLocationOnScreen(); |
|
160 |
|
161 // the right-top corner position |
|
162 p[0].x += (dim.width - 5); |
|
163 p[0].y += 5; |
|
164 } |
|
165 }); |
|
166 } catch (Exception ex) { |
|
167 throw new RuntimeException(ex); |
|
168 } |
|
169 ROBOT.mouseMove(p[0].x, p[0].y); |
134 ROBOT.clickMouse(); |
170 ROBOT.clickMouse(); |
135 ROBOT.hitKey(KeyEvent.VK_HOME); |
171 ROBOT.hitKey(KeyEvent.VK_HOME); |
136 ROBOT.waitForIdle(); |
172 ROBOT.waitForIdle(); |
137 // this will fail if caret moves out of the 1st line. |
173 // this will fail if caret moves out of the 1st line. |
138 if (getCaretOrdinate() != 0) { |
174 if (getCaretOrdinate() != 0) { |
|
175 // Dispose the test interface upon completion |
|
176 destroyTestInterface(); |
139 throw new RuntimeException("Test Failed."); |
177 throw new RuntimeException("Test Failed."); |
140 } |
178 } |
141 } |
179 } |
142 |
180 |
143 int getCaretOrdinate() { |
181 int getCaretOrdinate() { |