Skip to content

Commit a75de53

Browse files
committed
8365425: [macos26] javax/swing/JInternalFrame/8160248/JInternalFrameDraggingTest.java fails on macOS 26
Backport-of: bdf9834b81f0565e3572de42ebd42981d1d05a5c
1 parent cea617d commit a75de53

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test/jdk/javax/swing/JInternalFrame/8160248/JInternalFrameDraggingTest.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, 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
@@ -21,13 +21,15 @@
2121
* questions.
2222
*/
2323

24+
import java.io.File;
2425
import java.awt.BorderLayout;
2526
import java.awt.Color;
2627
import java.awt.Point;
2728
import java.awt.Rectangle;
2829
import java.awt.Robot;
2930
import java.awt.event.InputEvent;
3031
import java.awt.image.BufferedImage;
32+
import javax.imageio.ImageIO;
3133
import javax.swing.JDesktopPane;
3234
import javax.swing.JFrame;
3335
import javax.swing.JInternalFrame;
@@ -51,6 +53,7 @@ public class JInternalFrameDraggingTest {
5153
private static JInternalFrame internalFrame;
5254
private static int FRAME_SIZE = 500;
5355
private static Color BACKGROUND_COLOR = Color.ORANGE;
56+
private static final int tolerance = 10;
5457

5558
public static void main(String[] args) throws Exception {
5659
try {
@@ -69,14 +72,24 @@ public static void main(String[] args) throws Exception {
6972
BufferedImage img = robot.createScreenCapture(rect);
7073

7174
int testRGB = BACKGROUND_COLOR.getRGB();
75+
Color testColor = new Color(testRGB);
7276
for (int i = 1; i < size; i++) {
7377
int rgbCW = img.getRGB(i, size / 2);
7478
int rgbCH = img.getRGB(size / 2, i);
75-
if (rgbCW != testRGB || rgbCH != testRGB) {
79+
Color rgbCWColor = new Color(rgbCW);
80+
Color rgbCHColor = new Color(rgbCH);
81+
82+
if (Math.abs(rgbCWColor.getRed() - testColor.getRed()) > tolerance
83+
|| Math.abs(rgbCWColor.getGreen() - testColor.getGreen()) > tolerance
84+
|| Math.abs(rgbCWColor.getBlue() - testColor.getBlue()) > tolerance
85+
|| Math.abs(rgbCHColor.getRed() - testColor.getRed()) > tolerance
86+
|| Math.abs(rgbCHColor.getGreen() - testColor.getGreen()) > tolerance
87+
|| Math.abs(rgbCHColor.getBlue() - testColor.getBlue()) > tolerance) {
7688
System.out.println("i " + i + " rgbCW " +
7789
Integer.toHexString(rgbCW) +
7890
" testRGB " + Integer.toHexString(testRGB) +
7991
" rgbCH " + Integer.toHexString(rgbCH));
92+
ImageIO.write(img, "png", new File("JInternalFrameDraggingTest.png"));
8093
throw new RuntimeException("Background color is wrong!");
8194
}
8295
}

0 commit comments

Comments
 (0)