Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 71328 invoked from network); 26 Nov 2006 20:17:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Nov 2006 20:17:36 -0000 Received: (qmail 16980 invoked by uid 500); 26 Nov 2006 20:17:43 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 16924 invoked by uid 500); 26 Nov 2006 20:17:43 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 16837 invoked by uid 99); 26 Nov 2006 20:17:42 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Nov 2006 12:17:42 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Nov 2006 12:17:19 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id E75471A9859; Sun, 26 Nov 2006 12:16:16 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r479418 [6/43] - in /harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common: javax/swing/ javax/swing/border/ javax/swing/colorchooser/ javax/swing/event/ javax/swing/filechooser/ javax/swing/plaf/ javax/swing/plaf/basic/ ja... Date: Sun, 26 Nov 2006 20:15:55 -0000 To: commits@harmony.apache.org From: ndbeyer@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061126201616.E75471A9859@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboBoxUITest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboBoxUITest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboBoxUITest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboBoxUITest.java Sun Nov 26 12:15:43 2006 @@ -24,7 +24,6 @@ import java.awt.Font; import java.awt.Insets; import java.awt.Rectangle; - import javax.swing.BorderFactory; import javax.swing.CellRendererPane; import javax.swing.DefaultListCellRenderer; @@ -40,19 +39,23 @@ public class BasicComboBoxUITest extends SwingTestCase { private BasicComboBoxUI ui; + private JComboBox comboBox; + private JFrame frame; public BasicComboBoxUITest(final String name) { super(name); } + @Override protected void setUp() throws Exception { ui = new BasicComboBoxUI(); comboBox = new JComboBox(); frame = new JFrame(); } + @Override protected void tearDown() throws Exception { ui = null; comboBox = null; @@ -67,16 +70,13 @@ public void testCreateUI() throws Exception { ComponentUI ui1 = BasicComboBoxUI.createUI(new JComboBox()); assertNotNull(ui1); - ComponentUI ui2 = BasicComboBoxUI.createUI(new JComboBox()); assertNotNull(ui2); - assertNotSame(ui1, ui2); } public void testCreatePopup() throws Exception { assertNull(ui.popup); - ui.comboBox = comboBox; assertNotSame(ui.createPopup(), ui.createPopup()); assertNull(ui.popup); @@ -127,15 +127,12 @@ public void testAddRemoveEditor() throws Exception { ui.comboBox = comboBox; ui.uninstallComponents(); - assertEquals(0, ui.comboBox.getComponentCount()); assertNull(ui.editor); - ui.addEditor(); assertEquals(1, ui.comboBox.getComponentCount()); assertNotNull(ui.editor); assertTrue(ui.editor instanceof JTextField); - ui.removeEditor(); assertNull(ui.editor); assertEquals(0, ui.comboBox.getComponentCount()); @@ -144,32 +141,26 @@ public void testCreateArrowButton() throws Exception { JButton arrowButton = ui.createArrowButton(); assertTrue(arrowButton instanceof BasicArrowButton); - assertEquals(SwingConstants.SOUTH, ((BasicArrowButton)arrowButton).getDirection()); + assertEquals(SwingConstants.SOUTH, ((BasicArrowButton) arrowButton).getDirection()); assertEquals("", arrowButton.getText()); } public void testIsPopupVisible() throws Exception { createVisibleCombo(); - ui.popup = new BasicComboPopup(comboBox); assertFalse(ui.isPopupVisible(comboBox)); assertFalse(ui.popup.isVisible()); - ui.popup.show(); - assertTrue(ui.isPopupVisible(comboBox)); assertTrue(ui.popup.isVisible()); } public void testSetPopupVisible() throws Exception { createVisibleCombo(); - ui.popup = new BasicComboPopup(comboBox); assertFalse(ui.isPopupVisible(comboBox)); - ui.setPopupVisible(comboBox, true); assertTrue(ui.isPopupVisible(comboBox)); - ui.setPopupVisible(comboBox, false); assertFalse(ui.isPopupVisible(comboBox)); } @@ -177,7 +168,6 @@ public void testIsFocusTraversable() throws Exception { ui.comboBox = comboBox; assertTrue(ui.isFocusTraversable(comboBox)); - comboBox.setEditable(true); assertFalse(ui.isFocusTraversable(comboBox)); } @@ -187,11 +177,8 @@ ui.popup = new BasicComboPopup(comboBox); ui.listBox = ui.popup.getList(); ui.installListeners(); - assertEquals(ui.getMinimumSize(comboBox), ui.getPreferredSize(comboBox)); - comboBox.setEditable(true); - assertEquals(ui.getMinimumSize(comboBox), ui.getPreferredSize(comboBox)); assertEquals(ui.getMinimumSize(null), ui.getPreferredSize(null)); } @@ -201,17 +188,17 @@ ui.installUI(comboBox); comboBox.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); comboBox.setFont(comboBox.getFont().deriveFont(1f)); - - Dimension listPart = new BasicComboBoxRenderer().getListCellRendererComponent(ui.listBox, "", -1, false, false).getPreferredSize(); - Dimension expectedSize = new Dimension(listPart.width + listPart.height + 8, listPart.height + 8); + Dimension listPart = new BasicComboBoxRenderer().getListCellRendererComponent( + ui.listBox, "", -1, false, false).getPreferredSize(); + Dimension expectedSize = new Dimension(listPart.width + listPart.height + 8, + listPart.height + 8); assertEquals(expectedSize, ui.getMinimumSize(null)); assertEquals(expectedSize, ui.cachedMinimumSize); - ui.cachedMinimumSize = new Dimension(100, 100); assertEquals(ui.cachedMinimumSize, ui.getMinimumSize(null)); - comboBox.addItem("aaa"); - listPart = new BasicComboBoxRenderer().getListCellRendererComponent(ui.listBox, "aaa", -1, false, false).getPreferredSize(); + listPart = new BasicComboBoxRenderer().getListCellRendererComponent(ui.listBox, "aaa", + -1, false, false).getPreferredSize(); expectedSize = new Dimension(listPart.width + listPart.height + 8, listPart.height + 8); assertEquals(expectedSize, ui.getMinimumSize(null)); assertEquals(expectedSize, ui.cachedMinimumSize); @@ -219,62 +206,47 @@ public void testSelectNextPossibleValue() throws Exception { ui.comboBox = comboBox; - assertEquals(-1, comboBox.getSelectedIndex()); ui.selectNextPossibleValue(); assertEquals(-1, comboBox.getSelectedIndex()); - comboBox.addItem("a"); comboBox.addItem("b"); comboBox.addItem("c"); assertEquals(0, comboBox.getSelectedIndex()); - ui.selectNextPossibleValue(); assertEquals(1, comboBox.getSelectedIndex()); - ui.selectNextPossibleValue(); assertEquals(2, comboBox.getSelectedIndex()); - ui.selectNextPossibleValue(); assertEquals(2, comboBox.getSelectedIndex()); } public void testSelectPreviousPossibleValue() throws Exception { ui.comboBox = comboBox; - assertEquals(-1, comboBox.getSelectedIndex()); ui.selectPreviousPossibleValue(); assertEquals(-1, comboBox.getSelectedIndex()); - comboBox.addItem("a"); comboBox.addItem("b"); comboBox.addItem("c"); assertEquals(0, comboBox.getSelectedIndex()); - ui.selectPreviousPossibleValue(); assertEquals(0, comboBox.getSelectedIndex()); - comboBox.setSelectedIndex(2); - ui.selectPreviousPossibleValue(); assertEquals(1, comboBox.getSelectedIndex()); - ui.selectPreviousPossibleValue(); assertEquals(0, comboBox.getSelectedIndex()); - ui.selectPreviousPossibleValue(); assertEquals(0, comboBox.getSelectedIndex()); } public void testToggleOpenClose() throws Exception { createVisibleCombo(); - ui.popup = new BasicComboPopup(comboBox); assertFalse(ui.isPopupVisible(comboBox)); - ui.toggleOpenClose(); assertTrue(ui.isPopupVisible(comboBox)); - ui.toggleOpenClose(); assertFalse(ui.isPopupVisible(comboBox)); } @@ -290,7 +262,6 @@ public void testGetInsets() throws Exception { ui.comboBox = comboBox; assertEquals(comboBox.getInsets(), ui.getInsets()); - comboBox.setBorder(BorderFactory.createEmptyBorder(1, 2, 3, 4)); assertEquals(comboBox.getInsets(), ui.getInsets()); assertEquals(new Insets(1, 2, 3, 4), ui.getInsets()); @@ -302,10 +273,11 @@ if (isHarmony()) { comboBox.setFont(comboBox.getFont().deriveFont(40f)); } - assertEquals(comboBox.getRenderer().getListCellRendererComponent(ui.listBox, "", 0, false, false).getPreferredSize(), ui.getDefaultSize()); - + assertEquals(comboBox.getRenderer().getListCellRendererComponent(ui.listBox, "", 0, + false, false).getPreferredSize(), ui.getDefaultSize()); comboBox.addItem("a"); - assertEquals(comboBox.getRenderer().getListCellRendererComponent(ui.listBox, "", 0, false, false).getPreferredSize(), ui.getDefaultSize()); + assertEquals(comboBox.getRenderer().getListCellRendererComponent(ui.listBox, "", 0, + false, false).getPreferredSize(), ui.getDefaultSize()); } public void testGetDisplaySize() throws Exception { @@ -314,37 +286,33 @@ ui.listBox = ui.popup.getList(); ui.installListeners(); comboBox.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); - - assertEquals(new BasicComboBoxRenderer().getListCellRendererComponent(ui.listBox, "", -1, false, false).getPreferredSize(), ui.getDisplaySize()); - + assertEquals(new BasicComboBoxRenderer().getListCellRendererComponent(ui.listBox, "", + -1, false, false).getPreferredSize(), ui.getDisplaySize()); comboBox.addItem("a"); - assertEquals(new BasicComboBoxRenderer().getListCellRendererComponent(ui.listBox, "a", -1, false, false).getPreferredSize(), ui.getDisplaySize()); - + assertEquals(new BasicComboBoxRenderer().getListCellRendererComponent(ui.listBox, "a", + -1, false, false).getPreferredSize(), ui.getDisplaySize()); comboBox.addItem("aaaa"); comboBox.addItem("aa"); - assertEquals(new BasicComboBoxRenderer().getListCellRendererComponent(ui.listBox, "aaaa", -1, false, false).getPreferredSize(), ui.getDisplaySize()); + assertEquals(new BasicComboBoxRenderer().getListCellRendererComponent(ui.listBox, + "aaaa", -1, false, false).getPreferredSize(), ui.getDisplaySize()); } public void testInstallDefaults() throws Exception { comboBox.setFont(null); comboBox.setForeground(null); comboBox.setBackground(null); - ui.comboBox = comboBox; ui.listBox = new BasicComboPopup(comboBox).getList(); ui.installDefaults(); assertNotNull(comboBox.getFont()); assertNotNull(comboBox.getForeground()); assertNotNull(comboBox.getBackground()); - ui.uninstallDefaults(); - } public void testInstallUninstallListeners() throws Exception { ui.comboBox = comboBox; ui.popup = new BasicComboPopup(comboBox); - ui.uninstallListeners(); int focusListenerCount = ui.comboBox.getFocusListeners().length; int itemListenerCount = ui.comboBox.getItemListeners().length; @@ -359,11 +327,11 @@ assertNull(ui.popupMouseListener); assertNull(ui.popupMouseMotionListener); assertNull(ui.popupKeyListener); - ui.installListeners(); assertEquals(focusListenerCount + 1, ui.comboBox.getFocusListeners().length); assertEquals(keyListenerCount + 1, ui.comboBox.getKeyListeners().length); - assertEquals(propertyChangeListenerCount + 1, ui.comboBox.getPropertyChangeListeners().length); + assertEquals(propertyChangeListenerCount + 1, + ui.comboBox.getPropertyChangeListeners().length); assertEquals(itemListenerCount, ui.comboBox.getItemListeners().length); assertEquals(actionListenerCount, ui.comboBox.getActionListeners().length); assertNotNull(ui.focusListener); @@ -374,28 +342,26 @@ assertNotNull(ui.popupMouseListener); assertNotNull(ui.popupMouseMotionListener); assertNull(ui.popupKeyListener); - ui.uninstallListeners(); assertEquals(focusListenerCount, ui.comboBox.getFocusListeners().length); assertEquals(keyListenerCount, ui.comboBox.getKeyListeners().length); - assertEquals(propertyChangeListenerCount, ui.comboBox.getPropertyChangeListeners().length); + assertEquals(propertyChangeListenerCount, + ui.comboBox.getPropertyChangeListeners().length); assertEquals(itemListenerCount, ui.comboBox.getItemListeners().length); assertEquals(actionListenerCount, ui.comboBox.getActionListeners().length); -// assertNull(ui.focusListener); -// assertNull(ui.itemListener); -// assertNull(ui.keyListener); -// assertNull(ui.listDataListener); + // assertNull(ui.focusListener); + // assertNull(ui.itemListener); + // assertNull(ui.keyListener); + // assertNull(ui.listDataListener); } public void testInstallUninstallComponents() throws Exception { ui.comboBox = comboBox; ui.popup = new BasicComboPopup(comboBox); - ui.uninstallComponents(); assertEquals(0, ui.comboBox.getComponentCount()); assertNull(ui.arrowButton); assertNull(ui.editor); - ui.installComponents(); assertEquals(2, ui.comboBox.getComponentCount()); assertTrue(ui.comboBox.getComponent(0) instanceof BasicArrowButton); @@ -403,12 +369,10 @@ assertNotNull(ui.arrowButton); assertNull(ui.editor); ui.comboBox.add(new JLabel()); - ui.uninstallComponents(); assertEquals(0, ui.comboBox.getComponentCount()); assertNull(ui.arrowButton); assertNull(ui.editor); - comboBox.setEditable(true); ui.installComponents(); assertNotNull(ui.arrowButton); @@ -423,10 +387,8 @@ assertNotNull(ui.currentValuePane); assertNull(ui.listBox); int itemListenerCount = comboBox.getItemListeners().length; - ui.installUI(comboBox); assertEquals(itemListenerCount + 1, comboBox.getItemListeners().length); - assertNotNull(comboBox.getLayout()); assertTrue(ui.listBox == ui.popup.getList()); assertTrue(ui.listBox.getFont() == comboBox.getFont()); @@ -464,7 +426,6 @@ public void testConfigureUnconfigureArrowButton() throws Exception { ui.configureArrowButton(); ui.unconfigureArrowButton(); - ui.popup = new BasicComboPopup(comboBox); ui.comboBox = comboBox; ui.arrowButton = new JButton(); @@ -472,8 +433,8 @@ int mouseMotionListenerCount = ui.arrowButton.getMouseMotionListeners().length; ui.configureArrowButton(); assertEquals(mouseListenerCount + 1, ui.arrowButton.getMouseListeners().length); - assertEquals(mouseMotionListenerCount + 1, ui.arrowButton.getMouseMotionListeners().length); - + assertEquals(mouseMotionListenerCount + 1, + ui.arrowButton.getMouseMotionListeners().length); ui.unconfigureArrowButton(); assertEquals(mouseListenerCount, ui.arrowButton.getMouseListeners().length); assertEquals(mouseMotionListenerCount, ui.arrowButton.getMouseMotionListeners().length); @@ -487,19 +448,18 @@ assertEquals(newFont, ui.listBox.getFont()); assertEquals(comboBox.getToolTipText(), ui.arrowButton.getToolTipText()); assertEquals(comboBox.getRenderer(), ui.listBox.getCellRenderer()); - comboBox.setEnabled(false); assertFalse(comboBox.isEnabled()); assertFalse(ui.arrowButton.isEnabled()); assertTrue(ui.listBox.isEnabled()); - assertTrue(comboBox.getRenderer().getListCellRendererComponent(ui.listBox, "", -1, false, false).isEnabled()); + assertTrue(comboBox.getRenderer().getListCellRendererComponent(ui.listBox, "", -1, + false, false).isEnabled()); ui.paintCurrentValue(createTestGraphics(), new Rectangle(0, 0, 10, 10), false); - assertTrue(comboBox.getRenderer().getListCellRendererComponent(ui.listBox, "", -1, false, false).isEnabled()); - + assertTrue(comboBox.getRenderer().getListCellRendererComponent(ui.listBox, "", -1, + false, false).isEnabled()); String newTooltip = "combo tooltip"; comboBox.setToolTipText(newTooltip); assertEquals(newTooltip, ui.arrowButton.getToolTipText()); - ui.listBox.setCellRenderer(new DefaultListCellRenderer()); ListCellRenderer newRenderer = new DefaultListCellRenderer(); assertNotSame(ui.listBox.getCellRenderer(), comboBox.getRenderer()); @@ -508,6 +468,7 @@ assertEquals(newRenderer, ui.popup.getList().getCellRenderer()); } + @SuppressWarnings("deprecation") private void createVisibleCombo() { frame.getContentPane().add(comboBox); frame.show(); Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboPopupTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboPopupTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboPopupTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicComboPopupTest.java Sun Nov 26 12:15:43 2006 @@ -23,7 +23,6 @@ import java.awt.Insets; import java.awt.Point; import java.awt.event.MouseEvent; - import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JList; @@ -36,18 +35,21 @@ public class BasicComboPopupTest extends SwingTestCase { private BasicComboPopup popup; + private JComboBox comboBox; public BasicComboPopupTest(final String name) { super(name); } + @Override protected void setUp() throws Exception { - comboBox = new JComboBox(new Object[] {"1", "2", "3"}); + comboBox = new JComboBox(new Object[] { "1", "2", "3" }); popup = new BasicComboPopup(comboBox); - ((BasicComboBoxUI)comboBox.getUI()).popup = popup; + ((BasicComboBoxUI) comboBox.getUI()).popup = popup; } + @Override protected void tearDown() throws Exception { comboBox = null; popup = null; @@ -57,40 +59,30 @@ assertNotNull(popup.comboBox); assertNotNull(popup.list); assertNotNull(popup.scroller); - assertEquals(3, popup.list.getModel().getSize()); - popup = new BasicComboPopup(new JComboBox()); assertNotNull(popup.list); assertEquals(0, popup.list.getModel().getSize()); assertTrue(popup.comboBox.getModel() == popup.list.getModel()); - assertEquals(popup.getComponent(), popup); assertEquals(1, popup.getComponentCount()); assertEquals(popup.scroller, popup.getComponent(0)); - assertEquals(ListSelectionModel.SINGLE_SELECTION, popup.list.getSelectionMode()); assertTrue(popup.getBorder().getClass() == LineBorder.class); assertEquals(new Insets(1, 1, 1, 1), popup.getInsets()); - assertFalse(popup.isAutoScrolling); } public void testShowHide() throws Exception { createVisibleComboBox(); - popup.show(); assertTrue(popup.isShowing()); - popup.show(); assertTrue(popup.isShowing()); - popup.hide(); assertFalse(popup.isShowing()); - popup.hide(); assertFalse(popup.isShowing()); - popup.show(); assertTrue(popup.isShowing()); } @@ -98,7 +90,6 @@ public void testGetList() throws Exception { assertNotNull(popup.getList()); assertEquals(popup.list, popup.getList()); - JList newList = new JList(); popup.list = newList; assertEquals(newList, popup.getList()); @@ -106,7 +97,6 @@ public void testGetMouseListener() throws Exception { assertNull(popup.mouseListener); - assertEquals(popup.getMouseListener(), popup.mouseListener); if (isHarmony()) { assertTrue(popup.getMouseListener().getClass() == BasicComboPopup.InvocationMouseHandler.class); @@ -115,7 +105,6 @@ public void testGetMouseMotionListener() throws Exception { assertNull(popup.mouseMotionListener); - assertEquals(popup.getMouseMotionListener(), popup.mouseMotionListener); if (isHarmony()) { assertTrue(popup.getMouseMotionListener().getClass() == BasicComboPopup.InvocationMouseMotionHandler.class); @@ -134,14 +123,13 @@ int itemListenerCount = comboBox.getItemListeners().length; int propertyChangeListenerCount = comboBox.getPropertyChangeListeners().length; int keyListenerCount = comboBox.getKeyListeners().length; - popup = new BasicComboPopup(comboBox); assertEquals(mouseListenerCount, comboBox.getMouseListeners().length); assertEquals(mouseMotionListenerCount, comboBox.getMouseMotionListeners().length); assertEquals(keyListenerCount, comboBox.getKeyListeners().length); assertEquals(itemListenerCount + 1, comboBox.getItemListeners().length); - assertEquals(propertyChangeListenerCount + 1, comboBox.getPropertyChangeListeners().length); - + assertEquals(propertyChangeListenerCount + 1, + comboBox.getPropertyChangeListeners().length); popup.uninstallingUI(); assertEquals(mouseListenerCount, comboBox.getMouseListeners().length); assertEquals(mouseMotionListenerCount, comboBox.getMouseMotionListeners().length); @@ -153,28 +141,22 @@ public void testFirePopupMenuWillBecomeVisibleInvisibleCanceled() throws Exception { PopupMenuController comboController = new PopupMenuController(); PopupMenuController popupController = new PopupMenuController(); - popup.addPopupMenuListener(popupController); popup.comboBox.addPopupMenuListener(comboController); - popup.firePopupMenuCanceled(); assertNotNull(popupController.getEvent()); assertNotNull(comboController.getEvent()); assertEquals(PopupMenuController.MENU_CANCELED, popupController.getEventType()); assertEquals(PopupMenuController.MENU_CANCELED, comboController.getEventType()); - popupController.reset(); comboController.reset(); - popup.firePopupMenuWillBecomeInvisible(); assertNotNull(popupController.getEvent()); assertNotNull(comboController.getEvent()); assertEquals(PopupMenuController.MENU_INVISIBLE, popupController.getEventType()); assertEquals(PopupMenuController.MENU_INVISIBLE, comboController.getEventType()); - popupController.reset(); comboController.reset(); - popup.firePopupMenuWillBecomeVisible(); assertNotNull(popupController.getEvent()); assertNotNull(comboController.getEvent()); @@ -222,7 +204,8 @@ if (isHarmony()) { assertTrue(popup.listMouseMotionListener.getClass() == BasicComboPopup.ListMouseMotionHandler.class); assertTrue(popup.createListMouseMotionListener().getClass() == BasicComboPopup.ListMouseMotionHandler.class); - assertFalse(popup.createListMouseMotionListener() == popup.createListMouseMotionListener()); + assertFalse(popup.createListMouseMotionListener() == popup + .createListMouseMotionListener()); } } @@ -230,7 +213,8 @@ if (isHarmony()) { assertTrue(popup.propertyChangeListener.getClass() == BasicComboPopup.PropertyChangeHandler.class); assertTrue(popup.createPropertyChangeListener().getClass() == BasicComboPopup.PropertyChangeHandler.class); - assertFalse(popup.createPropertyChangeListener() == popup.createPropertyChangeListener()); + assertFalse(popup.createPropertyChangeListener() == popup + .createPropertyChangeListener()); } } @@ -251,7 +235,6 @@ popup.list = new JList(); int mouseListenerCount = popup.list.getMouseListeners().length; int mouseMotionListenerCount = popup.list.getMouseMotionListeners().length; - popup.configureList(); assertEquals(mouseListenerCount + 1, popup.list.getMouseListeners().length); assertEquals(mouseMotionListenerCount + 1, popup.list.getMouseMotionListeners().length); @@ -280,20 +263,19 @@ int itemListenerCount = comboBox.getItemListeners().length; int propertyChangeListenerCount = comboBox.getPropertyChangeListeners().length; int keyListenerCount = comboBox.getKeyListeners().length; - popup.installComboBoxListeners(); assertEquals(mouseListenerCount, comboBox.getMouseListeners().length); assertEquals(mouseMotionListenerCount, comboBox.getMouseMotionListeners().length); assertEquals(keyListenerCount, comboBox.getKeyListeners().length); assertEquals(itemListenerCount + 1, comboBox.getItemListeners().length); - assertEquals(propertyChangeListenerCount + 1, comboBox.getPropertyChangeListeners().length); + assertEquals(propertyChangeListenerCount + 1, + comboBox.getPropertyChangeListeners().length); } public void testInstallUninstallKeyboardActions() throws Exception { int count = popup.comboBox.getActionMap().allKeys().length; popup.uninstallKeyboardActions(); assertEquals(count, popup.comboBox.getActionMap().allKeys().length); - popup.installKeyboardActions(); assertEquals(count, popup.comboBox.getActionMap().allKeys().length); } @@ -302,7 +284,6 @@ int mouseListenerCount = popup.list.getMouseListeners().length; int mouseMotionListenerCount = popup.list.getMouseMotionListeners().length; int selectionListenerCount = popup.list.getListSelectionListeners().length; - popup.installListListeners(); assertEquals(mouseListenerCount + 1, popup.list.getMouseListeners().length); assertEquals(mouseMotionListenerCount + 1, popup.list.getMouseMotionListeners().length); @@ -316,17 +297,14 @@ public void testStartStopAutoscrolloing() throws Exception { assertNull(popup.autoscrollTimer); assertFalse(popup.isAutoScrolling); - popup.startAutoScrolling(BasicComboPopup.SCROLL_UP); assertNotNull(popup.autoscrollTimer); assertTrue(popup.isAutoScrolling); assertEquals(BasicComboPopup.SCROLL_UP, popup.scrollDirection); - popup.startAutoScrolling(BasicComboPopup.SCROLL_DOWN); assertNotNull(popup.autoscrollTimer); assertTrue(popup.isAutoScrolling); assertEquals(BasicComboPopup.SCROLL_DOWN, popup.scrollDirection); - popup.stopAutoScrolling(); assertFalse(popup.isAutoScrolling); } @@ -335,20 +313,15 @@ if (isHarmony()) { createVisibleComboBox(); popup.show(); - popup.list.setSelectedIndex(2); popup.autoScrollUp(); assertEquals(0, popup.list.getSelectedIndex()); - popup.autoScrollUp(); assertEquals(0, popup.list.getSelectedIndex()); - popup.autoScrollDown(); assertEquals(2, popup.list.getSelectedIndex()); - popup.autoScrollDown(); assertEquals(2, popup.list.getSelectedIndex()); - popup.autoScrollUp(); assertEquals(0, popup.list.getSelectedIndex()); } @@ -356,13 +329,12 @@ public void testGetAccessibleContext() throws Exception { assertNotNull(popup.getAccessibleContext()); -// Is not clear how it should be -// assertEquals(popup.comboBox, popup.getAccessibleContext().getAccessibleParent()); + // Is not clear how it should be + // assertEquals(popup.comboBox, popup.getAccessibleContext().getAccessibleParent()); } public void testTogglePopup() throws Exception { createVisibleComboBox(); - assertFalse(popup.isShowing()); popup.togglePopup(); assertTrue(popup.isShowing()); @@ -373,14 +345,16 @@ public void testConvertMouseEvent() throws Exception { MouseEvent original = createMouseEvent(0, 0); assertNotSame(original, popup.convertMouseEvent(original)); - comboBox.setLocation(0, 0); - assertEquals(new Point(10, 20), popup.convertMouseEvent(createMouseEvent(10, 20)).getPoint()); - assertEquals(new Point(-10, -20), popup.convertMouseEvent(createMouseEvent(-10, -20)).getPoint()); - + assertEquals(new Point(10, 20), popup.convertMouseEvent(createMouseEvent(10, 20)) + .getPoint()); + assertEquals(new Point(-10, -20), popup.convertMouseEvent(createMouseEvent(-10, -20)) + .getPoint()); comboBox.setLocation(100, 200); - assertEquals(new Point(110, 220), popup.convertMouseEvent(createMouseEvent(10, 20)).getPoint()); - assertEquals(new Point(90, 180), popup.convertMouseEvent(createMouseEvent(-10, -20)).getPoint()); + assertEquals(new Point(110, 220), popup.convertMouseEvent(createMouseEvent(10, 20)) + .getPoint()); + assertEquals(new Point(90, 180), popup.convertMouseEvent(createMouseEvent(-10, -20)) + .getPoint()); } public void testGetPopupHeightForRowCount() throws Exception { @@ -388,15 +362,12 @@ assertEquals(100, popup.getPopupHeightForRowCount(0)); assertEquals(100, popup.getPopupHeightForRowCount(1)); assertEquals(100, popup.getPopupHeightForRowCount(100)); - - popup = new BasicComboPopup(new JComboBox(new Object[] {"1"})); + popup = new BasicComboPopup(new JComboBox(new Object[] { "1" })); popup.list.setFont(comboBox.getFont().deriveFont(40f)); int oneElemHeight = popup.getPopupHeightForRowCount(1); assertTrue(oneElemHeight > 0 && oneElemHeight != 100); - - popup = new BasicComboPopup(new JComboBox(new Object[] {"1", "2", "3"})); + popup = new BasicComboPopup(new JComboBox(new Object[] { "1", "2", "3" })); popup.list.setFont(comboBox.getFont().deriveFont(40f)); - assertEquals(oneElemHeight, popup.getPopupHeightForRowCount(1)); assertEquals(2 * oneElemHeight, popup.getPopupHeightForRowCount(2)); assertEquals(3 * oneElemHeight, popup.getPopupHeightForRowCount(3)); @@ -404,11 +375,11 @@ assertEquals(100, popup.getPopupHeightForRowCount(0)); } - private MouseEvent createMouseEvent(final int x, final int y) { return new MouseEvent(comboBox, MouseEvent.MOUSE_CLICKED, 0, 0, x, y, 0, false); } + @SuppressWarnings("deprecation") private void createVisibleComboBox() { JFrame frame = new JFrame(); frame.getContentPane().add(comboBox); @@ -418,10 +389,13 @@ private class PopupMenuController implements PopupMenuListener { public static final int MENU_CANCELED = 1; + public static final int MENU_VISIBLE = 2; + public static final int MENU_INVISIBLE = 3; private PopupMenuEvent event; + private int eventType; public void popupMenuCanceled(final PopupMenuEvent e) { Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopIconUITest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopIconUITest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopIconUITest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopIconUITest.java Sun Nov 26 12:15:43 2006 @@ -18,23 +18,16 @@ * @author Vadim L. Bogdanov * @version $Revision$ */ - package javax.swing.plaf.basic; import java.awt.BorderLayout; import java.awt.Insets; - import java.beans.PropertyVetoException; - import javax.swing.JInternalFrame; import javax.swing.SwingTestCase; - import javax.swing.event.MouseInputListener; - import javax.swing.plaf.ComponentUI; -import org.apache.harmony.x.swing.Utilities; - public class BasicDesktopIconUITest extends SwingTestCase { private static boolean belongs(final Object o, final Object[] array) { for (int i = 0; i < array.length; i++) { @@ -47,23 +40,26 @@ private static class MyBasicDesktopIconUI extends BasicDesktopIconUI { public MouseInputListener mouseInputListener; + + @Override protected MouseInputListener createMouseInputListener() { mouseInputListener = super.createMouseInputListener(); return mouseInputListener; } } - private MyBasicDesktopIconUI ui; + private JInternalFrame.JDesktopIcon icon; + private JInternalFrame frame; /* * @see TestCase#setUp() */ + @Override protected void setUp() throws Exception { super.setUp(); - frame = new JInternalFrame(); icon = frame.getDesktopIcon(); ui = new MyBasicDesktopIconUI(); @@ -73,6 +69,7 @@ /* * @see TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { super.tearDown(); } @@ -87,7 +84,6 @@ public void testCreateUI() { ComponentUI ui1 = BasicDesktopIconUI.createUI(frame); ComponentUI ui2 = BasicDesktopIconUI.createUI(frame); - assertTrue("not null", ui1 != null); assertTrue("stateful", ui1 != ui2); } @@ -105,7 +101,6 @@ public void testCreateMouseInputListener() { MouseInputListener l1 = ui.createMouseInputListener(); MouseInputListener l2 = ui.createMouseInputListener(); - assertTrue("not null", l1 != null); if (isHarmony()) { assertSame("the same instance", l1, l2); @@ -121,7 +116,6 @@ } catch (PropertyVetoException e) { } assertTrue("is icon", frame.isIcon()); - ui.deiconize(); assertFalse("deiconized", frame.isIcon()); } @@ -132,7 +126,6 @@ public void testGetInsets() { final Insets validInsets = new Insets(5, 5, 5, 5); Insets insets = ui.getInsets(icon); - assertTrue("not null", insets != null); assertEquals("ok", validInsets, insets); } @@ -142,8 +135,7 @@ */ public void testGetMaximumSize() { if (isHarmony()) { - assertEquals("== minimumSize", - ui.getMinimumSize(icon), ui.getMaximumSize(icon)); + assertEquals("== minimumSize", ui.getMinimumSize(icon), ui.getMaximumSize(icon)); } } @@ -152,8 +144,7 @@ */ public void testGetMinimumSize() { if (isHarmony()) { - assertEquals("== preferredSize", - ui.getPreferredSize(icon), ui.getMinimumSize(icon)); + assertEquals("== preferredSize", ui.getPreferredSize(icon), ui.getMinimumSize(icon)); } } @@ -173,7 +164,6 @@ int count = icon.getComponentCount(); ui.uninstallComponents(); assertEquals("uninstalled", count - 1, icon.getComponentCount()); - ui.installComponents(); assertEquals("added 1 component", count, icon.getComponentCount()); assertTrue("added iconPane", icon.isAncestorOf(ui.iconPane)); @@ -185,7 +175,6 @@ public void testUninstallComponents() { int count = icon.getComponentCount(); assertTrue("added iconPane", icon.isAncestorOf(ui.iconPane)); - ui.uninstallComponents(); assertEquals("uninstalled", count - 1, icon.getComponentCount()); assertFalse("removed iconPane", icon.isAncestorOf(ui.iconPane)); @@ -197,7 +186,6 @@ public void testInstallDefaults() { icon.setBorder(null); icon.setLayout(null); - ui.installDefaults(); assertTrue("opaque", icon.isOpaque()); assertTrue("border", icon.getBorder() != null); @@ -209,7 +197,6 @@ */ public void testUninstallDefaults() { ui.uninstallDefaults(); - assertNull("border", icon.getBorder()); assertTrue("layout", icon.getLayout() instanceof BorderLayout); } @@ -219,13 +206,11 @@ */ public void testInstallListeners() { ui.uninstallListeners(); - ui.installListeners(); MouseInputListener listener = ui.mouseInputListener; - assertTrue("installed mouseListener", - belongs(listener, icon.getMouseListeners())); - assertTrue("installed mouseMotionListener", - belongs(listener, icon.getMouseMotionListeners())); + assertTrue("installed mouseListener", belongs(listener, icon.getMouseListeners())); + assertTrue("installed mouseMotionListener", belongs(listener, icon + .getMouseMotionListeners())); } /* @@ -234,11 +219,9 @@ public void testUninstallListeners() { MouseInputListener listener = ui.createMouseInputListener(); ui.uninstallListeners(); - - assertFalse("uninstalled mouseListener", - belongs(listener, icon.getMouseListeners())); - assertFalse("uninstalled mouseMotionListener", - belongs(listener, icon.getMouseMotionListeners())); + assertFalse("uninstalled mouseListener", belongs(listener, icon.getMouseListeners())); + assertFalse("uninstalled mouseMotionListener", belongs(listener, icon + .getMouseMotionListeners())); } /* Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopPaneUIActionsTest.java Sun Nov 26 12:15:43 2006 @@ -21,8 +21,8 @@ package javax.swing.plaf.basic; import java.beans.PropertyVetoException; - import javax.swing.AbstractAction; +import javax.swing.Action; import javax.swing.JButton; import javax.swing.JDesktopPane; import javax.swing.JFrame; @@ -31,18 +31,22 @@ public class BasicDesktopPaneUIActionsTest extends SwingTestCase { private JFrame frame; + private JDesktopPane desktop; + private JInternalFrame iframe1; + private JInternalFrame iframe2; + private BasicDesktopPaneUI ui; public BasicDesktopPaneUIActionsTest(final String name) { super(name); } + @Override protected void setUp() throws Exception { super.setUp(); - frame = new JFrame(); desktop = new JDesktopPane(); ui = new BasicDesktopPaneUI(); @@ -55,9 +59,9 @@ desktop.setSelectedFrame(iframe1); } + @Override protected void tearDown() throws Exception { super.tearDown(); - frame.dispose(); } @@ -65,11 +69,13 @@ if (!isHarmony()) { return; } - frame.setVisible(true); - class MyButton extends JButton { + private static final long serialVersionUID = 1L; + public boolean requestedFocus; + + @Override public void requestFocus() { requestedFocus = true; super.requestFocus(); @@ -79,14 +85,12 @@ MyButton b2 = new MyButton(); frame.getContentPane().add(b1, 0); frame.getContentPane().add(b2, 2); - AbstractAction action = ui.new NavigateAction(); - action.putValue(AbstractAction.NAME, "navigateNext"); + action.putValue(Action.NAME, "navigateNext"); b1.requestedFocus = false; action.actionPerformed(null); assertTrue(b1.requestedFocus); - - action.putValue(AbstractAction.NAME, "navigatePrevious"); + action.putValue(Action.NAME, "navigatePrevious"); b2.requestedFocus = false; action.actionPerformed(null); assertTrue(b2.requestedFocus); @@ -112,11 +116,9 @@ public void testOpenAction() throws PropertyVetoException { AbstractAction action = ui.new OpenAction(); - desktop.getSelectedFrame().setMaximum(true); action.actionPerformed(null); assertFalse(desktop.getSelectedFrame().isMaximum()); - desktop.getSelectedFrame().setIcon(true); action.actionPerformed(null); assertFalse(desktop.getSelectedFrame().isIcon()); Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopPaneUITest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopPaneUITest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopPaneUITest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicDesktopPaneUITest.java Sun Nov 26 12:15:43 2006 @@ -18,11 +18,9 @@ * @author Vadim L. Bogdanov * @version $Revision$ */ - package javax.swing.plaf.basic; import java.awt.Dimension; - import javax.swing.DefaultDesktopManager; import javax.swing.JComponent; import javax.swing.JDesktopPane; @@ -31,7 +29,6 @@ import javax.swing.plaf.ComponentUI; public class BasicDesktopPaneUITest extends SwingTestCase { - private JDesktopPane desktop; private BasicDesktopPaneUI ui; @@ -39,9 +36,9 @@ /* * @see TestCase#setUp() */ + @Override protected void setUp() throws Exception { super.setUp(); - desktop = new JDesktopPane(); ui = new BasicDesktopPaneUI(); desktop.setUI(ui); @@ -50,6 +47,7 @@ /* * @see TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { super.tearDown(); } @@ -68,7 +66,6 @@ public void testCreateUI() { ComponentUI ui1 = BasicDesktopPaneUI.createUI(desktop); ComponentUI ui2 = BasicDesktopPaneUI.createUI(desktop); - assertTrue("not null", ui1 != null); assertTrue("stateful", ui1 != ui2); } @@ -84,8 +81,8 @@ * Class under test for Dimension getMaximumSize(JComponent) */ public void testGetMaximumSize() { - assertEquals(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), - ui.getMaximumSize(desktop)); + assertEquals(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), ui + .getMaximumSize(desktop)); } /* @@ -119,20 +116,17 @@ desktop.setDesktopManager(null); ui.installDesktopManager(); assertNotNull(desktop.getDesktopManager()); - assertEquals("installed", ui.desktopManager, - desktop.getDesktopManager()); + assertEquals("installed", ui.desktopManager, desktop.getDesktopManager()); } public void testUninstallDesktopManager() { ui.installDesktopManager(); ui.uninstallDesktopManager(); assertNotNull(desktop.getDesktopManager()); - DefaultDesktopManager m = new DefaultDesktopManager(); desktop.setDesktopManager(m); ui.uninstallDesktopManager(); assertSame(m, desktop.getDesktopManager()); - desktop.setDesktopManager(null); ui.uninstallDesktopManager(); assertNotNull(desktop.getDesktopManager()); @@ -140,15 +134,15 @@ public void testInstallKeyboardActions() { assertNotNull("action map", SwingUtilities.getUIActionMap(desktop)); - assertNotNull("input map", SwingUtilities.getUIInputMap( - desktop, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)); + assertNotNull("input map", SwingUtilities.getUIInputMap(desktop, + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)); } public void testUninstallKeyboardActions() { ui.uninstallKeyboardActions(); assertNull("action map", SwingUtilities.getUIActionMap(desktop)); - assertNull("input map", SwingUtilities.getUIInputMap( - desktop, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)); + assertNull("input map", SwingUtilities.getUIInputMap(desktop, + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)); } public void testInstallListeners() { Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicEditorPaneUITest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicEditorPaneUITest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicEditorPaneUITest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicEditorPaneUITest.java Sun Nov 26 12:15:43 2006 @@ -18,7 +18,6 @@ * @author Evgeniya G. Maenkova * @version $Revision$ */ - package javax.swing.plaf.basic; import javax.swing.Action; @@ -29,27 +28,27 @@ import javax.swing.SwingTestCase; import javax.swing.plaf.ComponentUI; import javax.swing.text.DefaultEditorKit; -import javax.swing.SwingWaitTestCase; - - public class BasicEditorPaneUITest extends SwingTestCase { JEditorPane jep; + JFrame jf; + BasicEditorPaneUI ui; + @Override protected void setUp() throws Exception { super.setUp(); setIgnoreNotImplemented(true); jf = new JFrame(); jep = new JEditorPane(); - ui = (BasicEditorPaneUI)jep.getUI(); + ui = (BasicEditorPaneUI) jep.getUI(); jf.getContentPane().add(jep); - jf.setSize(200,300); + jf.setSize(200, 300); jf.pack(); } - + @Override protected void tearDown() throws Exception { jf.dispose(); super.tearDown(); @@ -67,19 +66,17 @@ } public void testGetEditorKit() { - assertEquals(jep.getEditorKit(),ui.getEditorKit(jep)); + assertEquals(jep.getEditorKit(), ui.getEditorKit(jep)); jep.setContentType("text/html"); - assertEquals(jep.getEditorKit(),ui.getEditorKit(jep)); + assertEquals(jep.getEditorKit(), ui.getEditorKit(jep)); jep.setContentType("text/rtf"); - assertEquals(jep.getEditorKit(),ui.getEditorKit(jep)); + assertEquals(jep.getEditorKit(), ui.getEditorKit(jep)); DefaultEditorKit kit = new DefaultEditorKit(); jep.setEditorKit(kit); - assertEquals(jep.getEditorKit(),ui.getEditorKit(jep)); - - assertEquals(kit,ui.getEditorKit(new JTextField())); - assertEquals(kit,ui.getEditorKit(new JTextArea())); - - BasicEditorPaneUI editorPaneUI = (BasicEditorPaneUI)BasicEditorPaneUI.createUI(jep); + assertEquals(jep.getEditorKit(), ui.getEditorKit(jep)); + assertEquals(kit, ui.getEditorKit(new JTextField())); + assertEquals(kit, ui.getEditorKit(new JTextArea())); + BasicEditorPaneUI editorPaneUI = (BasicEditorPaneUI) BasicEditorPaneUI.createUI(jep); assertNull(editorPaneUI.getComponent()); } @@ -87,35 +84,34 @@ assertEquals("EditorPane", ui.getPropertyPrefix()); } - void checkNames(final Action a1[], final Object a2[]){ - for (int i = 0; i < a1.length; i ++){ - String name = (String)a1[i].getValue(Action.NAME); + void checkNames(final Action a1[], final Object a2[]) { + for (int i = 0; i < a1.length; i++) { + String name = (String) a1[i].getValue(Action.NAME); boolean wasFound = false; - for(int j = 0; j < a2.length; j ++){ - if (a2[j].equals(name)){ + for (int j = 0; j < a2.length; j++) { + if (a2[j].equals(name)) { wasFound = true; break; } } assertTrue(wasFound); - if (!wasFound) + if (!wasFound) { System.out.println(name); + } } } public void testPropertyChange() { Action a1[] = jep.getActions(); Object a2[] = jep.getActionMap().getParent().getParent().allKeys(); - checkNames(a1,a2); - + checkNames(a1, a2); jep.setContentType("text/html"); a1 = jep.getActions(); a2 = jep.getActionMap().getParent().getParent().allKeys(); - checkNames(a1,a2); - + checkNames(a1, a2); jep.setContentType("text/rtf"); a1 = jep.getActions(); a2 = jep.getActionMap().getParent().getParent().allKeys(); - checkNames(a1,a2); + checkNames(a1, a2); } } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicFileChooserUITest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicFileChooserUITest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicFileChooserUITest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicFileChooserUITest.java Sun Nov 26 12:15:43 2006 @@ -21,7 +21,6 @@ package javax.swing.plaf.basic; import java.io.File; - import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JFileChooser; @@ -31,13 +30,16 @@ public class BasicFileChooserUITest extends SwingTestCase { private BasicFileChooserUI ui; + private JFileChooser fc; + @Override protected void setUp() throws Exception { fc = new JFileChooser(); ui = new BasicFileChooserUI(fc); } + @Override protected void tearDown() throws Exception { fc = null; ui = null; @@ -45,24 +47,27 @@ public void testGetAcceptAllFileFilter() throws Exception { ui.installUI(fc); - assertNotNull(ui.getAcceptAllFileFilter(fc)); - assertEquals(UIManager.getString("FileChooser.acceptAllFileFilterText"), ui.getAcceptAllFileFilter(fc).getDescription()); + assertEquals(UIManager.getString("FileChooser.acceptAllFileFilterText"), ui + .getAcceptAllFileFilter(fc).getDescription()); assertTrue(ui.getAcceptAllFileFilter(fc).accept(new File(""))); } public void testGetApproveButtonText() throws Exception { ui.installUI(fc); - assertEquals(UIManager.get("FileChooser.openDialogTitleText"), ui.getDialogTitle(fc)); assertEquals(UIManager.get("FileChooser.openButtonText"), ui.getApproveButtonText(fc)); - assertEquals(UIManager.get("FileChooser.openButtonToolTipText"), ui.getApproveButtonToolTipText(fc)); - assertEquals(UIManager.getInt("FileChooser.openButtonMnemonic"), ui.getApproveButtonMnemonic(fc)); + assertEquals(UIManager.get("FileChooser.openButtonToolTipText"), ui + .getApproveButtonToolTipText(fc)); + assertEquals(UIManager.getInt("FileChooser.openButtonMnemonic"), ui + .getApproveButtonMnemonic(fc)); fc.setDialogType(JFileChooser.SAVE_DIALOG); assertEquals(UIManager.get("FileChooser.saveDialogTitleText"), ui.getDialogTitle(fc)); assertEquals(UIManager.get("FileChooser.saveButtonText"), ui.getApproveButtonText(fc)); - assertEquals(UIManager.get("FileChooser.saveButtonToolTipText"), ui.getApproveButtonToolTipText(fc)); - assertEquals(UIManager.getInt("FileChooser.saveButtonMnemonic"), ui.getApproveButtonMnemonic(fc)); + assertEquals(UIManager.get("FileChooser.saveButtonToolTipText"), ui + .getApproveButtonToolTipText(fc)); + assertEquals(UIManager.getInt("FileChooser.saveButtonMnemonic"), ui + .getApproveButtonMnemonic(fc)); fc.setDialogType(JFileChooser.CUSTOM_DIALOG); assertNull(ui.getApproveButtonText(fc)); assertNull(ui.getApproveButtonToolTipText(fc)); @@ -77,7 +82,6 @@ public void testBasicFileView() throws Exception { BasicFileChooserUI.BasicFileView fileView = new BasicFileChooserUI(fc).new BasicFileView(); - assertNotNull(fileView); assertEquals(0, fileView.iconCache.size()); File f = new File("f"); @@ -90,9 +94,8 @@ fileView.cacheIcon(null, null); assertEquals(1, fileView.iconCache.size()); assertEquals(f.getName(), fileView.getDescription(f)); - ui.installUI(fc); - fileView = (BasicFileChooserUI.BasicFileView)ui.getFileView(fc); + fileView = (BasicFileChooserUI.BasicFileView) ui.getFileView(fc); fileView.clearIconCache(); assertEquals(0, fileView.iconCache.size()); f.delete(); Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicFormattedTextFieldUITest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicFormattedTextFieldUITest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicFormattedTextFieldUITest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicFormattedTextFieldUITest.java Sun Nov 26 12:15:43 2006 @@ -26,26 +26,23 @@ public class BasicFormattedTextFieldUITest extends SwingTestCase { BasicFormattedTextFieldUI ui; + @Override protected void setUp() throws Exception { super.setUp(); ui = new BasicFormattedTextFieldUI(); } + @Override protected void tearDown() throws Exception { super.tearDown(); } public void testCreateUIJComponent() { - assertTrue(BasicFormattedTextFieldUI.createUI(null) - instanceof BasicFormattedTextFieldUI); - assertTrue(BasicFormattedTextFieldUI.createUI( - new JFormattedTextField()) - instanceof BasicFormattedTextFieldUI); + assertTrue(BasicFormattedTextFieldUI.createUI(null) instanceof BasicFormattedTextFieldUI); + assertTrue(BasicFormattedTextFieldUI.createUI(new JFormattedTextField()) instanceof BasicFormattedTextFieldUI); } public void testGetPropertyPrefix() { - assertEquals("FormattedTextField", - ui.getPropertyPrefix()); + assertEquals("FormattedTextField", ui.getPropertyPrefix()); } - } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicGraphicsUtilsTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicGraphicsUtilsTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicGraphicsUtilsTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicGraphicsUtilsTest.java Sun Nov 26 12:15:43 2006 @@ -28,7 +28,6 @@ import java.awt.Insets; import java.awt.Toolkit; import java.awt.image.BufferedImage; - import javax.swing.BorderFactory; import javax.swing.DebugGraphics; import javax.swing.Icon; @@ -39,35 +38,41 @@ public class BasicGraphicsUtilsTest extends SwingTestCase { private JFrame frame; + private Graphics g; private int x = 0; + private final int y = 0; + private final int w = 10; + private final int h = 7; private final Color shadow = Color.RED; + private final Color darkShadow = Color.BLACK; + private final Color highlight = Color.GREEN; + private final Color lightHighlight = Color.ORANGE; public BasicGraphicsUtilsTest(final String name) { super(name); } + @Override protected void setUp() throws Exception { super.setUp(); - frame = new JFrame(); frame.setSize(30, 30); frame.setVisible(true); g = frame.getContentPane().getGraphics(); - } + @Override protected void tearDown() throws Exception { super.tearDown(); - frame.dispose(); } @@ -77,14 +82,13 @@ public void testDrawEtchedRect() { Color color = g.getColor(); - BasicGraphicsUtils.drawEtchedRect(g, x, y, w, h, shadow, darkShadow, - highlight, lightHighlight); + BasicGraphicsUtils.drawEtchedRect(g, x, y, w, h, shadow, darkShadow, highlight, + lightHighlight); assertSame(color, g.getColor()); } public void testGetEtchedInsets() { - assertEquals(new Insets(2, 2, 2, 2), - BasicGraphicsUtils.getEtchedInsets()); + assertEquals(new Insets(2, 2, 2, 2), BasicGraphicsUtils.getEtchedInsets()); } public void testDrawGroove() { @@ -94,27 +98,26 @@ } public void testGetGrooveInsets() { - assertEquals(new Insets(2, 2, 2, 2), - BasicGraphicsUtils.getGrooveInsets()); + assertEquals(new Insets(2, 2, 2, 2), BasicGraphicsUtils.getGrooveInsets()); } public void testDrawBezel() { Color color = g.getColor(); - BasicGraphicsUtils.drawBezel(g, x, y, w, h, true, true, shadow, - darkShadow, highlight, lightHighlight); - BasicGraphicsUtils.drawBezel(g, x, y, w, h, true, false, shadow, - darkShadow, highlight, lightHighlight); - BasicGraphicsUtils.drawBezel(g, x, y, w, h, false, true, shadow, - darkShadow, highlight, lightHighlight); - BasicGraphicsUtils.drawBezel(g, x, y, w, h, false, false, shadow, - darkShadow, highlight, lightHighlight); + BasicGraphicsUtils.drawBezel(g, x, y, w, h, true, true, shadow, darkShadow, highlight, + lightHighlight); + BasicGraphicsUtils.drawBezel(g, x, y, w, h, true, false, shadow, darkShadow, highlight, + lightHighlight); + BasicGraphicsUtils.drawBezel(g, x, y, w, h, false, true, shadow, darkShadow, highlight, + lightHighlight); + BasicGraphicsUtils.drawBezel(g, x, y, w, h, false, false, shadow, darkShadow, + highlight, lightHighlight); assertSame(color, g.getColor()); } public void testDrawLoweredBezel() { Color color = g.getColor(); - BasicGraphicsUtils.drawLoweredBezel(g, x, y, w, h, shadow, darkShadow, - highlight, lightHighlight); + BasicGraphicsUtils.drawLoweredBezel(g, x, y, w, h, shadow, darkShadow, highlight, + lightHighlight); if (isHarmony()) { assertSame(color, g.getColor()); } @@ -138,12 +141,15 @@ public void testGetPreferredButtonSize() { Icon icon = new ImageIcon(new BufferedImage(10, 20, BufferedImage.TYPE_INT_RGB)); JMenuItem item = new JMenuItem() { + private static final long serialVersionUID = 1L; + + @SuppressWarnings("deprecation") + @Override public FontMetrics getFontMetrics(Font font) { return Toolkit.getDefaultToolkit().getFontMetrics(font); } }; item.setBorder(BorderFactory.createEmptyBorder(10, 20, 30, 40)); - item.setIcon(icon); assertEquals(new Dimension(70, 60), BasicGraphicsUtils.getPreferredButtonSize(item, 3)); } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicIconFactoryTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicIconFactoryTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicIconFactoryTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicIconFactoryTest.java Sun Nov 26 12:15:43 2006 @@ -14,12 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /** * @author Sergey Burlak * @version $Revision$ */ - package javax.swing.plaf.basic; import javax.swing.Icon; @@ -38,12 +36,14 @@ public void testGetMenuItemArrowIcon() { checkIcon(BasicIconFactory.getMenuItemArrowIcon(), 8, 4); - assertSame(BasicIconFactory.getMenuItemArrowIcon(), BasicIconFactory.getMenuItemArrowIcon()); + assertSame(BasicIconFactory.getMenuItemArrowIcon(), BasicIconFactory + .getMenuItemArrowIcon()); } public void testCreateEmptyFrameIcon() { checkIcon(BasicIconFactory.createEmptyFrameIcon(), 16, 14); - assertSame(BasicIconFactory.createEmptyFrameIcon(), BasicIconFactory.createEmptyFrameIcon()); + assertSame(BasicIconFactory.createEmptyFrameIcon(), BasicIconFactory + .createEmptyFrameIcon()); } public void testGetCheckBoxIcon() { @@ -53,17 +53,20 @@ public void testGetCheckBoxMenuItemIcon() { checkIcon(BasicIconFactory.getCheckBoxMenuItemIcon(), 9, 9); - assertSame(BasicIconFactory.getCheckBoxMenuItemIcon(), BasicIconFactory.getCheckBoxMenuItemIcon()); + assertSame(BasicIconFactory.getCheckBoxMenuItemIcon(), BasicIconFactory + .getCheckBoxMenuItemIcon()); } public void testGetMenuItemCheckIcon() { checkIcon(BasicIconFactory.getMenuItemCheckIcon(), 9, 9); - assertSame(BasicIconFactory.getMenuItemCheckIcon(), BasicIconFactory.getMenuItemCheckIcon()); + assertSame(BasicIconFactory.getMenuItemCheckIcon(), BasicIconFactory + .getMenuItemCheckIcon()); } public void testGetRadioButtonMenuItemIcon() { checkIcon(BasicIconFactory.getRadioButtonMenuItemIcon(), 6, 6); - assertSame(BasicIconFactory.getRadioButtonMenuItemIcon(), BasicIconFactory.getRadioButtonMenuItemIcon()); + assertSame(BasicIconFactory.getRadioButtonMenuItemIcon(), BasicIconFactory + .getRadioButtonMenuItemIcon()); } private void checkIcon(final Icon icon, final int height, final int width) { Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameTitlePaneTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameTitlePaneTest.java?view=diff&rev=479418&r1=479417&r2=479418 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameTitlePaneTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameTitlePaneTest.java Sun Nov 26 12:15:43 2006 @@ -18,7 +18,6 @@ * @author Vadim L. Bogdanov * @version $Revision$ */ - package javax.swing.plaf.basic; import java.awt.BorderLayout; @@ -28,7 +27,6 @@ import java.awt.Rectangle; import java.beans.PropertyChangeListener; import java.beans.PropertyVetoException; - import javax.swing.JDesktopPane; import javax.swing.JFrame; import javax.swing.JInternalFrame; @@ -41,7 +39,6 @@ import javax.swing.event.InternalFrameEvent; public class BasicInternalFrameTitlePaneTest extends SwingTestCase { - private BasicInternalFrameTitlePane pane; private JInternalFrame frame; @@ -54,6 +51,7 @@ super(name); } + @Override protected void setUp() throws Exception { super.setUp(); frame = new JInternalFrame(); @@ -64,9 +62,9 @@ rootFrame = null; } + @Override protected void tearDown() throws Exception { super.tearDown(); - if (rootFrame != null) { rootFrame.dispose(); } @@ -74,47 +72,35 @@ private void checkButtonIcons() { assertTrue("closeButton ok", pane.closeButton.getIcon() == pane.closeIcon); - if (frame.isIcon()) { assertTrue("iconButton ok", pane.iconButton.getIcon() == pane.minIcon); } else { assertTrue("iconButton ok", pane.iconButton.getIcon() == pane.iconIcon); } - if (frame.isMaximum() && !frame.isIcon()) { assertTrue("maxButton ok", pane.maxButton.getIcon() == pane.minIcon); } else { assertTrue("maxButton ok", pane.maxButton.getIcon() == pane.maxIcon); } - - assertTrue("closeButton tooltip ok", - pane.closeButton.getToolTipText() != null); - assertTrue("iconButton tooltip ok", - pane.iconButton.getToolTipText() != null); - assertTrue("maxButton tooltip ok", - pane.maxButton.getToolTipText() != null); + assertTrue("closeButton tooltip ok", pane.closeButton.getToolTipText() != null); + assertTrue("iconButton tooltip ok", pane.iconButton.getToolTipText() != null); + assertTrue("maxButton tooltip ok", pane.maxButton.getToolTipText() != null); } private void checkEnabledActions() { assertEquals("iconifyAction", !frame.isIcon() && frame.isIconifiable(), - pane.iconifyAction.isEnabled()); - assertEquals("closeAction", frame.isClosable(), - pane.closeAction.isEnabled()); + pane.iconifyAction.isEnabled()); + assertEquals("closeAction", frame.isClosable(), pane.closeAction.isEnabled()); assertEquals("maximizeAction", frame.isMaximizable() && (!frame.isMaximum() || frame.isIcon() && frame.isIconifiable()), pane.maximizeAction.isEnabled()); - assertEquals("moveAction", - isHarmony() && frame.getDesktopPane() != null && !frame.isMaximum(), - pane.moveAction.isEnabled()); + assertEquals("moveAction", isHarmony() && frame.getDesktopPane() != null + && !frame.isMaximum(), pane.moveAction.isEnabled()); assertEquals("sizeAction", - !frame.isMaximum() && frame.isResizable() - && !frame.isIcon(), - pane.sizeAction.isEnabled()); - - assertEquals("restoreAction", - frame.isMaximum() && frame.isMaximizable() - || frame.isIcon() && frame.isIconifiable(), - pane.restoreAction.isEnabled()); + !frame.isMaximum() && frame.isResizable() && !frame.isIcon(), pane.sizeAction + .isEnabled()); + assertEquals("restoreAction", frame.isMaximum() && frame.isMaximizable() + || frame.isIcon() && frame.isIconifiable(), pane.restoreAction.isEnabled()); } private boolean belongs(final Object o, final Object[] array) { @@ -130,7 +116,6 @@ frame = new JInternalFrame("", true, true, true, true); pane = new BasicInternalFrameTitlePane(frame); assertEquals(4, pane.getComponentCount()); - frame = new JInternalFrame("", true, true, true, false); pane = new BasicInternalFrameTitlePane(frame); if (isHarmony()) { @@ -140,43 +125,34 @@ public void testCreateActions() { pane.createActions(); - // test created actions assertTrue("closeAction != null", pane.closeAction != null); - assertTrue("closeAction instanceof ok", pane.closeAction - instanceof BasicInternalFrameTitlePane.CloseAction); - + assertTrue("closeAction instanceof ok", + pane.closeAction instanceof BasicInternalFrameTitlePane.CloseAction); assertTrue("iconifyAction != null", pane.iconifyAction != null); - assertTrue("iconifyAction instanceof ok", pane.iconifyAction - instanceof BasicInternalFrameTitlePane.IconifyAction); - + assertTrue("iconifyAction instanceof ok", + pane.iconifyAction instanceof BasicInternalFrameTitlePane.IconifyAction); assertTrue("maximizeAction != null", pane.maximizeAction != null); - assertTrue("maximizeAction instanceof ok", pane.maximizeAction - instanceof BasicInternalFrameTitlePane.MaximizeAction); - + assertTrue("maximizeAction instanceof ok", + pane.maximizeAction instanceof BasicInternalFrameTitlePane.MaximizeAction); assertTrue("moveAction != null", pane.moveAction != null); - assertTrue("moveAction instanceof ok", pane.moveAction - instanceof BasicInternalFrameTitlePane.MoveAction); - + assertTrue("moveAction instanceof ok", + pane.moveAction instanceof BasicInternalFrameTitlePane.MoveAction); assertTrue("restoreAction != null", pane.restoreAction != null); - assertTrue("restoreAction instanceof ok", pane.restoreAction - instanceof BasicInternalFrameTitlePane.RestoreAction); - + assertTrue("restoreAction instanceof ok", + pane.restoreAction instanceof BasicInternalFrameTitlePane.RestoreAction); assertTrue("sizeAction != null", pane.sizeAction != null); - assertTrue("sizeAction instanceof ok", pane.sizeAction - instanceof BasicInternalFrameTitlePane.SizeAction); + assertTrue("sizeAction instanceof ok", + pane.sizeAction instanceof BasicInternalFrameTitlePane.SizeAction); } public void testCreateButtons() { pane.createButtons(); - // test created buttons assertTrue("maxButton != null", pane.maxButton != null); assertTrue("maxButton tooltip", pane.maxButton.getToolTipText() != null); - assertTrue("closeButton != null", pane.closeButton != null); assertTrue("closeButton tooltip", pane.closeButton.getToolTipText() != null); - assertTrue("iconButton != null", pane.iconButton != null); assertTrue("iconButton tooltip", pane.iconButton.getToolTipText() != null); } @@ -187,19 +163,16 @@ checkEnabledActions(); frame.setIconifiable(true); checkEnabledActions(); - // closeAction test frame.setClosable(false); checkEnabledActions(); frame.setClosable(true); checkEnabledActions(); - // maximizeAction test frame.setMaximizable(false); checkEnabledActions(); frame.setMaximizable(true); checkEnabledActions(); - // restoreAction test checkEnabledActions(); // normal bounds - disabled frame.setMaximizable(true); @@ -214,7 +187,6 @@ checkEnabledActions(); // disabled } frame.setMaximizable(true); - frame.setIconifiable(true); try { frame.setIcon(true); @@ -233,45 +205,36 @@ assertSame(UIManager.getIcon("InternalFrame.maximizeIcon"), pane.maxIcon); assertSame(UIManager.getIcon("InternalFrame.minimizeIcon"), pane.minIcon); assertSame(UIManager.getIcon("InternalFrame.iconifyIcon"), pane.iconIcon); - assertSame(UIManager.getColor("InternalFrame.activeTitleBackground"), - pane.selectedTitleColor); + pane.selectedTitleColor); assertSame(UIManager.getColor("InternalFrame.activeTitleForeground"), - pane.selectedTextColor); + pane.selectedTextColor); assertSame(UIManager.getColor("InternalFrame.inactiveTitleBackground"), - pane.notSelectedTitleColor); + pane.notSelectedTitleColor); assertSame(UIManager.getColor("InternalFrame.inactiveTitleForeground"), - pane.notSelectedTextColor); - assertSame(UIManager.getFont("InternalFrame.titleFont"), - pane.getFont()); + pane.notSelectedTextColor); + assertSame(UIManager.getFont("InternalFrame.titleFont"), pane.getFont()); } public void testInstallUninstallListeners() { pane.uninstallListeners(); - assertFalse("listener was uninstalled", - belongs(pane.propertyChangeListener, - frame.getPropertyChangeListeners())); - + assertFalse("listener was uninstalled", belongs(pane.propertyChangeListener, frame + .getPropertyChangeListeners())); pane.installListeners(); assertTrue("listener != null", pane.propertyChangeListener != null); - assertTrue("listener was installed", - belongs(pane.propertyChangeListener, - frame.getPropertyChangeListeners())); - + assertTrue("listener was installed", belongs(pane.propertyChangeListener, frame + .getPropertyChangeListeners())); pane.uninstallListeners(); - assertFalse("listener was uninstalled", - belongs(pane.propertyChangeListener, - frame.getPropertyChangeListeners())); + assertFalse("listener was uninstalled", belongs(pane.propertyChangeListener, frame + .getPropertyChangeListeners())); } public void testInstallTitlePane() { pane.installTitlePane(); - assertSame(UIManager.getIcon("InternalFrame.closeIcon"), pane.closeIcon); assertTrue("listener != null", pane.propertyChangeListener != null); - assertTrue("listener was installed", - belongs(pane.propertyChangeListener, - frame.getPropertyChangeListeners())); + assertTrue("listener was installed", belongs(pane.propertyChangeListener, frame + .getPropertyChangeListeners())); assertTrue("closeAction != null", pane.closeAction != null); assertNotNull(pane.getLayout()); assertTrue("maxButton != null", pane.maxButton != null); @@ -282,7 +245,6 @@ public void testSetButtonIcons() { checkButtonIcons(); - // test icons in Maximum state frame.setMaximizable(true); try { @@ -291,7 +253,6 @@ assertTrue("exception", false); } checkButtonIcons(); - // test icons in Icon state frame.setIconifiable(true); try { @@ -314,12 +275,11 @@ public void testShowSystemMenu() { createAndShowRootFrame(); - pane.showSystemMenu(); assertTrue("", pane.windowMenu.isPopupMenuVisible()); - pane.windowMenu = null; testExceptionalCase(new NullPointerCase() { + @Override public void exceptionalAction() throws Exception { pane.showSystemMenu(); } @@ -332,19 +292,15 @@ public void testBasicInternalFrameTitlePane() { pane = new BasicInternalFrameTitlePane(frame); - assertTrue("frame is set", pane.frame == frame); assertTrue("layout", pane.getLayout() != null); } public void testGetTitle() { createAndShowRootFrame(); - final String title = "Document #1"; - Font font = new Font("Fixed", Font.PLAIN, 10); FontMetrics fm = getFontMetrics(font); - assertEquals(title, pane.getTitle(title, fm, 110)); assertEquals("Documen...", pane.getTitle(title, fm, 109)); assertEquals("Do...", pane.getTitle(title, fm, 50)); @@ -358,7 +314,6 @@ public void testAddSystemMenuItems() { JMenu menu = new JMenu(); - pane.addSystemMenuItems(menu); assertEquals(7, menu.getItemCount()); } @@ -373,14 +328,14 @@ assertTrue("windowMenu != null", pane.windowMenu != null); assertEquals("7 items", 7, pane.windowMenu.getItemCount()); JMenuBar menuBar = pane.menuBar; - assertTrue("menuBar contains windowMenu", - menuBar.getMenu(0) == pane.windowMenu); + assertTrue("menuBar contains windowMenu", menuBar.getMenu(0) == pane.windowMenu); } public void testPostClosingEvent() { class MyInternalFrameAdapter extends InternalFrameAdapter { boolean ok = false; + @Override public void internalFrameClosing(final InternalFrameEvent e) { ok = true; } @@ -398,7 +353,7 @@ assertTrue("!= null", listener != null); if (isHarmony()) { assertTrue("instanceof TitlePaneLayout", - listener instanceof BasicInternalFrameTitlePane.PropertyChangeHandler); + listener instanceof BasicInternalFrameTitlePane.PropertyChangeHandler); } } @@ -407,7 +362,7 @@ assertTrue("!= null", layout != null); if (isHarmony()) { assertTrue("instanceof TitlePaneLayout", - layout instanceof BasicInternalFrameTitlePane.TitlePaneLayout); + layout instanceof BasicInternalFrameTitlePane.TitlePaneLayout); } } @@ -415,7 +370,6 @@ // test with isClosable == false pane.closeButton.doClick(0); assertFalse("not closed", frame.isClosed()); - // test with isClosable == true frame.setClosable(true); pane.closeButton.doClick(0); @@ -426,16 +380,13 @@ // test with isIconifiable == false pane.iconButton.doClick(0); assertFalse("not iconified", frame.isIcon()); - // test with isIconifiable == true frame.setIconifiable(true); pane.iconButton.doClick(0); assertTrue("iconified", frame.isIcon()); - // test iconify again pane.iconButton.doClick(0); assertFalse("deiconified", frame.isIcon()); - // test iconify from maximized state frame.setMaximizable(true); pane.maxButton.doClick(0); @@ -443,7 +394,6 @@ pane.iconButton.doClick(0); assertTrue("iconified", frame.isIcon()); assertTrue("maximized", frame.isMaximum()); - // test deiconify after iconify from maximized state pane.iconButton.doClick(0); assertFalse("deiconified", frame.isIcon()); @@ -454,16 +404,13 @@ // test with isMaximizable == false pane.maxButton.doClick(0); assertFalse("not maximized", frame.isMaximum()); - // test with isMaximizable == true frame.setMaximizable(true); pane.maxButton.doClick(0); assertTrue("maximized", frame.isMaximum()); - // test maximize again pane.maxButton.doClick(0); assertFalse("restored", frame.isMaximum()); - // test maximize from icon frame.setIconifiable(true); pane.iconButton.doClick(0); @@ -472,7 +419,6 @@ pane.maxButton.doClick(0); assertFalse("deiconified", frame.isIcon()); assertTrue("maximized", frame.isMaximum()); - // test maximize again frame.setIconifiable(true); pane.iconButton.doClick(0); @@ -486,33 +432,27 @@ frame.setMaximizable(true); pane.maxButton.doClick(0); assertTrue("maximized", frame.isMaximum()); - // test with isMaximizable == false frame.setMaximizable(false); JMenuItem menuItem = pane.menuBar.getMenu(0).getItem(0); assertEquals("name == Restore", "Restore", menuItem.getText()); menuItem.doClick(0); assertTrue("restored", frame.isMaximum()); - // test with isMaximizable == true frame.setMaximizable(true); menuItem.doClick(0); assertFalse("restored", frame.isMaximum()); - // test restore again menuItem.doClick(0); assertFalse("no change", frame.isMaximum()); - // iconify the frame frame.setIconifiable(true); pane.iconButton.doClick(0); assertTrue("iconified", frame.isIcon()); - // test restore of the iconified frame with isIconifiable == false frame.setIconifiable(false); menuItem.doClick(0); assertTrue("not restored", frame.isIcon()); - // test restore of the iconified frame with isIconifiable == true frame.setIconifiable(true); menuItem.doClick(0); @@ -535,57 +475,39 @@ final Rectangle closeButtonBounds = new Rectangle(182, 7, 16, 16); final Rectangle iconButtonBounds = new Rectangle(146, 7, 16, 16); final Rectangle maximizeButtonBounds = new Rectangle(164, 7, 16, 16); - // non-iconifiable, non-maximizable, non-closable layout.layoutContainer(null); - assertEquals("menuBar", menuBarBounds, - pane.menuBar.getBounds()); - assertEquals("iconButton", zeroBounds, - pane.iconButton.getBounds()); - assertEquals("maximizeButton", zeroBounds, - pane.maxButton.getBounds()); - assertEquals("closeButton", zeroBounds, - pane.closeButton.getBounds()); - + assertEquals("menuBar", menuBarBounds, pane.menuBar.getBounds()); + assertEquals("iconButton", zeroBounds, pane.iconButton.getBounds()); + assertEquals("maximizeButton", zeroBounds, pane.maxButton.getBounds()); + assertEquals("closeButton", zeroBounds, pane.closeButton.getBounds()); if (!isHarmony()) { return; } - // iconifiable, non-maximizable, non-closable frame.setIconifiable(true); layout.layoutContainer(null); - assertEquals("menuBar", menuBarBounds, - pane.menuBar.getBounds()); - assertEquals("iconButton", closeButtonBounds, - pane.iconButton.getBounds()); - assertEquals("maximizeButton", zeroBounds, - pane.maxButton.getBounds()); - assertEquals("closeButton", zeroBounds, - pane.closeButton.getBounds()); - + assertEquals("menuBar", menuBarBounds, pane.menuBar.getBounds()); + assertEquals("iconButton", closeButtonBounds, pane.iconButton.getBounds()); + assertEquals("maximizeButton", zeroBounds, pane.maxButton.getBounds()); + assertEquals("closeButton", zeroBounds, pane.closeButton.getBounds()); // iconifiable, maximizable, closable frame.setMaximizable(true); frame.setClosable(true); layout.layoutContainer(null); - assertEquals("menuBar", menuBarBounds, - pane.menuBar.getBounds()); - assertEquals("iconButton", iconButtonBounds, - pane.iconButton.getBounds()); - assertEquals("maximizeButton", maximizeButtonBounds, - pane.maxButton.getBounds()); - assertEquals("closeButton", closeButtonBounds, - pane.closeButton.getBounds()); - + assertEquals("menuBar", menuBarBounds, pane.menuBar.getBounds()); + assertEquals("iconButton", iconButtonBounds, pane.iconButton.getBounds()); + assertEquals("maximizeButton", maximizeButtonBounds, pane.maxButton.getBounds()); + assertEquals("closeButton", closeButtonBounds, pane.closeButton.getBounds()); // minimumLayoutSize(), preferredLayoutSize() implementations assertTrue("", layout.minimumLayoutSize(pane) != null); assertTrue("", layout.preferredLayoutSize(pane) != null); } + @SuppressWarnings("deprecation") public void testSystemMenuBar() { JMenuBar menuBar = pane.new SystemMenuBar(); - assertTrue("opaque", menuBar.isOpaque()); - assertFalse("isFocusTraversable", menuBar.isFocusTraversable()); assertFalse(menuBar.isFocusable()); } @@ -593,36 +515,22 @@ public void testPropertyChangeHandler() { // test "iconable" property change frame.setIconifiable(false); - frame.setIconifiable(true); - assertTrue("icon button added", belongs(pane.iconButton, - pane.getComponents())); - + assertTrue("icon button added", belongs(pane.iconButton, pane.getComponents())); frame.setIconifiable(false); - assertFalse("icon button removed", belongs(pane.iconButton, - pane.getComponents())); - + assertFalse("icon button removed", belongs(pane.iconButton, pane.getComponents())); // test "closable" property change frame.setClosable(false); - frame.setClosable(true); - assertTrue("close button added", belongs(pane.closeButton, - pane.getComponents())); - + assertTrue("close button added", belongs(pane.closeButton, pane.getComponents())); frame.setClosable(false); - assertFalse("close button removed", belongs(pane.closeButton, - pane.getComponents())); - + assertFalse("close button removed", belongs(pane.closeButton, pane.getComponents())); // test "maximizable" property change frame.setMaximizable(false); - frame.setMaximizable(true); - assertTrue("max button added", belongs(pane.maxButton, - pane.getComponents())); - + assertTrue("max button added", belongs(pane.maxButton, pane.getComponents())); frame.setMaximizable(false); - assertFalse("max button removed", belongs(pane.maxButton, - pane.getComponents())); + assertFalse("max button removed", belongs(pane.maxButton, pane.getComponents())); } public void testPaintTitleBackground() {