Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 70e2c01

Browse files
committedMar 2, 2020
8235153: [TESTBUG] [macos 10.15] java/awt/Graphics/DrawImageBG/SystemBgColorTest.java fails
Reviewed-by: aivanov
1 parent 78d35f1 commit 70e2c01

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed
 

‎test/jdk/java/awt/Graphics/DrawImageBG/SystemBgColorTest.java

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2020, 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
@@ -28,8 +28,14 @@
2828
* @run main SystemBgColorTest
2929
*/
3030

31-
import java.awt.*;
32-
import java.awt.image.*;
31+
import java.awt.AlphaComposite;
32+
import java.awt.Color;
33+
import java.awt.Graphics2D;
34+
import java.awt.Image;
35+
import java.awt.SystemColor;
36+
import java.awt.image.BufferedImage;
37+
import java.awt.image.DataBuffer;
38+
import java.awt.image.IndexColorModel;
3339

3440
public class SystemBgColorTest {
3541
public static final int TESTW = 10;
@@ -109,12 +115,20 @@ public static void test(Image src, int dsttype) {
109115
}
110116

111117
public static void test(Image src, BufferedImage dst, Color bg) {
112-
Graphics g = dst.getGraphics();
118+
Graphics2D g = (Graphics2D) dst.getGraphics();
119+
g.setComposite(AlphaComposite.Src);
113120
g.setColor(Color.white);
114121
g.fillRect(0, 0, TESTW, TESTH);
115122
g.drawImage(src, 0, 0, bg, null);
116-
if (dst.getRGB(0, 0) != bg.getRGB()) {
117-
error("bad bg pixel for: "+bg);
123+
int dstRGB = dst.getRGB(0, 0);
124+
int bgRGB = bg.getRGB();
125+
if (!dst.getColorModel().hasAlpha()) {
126+
bgRGB |= 0xFF000000;
127+
}
128+
if (dstRGB != bgRGB) {
129+
System.err.println("Actual: " + Integer.toHexString(dstRGB));
130+
System.err.println("Expected: " + Integer.toHexString(bgRGB));
131+
error("bad bg pixel for: " + bg);
118132
}
119133
}
120-
}
134+
}

0 commit comments

Comments
 (0)