01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.awt;
19:
20: import java.awt.Canvas;
21: import java.awt.Color;
22: import java.awt.Graphics2D;
23: import java.awt.Image;
24: import java.awt.Panel;
25: import java.awt.image.BufferedImage;
26: import java.io.File;
27: import java.io.IOException;
28:
29: import javax.imageio.ImageIO;
30: import javax.swing.JButton;
31: import javax.swing.JPanel;
32:
33: import junit.framework.TestCase;
34:
35: public class HeadlessTest extends TestCase {
36:
37: public void testJButton() {
38: JButton jb = new JButton();
39: jb.addNotify();
40: }
41:
42: public void testJPanel() {
43: JPanel jp = new JPanel();
44: jp.addNotify();
45: }
46:
47: public void testPanel() {
48: Panel p = new Panel();
49: p.addNotify();
50: }
51:
52: public void testCanvas() {
53: Canvas cnv = new Canvas();
54: cnv.addNotify();
55: }
56:
57: public void testBufferedImage() {
58: BufferedImage bi = new BufferedImage(800, 600,
59: BufferedImage.TYPE_3BYTE_BGR);
60: Graphics2D g2 = (Graphics2D) (bi.getGraphics());
61: g2.setColor(Color.RED);
62: g2.fillRect(200, 100, 600, 500);
63: g2.setColor(Color.GREEN);
64: g2.drawOval(500, 300, 100, 100);
65: Image i = null;
66: try {
67: File f = new File("test.jpg");
68: f.createNewFile();
69: ImageIO.write(bi, "jpg", f);
70: i = ImageIO.read(f);
71: f.delete();
72: } catch (IOException e) {
73: throw new AssertionError(e);
74: }
75: }
76: }
|