You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/11/26 21:15:55 UTC
svn commit: r479418 [7/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...
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameUI$InternalFrameLayoutTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameUI%24InternalFrameLayoutTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameUI$InternalFrameLayoutTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameUI$InternalFrameLayoutTest.java Sun Nov 26 12:15:43 2006
@@ -18,13 +18,11 @@
* @author Vadim L. Bogdanov
* @version $Revision$
*/
-
package javax.swing.plaf.basic;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.Rectangle;
-
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JInternalFrame;
@@ -37,23 +35,27 @@
*/
public class BasicInternalFrameUI$InternalFrameLayoutTest extends SwingTestCase {
private JInternalFrame frame;
+
private BasicInternalFrameUI ui;
+
private LayoutManager layout;
+
private JComponent titlePane;
+ @Override
protected void setUp() throws Exception {
super.setUp();
-
frame = new JInternalFrame();
frame.setBorder(BorderFactory.createEmptyBorder(5, 10, 15, 20));
ui = new BasicInternalFrameUI(frame);
frame.setUI(ui);
layout = frame.getLayout();
- titlePane = (JComponent)frame.getComponent(1);
+ titlePane = (JComponent) frame.getComponent(1);
titlePane.setPreferredSize(new Dimension(100, 20));
titlePane.setMinimumSize(new Dimension(80, 10));
}
+ @Override
protected void tearDown() throws Exception {
titlePane = null;
ui = null;
@@ -66,29 +68,20 @@
public void testPreferredLayoutSize() {
Dimension rootPanePreferredSize = new Dimension(32, 21);
frame.getRootPane().setPreferredSize(rootPanePreferredSize);
-
// only northPane is set
-
// 1.5 seems to add Insests before calculating max between TitlePane width
// and RootPane width which is likely a bug.
if (isHarmony()) {
- assertEquals("1 pane", new Dimension(130, 61),
- layout.preferredLayoutSize(frame));
+ assertEquals("1 pane", new Dimension(130, 61), layout.preferredLayoutSize(frame));
} else {
- assertEquals("1 pane", new Dimension(100, 61),
- layout.preferredLayoutSize(frame));
+ assertEquals("1 pane", new Dimension(100, 61), layout.preferredLayoutSize(frame));
}
- assertEquals("rootPane's preferred size not changed",
- rootPanePreferredSize,
- frame.getRootPane().getPreferredSize());
-
+ assertEquals("rootPane's preferred size not changed", rootPanePreferredSize, frame
+ .getRootPane().getPreferredSize());
titlePane.setPreferredSize(new Dimension(10, 20));
- assertEquals("1 pane", new Dimension(62, 61),
- layout.preferredLayoutSize(frame));
- assertEquals("rootPane's preferred size not changed",
- rootPanePreferredSize,
- frame.getRootPane().getPreferredSize());
-
+ assertEquals("1 pane", new Dimension(62, 61), layout.preferredLayoutSize(frame));
+ assertEquals("rootPane's preferred size not changed", rootPanePreferredSize, frame
+ .getRootPane().getPreferredSize());
// all panes are set
ui.getNorthPane().setPreferredSize(new Dimension(14, 18));
ui.setWestPane(new JPanel());
@@ -97,8 +90,7 @@
ui.getSouthPane().setPreferredSize(new Dimension(12, 23));
ui.setEastPane(new JPanel());
ui.getEastPane().setPreferredSize(new Dimension(13, 24));
- assertEquals("all panes", new Dimension(86, 82),
- layout.preferredLayoutSize(frame));
+ assertEquals("all panes", new Dimension(86, 82), layout.preferredLayoutSize(frame));
}
/*
@@ -106,11 +98,8 @@
*/
public void testMinimumLayoutSize() {
frame.getRootPane().setMinimumSize(new Dimension(32, 21));
-
// only northPane is set
- assertEquals("1 pane", new Dimension(110, 30),
- layout.minimumLayoutSize(frame));
-
+ assertEquals("1 pane", new Dimension(110, 30), layout.minimumLayoutSize(frame));
// all panes are set
ui.getNorthPane().setMinimumSize(new Dimension(14, 18));
ui.setWestPane(new JPanel());
@@ -119,8 +108,7 @@
ui.getSouthPane().setMinimumSize(new Dimension(12, 23));
ui.setEastPane(new JPanel());
ui.getEastPane().setMinimumSize(new Dimension(13, 24));
- assertEquals("all panes", new Dimension(44, 38),
- layout.minimumLayoutSize(frame));
+ assertEquals("all panes", new Dimension(44, 38), layout.minimumLayoutSize(frame));
}
/*
@@ -129,14 +117,10 @@
public void testLayoutContainer() {
frame.getRootPane().setPreferredSize(new Dimension(9, 21));
frame.setSize(100, 200);
-
// only northPane is set
layout.layoutContainer(frame);
- assertEquals(new Rectangle(10, 25, 70, 160),
- frame.getRootPane().getBounds());
- assertEquals(new Rectangle(10, 5, 70, 20),
- ui.getNorthPane().getBounds());
-
+ assertEquals(new Rectangle(10, 25, 70, 160), frame.getRootPane().getBounds());
+ assertEquals(new Rectangle(10, 5, 70, 20), ui.getNorthPane().getBounds());
// all panes are set
JPanel button = new JPanel();
button.setPreferredSize(new Dimension(11, 12));
@@ -147,23 +131,16 @@
button = new JPanel();
button.setPreferredSize(new Dimension(11, 12));
ui.setEastPane(button);
-
layout.layoutContainer(frame);
- assertEquals(new Rectangle(21, 25, 48, 148),
- frame.getRootPane().getBounds());
- assertEquals(new Rectangle(10, 5, 70, 20),
- ui.getNorthPane().getBounds());
- assertEquals(new Rectangle(10, 25, 11, 148),
- ui.getWestPane().getBounds());
- assertEquals(new Rectangle(10, 173, 70, 12),
- ui.getSouthPane().getBounds());
+ assertEquals(new Rectangle(21, 25, 48, 148), frame.getRootPane().getBounds());
+ assertEquals(new Rectangle(10, 5, 70, 20), ui.getNorthPane().getBounds());
+ assertEquals(new Rectangle(10, 25, 11, 148), ui.getWestPane().getBounds());
+ assertEquals(new Rectangle(10, 173, 70, 12), ui.getSouthPane().getBounds());
// 1.5 fails because of its bug in layout
if (isHarmony()) {
- assertEquals(new Rectangle(69, 25, 11, 148),
- ui.getEastPane().getBounds());
+ assertEquals(new Rectangle(69, 25, 11, 148), ui.getEastPane().getBounds());
} else {
- assertEquals(new Rectangle(48, 25, 11, 148),
- ui.getEastPane().getBounds());
+ assertEquals(new Rectangle(48, 25, 11, 148), ui.getEastPane().getBounds());
}
}
@@ -182,7 +159,6 @@
public void testRemoveLayoutComponent() {
layout.layoutContainer(frame);
Rectangle bounds = frame.getRootPane().getBounds();
-
layout.removeLayoutComponent(ui.getNorthPane());
layout.layoutContainer(frame);
assertEquals("nothing changed", bounds, frame.getRootPane().getBounds());
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicInternalFrameUITest.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;
@@ -27,7 +26,6 @@
import java.awt.event.ComponentListener;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
-
import javax.swing.BorderFactory;
import javax.swing.DesktopManager;
import javax.swing.InputMap;
@@ -45,10 +43,10 @@
public class BasicInternalFrameUITest extends SwingTestCase {
- /*
- *
- */
private class MyJInternalFrame extends JInternalFrame {
+ private static final long serialVersionUID = 1L;
+
+ @Override
protected boolean isRootPaneCheckingEnabled() {
return false;
}
@@ -61,6 +59,7 @@
/*
* @see TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
frame = new MyJInternalFrame();
@@ -70,16 +69,18 @@
/*
* @see TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
-
UIManager.getDefaults().remove("InternalFrame.windowBindings");
}
private boolean belongs(final Object o, final Object[] array) {
- for (int i = 0; i < array.length; i++)
- if (array[i] == o)
+ for (int i = 0; i < array.length; i++) {
+ if (array[i] == o) {
return true;
+ }
+ }
return false;
}
@@ -93,7 +94,6 @@
frame.setUI(ui);
ui.uninstallKeyboardActions();
int listenersCount = frame.getInternalFrameListeners().length;
-
ui.installKeyboardActions();
assertTrue("internalFrameListener was installed",
frame.getInternalFrameListeners().length == listenersCount + 1);
@@ -106,16 +106,12 @@
*/
public void testInstallUninstallComponents() {
ui.frame = frame;
-
ui.installComponents();
- assertTrue("titlePane installed",
- belongs(ui.titlePane, frame.getComponents()));
+ assertTrue("titlePane installed", belongs(ui.titlePane, frame.getComponents()));
assertTrue("northPane != null", ui.getNorthPane() != null);
-
// cannot call uninstallComponents() directly
ui.uninstallComponents();
- assertFalse("titlePane uninstalled",
- belongs(ui.titlePane, frame.getComponents()));
+ assertFalse("titlePane uninstalled", belongs(ui.titlePane, frame.getComponents()));
assertNull("northPane == null", ui.getNorthPane());
}
@@ -128,9 +124,7 @@
frame.setFrameIcon(null);
frame.setLayout(null);
ui.frame = frame;
-
ui.installDefaults();
-
assertTrue("background", frame.getBackground() != null);
assertTrue("opaque", frame.isOpaque());
assertTrue("border", frame.getBorder() != null);
@@ -144,16 +138,13 @@
*/
public void testUninstallDefaults() {
frame.setUI(ui);
-
// test general uninstallDefaults()
ui.uninstallDefaults();
-
assertTrue("background", frame.getBackground() != null);
assertNull("border", frame.getBorder());
assertNull("frameIcon", frame.getFrameIcon());
assertNull("layout", frame.getLayout());
assertNull("layout", ui.internalFrameLayout);
-
// test uninstallDefaults() with user-set values
frame.setBorder(BorderFactory.createEmptyBorder());
frame.setLayout(new BorderLayout());
@@ -167,20 +158,17 @@
*/
public void testInstallKeyboardActions() {
UIManager.getDefaults().put("InternalFrame.windowBindings",
- new Object[] { "shift ESCAPE", "showSystemMenu"});
-
+ new Object[] { "shift ESCAPE", "showSystemMenu" });
frame.setUI(ui);
ui.uninstallKeyboardActions();
int listenersCount = frame.getInternalFrameListeners().length;
assertNull("no UIActionMap", SwingUtilities.getUIActionMap(frame));
-
ui.installKeyboardActions();
- assertTrue("UIActionMap installed",
- SwingUtilities.getUIActionMap(frame) != null);
+ assertTrue("UIActionMap installed", SwingUtilities.getUIActionMap(frame) != null);
assertTrue("internalFrameListener istalled",
frame.getInternalFrameListeners().length == listenersCount + 1);
assertNull("inputMap not installed", SwingUtilities.getUIInputMap(frame,
- JComponent.WHEN_IN_FOCUSED_WINDOW));
+ JComponent.WHEN_IN_FOCUSED_WINDOW));
}
/*
@@ -188,22 +176,19 @@
*/
public void testUninstallKeyboardActions() {
UIManager.getDefaults().put("InternalFrame.windowBindings",
- new Object[] { "shift ESCAPE", "showSystemMenu"});
-
+ new Object[] { "shift ESCAPE", "showSystemMenu" });
frame.setUI(ui);
ui.setupMenuOpenKey();
int listenersCount = frame.getInternalFrameListeners().length;
- assertTrue("UIActionMap installed",
- SwingUtilities.getUIActionMap(frame) != null);
+ assertTrue("UIActionMap installed", SwingUtilities.getUIActionMap(frame) != null);
assertTrue("inputMap installed", SwingUtilities.getUIInputMap(frame,
- JComponent.WHEN_IN_FOCUSED_WINDOW) != null);
-
+ JComponent.WHEN_IN_FOCUSED_WINDOW) != null);
ui.uninstallKeyboardActions();
assertNull("no UIActionMap", SwingUtilities.getUIActionMap(frame));
assertTrue("internalFrameListener unistalled",
frame.getInternalFrameListeners().length == listenersCount - 1);
assertNull("inputMap uninstalled", SwingUtilities.getUIInputMap(frame,
- JComponent.WHEN_IN_FOCUSED_WINDOW));
+ JComponent.WHEN_IN_FOCUSED_WINDOW));
}
/*
@@ -214,38 +199,27 @@
f.setSize(50, 100);
f.getContentPane().add(frame);
f.setVisible(true);
-
frame.setUI(ui);
-
// glassPaneDispatcher
assertTrue("glassPaneDispatcher != null", ui.glassPaneDispatcher != null);
- assertTrue("glassPaneDispatcher is mouse listener",
- belongs(ui.glassPaneDispatcher,
- frame.getGlassPane().getMouseListeners()));
- assertTrue("glassPaneDispatcher is mouse motion listener",
- belongs(ui.glassPaneDispatcher,
- frame.getGlassPane().getMouseMotionListeners()));
-
+ assertTrue("glassPaneDispatcher is mouse listener", belongs(ui.glassPaneDispatcher,
+ frame.getGlassPane().getMouseListeners()));
+ assertTrue("glassPaneDispatcher is mouse motion listener", belongs(
+ ui.glassPaneDispatcher, frame.getGlassPane().getMouseMotionListeners()));
// borderListener
assertTrue("borderListener != null", ui.borderListener != null);
- assertTrue("borderListener is mouse listener",
- belongs(ui.borderListener, frame.getMouseListeners()));
- assertTrue("borderListener is mouse motion listener",
- belongs(ui.borderListener, frame.getMouseMotionListeners()));
-
+ assertTrue("borderListener is mouse listener", belongs(ui.borderListener, frame
+ .getMouseListeners()));
+ assertTrue("borderListener is mouse motion listener", belongs(ui.borderListener, frame
+ .getMouseMotionListeners()));
// propertyChangeListener
- assertTrue("propertyChangeListener != null",
- ui.propertyChangeListener != null);
- assertTrue("propertyChangeListener installed",
- belongs(ui.propertyChangeListener,
- frame.getPropertyChangeListeners()));
-
+ assertTrue("propertyChangeListener != null", ui.propertyChangeListener != null);
+ assertTrue("propertyChangeListener installed", belongs(ui.propertyChangeListener, frame
+ .getPropertyChangeListeners()));
// componentListener
assertTrue("componentListener != null", ui.componentListener != null);
- assertTrue("componentListener installed",
- belongs(ui.componentListener,
- frame.getParent().getComponentListeners()));
-
+ assertTrue("componentListener installed", belongs(ui.componentListener, frame
+ .getParent().getComponentListeners()));
f.dispose();
}
@@ -257,33 +231,24 @@
f.setSize(50, 100);
f.getContentPane().add(frame);
f.setVisible(true);
-
frame.setUI(ui);
ui.uninstallListeners();
-
// glassPaneDispatcher
- assertFalse("glassPaneDispatcher is not mouse listener",
- belongs(ui.glassPaneDispatcher,
- frame.getGlassPane().getMouseListeners()));
- assertFalse("glassPaneDispatcher is not mouse motion listener",
- belongs(ui.glassPaneDispatcher,
- frame.getGlassPane().getMouseMotionListeners()));
-
+ assertFalse("glassPaneDispatcher is not mouse listener", belongs(
+ ui.glassPaneDispatcher, frame.getGlassPane().getMouseListeners()));
+ assertFalse("glassPaneDispatcher is not mouse motion listener", belongs(
+ ui.glassPaneDispatcher, frame.getGlassPane().getMouseMotionListeners()));
// borderListener
- assertFalse("borderListener is not mouse listener",
- belongs(ui.borderListener, frame.getMouseListeners()));
- assertFalse("borderListener is not mouse motion listener",
- belongs(ui.borderListener, frame.getMouseMotionListeners()));
-
+ assertFalse("borderListener is not mouse listener", belongs(ui.borderListener, frame
+ .getMouseListeners()));
+ assertFalse("borderListener is not mouse motion listener", belongs(ui.borderListener,
+ frame.getMouseMotionListeners()));
// propertyChangeListener
- assertFalse("propertyChangeListener uninstalled",
- belongs(ui.propertyChangeListener,
- frame.getPropertyChangeListeners()));
-
+ assertFalse("propertyChangeListener uninstalled", belongs(ui.propertyChangeListener,
+ frame.getPropertyChangeListeners()));
// componentListener
- assertFalse("componentListener uninstalled",
- belongs(ui.componentListener, frame.getComponentListeners()));
-
+ assertFalse("componentListener uninstalled", belongs(ui.componentListener, frame
+ .getComponentListeners()));
f.dispose();
}
@@ -300,23 +265,20 @@
*/
public void testSetupMenuOpenKey() {
frame.setUI(ui);
-
assertNull("inputMap not installed", SwingUtilities.getUIInputMap(frame,
- JComponent.WHEN_IN_FOCUSED_WINDOW));
-
+ JComponent.WHEN_IN_FOCUSED_WINDOW));
// "InternalFrame.windowBindings" is empty - inputMap is not installed
final String key = "InternalFrame.windowBindings";
if (UIManager.get(key) == null) {
ui.setupMenuOpenKey();
- assertNull("inputMap not installed", SwingUtilities.getUIInputMap(frame, JComponent.WHEN_IN_FOCUSED_WINDOW));
+ assertNull("inputMap not installed", SwingUtilities.getUIInputMap(frame,
+ JComponent.WHEN_IN_FOCUSED_WINDOW));
}
-
// "InternalFrame.windowBindings" is not empty - inputMap is installed
- UIManager.getDefaults().put(key, new Object[] { "shift ESCAPE", "showSystemMenu"});
-
+ UIManager.getDefaults().put(key, new Object[] { "shift ESCAPE", "showSystemMenu" });
ui.setupMenuOpenKey();
-
- final InputMap uiInputMap = SwingUtilities.getUIInputMap(frame, JComponent.WHEN_IN_FOCUSED_WINDOW);
+ final InputMap uiInputMap = SwingUtilities.getUIInputMap(frame,
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
assertNotNull("inputMap installed", uiInputMap);
assertEquals(1, uiInputMap.allKeys().length);
}
@@ -326,7 +288,6 @@
*/
public void testBasicInternalFrameUI() {
ui = new BasicInternalFrameUI(frame);
-
assertTrue("frame is not set", ui.frame != frame);
assertTrue("ui is not installed", frame.getUI() != ui);
}
@@ -336,10 +297,9 @@
*/
public void testCreateBorderListener() {
MouseInputAdapter listener1 = ui.createBorderListener(frame);
- assertTrue("not null", listener1!= null);
+ assertTrue("not null", listener1 != null);
assertTrue("instanceof BorderListener",
- listener1 instanceof BasicInternalFrameUI.BorderListener);
-
+ listener1 instanceof BasicInternalFrameUI.BorderListener);
MouseInputAdapter listener2 = ui.createBorderListener(frame);
assertTrue("new instance", listener1 != listener2);
}
@@ -349,7 +309,6 @@
*/
public void testCreateWestPane() {
frame.setUI(ui);
-
assertNull("null", ui.createWestPane(frame));
assertNull("null", ui.createWestPane(null));
}
@@ -359,7 +318,6 @@
*/
public void testCreateSouthPane() {
frame.setUI(ui);
-
assertNull("null", ui.createSouthPane(frame));
assertNull("null", ui.createSouthPane(null));
}
@@ -373,7 +331,6 @@
assertFalse("doesn't belong", belongs(comp, frame.getComponents()));
assertTrue("northPane", ui.getNorthPane() != comp);
assertTrue("== titlePane", comp == ui.titlePane);
-
JComponent comp2 = ui.createNorthPane(frame);
assertTrue("new object", comp != comp2);
assertTrue("northPane", ui.getNorthPane() != comp2);
@@ -384,7 +341,6 @@
*/
public void testCreateEastPane() {
frame.setUI(ui);
-
assertNull("null", ui.createEastPane(frame));
assertNull("null", ui.createEastPane(null));
}
@@ -395,30 +351,25 @@
public void testReplacePane() {
frame.setUI(ui);
JComponent comp = new JButton("OK");
-
// ordinary replace
ui.replacePane(ui.getNorthPane(), comp);
- assertFalse("old pane removed",
- belongs(ui.getNorthPane(), frame.getComponents()));
- assertFalse("mouse listener removed",
- belongs(ui.borderListener, ui.getNorthPane().getMouseListeners()));
- assertFalse("mouse motion listener removed",
- belongs(ui.borderListener, ui.getNorthPane().getMouseMotionListeners()));
- assertTrue("new pane added",
- belongs(comp, frame.getComponents()));
- assertTrue("mouse listener istalled",
- belongs(ui.borderListener, comp.getMouseListeners()));
- assertTrue("mouse motion listener istalled",
- belongs(ui.borderListener, comp.getMouseMotionListeners()));
-
+ assertFalse("old pane removed", belongs(ui.getNorthPane(), frame.getComponents()));
+ assertFalse("mouse listener removed", belongs(ui.borderListener, ui.getNorthPane()
+ .getMouseListeners()));
+ assertFalse("mouse motion listener removed", belongs(ui.borderListener, ui
+ .getNorthPane().getMouseMotionListeners()));
+ assertTrue("new pane added", belongs(comp, frame.getComponents()));
+ assertTrue("mouse listener istalled", belongs(ui.borderListener, comp
+ .getMouseListeners()));
+ assertTrue("mouse motion listener istalled", belongs(ui.borderListener, comp
+ .getMouseMotionListeners()));
// replace to null
ui.replacePane(comp, null);
- assertFalse("new pane removed",
- belongs(comp, frame.getComponents()));
- assertFalse("mouse listener removed",
- belongs(ui.borderListener, comp.getMouseListeners()));
- assertFalse("mouse motion listener removed",
- belongs(ui.borderListener, comp.getMouseMotionListeners()));
+ assertFalse("new pane removed", belongs(comp, frame.getComponents()));
+ assertFalse("mouse listener removed", belongs(ui.borderListener, comp
+ .getMouseListeners()));
+ assertFalse("mouse motion listener removed", belongs(ui.borderListener, comp
+ .getMouseMotionListeners()));
}
/*
@@ -427,23 +378,16 @@
public void testGetPreferredSize() {
frame.setPreferredSize(new Dimension(200, 200));
Dimension standardSize = new Dimension(100, 100);
-
// ui is not installed into the frame
- assertTrue("standard size",
- ui.getPreferredSize(frame).equals(standardSize));
-
+ assertTrue("standard size", ui.getPreferredSize(frame).equals(standardSize));
// ui.getPreferredSize(null) crashes with NullPointerException
-
ui.installUI(frame);
-
// ui is installed into the frame
- assertTrue("size ok",
- ui.getPreferredSize(frame).equals(
- ui.internalFrameLayout.preferredLayoutSize(frame)));
- assertTrue("standard size",
- ui.getPreferredSize(null).equals(standardSize));
- assertTrue("standard size",
- ui.getPreferredSize(new JInternalFrame()).equals(standardSize));
+ assertTrue("size ok", ui.getPreferredSize(frame).equals(
+ ui.internalFrameLayout.preferredLayoutSize(frame)));
+ assertTrue("standard size", ui.getPreferredSize(null).equals(standardSize));
+ assertTrue("standard size", ui.getPreferredSize(new JInternalFrame()).equals(
+ standardSize));
}
/*
@@ -452,24 +396,16 @@
public void testGetMinimumSize() {
frame.setMinimumSize(new Dimension(200, 200));
Dimension standardSize = new Dimension(0, 0);
-
-
// ui is not installed into the frame
- assertTrue("standard size",
- ui.getMinimumSize(frame).equals(standardSize));
-
+ assertTrue("standard size", ui.getMinimumSize(frame).equals(standardSize));
// ui.getMinimumSize(null) crashes with NullPointerException
-
ui.installUI(frame);
-
// ui is installed into the frame
- assertTrue("size ok",
- ui.getMinimumSize(frame).equals(
- ui.internalFrameLayout.minimumLayoutSize(frame)));
- assertTrue("standard size",
- ui.getMinimumSize(null).equals(standardSize));
- assertTrue("standard size",
- ui.getMinimumSize(new JInternalFrame()).equals(standardSize));
+ assertTrue("size ok", ui.getMinimumSize(frame).equals(
+ ui.internalFrameLayout.minimumLayoutSize(frame)));
+ assertTrue("standard size", ui.getMinimumSize(null).equals(standardSize));
+ assertTrue("standard size", ui.getMinimumSize(new JInternalFrame())
+ .equals(standardSize));
}
/*
@@ -477,12 +413,10 @@
*/
public void testGetMaximumSize() {
ui.installUI(frame);
-
// ui is installed into the frame
Dimension size = ui.getMaximumSize(frame);
assertTrue(size.width >= Short.MAX_VALUE);
assertTrue(size.height >= Short.MAX_VALUE);
-
size = ui.getMaximumSize(null);
assertTrue(size.width >= Short.MAX_VALUE);
assertTrue(size.height >= Short.MAX_VALUE);
@@ -505,7 +439,6 @@
frame.setUI(ui);
frame.setSize(size);
frame.setMaximizable(true);
-
JDesktopPane desktop = new JDesktopPane();
desktop.setSize(new Dimension(100, 200));
desktop.add(frame);
@@ -516,7 +449,6 @@
}
assertTrue("size changed", frame.getSize().equals(desktop.getSize()));
frame.setMaximizable(false);
-
ui.minimizeFrame(frame);
assertFalse("minimized", frame.getSize().equals(desktop.getSize()));
}
@@ -526,11 +458,9 @@
*/
public void testMaximizeFrame() {
frame.setUI(ui);
-
JDesktopPane desktop = new JDesktopPane();
desktop.setSize(new Dimension(100, 200));
desktop.add(frame);
-
ui.maximizeFrame(frame);
assertTrue("maximized", frame.getSize().equals(desktop.getSize()));
}
@@ -540,11 +470,9 @@
*/
public void testIconifyFrame() {
frame.setUI(ui);
-
JDesktopPane desktop = new JDesktopPane();
desktop.setSize(new Dimension(100, 200));
desktop.add(frame);
-
ui.iconifyFrame(frame);
assertTrue("iconified", desktop.isAncestorOf(frame.getDesktopIcon()));
}
@@ -554,11 +482,9 @@
*/
public void testDeiconifyFrame() {
frame.setUI(ui);
-
JDesktopPane desktop = new JDesktopPane();
desktop.setSize(new Dimension(100, 200));
desktop.add(frame);
-
frame.setIconifiable(true);
try {
frame.setIcon(true);
@@ -567,7 +493,6 @@
}
assertTrue("iconified", desktop.isAncestorOf(frame.getDesktopIcon()));
frame.setIconifiable(false);
-
ui.deiconifyFrame(frame);
assertTrue("deiconified", desktop.isAncestorOf(frame));
}
@@ -577,12 +502,10 @@
*/
public void testActivateFrame() {
frame.setUI(ui);
-
JDesktopPane desktop = new JDesktopPane();
desktop.setSize(new Dimension(100, 200));
desktop.add(frame);
assertTrue("not selected", desktop.getSelectedFrame() != frame);
-
ui.activateFrame(frame);
assertTrue("activated", desktop.getSelectedFrame() == frame);
}
@@ -592,13 +515,11 @@
*/
public void testDeactivateFrame() {
frame.setUI(ui);
-
JDesktopPane desktop = new JDesktopPane();
desktop.setSize(new Dimension(100, 200));
desktop.add(frame);
ui.activateFrame(frame);
assertTrue("activated", desktop.getSelectedFrame() == frame);
-
ui.deactivateFrame(frame);
assertTrue("deactivated", desktop.getSelectedFrame() != frame);
}
@@ -608,15 +529,12 @@
*/
public void testCloseFrame() {
frame.setUI(ui);
-
JDesktopPane desktop = new JDesktopPane();
desktop.setSize(new Dimension(100, 200));
desktop.add(frame);
-
ui.closeFrame(frame);
assertFalse("frame removed", desktop.isAncestorOf(frame));
- assertFalse("desktop icon removed", desktop.isAncestorOf(
- frame.getDesktopIcon()));
+ assertFalse("desktop icon removed", desktop.isAncestorOf(frame.getDesktopIcon()));
}
/*
@@ -627,16 +545,13 @@
public void testSetGetWestPane() {
frame.setUI(ui);
JButton comp = new JButton("ok");
-
// null by default
assertNull("null by default", ui.getWestPane());
-
// general setting
ui.setWestPane(comp);
assertTrue("was set", ui.getWestPane() == comp);
assertTrue("field was set", ui.westPane == comp);
assertFalse("not added", belongs(comp, frame.getComponents()));
-
// setting to null
ui.setWestPane(null);
assertNull("was set", ui.getWestPane());
@@ -650,16 +565,13 @@
public void testSetGetSouthPane() {
frame.setUI(ui);
JButton comp = new JButton("ok");
-
// null by default
assertNull("null by default", ui.getSouthPane());
-
// general setting
ui.setSouthPane(comp);
assertTrue("was set", ui.getSouthPane() == comp);
assertTrue("field was set", ui.southPane == comp);
assertFalse("not added", belongs(comp, frame.getComponents()));
-
// setting to null
ui.setSouthPane(null);
assertNull("was set", ui.getSouthPane());
@@ -673,16 +585,13 @@
public void testSetGetNorthPane() {
frame.setUI(ui);
JComponent comp = new JButton("ok");
-
// not null by default
assertTrue("not null by default", ui.getNorthPane() != null);
-
// general setting
ui.setNorthPane(comp);
assertTrue("was set", ui.getNorthPane() == comp);
assertTrue("field was set", ui.northPane == comp);
assertTrue("added", belongs(comp, frame.getComponents()));
-
// setting to null
ui.setNorthPane(null);
assertNull("was set", ui.getNorthPane());
@@ -696,16 +605,13 @@
public void testSetGetEastPane() {
frame.setUI(ui);
JButton comp = new JButton("ok");
-
// null by default
assertNull("null by default", ui.getEastPane());
-
// general setting
ui.setEastPane(comp);
assertTrue("was set", ui.getEastPane() == comp);
assertTrue("field was set", ui.eastPane == comp);
assertFalse("not added", belongs(comp, frame.getComponents()));
-
// setting to null
ui.setEastPane(null);
assertNull("was set", ui.getEastPane());
@@ -717,7 +623,6 @@
public void testCreateUI() {
ComponentUI ui1 = BasicInternalFrameUI.createUI(frame);
ComponentUI ui2 = BasicInternalFrameUI.createUI(frame);
-
assertTrue("not null", ui1 != null);
assertTrue("statefull", ui1 != ui2);
}
@@ -728,14 +633,12 @@
public void testInstallUI() {
frame.setBorder(null);
ui.installUI(frame);
-
// we'll check only some key points
- assertTrue("installed titlePane",
- belongs(ui.titlePane, frame.getComponents()));
+ assertTrue("installed titlePane", belongs(ui.titlePane, frame.getComponents()));
assertTrue("installed border", frame.getBorder() != null);
assertTrue("borderListener != null", ui.borderListener != null);
- assertTrue("installed borderListener",
- belongs(ui.borderListener, frame.getMouseListeners()));
+ assertTrue("installed borderListener", belongs(ui.borderListener, frame
+ .getMouseListeners()));
}
/*
@@ -744,13 +647,11 @@
public void testUninstallUI() {
ui.installUI(frame);
ui.uninstallUI(frame);
-
// we'll check only some key points
- assertFalse("uninstalled titlePane",
- belongs(ui.titlePane, frame.getComponents()));
+ assertFalse("uninstalled titlePane", belongs(ui.titlePane, frame.getComponents()));
assertFalse("uninstalled border", frame.getBorder() != null);
- assertFalse("uninstalled borderListener",
- belongs(ui.borderListener, frame.getMouseListeners()));
+ assertFalse("uninstalled borderListener", belongs(ui.borderListener, frame
+ .getMouseListeners()));
}
/*
@@ -758,28 +659,24 @@
*/
public void testInstallMouseHandlers() {
ui.borderListener = ui.createBorderListener(frame);
-
// install to frame
ui.installMouseHandlers(frame);
-
- assertTrue("mouseListener in frame",
- belongs(ui.borderListener, frame.getMouseListeners()));
- assertTrue("mouseMotionListener in frame",
- belongs(ui.borderListener, frame.getMouseMotionListeners()));
-
+ assertTrue("mouseListener in frame", belongs(ui.borderListener, frame
+ .getMouseListeners()));
+ assertTrue("mouseMotionListener in frame", belongs(ui.borderListener, frame
+ .getMouseMotionListeners()));
// install to titlePane
ui.titlePane = new BasicInternalFrameTitlePane(frame);
ui.installMouseHandlers(ui.titlePane);
- assertTrue("mouseListener in titlePane",
- belongs(ui.borderListener, ui.titlePane.getMouseListeners()));
- assertTrue("mouseMotionListener in titlePane",
- belongs(ui.borderListener, ui.titlePane.getMouseMotionListeners()));
-
-// JInternalFrame frame = new JInternalFrame();
-// ui.frame = frame;
-// System.out.println(frame.getMouseListeners().length);
-// ui.installMouseHandlers(frame);
-// System.out.println(frame.getMouseListeners().length);
+ assertTrue("mouseListener in titlePane", belongs(ui.borderListener, ui.titlePane
+ .getMouseListeners()));
+ assertTrue("mouseMotionListener in titlePane", belongs(ui.borderListener, ui.titlePane
+ .getMouseMotionListeners()));
+ // JInternalFrame frame = new JInternalFrame();
+ // ui.frame = frame;
+ // System.out.println(frame.getMouseListeners().length);
+ // ui.installMouseHandlers(frame);
+ // System.out.println(frame.getMouseListeners().length);
}
/*
@@ -790,20 +687,18 @@
ui.installMouseHandlers(frame);
ui.titlePane = new BasicInternalFrameTitlePane(frame);
ui.installMouseHandlers(ui.titlePane);
-
// deinstall from frame
ui.deinstallMouseHandlers(frame);
- assertFalse("deinstalled mouseListener from frame",
- belongs(ui.borderListener, frame.getMouseListeners()));
- assertFalse("deinstalled mouseMotionListener from frame",
- belongs(ui.borderListener, frame.getMouseMotionListeners()));
-
+ assertFalse("deinstalled mouseListener from frame", belongs(ui.borderListener, frame
+ .getMouseListeners()));
+ assertFalse("deinstalled mouseMotionListener from frame", belongs(ui.borderListener,
+ frame.getMouseMotionListeners()));
// deinstall from titlePane
ui.deinstallMouseHandlers(ui.titlePane);
- assertFalse("deinstalled mouseListener from titlePane",
- belongs(ui.borderListener, ui.titlePane.getMouseListeners()));
- assertFalse("deinstalled mouseMotionListener from titlePane",
- belongs(ui.borderListener, ui.titlePane.getMouseMotionListeners()));
+ assertFalse("deinstalled mouseListener from titlePane", belongs(ui.borderListener,
+ ui.titlePane.getMouseListeners()));
+ assertFalse("deinstalled mouseMotionListener from titlePane", belongs(
+ ui.borderListener, ui.titlePane.getMouseMotionListeners()));
}
/*
@@ -811,23 +706,19 @@
*/
public void testGetDesktopManager() {
frame.setUI(ui);
-
// no desktop pane, the default desktop manager is created
DesktopManager manager1 = ui.getDesktopManager();
assertTrue("not null", manager1 != null);
-
DesktopManager manager2 = ui.getDesktopManager();
assertTrue("the same object", manager1 == manager2);
assertNull("no desktop pane", frame.getDesktopPane());
-
// the desktop pane is set
JDesktopPane desktop = new JDesktopPane();
desktop.add(frame);
-
manager2 = ui.getDesktopManager();
assertTrue("not null", manager2 != null);
- assertTrue("is taken from desktop pane",
- manager2 == frame.getDesktopPane().getDesktopManager());
+ assertTrue("is taken from desktop pane", manager2 == frame.getDesktopPane()
+ .getDesktopManager());
assertTrue("another object", manager2 != manager1);
}
@@ -837,7 +728,6 @@
public void testCreateDesktopManager() {
DesktopManager manager1 = ui.createDesktopManager();
assertTrue("not null", manager1 != null);
-
DesktopManager manager2 = ui.createDesktopManager();
assertTrue("other object", manager1 != manager2);
}
@@ -848,7 +738,6 @@
public void testCreatePropertyChangeListener() {
PropertyChangeListener listener1 = ui.createPropertyChangeListener();
assertTrue("not null", listener1 != null);
-
PropertyChangeListener listener2 = ui.createPropertyChangeListener();
assertTrue("the same object", listener1 == listener2);
//assertTrue("is saved", ui.propertyChangeListener == listener1);
@@ -868,11 +757,10 @@
*/
public void testCreateLayoutManager() {
LayoutManager layout = ui.createLayoutManager();
-
assertTrue("not null", layout != null);
if (isHarmony()) {
- assertTrue("instanceof InternalFrameLayout", layout instanceof
- BasicInternalFrameUI.InternalFrameLayout);
+ assertTrue("instanceof InternalFrameLayout",
+ layout instanceof BasicInternalFrameUI.InternalFrameLayout);
}
assertNotSame(layout, ui.internalFrameLayout);
}
@@ -884,12 +772,9 @@
*/
public void testSetIsKeyBindingRegistered() {
frame.setUI(ui);
-
assertFalse("false by default", ui.isKeyBindingRegistered());
-
ui.setKeyBindingRegistered(true);
assertTrue("set to true", ui.isKeyBindingRegistered());
-
ui.setKeyBindingRegistered(false);
assertFalse("set to false", ui.isKeyBindingRegistered());
}
@@ -901,12 +786,9 @@
*/
public void testSetIsKeyBindingActive() {
frame.setUI(ui);
-
assertFalse("false by default", ui.isKeyBindingActive());
-
ui.setKeyBindingActive(true);
assertTrue("set to true", ui.isKeyBindingActive());
-
ui.setKeyBindingActive(false);
assertFalse("set to false", ui.isKeyBindingActive());
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicLabelUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicLabelUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicLabelUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicLabelUITest.java Sun Nov 26 12:15:43 2006
@@ -22,7 +22,6 @@
import java.awt.Color;
import java.awt.Dimension;
-
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.SwingTestCase;
@@ -32,17 +31,20 @@
public class BasicLabelUITest extends SwingTestCase {
private JLabel label;
+
private BasicLabelUI ui;
public BasicLabelUITest(final String name) {
super(name);
}
+ @Override
protected void setUp() throws Exception {
label = new JLabel();
ui = new BasicLabelUI();
}
+ @Override
protected void tearDown() throws Exception {
ui = null;
label = null;
@@ -60,14 +62,13 @@
Dimension prefSize = ui.getPreferredSize(label);
assertTrue(prefSize.width > 0);
assertTrue(prefSize.height > 0);
-
final Dimension d = new Dimension(100, 100);
ui = new BasicLabelUI() {
+ @Override
public Dimension getPreferredSize(final JComponent c) {
return d;
}
};
-
assertSame(d, ui.getPreferredSize(label));
assertSame(d, ui.getMinimumSize(label));
assertSame(d, ui.getMaximumSize(label));
@@ -77,7 +78,6 @@
Color c = new ColorUIResource(Color.black);
label.setForeground(new ColorUIResource(c));
label.setBackground(new ColorUIResource(c));
-
ui.installUI(label);
assertEquals(UIManager.getColor("Label.foreground"), label.getForeground());
assertEquals(UIManager.getColor("Label.background"), label.getBackground());
@@ -90,7 +90,6 @@
assertEquals(0, label.getInputMap().size());
assertEquals(0, label.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).size());
assertEquals(0, label.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).size());
-
ui.installKeyboardActions(label);
assertEquals(0, label.getInputMap().size());
assertEquals(0, label.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).size());
@@ -100,7 +99,6 @@
public void testInstallUninstallComponents() throws Exception {
label.removeAll();
assertEquals(0, label.getComponentCount());
-
ui.installComponents(label);
assertEquals(0, label.getComponentCount());
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicListUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicListUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicListUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicListUITest.java Sun Nov 26 12:15:43 2006
@@ -27,7 +27,6 @@
import java.awt.Point;
import java.awt.Rectangle;
import java.util.Arrays;
-
import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JComponent;
@@ -42,23 +41,28 @@
public class BasicListUITest extends SwingTestCase {
private JList list;
+
private BasicListUI ui;
private Object defaultBackground;
+
private Object defaultForeground;
+
private Object defaultFont;
+
private Object defaultRenderer;
+
private Object defaultBorder;
public BasicListUITest(final String name) {
super(name);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
ui = new BasicListUI();
list = new JList();
-
defaultBackground = UIManager.get("List.background");
defaultForeground = UIManager.get("List.foreground");
defaultFont = UIManager.get("List.font");
@@ -66,10 +70,10 @@
defaultBorder = UIManager.get("List.border");
}
+ @Override
protected void tearDown() throws Exception {
ui = null;
list = null;
-
UIManager.put("List.background", defaultBackground);
UIManager.put("List.foreground", defaultForeground);
UIManager.put("List.font", defaultFont);
@@ -90,14 +94,12 @@
public void testBasicListUI_FocusListener() throws Exception {
assertNull(ui.focusListener);
int listenersCount = list.getFocusListeners().length;
-
ui.installUI(list);
if (isHarmony()) {
assertTrue(ui.focusListener instanceof BasicListUI.FocusHandler);
}
assertTrue(Arrays.asList(list.getFocusListeners()).contains(ui.focusListener));
assertEquals(listenersCount + 1, list.getFocusListeners().length);
-
ui.uninstallUI(list);
assertNull(ui.focusListener);
assertEquals(listenersCount, list.getFocusListeners().length);
@@ -106,17 +108,14 @@
public void testBasicListUI_ListDataHandler() throws Exception {
}
-
public void testConvertRowToY() throws Exception {
ui.installUI(list);
assertEquals(-1, ui.convertRowToY(0));
assertEquals(-1, ui.convertRowToY(-1));
-
- list.setListData(new Object[] {"a", "b"});
+ list.setListData(new Object[] { "a", "b" });
ui.installUI(list);
list.setFixedCellHeight(20);
ui.maybeUpdateLayoutState();
-
assertEquals(-1, ui.convertRowToY(-1));
assertEquals(0, ui.convertRowToY(0));
assertEquals(20, ui.convertRowToY(1));
@@ -125,8 +124,7 @@
public void testConvertYToRow() throws Exception {
ui.installUI(list);
assertEquals(-1, ui.convertYToRow(0));
-
- list.setListData(new Object[] {"a", "b"});
+ list.setListData(new Object[] { "a", "b" });
list.setFixedCellHeight(10);
ui.maybeUpdateLayoutState();
assertEquals(0, ui.convertYToRow(0));
@@ -166,33 +164,28 @@
}
public void testCreateUI() throws Exception {
- BasicListUI newUI1 = (BasicListUI)BasicListUI.createUI(list);
- BasicListUI newUI2 = (BasicListUI)BasicListUI.createUI(list);
+ BasicListUI newUI1 = (BasicListUI) BasicListUI.createUI(list);
+ BasicListUI newUI2 = (BasicListUI) BasicListUI.createUI(list);
assertNotSame(newUI1, newUI2);
}
public void testGetCellBounds() throws Exception {
ui.installUI(list);
-
assertNull(ui.getCellBounds(list, 0, 0));
assertNull(ui.getCellBounds(list, -1, -1));
-
- list.setListData(new Object[] {"a", "b"});
+ list.setListData(new Object[] { "a", "b" });
list.setFixedCellHeight(10);
list.setFixedCellWidth(20);
list.setSize(100, 100);
assertEquals(new Rectangle(0, 0, 100, 10), ui.getCellBounds(list, 0, 0));
assertEquals(new Rectangle(0, 10, 100, 10), ui.getCellBounds(list, 1, 1));
assertEquals(new Rectangle(0, 0, 100, 20), ui.getCellBounds(list, 0, 1));
-
list.setLayoutOrientation(JList.VERTICAL_WRAP);
assertEquals(new Rectangle(0, 0, 20, 10), ui.getCellBounds(list, 0, 0));
assertEquals(new Rectangle(0, 10, 20, 10), ui.getCellBounds(list, 1, 1));
assertEquals(new Rectangle(0, 0, 20, 20), ui.getCellBounds(list, 1, 0));
-
list.setBorder(BorderFactory.createEmptyBorder(10, 5, 20, 7));
assertEquals(new Rectangle(5, 10, 20, 10), ui.getCellBounds(list, 0, 0));
-
list.setLayoutOrientation(JList.VERTICAL);
assertEquals(new Rectangle(5, 10, 100 - 5 - 7, 20), ui.getCellBounds(list, 0, 1));
}
@@ -211,35 +204,31 @@
ui.installUI(list);
list.setSize(100, 100);
assertEquals(new Dimension(0, 0), ui.getPreferredSize(list));
-
- list.setListData(new Object[] {"a", "bbb"});
- Component renderer = new DefaultListCellRenderer().getListCellRendererComponent(list, "bbb", 1, false, false);
- assertEquals(new Dimension(renderer.getPreferredSize().width, 2 * renderer.getPreferredSize().height), ui.getPreferredSize(list));
-
+ list.setListData(new Object[] { "a", "bbb" });
+ Component renderer = new DefaultListCellRenderer().getListCellRendererComponent(list,
+ "bbb", 1, false, false);
+ assertEquals(new Dimension(renderer.getPreferredSize().width, 2 * renderer
+ .getPreferredSize().height), ui.getPreferredSize(list));
list.setFixedCellHeight(20);
list.setFixedCellWidth(30);
assertEquals(new Dimension(30, 40), ui.getPreferredSize(list));
-
list.setVisibleRowCount(1);
assertEquals(new Dimension(30, 40), ui.getPreferredSize(list));
-
list.setLayoutOrientation(JList.VERTICAL_WRAP);
assertEquals(new Dimension(60, 20), ui.getPreferredSize(list));
}
public void testGetRowHeight() throws Exception {
assertEquals(-1, ui.getRowHeight(-1));
-
ui.installUI(list);
assertEquals(-1, ui.getRowHeight(0));
-
- list.setListData(new Object[] {"a", "bbb"});
+ list.setListData(new Object[] { "a", "bbb" });
ui.maybeUpdateLayoutState();
- Component renderer = new DefaultListCellRenderer().getListCellRendererComponent(list, "bbb", 1, false, false);
+ Component renderer = new DefaultListCellRenderer().getListCellRendererComponent(list,
+ "bbb", 1, false, false);
assertEquals(renderer.getPreferredSize().height, ui.getRowHeight(0));
assertEquals(renderer.getPreferredSize().height, ui.getRowHeight(1));
assertEquals(-1, ui.getRowHeight(2));
-
list.setFixedCellHeight(30);
ui.maybeUpdateLayoutState();
assertEquals(30, ui.getRowHeight(0));
@@ -249,17 +238,17 @@
ui.installUI(list);
assertNull(ui.indexToLocation(list, -1));
assertNull(ui.indexToLocation(list, 0));
-
- list.setListData(new Object[] {"a", "bbb"});
- Component renderer = new DefaultListCellRenderer().getListCellRendererComponent(list, "bbb", 1, false, false);
+ list.setListData(new Object[] { "a", "bbb" });
+ Component renderer = new DefaultListCellRenderer().getListCellRendererComponent(list,
+ "bbb", 1, false, false);
assertEquals(new Point(0, 0), ui.indexToLocation(list, 0));
- assertEquals(new Point(0, renderer.getPreferredSize().height), ui.indexToLocation(list, 1));
-
+ assertEquals(new Point(0, renderer.getPreferredSize().height), ui.indexToLocation(list,
+ 1));
list.setVisibleRowCount(1);
list.setLayoutOrientation(JList.VERTICAL_WRAP);
assertEquals(new Point(0, 0), ui.indexToLocation(list, 0));
- assertEquals(new Point(renderer.getPreferredSize().width, 0), ui.indexToLocation(list, 1));
-
+ assertEquals(new Point(renderer.getPreferredSize().width, 0), ui.indexToLocation(list,
+ 1));
assertNull(ui.indexToLocation(list, 2));
}
@@ -272,7 +261,6 @@
UIManager.getDefaults().put("List.cellRenderer", renderer);
Border border = new BorderUIResource(BorderFactory.createEmptyBorder(0, 0, 0, 0));
UIManager.getDefaults().put("List.border", border);
-
list.setUI(ui);
ui.installDefaults();
assertEquals(Color.red, list.getBackground());
@@ -291,17 +279,14 @@
UIManager.getDefaults().put("List.cellRenderer", renderer);
Border border = new BorderUIResource(BorderFactory.createEmptyBorder(0, 0, 0, 0));
UIManager.getDefaults().put("List.border", border);
-
list.setUI(ui);
ui.installDefaults();
-
ui.uninstallDefaults();
assertNull(list.getBackground());
assertNull(list.getForeground());
assertNull(list.getFont());
assertNull(list.getCellRenderer());
assertNull(list.getBorder());
-
UIManager.getDefaults().put("List.background", Color.red);
list.setUI(ui);
ui.uninstallDefaults();
@@ -327,16 +312,12 @@
public void testInstallListeners() throws Exception {
list.setUI(ui);
-
assertNotNull(ui.focusListener);
assertTrue(list.getFocusListeners().length > 0);
-
assertNotNull(ui.listDataListener);
-
assertNotNull(ui.mouseInputListener);
assertTrue(list.getMouseListeners().length > 0);
assertTrue(list.getMouseMotionListeners().length > 0);
-
assertNotNull(ui.propertyChangeListener);
assertTrue(list.getPropertyChangeListeners().length > 0);
}
@@ -347,23 +328,17 @@
int mouseListenersCount = list.getMouseListeners().length;
int mouseMotionListenersCount = list.getMouseMotionListeners().length;
int propertyChangeListenersCount = list.getPropertyChangeListeners().length;
-
ui.uninstallListeners();
-
assertNull(ui.focusListener);
assertTrue(focusListenersCount > list.getFocusListeners().length);
-
assertNull(ui.listDataListener);
-
assertNull(ui.mouseInputListener);
assertTrue(mouseListenersCount > list.getMouseListeners().length);
assertTrue(mouseMotionListenersCount > list.getMouseMotionListeners().length);
-
assertNull(ui.propertyChangeListener);
assertTrue(propertyChangeListenersCount > list.getPropertyChangeListeners().length);
}
-
public void testInstallUI() throws Exception {
ui.installUI(list);
assertNotNull(list.getBackground());
@@ -386,13 +361,11 @@
public void testLocationToIndex() throws Exception {
ui.installUI(list);
assertEquals(-1, ui.locationToIndex(list, new Point(3, 3)));
-
- list.setListData(new Object[] {"aa", "bb"});
+ list.setListData(new Object[] { "aa", "bb" });
assertEquals(0, ui.locationToIndex(list, new Point(3, 3)));
assertEquals(1, ui.locationToIndex(list, new Point(3, 25)));
assertEquals(0, ui.locationToIndex(list, new Point(70, 3)));
assertEquals(1, ui.locationToIndex(list, new Point(70, 25)));
-
list.setVisibleRowCount(1);
list.setLayoutOrientation(JList.VERTICAL_WRAP);
assertEquals(0, ui.locationToIndex(list, new Point(3, 3)));
@@ -418,26 +391,22 @@
public void testUpdateLayoutState() throws Exception {
ui.installUI(list);
-
assertEquals(-1, ui.cellHeight);
assertEquals(-1, ui.cellWidth);
assertNull(ui.cellHeights);
-
list.setSize(100, 100);
ui.maybeUpdateLayoutState();
assertEquals(-1, ui.cellHeight);
assertEquals(-1, ui.cellWidth);
assertNotNull(ui.cellHeights);
assertEquals(0, ui.cellHeights.length);
-
- list.setListData(new Object[] {"aa"});
+ list.setListData(new Object[] { "aa" });
ui.maybeUpdateLayoutState();
assertEquals(-1, ui.cellHeight);
assertTrue(ui.cellWidth > 0);
assertNotNull(ui.cellHeights);
assertEquals(1, ui.cellHeights.length);
assertTrue(ui.cellHeights[0] > 0);
-
list.setLayoutOrientation(JList.VERTICAL_WRAP);
ui.maybeUpdateLayoutState();
assertTrue(ui.cellHeight > 0);
@@ -447,76 +416,62 @@
public void testSelectNextPreviousIndex() throws Exception {
ui.installUI(list);
- list.setListData(new Object[] {"1", "2", "3"});
+ list.setListData(new Object[] { "1", "2", "3" });
assertTrue(list.isSelectionEmpty());
-
list.setSelectedIndex(0);
ui.selectNextIndex();
assertFalse(list.isSelectedIndex(0));
assertTrue(list.isSelectedIndex(1));
assertFalse(list.isSelectedIndex(2));
-
ui.selectNextIndex();
assertFalse(list.isSelectedIndex(0));
assertFalse(list.isSelectedIndex(1));
assertTrue(list.isSelectedIndex(2));
-
ui.selectNextIndex();
assertFalse(list.isSelectedIndex(0));
assertFalse(list.isSelectedIndex(1));
assertTrue(list.isSelectedIndex(2));
-
ui.selectPreviousIndex();
assertFalse(list.isSelectedIndex(0));
assertTrue(list.isSelectedIndex(1));
assertFalse(list.isSelectedIndex(2));
-
ui.selectPreviousIndex();
assertTrue(list.isSelectedIndex(0));
assertFalse(list.isSelectedIndex(1));
assertFalse(list.isSelectedIndex(2));
-
ui.selectPreviousIndex();
assertTrue(list.isSelectedIndex(0));
assertFalse(list.isSelectedIndex(1));
assertFalse(list.isSelectedIndex(2));
-
list.clearSelection();
ui.selectNextIndex();
assertTrue(list.isSelectedIndex(0));
assertFalse(list.isSelectedIndex(1));
assertFalse(list.isSelectedIndex(2));
-
list.clearSelection();
ui.selectPreviousIndex();
assertTrue(list.isSelectionEmpty());
-
-
list.setSelectionInterval(0, 1);
ui.selectNextIndex();
assertFalse(list.isSelectedIndex(0));
assertTrue(list.isSelectedIndex(1));
assertFalse(list.isSelectedIndex(2));
-
list.setSelectionInterval(1, 0);
ui.selectNextIndex();
assertFalse(list.isSelectedIndex(0));
assertTrue(list.isSelectedIndex(1));
assertFalse(list.isSelectedIndex(2));
-
list.setSelectedIndex(1);
list.setSelectionInterval(0, 0);
ui.selectNextIndex();
assertFalse(list.isSelectedIndex(0));
assertTrue(list.isSelectedIndex(1));
assertFalse(list.isSelectedIndex(2));
-
list.setSelectionInterval(0, 1);
ui.selectPreviousIndex();
assertTrue(list.isSelectedIndex(0));
assertTrue(list.isSelectedIndex(1));
assertFalse(list.isSelectedIndex(2));
-
list.setSelectionInterval(2, 1);
ui.selectPreviousIndex();
assertTrue(list.isSelectedIndex(0));
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicLookAndFeelTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicLookAndFeelTest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicLookAndFeelTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicLookAndFeelTest.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.Action;
@@ -30,10 +28,12 @@
public class BasicLookAndFeelTest extends SwingTestCase {
private BasicLookAndFeel lf;
+ @Override
public void setUp() {
lf = basicLookAndFeelInstance();
}
+ @Override
public void tearDown() {
lf = null;
}
@@ -58,18 +58,27 @@
private LookAndFeel lookAndFeelInstance() {
return new LookAndFeel() {
+ @Override
public String getDescription() {
return null;
}
+
+ @Override
public String getID() {
return null;
}
+
+ @Override
public String getName() {
return null;
}
+
+ @Override
public boolean isNativeLookAndFeel() {
return false;
}
+
+ @Override
public boolean isSupportedLookAndFeel() {
return false;
}
@@ -78,18 +87,29 @@
private BasicLookAndFeel basicLookAndFeelInstance() {
return new BasicLookAndFeel() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public String getDescription() {
return "basic description";
}
+
+ @Override
public String getID() {
return "basic id";
}
+
+ @Override
public String getName() {
return "basic name";
}
+
+ @Override
public boolean isNativeLookAndFeel() {
return false;
}
+
+ @Override
public boolean isSupportedLookAndFeel() {
return false;
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuBarUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuBarUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuBarUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuBarUITest.java Sun Nov 26 12:15:43 2006
@@ -15,16 +15,15 @@
* limitations under the License.
*/
/**
-* @author Alexander T. Simbirtsev
-* @version $Revision$
-*/
+ * @author Alexander T. Simbirtsev
+ * @version $Revision$
+ */
package javax.swing.plaf.basic;
import java.awt.Color;
import java.awt.Font;
import java.awt.LayoutManager;
import java.awt.event.ContainerListener;
-
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JMenu;
@@ -39,14 +38,15 @@
import javax.swing.plaf.FontUIResource;
public class BasicMenuBarUITest extends SwingTestCase {
-
protected BasicMenuBarUI menuBarUI;
+ @Override
protected void setUp() throws Exception {
super.setUp();
menuBarUI = new BasicMenuBarUI();
}
+ @Override
protected void tearDown() throws Exception {
menuBarUI = null;
super.tearDown();
@@ -60,11 +60,9 @@
menu.setUI(menuBarUI);
LayoutManager oldManager = menu.getLayout();
menuBarUI.uninstallUI(menu);
-
menuBarUI.installUI(menu);
assertNotNull(menu.getLayout());
assertNotSame(oldManager, menu.getLayout());
-
menuBarUI.uninstallUI(menu);
oldManager = new OverlayLayout(menu);
menu.setLayout(oldManager);
@@ -77,7 +75,6 @@
menu.setUI(menuBarUI);
menuBarUI.installUI(menu);
assertSame(menu, menuBarUI.menuBar);
-
menuBarUI.uninstallUI(menu);
assertNull(menuBarUI.menuBar);
}
@@ -124,14 +121,12 @@
UIManager.getDefaults().put("MenuBar.font", font);
Border border = new BorderUIResource(BorderFactory.createEmptyBorder(0, 0, 0, 0));
UIManager.getDefaults().put("MenuBar.border", border);
-
menuBar.setUI(menuBarUI);
menuBarUI.installDefaults();
assertEquals(Color.red, menuBar.getBackground());
assertEquals(Color.yellow, menuBar.getForeground());
assertEquals(font, menuBar.getFont());
assertEquals(border, menuBar.getBorder());
-
menuBarUI.uninstallDefaults();
assertEquals(Color.red, menuBar.getBackground());
assertEquals(Color.yellow, menuBar.getForeground());
@@ -145,14 +140,13 @@
public void testInstallUninstallKeyboardActions() {
JMenuBar menuBar = new JMenuBar();
menuBar.setUI(menuBarUI);
-
menuBarUI.installKeyboardActions();
assertEquals(1, menuBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).allKeys().length);
assertEquals(1, menuBar.getActionMap().allKeys().length);
-
menuBarUI.uninstallKeyboardActions();
if (isHarmony()) {
- assertEquals(0, menuBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).allKeys().length);
+ assertEquals(0,
+ menuBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).allKeys().length);
assertEquals(0, menuBar.getActionMap().allKeys().length);
} else {
assertNull(menuBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).allKeys());
@@ -167,17 +161,15 @@
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu();
menuBar.add(menu);
- menuBarUI = (BasicMenuBarUI)menuBar.getUI();
+ menuBarUI = (BasicMenuBarUI) menuBar.getUI();
menuBarUI.uninstallListeners();
assertEquals(0, menuBar.getContainerListeners().length);
assertNull(menuBarUI.changeListener);
assertNull(menuBarUI.containerListener);
-
menuBarUI.menuBar = menuBar;
menuBarUI.installListeners();
assertEquals(1, menuBar.getContainerListeners().length);
assertNotNull(menuBarUI.changeListener);
assertNotNull(menuBarUI.containerListener);
}
-
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuItemUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuItemUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuItemUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuItemUITest.java Sun Nov 26 12:15:43 2006
@@ -15,21 +15,18 @@
* limitations under the License.
*/
/**
-* @author Alexander T. Simbirtsev
-* @version $Revision$
-*/
+ * @author Alexander T. Simbirtsev
+ * @version $Revision$
+ */
package javax.swing.plaf.basic;
import java.awt.Color;
-import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
-import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
-
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
@@ -51,13 +48,15 @@
import javax.swing.plaf.InsetsUIResource;
public class BasicMenuItemUITest extends SwingTestCase {
-
protected String prefix;
+
protected BasicMenuItemUI menuItemUI;
private Icon oldArrow;
+
private Icon oldCheck;
+ @Override
protected void setUp() throws Exception {
super.setUp();
menuItemUI = new BasicMenuItemUI();
@@ -67,6 +66,7 @@
MenuSelectionManager.defaultManager().clearSelectedPath();
}
+ @Override
protected void tearDown() throws Exception {
menuItemUI = null;
UIManager.put(prefix + "arrowIcon", oldArrow);
@@ -77,6 +77,7 @@
/*
* Test method for 'javax.swing.plaf.basic.BasicMenuItemUI.paint(Graphics, JComponent)'
*/
+ @SuppressWarnings("deprecation")
public void testPaint() {
JFrame frame = new JFrame();
JMenuItem item = new JMenuItem();
@@ -91,9 +92,10 @@
* Test method for 'javax.swing.plaf.basic.BasicMenuItemUI.getPreferredSize(JComponent)'
*/
public void testGetSizes() {
- Dimension minimum = new Dimension(0, 0);
- Dimension maximum = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
JMenuItem item = new JMenuItem() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public FontMetrics getFontMetrics(Font font) {
return BasicMenuItemUITest.this.getFontMetrics(font);
}
@@ -104,21 +106,21 @@
UIManager.put("OptionPane.margin", margin);
menuItemUI = new BasicMenuItemUI();
item.setUI(menuItemUI);
-
assertNull(menuItemUI.getMinimumSize(item));
assertNull(menuItemUI.getMaximumSize(item));
- assertEquals(menuItemUI.getPreferredMenuItemSize(item, menuItemUI.checkIcon, menuItemUI.arrowIcon, menuItemUI.defaultTextIconGap),
- menuItemUI.getPreferredSize(item));
-
+ assertEquals(menuItemUI.getPreferredMenuItemSize(item, menuItemUI.checkIcon,
+ menuItemUI.arrowIcon, menuItemUI.defaultTextIconGap), menuItemUI
+ .getPreferredSize(item));
item.setIcon(new ImageIcon(new BufferedImage(10, 20, BufferedImage.TYPE_INT_RGB)));
assertNull(menuItemUI.getMinimumSize(item));
assertNull(menuItemUI.getMaximumSize(item));
- assertEquals(menuItemUI.getPreferredMenuItemSize(item, menuItemUI.checkIcon, menuItemUI.arrowIcon, menuItemUI.defaultTextIconGap),
- menuItemUI.getPreferredSize(item));
-
+ assertEquals(menuItemUI.getPreferredMenuItemSize(item, menuItemUI.checkIcon,
+ menuItemUI.arrowIcon, menuItemUI.defaultTextIconGap), menuItemUI
+ .getPreferredSize(item));
item.setAccelerator(KeyStroke.getKeyStroke('a'));
- assertEquals(menuItemUI.getPreferredMenuItemSize(item, menuItemUI.checkIcon, menuItemUI.arrowIcon, menuItemUI.defaultTextIconGap),
- menuItemUI.getPreferredSize(item));
+ assertEquals(menuItemUI.getPreferredMenuItemSize(item, menuItemUI.checkIcon,
+ menuItemUI.arrowIcon, menuItemUI.defaultTextIconGap), menuItemUI
+ .getPreferredSize(item));
}
/*
@@ -126,13 +128,11 @@
*/
public void testInstallUninstallUI() {
JMenuItem item = new JMenuItem();
-
menuItemUI.installUI(item);
assertNotNull(item.getBorder());
assertNotNull(SwingUtilities.getUIActionMap(item));
assertNotNull(menuItemUI.mouseInputListener);
assertEquals(0, item.getComponentCount());
-
menuItemUI.uninstallUI(item);
assertNull(item.getBorder());
assertNull(SwingUtilities.getUIActionMap(item));
@@ -158,11 +158,16 @@
item.setUI(menuItemUI);
UIManager.getDefaults().put(prefix + "background", new ColorUIResource(Color.red));
UIManager.getDefaults().put(prefix + "foreground", new ColorUIResource(Color.yellow));
- UIManager.getDefaults().put(prefix + "acceleratorForeground", new ColorUIResource(Color.cyan));
- UIManager.getDefaults().put(prefix + "acceleratorSelectionForeground", new ColorUIResource(Color.magenta));
- UIManager.getDefaults().put(prefix + "selectionBackground", new ColorUIResource(Color.green));
- UIManager.getDefaults().put(prefix + "selectionForeground", new ColorUIResource(Color.pink));
- UIManager.getDefaults().put(prefix + "disabledForeground", new ColorUIResource(Color.orange));
+ UIManager.getDefaults().put(prefix + "acceleratorForeground",
+ new ColorUIResource(Color.cyan));
+ UIManager.getDefaults().put(prefix + "acceleratorSelectionForeground",
+ new ColorUIResource(Color.magenta));
+ UIManager.getDefaults().put(prefix + "selectionBackground",
+ new ColorUIResource(Color.green));
+ UIManager.getDefaults().put(prefix + "selectionForeground",
+ new ColorUIResource(Color.pink));
+ UIManager.getDefaults().put(prefix + "disabledForeground",
+ new ColorUIResource(Color.orange));
Font font = new FontUIResource(item.getFont().deriveFont(100f));
UIManager.getDefaults().put(prefix + "font", font);
Border border = new BorderUIResource(BorderFactory.createEmptyBorder(0, 0, 0, 0));
@@ -174,7 +179,6 @@
Icon check = new ImageIcon(new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB));
UIManager.getDefaults().put(prefix + "checkIcon", check);
UIManager.getDefaults().put(prefix + "borderPainted", Boolean.FALSE);
-
menuItemUI.defaultTextIconGap = 1000;
menuItemUI.oldBorderPainted = true;
menuItemUI.installDefaults();
@@ -194,7 +198,6 @@
assertEquals(Color.orange, menuItemUI.disabledForeground);
assertEquals(arrow, menuItemUI.arrowIcon);
assertEquals(check, menuItemUI.checkIcon);
-
menuItemUI.uninstallDefaults();
assertNull(item.getBackground());
assertNull(item.getForeground());
@@ -226,7 +229,7 @@
*/
public void testInstallUninstallListeners() {
JMenuItem item = new JMenuItem();
- menuItemUI = (BasicMenuItemUI)item.getUI();
+ menuItemUI = (BasicMenuItemUI) item.getUI();
menuItemUI.uninstallListeners();
assertEquals(0, item.getMenuDragMouseListeners().length);
assertEquals(0, item.getMenuKeyListeners().length);
@@ -236,7 +239,6 @@
assertNull(menuItemUI.mouseInputListener);
assertNull(menuItemUI.menuKeyListener);
assertNull(menuItemUI.menuDragMouseListener);
-
menuItemUI.menuItem = item;
menuItemUI.installListeners();
Object listener = menuItemUI.mouseInputListener;
@@ -261,16 +263,13 @@
public void testInstallUninstallKeyboardActions() {
JMenuItem item = new JMenuItem();
item.setUI(menuItemUI);
-
menuItemUI.uninstallKeyboardActions();
assertEquals("RegisteredKeyStrokes", 0, item.getRegisteredKeyStrokes().length);
-
menuItemUI.installKeyboardActions();
assertEquals(14, item.getActionMap().allKeys().length);
if (!isHarmony()) {
assertEquals(1, item.getActionMap().getParent().keys().length);
}
-
menuItemUI.uninstallKeyboardActions();
if (isHarmony()) {
assertEquals(0, item.getActionMap().allKeys().length);
@@ -312,17 +311,11 @@
Icon icon2 = new ImageIcon(new BufferedImage(10, 20, BufferedImage.TYPE_INT_RGB));
Icon icon3 = new ImageIcon(new BufferedImage(100, 20, BufferedImage.TYPE_INT_RGB));
Icon icon4 = new ImageIcon(new BufferedImage(1000, 20, BufferedImage.TYPE_INT_RGB));
- Icon icon5 = new Icon() {
- public void paintIcon(Component c, Graphics g, int x, int y) {
- }
- public int getIconWidth() {
- return 100000;
- }
- public int getIconHeight() {
- return 0;
- }
- };
JMenuItem item = new JMenuItem() {
+ private static final long serialVersionUID = 1L;
+
+ @SuppressWarnings("deprecation")
+ @Override
public FontMetrics getFontMetrics(Font font) {
return Toolkit.getDefaultToolkit().getFontMetrics(font);
}
@@ -331,24 +324,29 @@
UIManager.put("MenuItem.border", border);
Insets margin = new InsetsUIResource(1, 2, 3, 4);
UIManager.put("OptionPane.margin", margin);
-
menuItemUI = new BasicMenuItemUI();
item.setUI(menuItemUI);
-
- assertEquals(new Dimension(61, 41), menuItemUI.getPreferredMenuItemSize(item, icon1, icon1, 0));
- assertEquals(new Dimension(71, 41), menuItemUI.getPreferredMenuItemSize(item, icon1, icon2, 0));
- assertEquals(new Dimension(171, 41), menuItemUI.getPreferredMenuItemSize(item, icon2, icon3, 0));
- assertEquals(new Dimension(211, 41), menuItemUI.getPreferredMenuItemSize(item, icon2, icon3, 10));
- assertEquals(new Dimension(251, 41), menuItemUI.getPreferredMenuItemSize(item, icon2, icon3, 20));
-
+ assertEquals(new Dimension(61, 41), menuItemUI.getPreferredMenuItemSize(item, icon1,
+ icon1, 0));
+ assertEquals(new Dimension(71, 41), menuItemUI.getPreferredMenuItemSize(item, icon1,
+ icon2, 0));
+ assertEquals(new Dimension(171, 41), menuItemUI.getPreferredMenuItemSize(item, icon2,
+ icon3, 0));
+ assertEquals(new Dimension(211, 41), menuItemUI.getPreferredMenuItemSize(item, icon2,
+ icon3, 10));
+ assertEquals(new Dimension(251, 41), menuItemUI.getPreferredMenuItemSize(item, icon2,
+ icon3, 20));
item.setIcon(icon4);
- assertEquals(new Dimension(1061, 61), menuItemUI.getPreferredMenuItemSize(item, icon1, icon1, 0));
- assertEquals(new Dimension(1171, 61), menuItemUI.getPreferredMenuItemSize(item, icon2, icon3, 0));
+ assertEquals(new Dimension(1061, 61), menuItemUI.getPreferredMenuItemSize(item, icon1,
+ icon1, 0));
+ assertEquals(new Dimension(1171, 61), menuItemUI.getPreferredMenuItemSize(item, icon2,
+ icon3, 0));
}
/*
* Test method for 'javax.swing.plaf.basic.BasicMenuItemUI.getPath()'
*/
+ @SuppressWarnings("deprecation")
public void testGetPath() {
JFrame frame = new JFrame();
JMenuBar menuBar = new JMenuBar();
@@ -364,27 +362,24 @@
frame.pack();
frame.show();
assertEquals(0, menuItemUI.getPath().length);
-
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
- manager.setSelectedPath(new MenuElement[] {menuBar, menu, menu.getPopupMenu(), item});
+ manager.setSelectedPath(new MenuElement[] { menuBar, menu, menu.getPopupMenu(), item });
assertEquals(4, menuItemUI.getPath().length);
assertSame(menuBar, menuItemUI.getPath()[0]);
assertSame(menu, menuItemUI.getPath()[1]);
assertSame(menu.getPopupMenu(), menuItemUI.getPath()[2]);
assertSame(item, menuItemUI.getPath()[3]);
-
- manager.setSelectedPath(new MenuElement[] {menuBar, item2, menu2, menu.getPopupMenu()});
+ manager
+ .setSelectedPath(new MenuElement[] { menuBar, item2, menu2, menu.getPopupMenu() });
assertEquals(5, menuItemUI.getPath().length);
assertSame(menuBar, menuItemUI.getPath()[0]);
assertSame(item2, menuItemUI.getPath()[1]);
assertSame(menu2, menuItemUI.getPath()[2]);
assertSame(menu.getPopupMenu(), menuItemUI.getPath()[3]);
assertSame(item, menuItemUI.getPath()[4]);
-
- manager.setSelectedPath(new MenuElement[] {menuBar});
+ manager.setSelectedPath(new MenuElement[] { menuBar });
assertEquals(1, menuItemUI.getPath().length);
assertSame(item, menuItemUI.getPath()[0]);
-
manager.clearSelectedPath();
assertEquals(0, menuItemUI.getPath().length);
frame.dispose();
@@ -395,18 +390,21 @@
*/
public void testDoClick() {
class MyJMenuItem extends JMenuItem {
+ private static final long serialVersionUID = 1L;
+
public int time = -111;
+
+ @Override
public void doClick(final int pressTime) {
time = pressTime;
}
}
MenuSelectionManager manager = new MenuSelectionManager();
- manager.setSelectedPath(new MenuElement[] {new JMenu(), new JMenu()});
+ manager.setSelectedPath(new MenuElement[] { new JMenu(), new JMenu() });
MyJMenuItem item = new MyJMenuItem();
item.setUI(menuItemUI);
menuItemUI.doClick(manager);
assertEquals(0, manager.getSelectedPath().length);
assertEquals(0, item.time);
}
-
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuUITest.java?view=diff&rev=479418&r1=479417&r2=479418
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuUITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicMenuUITest.java Sun Nov 26 12:15:43 2006
@@ -15,9 +15,9 @@
* limitations under the License.
*/
/**
-* @author Alexander T. Simbirtsev
-* @version $Revision$
-*/
+ * @author Alexander T. Simbirtsev
+ * @version $Revision$
+ */
package javax.swing.plaf.basic;
import java.awt.Color;
@@ -25,7 +25,6 @@
import java.awt.Font;
import java.awt.Insets;
import java.awt.image.BufferedImage;
-
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
@@ -42,12 +41,13 @@
import javax.swing.plaf.InsetsUIResource;
public class BasicMenuUITest extends SwingTestCase {
-
protected BasicMenuUI menuUI;
private Icon oldArrow;
+
private Icon oldCheck;
+ @Override
protected void setUp() throws Exception {
super.setUp();
menuUI = new BasicMenuUI();
@@ -55,6 +55,7 @@
oldCheck = UIManager.getIcon("Menu.checkIcon");
}
+ @Override
protected void tearDown() throws Exception {
menuUI = null;
UIManager.put("Menu.arrowIcon", oldArrow);
@@ -69,13 +70,10 @@
JMenuBar bar = new JMenuBar();
JMenu menu1 = new JMenu();
menu1.setUI(menuUI);
-
assertNull(menuUI.getMaximumSize(menu1));
-
bar.add(menu1);
assertEquals(menuUI.getPreferredSize(menu1).width, menuUI.getMaximumSize(menu1).width);
assertEquals(Short.MAX_VALUE, menuUI.getMaximumSize(menu1).height);
-
menu1.setPreferredSize(new Dimension(1000, 1000));
assertEquals(1000, menuUI.getMaximumSize(menu1).width);
assertEquals(Short.MAX_VALUE, menuUI.getMaximumSize(menu1).height);
@@ -105,11 +103,16 @@
JMenu menu = new JMenu();
UIManager.getDefaults().put("Menu.background", new ColorUIResource(Color.red));
UIManager.getDefaults().put("Menu.foreground", new ColorUIResource(Color.yellow));
- UIManager.getDefaults().put("Menu.acceleratorForeground", new ColorUIResource(Color.cyan));
- UIManager.getDefaults().put("Menu.acceleratorSelectionForeground", new ColorUIResource(Color.magenta));
- UIManager.getDefaults().put("Menu.selectionBackground", new ColorUIResource(Color.green));
- UIManager.getDefaults().put("Menu.selectionForeground", new ColorUIResource(Color.pink));
- UIManager.getDefaults().put("Menu.disabledForeground", new ColorUIResource(Color.orange));
+ UIManager.getDefaults().put("Menu.acceleratorForeground",
+ new ColorUIResource(Color.cyan));
+ UIManager.getDefaults().put("Menu.acceleratorSelectionForeground",
+ new ColorUIResource(Color.magenta));
+ UIManager.getDefaults().put("Menu.selectionBackground",
+ new ColorUIResource(Color.green));
+ UIManager.getDefaults()
+ .put("Menu.selectionForeground", new ColorUIResource(Color.pink));
+ UIManager.getDefaults().put("Menu.disabledForeground",
+ new ColorUIResource(Color.orange));
Font font = new FontUIResource(menu.getFont().deriveFont(100f));
UIManager.getDefaults().put("Menu.font", font);
Border border = new BorderUIResource(BorderFactory.createEmptyBorder(0, 0, 0, 0));
@@ -120,7 +123,6 @@
UIManager.getDefaults().put("Menu.arrowIcon", arrow);
Icon check = new ImageIcon(new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB));
UIManager.getDefaults().put("Menu.checkIcon", check);
-
menu.setUI(menuUI);
menuUI.installDefaults();
assertEquals(Color.red, menu.getBackground());
@@ -140,7 +142,6 @@
if (isHarmony()) {
assertFalse(menu.isOpaque());
}
-
menuUI.uninstallDefaults();
assertNull(menu.getBackground());
assertNull(menu.getForeground());
@@ -163,7 +164,7 @@
*/
public void testInstallUninstallListeners() {
JMenu menu = new JMenu();
- menuUI = (BasicMenuUI)menu.getUI();
+ menuUI = (BasicMenuUI) menu.getUI();
menuUI.uninstallListeners();
assertEquals(0, menu.getMenuDragMouseListeners().length);
assertEquals(0, menu.getMenuKeyListeners().length);
@@ -174,7 +175,6 @@
assertNull(menuUI.mouseInputListener);
assertNull(menuUI.menuKeyListener);
assertNull(menuUI.menuDragMouseListener);
-
menuUI.menuItem = menu;
menuUI.installListeners();
assertNull(menuUI.changeListener);
@@ -194,7 +194,6 @@
assertSame(menuUI.propertyChangeListener, menu.getPropertyChangeListeners()[0]);
assertSame(menuUI.mouseInputListener, menu.getMouseMotionListeners()[0]);
assertSame(menuUI.mouseInputListener, menu.getMouseListeners()[0]);
-
menuUI.uninstallListeners();
assertNull(menuUI.propertyChangeListener);
assertNull(menuUI.mouseInputListener);
@@ -213,10 +212,8 @@
public void testInstallUninstallKeyboardActions() {
JMenu menu = new JMenu();
menu.setUI(menuUI);
-
menuUI.uninstallKeyboardActions();
assertEquals("RegisteredKeyStrokes", 0, menu.getRegisteredKeyStrokes().length);
-
menuUI.installKeyboardActions();
if (isHarmony()) {
assertEquals(14, menu.getActionMap().allKeys().length);
@@ -246,8 +243,8 @@
public void testCreateMenuDragMouseListener() {
assertNotNull(menuUI.createMenuDragMouseListener(null));
if (isHarmony()) {
- assertSame(menuUI.createMenuDragMouseListener(null),
- menuUI.createMenuDragMouseListener(null));
+ assertSame(menuUI.createMenuDragMouseListener(null), menuUI
+ .createMenuDragMouseListener(null));
}
}
@@ -257,8 +254,7 @@
public void testCreateMenuKeyListener() {
if (isHarmony()) {
assertNull(menuUI.createMenuKeyListener(null));
- assertSame(menuUI.createMenuKeyListener(null),
- menuUI.createMenuKeyListener(null));
+ assertSame(menuUI.createMenuKeyListener(null), menuUI.createMenuKeyListener(null));
} else {
assertNotNull(menuUI.createMenuKeyListener(null));
}
@@ -271,7 +267,6 @@
assertNull(menuUI.changeListener);
assertNull(menuUI.menuListener);
assertNull(menuUI.propertyChangeListener);
-
}
/*
@@ -302,13 +297,11 @@
public void testInstallUninstallUI() {
JMenu item = new JMenu();
-
menuUI.installUI(item);
assertNotNull(item.getBorder());
assertNotNull(SwingUtilities.getUIActionMap(item));
assertNotNull(menuUI.mouseInputListener);
assertEquals(0, item.getComponentCount());
-
menuUI.uninstallUI(item);
assertNull(item.getBorder());
assertNull(SwingUtilities.getUIActionMap(item));