Skip to content

Commit 9796aac

Browse files
committed
8223543: [TESTBUG] Regression test java/awt/Graphics2D/DrawString/LCDTextSrcEa.java has issues
Backport-of: d41331e6f2255aa07dbbbbccf62e39c50269e269
1 parent 3210c99 commit 9796aac

File tree

1 file changed

+26
-33
lines changed

1 file changed

+26
-33
lines changed

test/jdk/java/awt/Graphics2D/DrawString/LCDTextSrcEa.java

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,44 +23,38 @@
2323

2424
/**
2525
* @test
26-
* @key headful
27-
* @bug 6996867
26+
* @bug 6996867 8223543
27+
* @requires (os.family == "windows")
2828
* @summary Render as LCD Text in SrcEa composite mode.
2929
*/
3030

31-
import java.awt.*;
32-
import java.awt.event.*;
33-
import java.awt.image.*;
31+
import java.awt.AlphaComposite;
32+
import java.awt.Color;
33+
import java.awt.Graphics2D;
34+
import java.awt.RenderingHints;
35+
import java.awt.image.BufferedImage;
3436

35-
public class LCDTextSrcEa extends Component {
36-
37-
static int SZ=150;
38-
BufferedImage target =
39-
new BufferedImage(SZ, SZ, BufferedImage.TYPE_INT_RGB);
40-
41-
public static void main(String args[]) {
42-
Frame f = new Frame("LCD Text SrcEa Test");
43-
f.addWindowListener(new WindowAdapter() {
44-
@Override
45-
public void windowClosing(WindowEvent e) {
46-
System.exit(0);
47-
}
48-
});
49-
LCDTextSrcEa td = new LCDTextSrcEa();
50-
f.add("Center", td);
51-
f.pack();
52-
f.setVisible(true);
53-
}
54-
55-
public Dimension getPreferredSize() {
56-
return new Dimension(SZ,SZ);
57-
}
58-
59-
public void paint(Graphics gx) {
37+
public class LCDTextSrcEa {
6038

39+
public static void main(String[] args) {
40+
String os = System.getProperty("os.name");
41+
if (os.toLowerCase().startsWith("mac")) {
42+
System.out.println("macOS doesn't support LCD any more. Skipping");
43+
return;
44+
}
45+
/* Sometimes freetype on Linux is built without LCD support, so
46+
* it can't be relied upon to test there.
47+
*/
48+
if (os.toLowerCase().startsWith("linux")) {
49+
System.out.println("Linux freetype may not do LCD. Skipping");
50+
return;
51+
}
52+
int SZ=200;
53+
BufferedImage target =
54+
new BufferedImage(SZ, SZ, BufferedImage.TYPE_INT_RGB);
6155
Graphics2D g2d = (Graphics2D) target.getGraphics();
6256
g2d.setColor(Color.white);
63-
g2d.fillRect(0, 0, getWidth(), getHeight());
57+
g2d.fillRect(0, 0, SZ, SZ);
6458

6559
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.01f));
6660
g2d.setRenderingHint(
@@ -72,7 +66,6 @@ public void paint(Graphics gx) {
7266

7367
g2d.setColor(Color.black);
7468
g2d.drawString("Some sample text.", 10, 20);
75-
gx.drawImage(target, 0, 0, null);
7669
boolean nongrey = false;
7770
//Test BI: should be some non-greyscale color
7871
for (int px=0;px<SZ;px++) {

0 commit comments

Comments
 (0)