JBR-1380: Regression test java/awt/Graphics2D/DrawString/LCDTextSrcEa.java works incorrectly
diff --git a/test/java/awt/Graphics2D/DrawString/LCDTextSrcEa.java b/test/java/awt/Graphics2D/DrawString/LCDTextSrcEa.java
index 74c228e..ac00940 100644
--- a/test/java/awt/Graphics2D/DrawString/LCDTextSrcEa.java
+++ b/test/java/awt/Graphics2D/DrawString/LCDTextSrcEa.java
@@ -30,14 +30,20 @@
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
public class LCDTextSrcEa extends Component {
+ private static final int TIMEOUT = 20000;
+ private static volatile boolean nongrey = false;
+ private static CountDownLatch latch = new CountDownLatch(1);
+
static int SZ=150;
BufferedImage target =
new BufferedImage(SZ, SZ, BufferedImage.TYPE_INT_RGB);
- public static void main(String args[]) {
+ public static void main(String args[]) throws InterruptedException {
Frame f = new Frame("LCD Text SrcEa Test");
f.addWindowListener(new WindowAdapter() {
@Override
@@ -49,6 +55,16 @@
f.add("Center", td);
f.pack();
f.setVisible(true);
+
+ if(!latch.await(TIMEOUT, TimeUnit.MILLISECONDS)) {
+ throw new RuntimeException("ERROR: Test paint method has not finished for " + TIMEOUT + "msec");
+ }
+
+ f.dispose();
+
+ if (!nongrey) {
+ throw new RuntimeException("No LCD text found");
+ }
}
public Dimension getPreferredSize() {
@@ -72,7 +88,7 @@
g2d.setColor(Color.black);
g2d.drawString("Some sample text.", 10, 20);
gx.drawImage(target, 0, 0, null);
- boolean nongrey = false;
+
//Test BI: should be some non-greyscale color
for (int px=0;px<SZ;px++) {
for (int py=0;py<SZ;py++) {
@@ -86,8 +102,6 @@
}
}
}
- if (!nongrey) {
- throw new RuntimeException("No LCD text found");
- }
+ latch.countDown();
}
}