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 *
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.
22 */
23 /* @test
24 @bug 4936917 7190578
25 @summary Tests if background is correctly painted when <BODY> has css margins
26 @author Denis Sharypov
27 @library ../../../regtesthelpers
28 @run main bug4936917
29 */
30
31
32
33 import java.awt.Color;
34 import java.awt.Point;
35 import java.awt.Robot;
36 import java.util.Timer;
37 import javax.swing.JComponent;
38 import javax.swing.JEditorPane;
39 import javax.swing.JFrame;
40 import javax.swing.SwingUtilities;
41
42
43 public class bug4936917 {
44
55 "<body> some text </body></html>";
56
57 public void init() throws Exception {
58 SwingUtilities.invokeAndWait(new Runnable() {
59 @Override
60 public void run() {
61 editorPane = new JEditorPane("text/html", "");
62 editorPane.setEditable(false);
63 editorPane.setMargin(new java.awt.Insets(0, 0, 0, 0));
64 editorPane.setText(text);
65
66 f = new JFrame();
67 f.getContentPane().add(editorPane);
68 f.setSize(600, 400);
69 f.setVisible(true);
70 }
71 });
72 blockTillDisplayed(editorPane);
73 Robot robot = new Robot();
74 robot.waitForIdle();
75
76 int x0 = p.x + 15 ;
77 int y = p.y + 15;
78 int match = 0;
79 int nonmatch = 0;
80
81 passed = true;
82 for (int x = x0; x < x0 + 10; x++) {
83 System.out.println("color ("+x+"," + y +")=" + robot.getPixelColor(x,y));
84 if (!robot.getPixelColor(x, y).equals(new Color(0xcc, 0xcc, 0xcc))) {
85 nonmatch++;
86 } else match++;
87 }
88 if (nonmatch > match) {
89 passed = false;
90 }
91 }
92
93 void blockTillDisplayed(JComponent comp) throws Exception {
94 while (p == null) {
|
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 *
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.
22 */
23 /* @test
24 @bug 4936917 7190578 8174717
25 @summary Tests if background is correctly painted when <BODY> has css margins
26 @author Denis Sharypov
27 @library ../../../regtesthelpers
28 @run main bug4936917
29 */
30
31
32
33 import java.awt.Color;
34 import java.awt.Point;
35 import java.awt.Robot;
36 import java.util.Timer;
37 import javax.swing.JComponent;
38 import javax.swing.JEditorPane;
39 import javax.swing.JFrame;
40 import javax.swing.SwingUtilities;
41
42
43 public class bug4936917 {
44
55 "<body> some text </body></html>";
56
57 public void init() throws Exception {
58 SwingUtilities.invokeAndWait(new Runnable() {
59 @Override
60 public void run() {
61 editorPane = new JEditorPane("text/html", "");
62 editorPane.setEditable(false);
63 editorPane.setMargin(new java.awt.Insets(0, 0, 0, 0));
64 editorPane.setText(text);
65
66 f = new JFrame();
67 f.getContentPane().add(editorPane);
68 f.setSize(600, 400);
69 f.setVisible(true);
70 }
71 });
72 blockTillDisplayed(editorPane);
73 Robot robot = new Robot();
74 robot.waitForIdle();
75 robot.delay(300);
76
77 int x0 = p.x + 15 ;
78 int y = p.y + 15;
79 int match = 0;
80 int nonmatch = 0;
81
82 passed = true;
83 for (int x = x0; x < x0 + 10; x++) {
84 System.out.println("color ("+x+"," + y +")=" + robot.getPixelColor(x,y));
85 if (!robot.getPixelColor(x, y).equals(new Color(0xcc, 0xcc, 0xcc))) {
86 nonmatch++;
87 } else match++;
88 }
89 if (nonmatch > match) {
90 passed = false;
91 }
92 }
93
94 void blockTillDisplayed(JComponent comp) throws Exception {
95 while (p == null) {
|