001    package nl.cwi.sen1.visplugin;
002    
003    import javax.swing.JPanel;
004    import junit.framework.TestCase;
005    
006    
007    /**
008     * Unit test for ContainerPanel class
009     *
010     * @author Arjen van Schie
011     * @date 16-3-2007
012     */
013    public class ContainerPanelTest extends TestCase {
014    
015        private ContainerPanel m_containerPanel=null;
016        private JPanel m_contentPanel=null;
017    
018        public ContainerPanelTest(String name) {
019            super(name);
020        }
021    
022        protected void setUp() throws Exception {
023            super.setUp();
024            m_contentPanel = new JPanel();
025            m_containerPanel = new ContainerPanel(m_contentPanel);
026        }
027    
028        protected void tearDown() throws Exception {
029            super.tearDown();
030            m_contentPanel=null;
031            m_containerPanel=null;
032        }
033    
034        /*
035         * Test method for 'ContainerPanel.ContainerPanel(JPanel)'
036         */
037        public void testContainerPanel() {
038            m_containerPanel =null;
039            m_containerPanel = new ContainerPanel(m_contentPanel);
040            assertNotNull(m_containerPanel);
041        }
042    
043        /*
044         * Test method for 'ContainerPanel.showRstoreChangedWarning()'
045         */
046        public void testShowRstoreChangedWarning() {
047            // check first to see there is no warning
048            m_containerPanel.hideWarning();
049            assertEquals(true, m_containerPanel.getCurrentWarning().equals("empty") );
050    
051            // check if the warning gets set
052            m_containerPanel.showRstoreChangedWarning();
053            assertEquals(false, m_containerPanel.getCurrentWarning().equals("empty") );
054        }
055    
056        /*
057         * Test method for 'ContainerPanel.showRstoreUnloadedWarning()'
058         */
059        public void testShowRstoreUnloadedWarning() {
060            // check first to see there is no warning
061            m_containerPanel.hideWarning();
062            assertEquals(true, m_containerPanel.getCurrentWarning().equals("empty") );
063    
064            // check if the warning gets set
065            m_containerPanel.showRstoreUnloadedWarning();
066            assertEquals(false, m_containerPanel.getCurrentWarning().equals("empty") );
067        }
068    
069        /*
070         * Test method for 'ContainerPanel.hideWarning()'
071         */
072        public void testHideWarning() {
073            // check first if the warning gets set
074            m_containerPanel.showRstoreUnloadedWarning();
075            assertEquals(false, m_containerPanel.getCurrentWarning().equals("empty") );
076    
077            // check to see there is no warning after hiding it
078            m_containerPanel.hideWarning();
079            assertEquals(true, m_containerPanel.getCurrentWarning().equals("empty") );
080        }
081    
082        /*
083         * Test method for 'ContainerPanel.getContentPanel()'
084         */
085        public void testGetContentPanel() {
086            assertEquals(true, m_contentPanel == m_containerPanel.getContentPanel() );
087        }
088    
089    }