Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / panelGroup / TestPanelGroupManager.java @ 40561

History | View | Annotate | Download (4.28 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.gui.beans.panelGroup;
25

    
26
import junit.framework.TestCase;
27

    
28
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel;
29
import org.gvsig.gui.beans.panelGroup.treePanel.TreePanel;
30

    
31
/**
32
 * <p>Tests the class {@link PanelGroupManager PanelGroupManager}.</p>
33
 * 
34
 * @version 06/11/2007
35
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) 
36
 */
37
public class TestPanelGroupManager extends TestCase {
38
        private PanelGroupManager manager;
39
        private Object reference; 
40

    
41
        /*
42
         * (non-Javadoc)
43
         * @see junit.framework.TestCase#setUp()
44
         */
45
        protected void setUp() throws Exception {
46
                super.setUp();
47
                
48
                manager = PanelGroupManager.getManager();
49
                manager.registerPanelGroup(TabbedPanel.class);
50
                manager.setDefaultType(TabbedPanel.class);
51

    
52
                reference = new Object();
53
        }
54

    
55
        /*
56
         * (non-Javadoc)
57
         * @see junit.framework.TestCase#tearDown()
58
         */
59
        protected void tearDown() throws Exception {
60
                super.tearDown();
61
        }
62

    
63
        /**
64
         * <p>Test, results must be valid.</p>
65
         */
66
        public void testGetManager() {
67
                try {
68
                        assertSame(manager, PanelGroupManager.getManager());
69
                } catch (Exception e) {
70
                        e.printStackTrace();
71
                        fail();
72
                }
73
        }
74

    
75
        /**
76
         * <p>Test, results must be valid.</p>
77
         */
78
        public void testDefaultType() {
79
                try {
80
                        assertSame(manager.getPanelGroup(reference).getClass(), TabbedPanel.class);
81
                } catch (Exception e) {
82
                        e.printStackTrace();
83
                        fail();
84
                }
85
        }
86

    
87
        /**
88
         * <p>Test, results must be valid.</p>
89
         */
90
        public void testTabbedPanelType() {
91
                try {
92
                        manager.setDefaultType(TabbedPanel.class);
93
                        assertSame(manager.getPanelGroup(reference).getClass(), TabbedPanel.class);
94
                } catch (Exception e) {
95
                        e.printStackTrace();
96
                        fail();
97
                }
98
        }
99

    
100
        /**
101
         * <p>Test, results must be valid.</p>
102
         */
103
        public void testTreePanelType() {
104
                try {
105
                        manager.registerPanelGroup(TreePanel.class);
106
                        manager.setDefaultType(TreePanel.class);
107
                        assertSame(manager.getPanelGroup(reference).getClass(), TreePanel.class);
108
                } catch (Exception e) {
109
                        e.printStackTrace();
110
                        fail();
111
                }
112
        }
113
        
114
        /**
115
         * <p>Test, results must be valid.</p>
116
         */
117
        public void testCreateAPanelGroupManager() {
118
                try {
119
                        manager.setDefaultType(TreePanel.class);
120
                        assertSame(manager.getPanelGroup(reference).getClass(), TreePanel.class);
121
                } catch (Exception e) {
122
                        e.printStackTrace();
123
                        fail();
124
                }
125
        }
126

    
127
        /**
128
         * <p>Test, results must be valid.</p>
129
         */
130
        public void test1RegistegerAndDeregisterTypes() {
131
                try {
132
                        manager.setDefaultType(TabbedPanel.class);
133
                        manager.deregisterPanelGroup(TabbedPanel.class);
134

    
135
                        AbstractPanelGroup panelGroup = manager.getPanelGroup(reference);
136
                        
137
                        assertEquals(panelGroup, null);
138
                } catch (Exception e) {
139
                        e.printStackTrace();
140
                        fail();
141
                }
142
        }        
143

    
144
        /**
145
         * <p>Test, results must be valid.</p>
146
         */
147
        public void test2RegistegerAndDeregisterTypes() {
148
                try {
149
                        manager.deregisterPanelGroup(TabbedPanel.class);
150
                        manager.deregisterPanelGroup(TreePanel.class);
151
                        manager.registerPanelGroup(TabbedPanel.class);
152
                        manager.registerPanelGroup(TreePanel.class);
153
                        manager.setDefaultType(TabbedPanel.class);
154
                        manager.registerPanelGroup(TabbedPanel.class);
155
                        manager.registerPanelGroup(TreePanel.class);
156
                        manager.deregisterPanelGroup(TreePanel.class);
157
                        manager.deregisterPanelGroup(TabbedPanel.class);
158

    
159
                        AbstractPanelGroup panelGroup = manager.getPanelGroup(reference);
160
                        
161
                        assertEquals(panelGroup, null);
162
                } catch (Exception e) {
163
                        e.printStackTrace();
164
                        fail();
165
                }
166
        }        
167
}