| 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 junit.framework.TestCase; |
| 19 | import net.sf.jomic.tools.TestTools; |
| 20 | |
| 21 | /** |
| 22 | * TestCase for JomicFrame. |
| 23 | * |
| 24 | * @author Thomas Aglassinger |
| 25 | */ |
| 26 | public class JomicFrameTest extends TestCase |
| 27 | { |
| 28 | private TestTools testTools; |
| 29 | |
| 30 | protected void setUp() |
| 31 | throws Exception { |
| 32 | super.setUp(); |
| 33 | testTools = TestTools.instance(); |
| 34 | testTools.setupCache(); |
| 35 | } |
| 36 | |
| 37 | public void testFrameWithComic() { |
| 38 | testFrameWithComic(createJomicFrame()); |
| 39 | } |
| 40 | |
| 41 | public void testFrameWithComic(JomicFrame frame) { |
| 42 | assert frame != null; |
| 43 | try { |
| 44 | frame.open(testTools.getTestComicFile()); |
| 45 | frame.waitForOpen(); |
| 46 | } finally { |
| 47 | disposeJomicFrame(frame); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | public void testSimpleFrame() |
| 52 | throws Exception { |
| 53 | JomicFrame frame = createJomicFrame(); |
| 54 | |
| 55 | try { |
| 56 | testTools.waitSomeTime(); |
| 57 | } finally { |
| 58 | disposeJomicFrame(frame); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | public void testTooSmallFrame() { |
| 63 | JomicFrame tinyFrame = createJomicFrame(0, 0); |
| 64 | |
| 65 | try { |
| 66 | testFrameWithComic(tinyFrame); |
| 67 | } finally { |
| 68 | disposeJomicFrame(tinyFrame); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | protected void tearDown() |
| 73 | throws Exception { |
| 74 | testTools = null; |
| 75 | super.tearDown(); |
| 76 | } |
| 77 | |
| 78 | private JomicFrame createJomicFrame(int width, int height) { |
| 79 | JomicFrame result = new JomicFrame(); |
| 80 | |
| 81 | result.setTitle(JomicFrameTest.class.getName()); |
| 82 | result.setSize(width, height); |
| 83 | result.setVisible(true); |
| 84 | return result; |
| 85 | } |
| 86 | |
| 87 | private JomicFrame createJomicFrame() { |
| 88 | return createJomicFrame(TestTools.FRAME_WIDTH, TestTools.FRAME_HEIGHT); |
| 89 | } |
| 90 | |
| 91 | private void disposeJomicFrame(JomicFrame frame) { |
| 92 | frame.dispose(); |
| 93 | // TODO: Ensure that all files have been removed. |
| 94 | } |
| 95 | } |