EMMA Coverage Report (generated Sun Apr 20 22:38:01 CEST 2008)
[all classes][net.sf.jomic.comic]

COVERAGE SUMMARY FOR SOURCE FILE [AbstractComicArchiveTest.java]

nameclass, %method, %block, %line, %
AbstractComicArchiveTest.java100% (1/1)100% (7/7)89%  (170/190)94%  (36.8/39)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractComicArchiveTest100% (1/1)100% (7/7)89%  (170/190)94%  (36.8/39)
testExtract (String): void 100% (1/1)73%  (11/15)83%  (2.5/3)
setUp (): void 100% (1/1)75%  (15/20)95%  (4.8/5)
<static initializer> 100% (1/1)80%  (12/15)80%  (0.8/1)
testExtract (File): void 100% (1/1)94%  (117/125)95%  (23.7/25)
AbstractComicArchiveTest (): void 100% (1/1)100% (3/3)100% (1/1)
getTestTools (): TestTools 100% (1/1)100% (3/3)100% (1/1)
tearDown (): void 100% (1/1)100% (9/9)100% (4/4)

1// Jomic - a viewer for comic book archives.
2// Copyright (C) 2004-2008 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.comic;
17 
18import java.awt.image.RenderedImage;
19import java.io.File;
20 
21import javax.swing.JFrame;
22import javax.swing.JScrollPane;
23 
24import junit.framework.TestCase;
25import net.sf.jomic.tools.TestTools;
26import net.sf.wraplog.Logger;
27 
28import com.sun.media.jai.widget.DisplayJAI;
29 
30/**
31 *  Abstract TestCase to extract a comic archive.
32 *
33 * @author    Thomas Aglassinger
34 */
35abstract class AbstractComicArchiveTest extends TestCase
36{
37    private Logger logger;
38    private TestTools testTools;
39 
40    protected void setUp()
41        throws Exception {
42        super.setUp();
43        logger = Logger.getLogger(AbstractComicArchiveTest.class);
44        testTools = TestTools.instance();
45        testTools.setupCache();
46    }
47 
48    public TestTools getTestTools() {
49        return testTools;
50    }
51 
52    protected void tearDown()
53        throws Exception {
54        super.tearDown();
55        testTools = null;
56        logger = null;
57    }
58 
59    protected void testExtract(String name)
60        throws Exception {
61        assert name != null;
62        testExtract(testTools.getTestFile(name));
63    }
64 
65    protected void testExtract(File archive)
66        throws Exception {
67        assert archive != null;
68        if (logger.isInfoEnabled()) {
69            logger.info("test extract \"" + archive + "\"");
70        }
71        ComicModel model = null;
72        JFrame frame = null;
73 
74        try {
75            model = new ComicModel(archive);
76            frame = new JFrame(ComicModelTest.class.getName());
77 
78            DisplayJAI imagePane = new DisplayJAI();
79 
80            frame.getContentPane().add(new JScrollPane(imagePane));
81            frame.setSize(TestTools.FRAME_WIDTH, TestTools.FRAME_HEIGHT);
82 
83            boolean firstTime = true;
84 
85            for (int page = 0; page < model.getImageCount(); page += 1) {
86                if (logger.isDebugEnabled()) {
87                    logger.debug("view page " + page);
88                }
89                RenderedImage image = model.getImage(page);
90 
91                imagePane.set(image);
92                if (firstTime) {
93                    firstTime = false;
94                    frame.pack();
95                    frame.setVisible(true);
96                }
97            }
98        } finally {
99            if (model != null) {
100                model.dispose();
101            }
102            if (frame != null) {
103                frame.dispose();
104            }
105            // TOOD: assert all files have been removed
106        }
107    }
108 
109}

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