--- old/test/jdk/java/awt/Window/ShapedAndTranslucentWindows/Common.java 2018-02-26 15:26:31.000000000 +0530 +++ new/test/jdk/java/awt/Window/ShapedAndTranslucentWindows/Common.java 2018-02-26 15:26:31.000000000 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, 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 @@ -261,13 +261,13 @@ for (Point p : points) { p.translate(location.x, location.y); if (areBackgroundPoints) { - if (!robot.getPixelColor(p.x, p.y).equals(BG_COLOR)) + if (!similarColors(robot.getPixelColor(p.x, p.y), BG_COLOR)) throw new RuntimeException("Background point " + p + " color " + robot.getPixelColor(p.x, p.y) + " does not equal to background color " + BG_COLOR); else System.out.println("OK with background point " + p); } else { - if (robot.getPixelColor(p.x, p.y).equals(BG_COLOR)) + if (similarColors(robot.getPixelColor(p.x, p.y), BG_COLOR)) throw new RuntimeException("Foreground point " + p + " equals to background color " + BG_COLOR); else @@ -276,6 +276,17 @@ } } + public static boolean similarColors(final Color c1, final Color c2) { + if((Math.abs(c1.getRed() - c2.getRed()) < 40) && + (Math.abs(c1.getBlue() - c2.getBlue()) < 40) && + (Math.abs(c1.getGreen() - c2.getGreen()) < 40)) { + return true; + } + else { + return false; + } + } + public void initBackgroundFrame() { background = new Frame(); background.setUndecorated(true);