| 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.common; |
| 17 | |
| 18 | import javax.swing.Icon; |
| 19 | |
| 20 | import junit.framework.TestCase; |
| 21 | import net.sf.jomic.tools.ErrorTools; |
| 22 | import net.sf.jomic.tools.TestTools; |
| 23 | |
| 24 | /** |
| 25 | * TestCase for JomicTools. |
| 26 | * |
| 27 | * @author Thomas Aglassinger |
| 28 | */ |
| 29 | public class JomicToolsTest extends TestCase |
| 30 | { |
| 31 | private ErrorTools errorTools; |
| 32 | private int initialMessageCount; |
| 33 | private JomicTools jomicTools; |
| 34 | |
| 35 | /* |
| 36 | * @see TestCase#setUp() |
| 37 | */ |
| 38 | protected void setUp() |
| 39 | throws Exception { |
| 40 | super.setUp(); |
| 41 | TestTools.instance(); |
| 42 | errorTools = ErrorTools.instance(); |
| 43 | jomicTools = JomicTools.instance(); |
| 44 | initialMessageCount = errorTools.getMessageCount(); |
| 45 | } |
| 46 | |
| 47 | public void testLogo() { |
| 48 | Icon logo = jomicTools.getJomicLogo(); |
| 49 | |
| 50 | assertNotNull("logo", logo); |
| 51 | } |
| 52 | |
| 53 | public void testShowMessage() { |
| 54 | System.setProperty(PropertyConstants.TEST_IGNORE_MESSAGE_DIALOGS, Boolean.TRUE.toString()); |
| 55 | try { |
| 56 | jomicTools.showWarning(null, "errors.cannotProcessActionEvent", JomicToolsTest.class.getName(), null); |
| 57 | assertEquals("errorTools.getMessageCount()", initialMessageCount + 1, errorTools.getMessageCount()); |
| 58 | jomicTools.showError(null, "errors.cannotProcessActionEvent", JomicToolsTest.class.getName(), null); |
| 59 | assertEquals("errorTools.getMessageCount()", initialMessageCount + 2, errorTools.getMessageCount()); |
| 60 | } finally { |
| 61 | System.setProperty(PropertyConstants.TEST_IGNORE_MESSAGE_DIALOGS, Boolean.FALSE.toString()); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /* |
| 66 | * @see TestCase#tearDown() |
| 67 | */ |
| 68 | protected void tearDown() |
| 69 | throws Exception { |
| 70 | jomicTools = null; |
| 71 | errorTools = null; |
| 72 | super.tearDown(); |
| 73 | } |
| 74 | |
| 75 | } |