author | serb |
Wed, 21 Feb 2018 12:49:00 -0800 | |
changeset 49096 | eaef201ec301 |
parent 47216 | 71c04702a3d5 |
child 52739 | 7199c4da1a6f |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
@test |
|
26 |
@bug 6246467 |
|
49096
eaef201ec301
8198333: ProblemList should be updated for headless mode
serb
parents:
47216
diff
changeset
|
27 |
@key headful |
eaef201ec301
8198333: ProblemList should be updated for headless mode
serb
parents:
47216
diff
changeset
|
28 |
@requires (os.family == "linux") | (os.family == "solaris") |
2 | 29 |
@summary List does not honor user specified background, foreground colors on XToolkit |
30 |
@author Dmitry Cherepanov area=awt.list |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
31 |
@library ../../../../lib/testlibrary |
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
32 |
@build ExtendedRobot |
2 | 33 |
@run main SetBackgroundTest |
34 |
*/ |
|
35 |
||
36 |
/** |
|
37 |
* SetBackgroundTest.java |
|
38 |
* |
|
39 |
* summary: |
|
40 |
*/ |
|
41 |
||
42 |
import java.awt.*; |
|
43 |
import java.awt.event.*; |
|
44 |
||
45 |
public class SetBackgroundTest |
|
46 |
{ |
|
47 |
||
48 |
private static boolean isXAWT = (Toolkit.getDefaultToolkit().getClass().getName().equals("sun.awt.X11.XToolkit")); |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
49 |
private static ExtendedRobot robot = null; |
2 | 50 |
private static Frame frame = null; |
51 |
||
52 |
private static final Color color = Color.red; |
|
53 |
private static Color roughColor = null; |
|
54 |
||
55 |
private static void initRoughColor(){ |
|
56 |
||
57 |
Canvas canvas = new Canvas(); |
|
58 |
canvas.setBackground(color); |
|
59 |
frame.add(canvas, BorderLayout.CENTER); |
|
60 |
frame.validate(); |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
61 |
robot.waitForIdle(500); |
2 | 62 |
|
63 |
Point loc = canvas.getLocationOnScreen(); |
|
64 |
Color robotColor = robot.getPixelColor(loc.x + canvas.getWidth()/2, loc.y + canvas.getHeight()/2); |
|
65 |
roughColor = robotColor; |
|
66 |
||
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
67 |
System.out.println(" --- init rough color ... "); |
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
68 |
System.out.println(" color = "+color); |
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
69 |
System.out.println(" roughColor = "+roughColor); |
2 | 70 |
|
71 |
frame.remove(canvas); |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
72 |
robot.waitForIdle(500); |
2 | 73 |
} |
74 |
||
75 |
||
76 |
private static void test() { |
|
77 |
if (!isXAWT){ |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
78 |
System.out.println(" this is XAWT-only test. "); |
2 | 79 |
return; |
80 |
} |
|
81 |
||
82 |
frame = new Frame(); |
|
83 |
frame.setBounds(400,400,200,200); |
|
84 |
frame.setLayout(new BorderLayout()); |
|
85 |
frame.setVisible(true); |
|
86 |
||
87 |
||
88 |
try{ |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
89 |
robot = new ExtendedRobot(); |
2 | 90 |
}catch(AWTException e){ |
91 |
throw new RuntimeException(e.getMessage()); |
|
92 |
} |
|
93 |
||
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
94 |
robot.waitForIdle(500); |
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
95 |
|
2 | 96 |
initRoughColor(); |
97 |
Component[] components = new Component[] { |
|
98 |
new Button(), new Checkbox(), new Label(), new List(3, false), |
|
99 |
new TextArea(), new TextField(), new Choice() |
|
100 |
}; |
|
101 |
||
102 |
for (Component component : components) { |
|
103 |
testComponent(new Panel(), component, color); |
|
104 |
} |
|
105 |
||
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
106 |
robot.waitForIdle(1500); |
2 | 107 |
frame.dispose(); |
108 |
} |
|
109 |
||
110 |
private static void testComponent(Container container, Component component, Color color){ |
|
111 |
||
112 |
component.setBackground(color); |
|
113 |
||
114 |
container.setLayout(new BorderLayout()); |
|
115 |
container.add(component, BorderLayout.CENTER); |
|
116 |
frame.add(container, BorderLayout.CENTER); |
|
117 |
frame.add("Center", container); |
|
118 |
frame.validate(); |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
119 |
robot.waitForIdle(500); |
2 | 120 |
|
121 |
Point loc = component.getLocationOnScreen(); |
|
122 |
Color robotColor = robot.getPixelColor(loc.x + component.getWidth()/2, loc.y + component.getHeight()/2); |
|
123 |
||
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
124 |
System.out.println(" --- test ... "); |
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
125 |
System.out.println(" container = "+container); |
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
126 |
System.out.println(" component = "+component); |
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
127 |
System.out.println(" color = "+color); |
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
128 |
System.out.println(" roughColor = "+roughColor); |
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
129 |
System.out.println(" robotColor = "+robotColor); |
2 | 130 |
|
131 |
if(robotColor.getRGB() != roughColor.getRGB()){ |
|
132 |
throw new RuntimeException(" the case failed. "); |
|
133 |
} else { |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
134 |
System.out.println(" the case passed. "); |
2 | 135 |
} |
136 |
||
137 |
container.remove(component); |
|
138 |
frame.remove(container); |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
139 |
robot.waitForIdle(500); |
2 | 140 |
} |
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
141 |
public static void main( String args[] ) throws Exception |
2 | 142 |
{ |
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
143 |
test(); |
2 | 144 |
} |
145 |
} |
|
146 |