Skip to content
Permalink
Browse files

8232226: [macos 10.15] test/jdk/java/awt/color/EqualityTest/EqualityT…

…est.java may fail

Reviewed-by: prr, pbansal
  • Loading branch information
mrserb committed Dec 5, 2019
1 parent 36eb751 commit cd2cc6d796ed039e9e03afd6de1ad519bdba3324
Showing with 78 additions and 0 deletions.
  1. +78 −0 test/jdk/java/awt/ColorClass/EqualityTest/EqualityTest.java
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2011, 2019, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

import java.awt.Color;
import java.awt.SystemColor;

/**
* @test
* @bug 4559156
* @summary java.awt.Color.equals() does not work when comparing to
* java.awt.SystemColor
*/
public final class EqualityTest {

private final static SystemColor [] colorArray = {
SystemColor.desktop,
SystemColor.activeCaption,
SystemColor.activeCaptionText,
SystemColor.activeCaptionBorder,
SystemColor.inactiveCaption,
SystemColor.inactiveCaptionText,
SystemColor.inactiveCaptionBorder,
SystemColor.window,
SystemColor.windowBorder,
SystemColor.windowText,
SystemColor.menu,
SystemColor.menuText,
SystemColor.text,
SystemColor.textText,
SystemColor.textHighlight,
SystemColor.textHighlightText,
SystemColor.textInactiveText,
SystemColor.control,
SystemColor.controlText,
SystemColor.controlHighlight,
SystemColor.controlLtHighlight,
SystemColor.controlShadow,
SystemColor.controlDkShadow,
SystemColor.scrollbar,
SystemColor.info,
SystemColor.infoText
};

public static void main(final String[] str) {
for (final SystemColor system : colorArray) {
Color color = new Color(system.getRGB(), system.getAlpha() < 255);
System.out.printf("System color = %s = [%d]: color = %s [%d]%n",
system, system.getRGB(), color, color.getRGB());
boolean equalityStatement1 = color.equals(system);
boolean equalityStatement2 = system.equals(color);
if (!equalityStatement1 || !equalityStatement2) {
System.out.println("COLOR.equals(SC) = " + equalityStatement1);
System.out.println("SC.equals(COLOR) = " + equalityStatement2);
throw new RuntimeException("The equals() method doesn't work correctly");
}
}
}
}

0 comments on commit cd2cc6d

Please sign in to comment.
You can’t perform that action at this time.