JDK-6272212 : Regression testcase java/awt/List/SetBackgroundTest/SetBackgroundTest.html fails
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2005-05-18
  • Updated: 2011-01-19
  • Resolved: 2005-08-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b47Fixed
Related Reports
Relates :  
Description
This occurs on Cinnabar on AWT PIT build for mustang b38

java version "1.6.0-awt.pit-int-jcg-linux-02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-awt.pit-int-jcg-linux-02-dm97671_11_may_2005_09_09-b00)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b35, mixed mode)

The regression testcase java/awt/List/SetBackgroundTest/SetBackgroundTest.html fails. The jtr file attached.
###@###.### 2005-05-18 05:24:34 GMT

Comments
SUGGESTED FIX *** /net/aquila/export/dc158259/Mustang//webrev/test/java/awt/List/SetBackgroundTest/SetBackgroundTest.java- 2005-07-20 12:42:39.000000000 +0400 --- /net/aquila/export/dc158259/Mustang//webrev/test/java/awt/List/SetBackgroundTest/SetBackgroundTest.java 2005-07-20 12:42:39.000000000 +0400 *************** *** 8,15 **** import java.applet.Applet; import java.awt.*; ! import java.util.ArrayList; ! import java.util.Iterator; public class SetBackgroundTest extends Applet { --- 8,14 ---- import java.applet.Applet; import java.awt.*; ! import java.util.HashMap; public class SetBackgroundTest extends Applet { *************** *** 17,22 **** --- 16,28 ---- Frame f; boolean motif = (Toolkit.getDefaultToolkit().getClass().getName().equals("sun.awt.X11.MToolkit")); boolean win = (System.getProperty("os.name").startsWith("Windows")); + // Template color is rough color + // It's based on the some interested color (Color.red, ...) and + // is calculated in the environment with unknown depth + HashMap <Color, Color> template = new HashMap<Color, Color>(); + Canvas canvas = new Canvas(); + Robot r = null; + Point loc = null; public void init() { *************** *** 50,55 **** --- 56,69 ---- f.pack(); f.setVisible(true); + try{ + r = new Robot(); + }catch(AWTException e){ + throw new RuntimeException(e.getMessage()); + } + + getRoughColors(); + Color color; // foreground (actionType == 2) not implemented yet for(int actionType = 1; actionType < 2; actionType++){ *************** *** 57,66 **** if (actionType == ActionType.BACKGROUND){ childs = createChilds(ActionType.BACKGROUND); ! color = Color.red; }else{ childs = createChilds(ActionType.FOREGROUND); ! color = Color.blue; } for(int i = 0; i < childs.length; i++){ --- 71,80 ---- if (actionType == ActionType.BACKGROUND){ childs = createChilds(ActionType.BACKGROUND); ! color = template.get(Color.red); }else{ childs = createChilds(ActionType.FOREGROUND); ! color = template.get(Color.blue); } for(int i = 0; i < childs.length; i++){ *************** *** 73,78 **** --- 87,123 ---- f.dispose(); } + // Fixed 6272212: Regression testcase java/awt/List/SetBackgroundTest/SetBackgroundTest.html fails + // Here, we define template values using setBackground/getPixelColor for trivial situation + private void getRoughColors(){ + + f.add(canvas, BorderLayout.CENTER); + f.validate(); + + r.delay(500); + loc = canvas.getLocationOnScreen(); + r.delay(500); + + template.put(Color.red, getRoughColor(Color.red)); + template.put(Color.blue, getRoughColor(Color.blue)); + template.put(SystemColor.window, getRoughColor(SystemColor.window)); + template.put(SystemColor.text, getRoughColor(SystemColor.text)); + + f.remove(canvas); + r.delay(500); + } + + private Color getRoughColor(Color color){ + r.delay(500); + canvas.setBackground(color); + r.delay(500); + Color rough = r.getPixelColor(loc.x + canvas.getWidth()/2, loc.y + canvas.getHeight()/2); + r.delay(500); + System.out.println("exact color="+color.getRGB()); + System.out.println("rough color="+rough.getRGB()); + return rough; + } + private void test(TestCase test){ add(test); *************** *** 126,136 **** container.add(child, BorderLayout.CENTER); f.validate(); ! try { ! Thread.sleep(500); ! } catch (InterruptedException ie) { ! System.exit(0); ! } } private void remove(TestCase test){ --- 171,177 ---- container.add(child, BorderLayout.CENTER); f.validate(); ! r.delay(500); } private void remove(TestCase test){ *************** *** 142,152 **** f.remove(container); f.validate(); ! try { ! Thread.sleep(100); ! } catch (InterruptedException ie) { ! System.exit(0); ! } } private void check(TestCase test){ --- 183,189 ---- f.remove(container); f.validate(); ! r.delay(100); } private void check(TestCase test){ *************** *** 156,172 **** int actionType = test.getActionType(); int settingType = test.getSettingType(); Color color = test.getColor(); ! Point loc = child.getLocationOnScreen(); ! ! Robot r; ! ! try{ ! r = new Robot(); ! }catch(AWTException e){ ! throw new RuntimeException(e.getMessage()); ! } Color robotColor = r.getPixelColor(loc.x + child.getWidth()/2, loc.y + child.getHeight()/2); System.out.println(""+actionType+","+settingType+" robotColor.getRGB()-"+robotColor.getRGB()); if(child instanceof Choice){ --- 193,203 ---- int actionType = test.getActionType(); int settingType = test.getSettingType(); Color color = test.getColor(); ! loc = child.getLocationOnScreen(); + r.delay(500); Color robotColor = r.getPixelColor(loc.x + child.getWidth()/2, loc.y + child.getHeight()/2); + r.delay(500); System.out.println(""+actionType+","+settingType+" robotColor.getRGB()-"+robotColor.getRGB()); if(child instanceof Choice){ *************** *** 175,181 **** return; } if (settingType == SettingType.EXPLICIT || settingType == SettingType.DEFAULT){ ! color = SystemColor.window; } if(robotColor.getRGB() != color.getRGB()){ throw new RuntimeException("test failed. BG, "+settingType+", "+child+", "+robotColor+" != "+color); --- 206,212 ---- return; } if (settingType == SettingType.EXPLICIT || settingType == SettingType.DEFAULT){ ! color = template.get(SystemColor.window); } if(robotColor.getRGB() != color.getRGB()){ throw new RuntimeException("test failed. BG, "+settingType+", "+child+", "+robotColor+" != "+color); *************** *** 195,207 **** if (actionType == ActionType.BACKGROUND){ if (child instanceof Button || child instanceof Checkbox || child instanceof Label){ if(settingType == SettingType.DEFAULT){ ! color = SystemColor.window; } if(robotColor.getRGB() != color.getRGB()){ throw new RuntimeException("test failed. BG, "+settingType+", "+child+", "+robotColor+" != "+color); } }else{ ! if(robotColor.getRGB() != SystemColor.text.getRGB()){ throw new RuntimeException("test failed. BG, "+settingType+", "+child+", "+robotColor+" != "+SystemColor.text); } } --- 226,238 ---- if (actionType == ActionType.BACKGROUND){ if (child instanceof Button || child instanceof Checkbox || child instanceof Label){ if(settingType == SettingType.DEFAULT){ ! color = template.get(SystemColor.window); } if(robotColor.getRGB() != color.getRGB()){ throw new RuntimeException("test failed. BG, "+settingType+", "+child+", "+robotColor+" != "+color); } }else{ ! if(robotColor.getRGB() != template.get(SystemColor.text).getRGB()){ throw new RuntimeException("test failed. BG, "+settingType+", "+child+", "+robotColor+" != "+SystemColor.text); } } ###@###.### 2005-07-20 12:17:49 GMT
20-07-2005

EVALUATION This is the bug in the regression test. The responsibility of this bug depend on environement. Actually, the regression test is ok if the color quality is 24 bit and more. But this bug is reproducible if the depth is 16 bit and less. In the test we use Robot.getRixelColor() and compare the resulted value with the template values (Color.red, ...). But this values is acceptable only if the depth is high. It's possible to complete this test by means of the calculating of the template values at the beggining of the test. Namely, we place canvas on frame and do setBackround/getPixelColor for the interested colors (that we using in the test). ###@###.### 2005-07-19 13:40:19 GMT ###@###.### 2005-07-19 15:19:50 GMT
19-07-2005