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

COVERAGE SUMMARY FOR SOURCE FILE [ThumbnailTest.java]

nameclass, %method, %block, %line, %
ThumbnailTest.java100% (1/1)100% (5/5)98%  (59/60)100% (19.9/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ThumbnailTest100% (1/1)100% (5/5)98%  (59/60)100% (19.9/20)
setUp (): void 100% (1/1)94%  (16/17)99%  (3.9/4)
ThumbnailTest (): void 100% (1/1)100% (3/3)100% (1/1)
clearComicCaches (File): void 100% (1/1)100% (6/6)100% (2/2)
tearDown (): void 100% (1/1)100% (6/6)100% (3/3)
testThumbsCache (): void 100% (1/1)100% (28/28)100% (10/10)

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;
20import java.io.IOException;
21 
22import junit.framework.TestCase;
23import net.sf.jomic.common.Settings;
24import net.sf.jomic.tools.FileTools;
25import net.sf.jomic.tools.TestTools;
26import net.sf.wraplog.Logger;
27 
28/**
29 *  TestCase for Thumbnail.
30 *
31 * @author    Thomas Aglassinger
32 */
33public class ThumbnailTest extends TestCase
34{
35    static final int MAX_THUMB_HEIGHT = 100;
36    static final int MAX_THUMB_WIDTH = 135;
37 
38    private Logger logger;
39    private TestTools testTools;
40 
41    /*
42     *  @see TestCase#setUp()
43     */
44    protected void setUp()
45        throws Exception {
46        super.setUp();
47        logger = Logger.getLogger(ThumbnailTest.class);
48        testTools = TestTools.instance();
49    }
50 
51    public void testThumbsCache()
52        throws IOException {
53        File cacheDir = Settings.instance().getCacheDir();
54 
55        clearComicCaches(cacheDir);
56 
57        ComicCache comicCache = ComicCache.instance();
58 
59        comicCache.setUp(cacheDir);
60 
61        File imageFile = testTools.getTestImageFile();
62        RenderedImage thumbImage = comicCache.getThumbnail(imageFile);
63 
64        assertNotNull(thumbImage);
65 
66        RenderedImage againThumbImage = comicCache.getThumbnail(imageFile);
67 
68        assertNotNull(againThumbImage);
69    }
70 
71    /*
72     *  @see TestCase#tearDown()
73     */
74    protected void tearDown()
75        throws Exception {
76        testTools = null;
77        super.tearDown();
78    }
79 
80    // TODO: find a dencent way to clear the files in the cache
81    private void clearComicCaches(File cacheDir) {
82        FileTools.instance().attemptToDeleteAll(cacheDir, logger);
83    }
84}
85 

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