Skip to content

Commit

Permalink
8286846: test/jdk/javax/swing/plaf/aqua/CustomComboBoxFocusTest.java …
Browse files Browse the repository at this point in the history
…fails on mac aarch64

Backport-of: d7341ae42e11fd08508c5f9c67c09c44b62da59b
  • Loading branch information
GoeLin committed Dec 8, 2023
1 parent bf7c221 commit 7202558
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions test/jdk/javax/swing/plaf/aqua/CustomComboBoxFocusTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,15 +25,15 @@
* @test
* @key headful
* @bug 8073001 8081764
* @requires (os.family == "mac")
* @summary Test verifies that combo box with custom editor renders
* focus ring around arrow button correctly.
* @library /test/lib
* @build jdk.test.lib.Platform
* @run main CustomComboBoxFocusTest
*/

import java.awt.AWTException;
import java.awt.Component;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Rectangle;
Expand All @@ -55,29 +55,24 @@
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

import jdk.test.lib.Platform;

public class CustomComboBoxFocusTest {

private static CustomComboBoxFocusTest test = null;
static int colorTolerance = 5;

public static void main(String[] args) {
if (!Platform.isOSX()) {
public static void main(String[] args) throws Exception {
if (!System.getProperty("os.name").toLowerCase().contains("os x")) {
System.out.println("Only Mac platform test. Test is skipped for other OS.");
return;
}

try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
test = new CustomComboBoxFocusTest();
}
});
} catch (InterruptedException | InvocationTargetException e ) {
throw new RuntimeException("Test failed.", e);
}
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
test = new CustomComboBoxFocusTest();
}
});

SwingUtilities.invokeLater(test.init);
SwingUtilities.invokeAndWait(test.init);

try {
System.out.println("Wait for screenshots...");
Expand Down Expand Up @@ -130,7 +125,23 @@ private boolean match() {

for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
if (a.getRGB(x, y) != b.getRGB(x, y)) {
Color refRGB = new Color(a.getRGB(x,y));
Color customRGB = new Color(b.getRGB(x,y));

int red1 = refRGB.getRed();
int blue1 = refRGB.getBlue();
int green1 = refRGB.getGreen();

int red2 = customRGB.getRed();
int blue2 = customRGB.getBlue();
int green2 = customRGB.getGreen();

if ((Math.abs(red1 - red2) > colorTolerance) ||
(Math.abs(green1 - green2) > colorTolerance) ||
(Math.abs(blue1 - blue2) > colorTolerance)) {
System.out.println("x " + x + " y " + y +
" refRGB " + refRGB +
" customRGB " + customRGB);
return false;
}
}
Expand Down Expand Up @@ -222,6 +233,7 @@ public void removeActionListener(ActionListener actionListener) {
f.add(p);

f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}

Expand Down

1 comment on commit 7202558

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.