EMMA Coverage Report (generated Sat Oct 08 11:41:37 CEST 2011)
[all classes][net.sf.jomic.ui]

COVERAGE SUMMARY FOR SOURCE FILE [ColorBoxTest.java]

nameclass, %method, %block, %line, %
ColorBoxTest.java100% (1/1)100% (4/4)97%  (212/219)99%  (49.3/50)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ColorBoxTest100% (1/1)100% (4/4)97%  (212/219)99%  (49.3/50)
<static initializer> 100% (1/1)80%  (12/15)80%  (0.8/1)
createColorBox (Color): ColorBox 100% (1/1)82%  (18/22)88%  (3.5/4)
ColorBoxTest (): void 100% (1/1)100% (3/3)100% (1/1)
testColorBox (): void 100% (1/1)100% (179/179)100% (45/45)

1// Jomic - a viewer for comic book archives.
2// Copyright (C) 2004-2011 Thomas Aglassinger
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16package net.sf.jomic.ui;
17 
18import java.awt.Color;
19import java.awt.Dimension;
20import java.awt.Frame;
21import java.awt.GridBagConstraints;
22import java.awt.GridBagLayout;
23import java.awt.image.RenderedImage;
24import java.io.IOException;
25 
26import javax.swing.BorderFactory;
27import javax.swing.ImageIcon;
28import javax.swing.JLabel;
29import javax.swing.JPanel;
30import javax.swing.JScrollPane;
31 
32import junit.extensions.abbot.ComponentTestFixture;
33import net.sf.jomic.tools.ColorBox;
34import net.sf.jomic.tools.ImageTools;
35import net.sf.jomic.tools.TestTools;
36 
37/**
38 *  TestCase for ColorBox.
39 *
40 * @author    Thomas Aglassinger
41 */
42public class ColorBoxTest extends ComponentTestFixture
43{
44    public void testColorBox()
45        throws IOException {
46        TestTools testTools = TestTools.instance();
47        ImageTools imageTools = ImageTools.instance();
48 
49        RenderedImage image = testTools.getTestImage();
50        ImageIcon icon = imageTools.getAsImageIcon(image);
51        GridBagConstraints c = new GridBagConstraints();
52        JPanel pane = new JPanel(new GridBagLayout());
53 
54        c.gridx = 0;
55        c.gridy = 0;
56        c.gridwidth = GridBagConstraints.REMAINDER;
57        c.weightx = 1.0;
58        c.weighty = 1.0;
59        c.fill = GridBagConstraints.BOTH;
60        pane.add(createColorBox(Color.RED), c);
61        c.gridy += 1;
62        c.gridwidth = 1;
63        c.weighty = 0.0;
64        pane.add(createColorBox(Color.GREEN), c);
65        c.gridx += 1;
66        c.weightx = 0.0;
67        c.fill = GridBagConstraints.NONE;
68 
69        JLabel iconLabel = new JLabel(icon);
70 
71        pane.add(iconLabel, c);
72        c.gridx += 1;
73        c.weightx = 1.0;
74        c.fill = GridBagConstraints.BOTH;
75        pane.add(createColorBox(Color.BLUE), c);
76        c.gridx = 0;
77        c.gridy += 1;
78        c.weighty = 1.0;
79        c.gridwidth = GridBagConstraints.REMAINDER;
80        pane.add(createColorBox(Color.CYAN), c);
81        pane.setBorder(BorderFactory.createEmptyBorder());
82 
83        Frame frame = showFrame(new JScrollPane(pane));
84        int width = frame.getWidth();
85        int height = frame.getHeight();
86        int tooBigWidth = 3 * width / 2;
87        int tooBigHeight = 3 * height / 2;
88        int tooSmallWidth = 2 * width / 3;
89        int tooSmallHeight = 2 * height / 3;
90 
91        testTools.waitSomeTime();
92        frame.setSize(tooBigWidth, tooBigHeight);
93        testTools.waitSomeTime();
94        frame.setSize(tooSmallWidth, tooSmallHeight);
95        testTools.waitSomeTime();
96    }
97 
98    private ColorBox createColorBox(Color color) {
99        assert color != null;
100        ColorBox result = new ColorBox(color);
101 
102        result.setPreferredSize(new Dimension(0, 0));
103        return result;
104    }
105 
106}

[all classes][net.sf.jomic.ui]
EMMA 2.0.4217 (C) Vladimir Roubtsov