/** * Tests the <code>setContent(JComponent)</code> for proper behavior. Verifies that field is set, * container is updated, property change event is fired. * * @throws Exception to JUnit */ public void testMethodSetContent_JComponent() throws Exception { JComponent content = new JPanel(); target.setContent(content); // check field assertEquals("Content", content, target.getContent()); PropertyChangeEvent event = listener.getEvent(); TestHelper.assertEvent( event, DefaultExpandedSideMenuPanel.CONTENT_COMPONENT, TestHelper.CONTENT, content); // check container assertEquals("only 4 components there should be.", 4, target.getComponentCount()); assertEquals("content", content, target.getComponents()[3]); }
/** * Tests the <code>setTextLabel(JLabel)</code> for proper behavior.Verifies that field is set, * container is updated, title is set, property change event is fired. * * @throws Exception to JUnit */ public void testMethodSetTextLabel_JLabel() throws Exception { JLabel label = new JLabel("new"); JLabel old = target.getTextLabel(); target.setTextLabel(label); // check field assertEquals("new lable", label, target.getTextLabel()); assertEquals("title", TestHelper.TITLE, target.getTextLabel().getText()); PropertyChangeEvent event = listener.getEvent(); TestHelper.assertEvent(event, DefaultExpandedSideMenuPanel.TEXT_LABEL, old, label); // check container assertEquals("only 4 components there should be.", 4, target.getComponentCount()); assertEquals("label", label, target.getComponents()[3]); }
/** * Tests the <code>setPinButton(JToggleButton)</code> for proper behavior. Verifies that field is * set, action listener should be removed, container is updated, property change event is fired. * * @throws Exception to JUnit */ public void testMethodSetPinButton_JToggleButton() throws Exception { JToggleButton button = new JToggleButton(); JToggleButton oldButton = (JToggleButton) TestHelper.getPrivateField(DefaultExpandedSideMenuPanel.class, target, "pinButton"); target.setPinButton(button); // check field assertEquals("pinButton", button, target.getPinButton()); // check old button assertEquals("action listener should be removed.", 0, oldButton.getActionListeners().length); PropertyChangeEvent event = listener.getEvent(); TestHelper.assertEvent(event, DefaultExpandedSideMenuPanel.PIN_BUTTON, oldButton, button); // check container assertEquals("only 4 components there should be.", 4, target.getComponentCount()); assertEquals("content", button, target.getComponents()[3]); }