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

COVERAGE SUMMARY FOR SOURCE FILE [ConvertDialogTest.java]

nameclass, %method, %block, %line, %
ConvertDialogTest.java100% (2/2)100% (6/6)92%  (148/161)93%  (38.2/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ConvertDialogTest100% (1/1)100% (4/4)90%  (115/128)92%  (31.2/34)
testConvertFrame (): void 100% (1/1)88%  (87/99)89%  (22.2/25)
setUp (): void 100% (1/1)96%  (22/23)99%  (6/6)
ConvertDialogTest (): void 100% (1/1)100% (3/3)100% (1/1)
tearDown (): void 100% (1/1)100% (3/3)100% (2/2)
     
class ConvertDialogTest$1100% (1/1)100% (2/2)100% (33/33)100% (7/7)
ConvertDialogTest$1 (ConvertDialogTest): void 100% (1/1)100% (6/6)100% (1/1)
run (): void 100% (1/1)100% (27/27)100% (6/6)

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.ui;
17 
18import java.io.File;
19 
20import javax.swing.JButton;
21import javax.swing.JOptionPane;
22import javax.swing.SwingUtilities;
23 
24import junit.framework.TestCase;
25import net.sf.jomic.tools.StandardConstants;
26import net.sf.jomic.tools.TestTools;
27import net.sf.wraplog.Logger;
28 
29/**
30 *  TestCase for ConvertDialog.
31 *
32 * @author    Thomas Aglassinger
33 */
34public class ConvertDialogTest extends TestCase implements StandardConstants
35{
36    private ConvertDialog convertDialog;
37    private boolean dialogOpened;
38    private Logger logger;
39    private TestTools testTools;
40 
41    protected void setUp()
42        throws Exception {
43        super.setUp();
44        testTools = TestTools.instance();
45        dialogOpened = false;
46        convertDialog = null;
47        logger = Logger.getLogger(ConvertDialogTest.class);
48    }
49 
50    public void testConvertFrame() {
51 
52        SwingUtilities.invokeLater(
53                    new Runnable()
54                    {
55                        public void run() {
56                            convertDialog = new ConvertDialog();
57                            convertDialog.setModal(false);
58                            convertDialog.pack();
59                            convertDialog.setVisible(true);
60                            dialogOpened = true;
61                        }
62                    });
63        while (!dialogOpened) {
64            try {
65                Thread.sleep(TICK);
66            } catch (InterruptedException interruption) {
67                logger.warn("ignoring interruption", interruption);
68            }
69        }
70        logger.debug("dialog opened");
71 
72        JButton convertButton = convertDialog.getConvertButton();
73        String targetDirName = testTools.getTestFileName(ConvertDialogTest.class, "testConvertFrame", null, null);
74        File targetDir = testTools.getTestOutputFile(targetDirName);
75 
76        assertFalse(convertButton.isEnabled());
77        convertDialog.addComicToConvert(testTools.getTestComicFile());
78        assertFalse(convertButton.isEnabled());
79        convertDialog.setTargetDir(targetDir);
80        assertTrue(convertButton.isEnabled());
81 
82        testTools.waitSomeTime();
83 
84        if (convertButton.isEnabled()) {
85            convertButton.doClick();
86            assertEquals(JOptionPane.OK_OPTION, convertDialog.getSelection());
87            assertNotNull(convertDialog.getTargetDir());
88 
89            File[] selectedFiles = convertDialog.getSelectedFiles();
90 
91            assertNotNull(selectedFiles);
92            testTools.assertGreaterThan(selectedFiles.length, 0);
93        }
94        convertDialog.dispose();
95    }
96 
97    protected void tearDown()
98        throws Exception {
99        super.tearDown();
100    }
101}

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