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.JMenuItem; |
19 | |
20 | import net.sf.jomic.JomicTestFixture; |
21 | import net.sf.jomic.comic.ComicView; |
22 | |
23 | /** |
24 | * TestCase for items in "Go" menu. |
25 | * |
26 | * @author Thomas Aglassinger |
27 | */ |
28 | public class GoMenuTest extends JomicTestFixture |
29 | { |
30 | public void testGoMenu() |
31 | throws Exception { |
32 | JomicFrame jomicFrame = setUpJomicFrame(); |
33 | ComicView comicView = jomicFrame.getComicView(); |
34 | |
35 | assertNotNull(comicView); |
36 | |
37 | JMenuItem goFirstItem = findMenuItem("Go|First"); |
38 | JMenuItem goLastItem = findMenuItem("Go|Last"); |
39 | JMenuItem goNextItem = findMenuItem("Go|Next"); |
40 | JMenuItem goPreviousItem = findMenuItem("Go|Previous"); |
41 | |
42 | goLastItem.doClick(); |
43 | assertEquals(comicView.getPageCount() - 1, comicView.getPage()); |
44 | assertTrue(goFirstItem.isEnabled()); |
45 | assertFalse(goLastItem.isEnabled()); |
46 | assertFalse(goNextItem.isEnabled()); |
47 | assertTrue(goPreviousItem.isEnabled()); |
48 | |
49 | goFirstItem.doClick(); |
50 | assertEquals(0, comicView.getPage()); |
51 | assertFalse(goFirstItem.isEnabled()); |
52 | assertTrue(goLastItem.isEnabled()); |
53 | assertTrue(goNextItem.isEnabled()); |
54 | assertFalse(goPreviousItem.isEnabled()); |
55 | |
56 | goNextItem.doClick(); |
57 | assertEquals(1, comicView.getPage()); |
58 | assertTrue(goFirstItem.isEnabled()); |
59 | assertTrue(goLastItem.isEnabled()); |
60 | assertTrue(goNextItem.isEnabled()); |
61 | assertTrue(goPreviousItem.isEnabled()); |
62 | |
63 | goPreviousItem.doClick(); |
64 | assertEquals(0, comicView.getPage()); |
65 | assertFalse(goFirstItem.isEnabled()); |
66 | assertTrue(goLastItem.isEnabled()); |
67 | assertTrue(goNextItem.isEnabled()); |
68 | assertFalse(goPreviousItem.isEnabled()); |
69 | } |
70 | } |