| 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.JFrame; |
| 19 | import javax.swing.JList; |
| 20 | import javax.swing.JScrollPane; |
| 21 | import javax.swing.ListCellRenderer; |
| 22 | |
| 23 | import net.sf.jomic.tools.TestTools; |
| 24 | |
| 25 | import junit.framework.TestCase; |
| 26 | |
| 27 | /** |
| 28 | * TestCase for FileArchiveListCellRenderer. |
| 29 | * |
| 30 | * @author Thomas Aglassinger |
| 31 | */ |
| 32 | public class FileArchiveListCellRendererTest extends TestCase |
| 33 | { |
| 34 | |
| 35 | private TestTools testTools; |
| 36 | |
| 37 | /* |
| 38 | * (non-Javadoc) |
| 39 | * @see junit.framework.TestCase#setUp() |
| 40 | */ |
| 41 | protected void setUp() |
| 42 | throws Exception { |
| 43 | super.setUp(); |
| 44 | // init logger |
| 45 | testTools = TestTools.instance(); |
| 46 | } |
| 47 | |
| 48 | public void testRenderer() { |
| 49 | String[] fileNames = new String[32]; |
| 50 | |
| 51 | for (int i = 0; i < fileNames.length; i += 1) { |
| 52 | fileNames[i] = "some" + i + ".txt"; |
| 53 | } |
| 54 | fileNames[2] = "hugo.zip"; |
| 55 | fileNames[3] = "resi.cbr"; |
| 56 | fileNames[5] = "sepp.cbz"; |
| 57 | fileNames[9] = "susi.rar"; |
| 58 | fileNames[11] = "hinz.cbz"; |
| 59 | |
| 60 | JList list = new JList(fileNames); |
| 61 | ListCellRenderer renderer = new FileArchiveListCellRenderer(); |
| 62 | |
| 63 | list.setCellRenderer(renderer); |
| 64 | |
| 65 | JFrame frame = new JFrame(FileArchiveListCellRendererTest.class.getName()); |
| 66 | |
| 67 | try { |
| 68 | frame.getContentPane().add(new JScrollPane(list)); |
| 69 | frame.pack(); |
| 70 | frame.setVisible(true); |
| 71 | testTools.waitSomeTime(); |
| 72 | // TODO: check that certain elements really are disabled |
| 73 | } finally { |
| 74 | frame.dispose(); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | } |