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

COVERAGE SUMMARY FOR SOURCE FILE [ConversionTest.java]

nameclass, %method, %block, %line, %
ConversionTest.java100% (1/1)100% (6/6)100% (145/145)100% (43/43)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ConversionTest100% (1/1)100% (6/6)100% (145/145)100% (43/43)
ConversionTest (): void 100% (1/1)100% (3/3)100% (1/1)
setUp (): void 100% (1/1)100% (9/9)100% (4/4)
testCanExcludeThumbPages (): void 100% (1/1)100% (54/54)100% (15/15)
testCanLimitImageSize (String): void 100% (1/1)100% (71/71)100% (19/19)
testCanLimitSizeWithLandscape (): void 100% (1/1)100% (4/4)100% (2/2)
testCanLimitSizeWithPortrait (): void 100% (1/1)100% (4/4)100% (2/2)

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.comic;
17 
18import java.awt.Dimension;
19import java.io.File;
20import java.io.IOException;
21 
22import net.sf.jomic.tools.ImageInfo;
23import net.sf.jomic.tools.ImageTools;
24import net.sf.jomic.tools.TestTools;
25import junit.framework.TestCase;
26 
27/**
28 *  TestCase for conversion.
29 *
30 * @author    Thomas Aglassinger
31 */
32public class ConversionTest extends TestCase
33{
34    private ImageTools imageTools;
35    private TestTools testTools;
36 
37    protected void setUp()
38        throws Exception {
39        super.setUp();
40        testTools = TestTools.instance();
41        imageTools = ImageTools.instance();
42    }
43 
44    public void testCanExcludeThumbPages() {
45        Conversion conversion = new Conversion();
46        File imageFile = testTools.getTestImageFile();
47        ImageInfo imageInfo = new ImageInfo(imageFile);
48        int imageWidth = imageInfo.getWidth();
49        int imageHeight = imageInfo.getHeight();
50 
51 
52        conversion.setMaxThumbWidth(imageWidth);
53        conversion.setMaxThumbHeight(imageHeight);
54        conversion.setExcludeThumbPages(false);
55        assertTrue(conversion.isAddable(imageInfo));
56 
57        conversion.setExcludeThumbPages(true);
58        assertFalse(conversion.isAddable(imageInfo));
59 
60        conversion.setMaxThumbWidth(imageWidth - 1);
61        conversion.setMaxThumbHeight(imageHeight - 1);
62        assertTrue(conversion.isAddable(imageInfo));
63    }
64 
65    public void testCanLimitSizeWithLandscape()
66        throws IOException {
67        testCanLimitImageSize(TestTools.TEST_IMAGE_LANDSCAPE_NAME);
68    }
69 
70    public void testCanLimitSizeWithPortrait()
71        throws IOException {
72        testCanLimitImageSize(TestTools.TEST_IMAGE_PORTRAIT_NAME);
73    }
74 
75    private void testCanLimitImageSize(String imageName)
76        throws IOException {
77        File imageFile = testTools.getTestFile(imageName);
78        Conversion conversion = new Conversion();
79        Dimension imageSize = imageTools.getImageDimension(imageFile);
80        int imageWidth = imageSize.width;
81        int imageHeight = imageSize.height;
82 
83        if (imageTools.isLandscape(imageSize)) {
84            imageWidth = imageWidth / 2;
85        }
86 
87        conversion.setMaxImageWidth(imageWidth);
88        conversion.setMaxImageHeight(imageHeight);
89        assertFalse(conversion.isLimitImageSize());
90        assertFalse(conversion.needsTrim(imageSize));
91 
92        conversion.setLimitImageSize(true);
93        assertFalse(conversion.needsTrim(imageSize));
94 
95        conversion.setMaxImageWidth(imageWidth - 1);
96        assertTrue(conversion.needsTrim(imageSize));
97 
98        conversion.setMaxImageWidth(imageWidth);
99        conversion.setMaxImageHeight(imageHeight - 1);
100        assertTrue(conversion.needsTrim(imageSize));
101    }
102}

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