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