8166003: [PIT][TEST_BUG] missing helper for javax/swing/text/GlyphPainter2/6427244/bug6427244.java
authorpnarayanan
Fri, 11 Nov 2016 15:30:22 +0530
changeset 42212 e5662f6598d4
parent 42211 ac4e6dc2d20f
child 42213 e106919ddda1
8166003: [PIT][TEST_BUG] missing helper for javax/swing/text/GlyphPainter2/6427244/bug6427244.java Reviewed-by: prr, psadhukhan
jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java
--- a/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java	Fri Nov 11 13:58:42 2016 +0530
+++ b/jdk/test/javax/swing/text/GlyphPainter2/6427244/bug6427244.java	Fri Nov 11 15:30:22 2016 +0530
@@ -23,11 +23,11 @@
  */
 
 /* @test
-   @bug 6427244 8144240
+   @bug 6427244 8144240 8166003
    @summary Test that pressing HOME correctly moves caret in I18N document.
    @author Sergey Groznyh
    @library ../../../regtesthelpers
-   @build JRobot Util TestCase
+   @build JRobot
    @run main bug6427244
 */
 
@@ -36,12 +36,13 @@
 import java.awt.Point;
 import java.awt.Shape;
 import java.awt.event.KeyEvent;
+import javax.swing.JComponent;
 import javax.swing.JFrame;
 import javax.swing.JTextPane;
 import javax.swing.SwingUtilities;
 import javax.swing.text.Position;
 
-public class bug6427244 extends TestCase {
+public class bug6427244 {
     private static final JRobot ROBOT = JRobot.getRobot();
 
     final static int TP_SIZE = 200;
@@ -105,13 +106,25 @@
                     dim = c.getSize();
                 }
             });
-            Util.blockTillDisplayed(tp);
+            blockTillDisplayed(tp);
             ROBOT.waitForIdle();
         } catch (Exception ex) {
             throw new RuntimeException(ex);
         }
     }
 
+    void blockTillDisplayed(JComponent comp) {
+        if(comp != null) {
+            while (!comp.isVisible()) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException ie) {
+                    /* No-op */
+                }
+            }
+        }
+    }
+
     public void testCaretPosition() {
         Point p = tp.getLocationOnScreen();
         // the right-top corner position
@@ -122,7 +135,9 @@
         ROBOT.hitKey(KeyEvent.VK_HOME);
         ROBOT.waitForIdle();
         // this will fail if caret moves out of the 1st line.
-        assertEquals(0, getCaretOrdinate());
+        if (getCaretOrdinate() != 0) {
+            throw new RuntimeException("Test Failed.");
+        }
     }
 
     int getCaretOrdinate() {