Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 86759 invoked from network); 26 Nov 2006 00:05:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Nov 2006 00:05:47 -0000 Received: (qmail 24989 invoked by uid 500); 26 Nov 2006 00:05:56 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 24881 invoked by uid 500); 26 Nov 2006 00:05:56 -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 24872 invoked by uid 99); 26 Nov 2006 00:05:56 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Nov 2006 16:05:56 -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; Sat, 25 Nov 2006 16:05:44 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 0F42C1A986C; Sat, 25 Nov 2006 16:04:26 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r479240 [12/28] - /harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ Date: Sun, 26 Nov 2006 00:04:16 -0000 To: commits@harmony.apache.org From: ndbeyer@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061126000426.0F42C1A986C@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/JFormattedTextFieldTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFormattedTextFieldTest.java?view=diff&rev=479240&r1=479239&r2=479240 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFormattedTextFieldTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFormattedTextFieldTest.java Sat Nov 25 16:04:10 2006 @@ -30,7 +30,6 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; - import javax.swing.text.DateFormatter; import javax.swing.text.DefaultEditorKit; import javax.swing.text.DefaultFormatter; @@ -41,18 +40,26 @@ public class JFormattedTextFieldTest extends SwingTestCase { JFrame jf; + DbgFormattedField tf; + boolean bWasException; + String message; + PropertyChangeListenerImpl listener = new PropertyChangeListenerImpl(); + private FocusEvent FOCUS_LOST; - private FocusEvent FOCUS_GAINED; + private FocusEvent FOCUS_GAINED; class PropertyChangeListenerImpl implements PropertyChangeListener { String name; + Object oldValue; + Object newValue; + String interestingPropertyName; public void propertyChange(final PropertyChangeEvent e) { @@ -70,7 +77,11 @@ } class DbgFormattedField extends JFormattedTextField { + private static final long serialVersionUID = 1L; + private boolean wasCallCommitEdit; + + @Override public void commitEdit() throws ParseException { wasCallCommitEdit = true; super.commitEdit(); @@ -84,14 +95,19 @@ }; class DbgFormatter extends DefaultFormatter { + private static final long serialVersionUID = 1L; + boolean wasCallInstall; + boolean wasCallUninstall; + @Override public void install(final JFormattedTextField ftf) { wasCallInstall = true; super.install(ftf); } + @Override public void uninstall() { wasCallUninstall = true; super.uninstall(); @@ -108,16 +124,18 @@ wasCallUninstall = false; return result; } - } class FTF extends JFormattedTextField { + private static final long serialVersionUID = 1L; + boolean hasFocus; public FTF(final boolean hasFocus) { setHasFocus(hasFocus); } + @Override public boolean hasFocus() { return hasFocus; } @@ -126,16 +144,17 @@ this.hasFocus = hasFocus; } } + + @Override protected void setUp() throws Exception { super.setUp(); - jf = new JFrame(); + jf = new JFrame(); tf = new DbgFormattedField(); tf.addPropertyChangeListener(listener); initFocusEvent(); jf.getContentPane().add(tf); jf.setSize(200, 300); jf.pack(); - bWasException = false; message = null; } @@ -147,14 +166,13 @@ } } + @Override protected void tearDown() throws Exception { super.tearDown(); jf.dispose(); } - private void checkEvent(final String name, - final Object oldValue, - final Object newValue) { + private void checkEvent(final String name, final Object oldValue, final Object newValue) { assertEquals(name, listener.name); assertEquals(oldValue, listener.oldValue); assertEquals(newValue, listener.newValue); @@ -164,13 +182,10 @@ Object value = Color.RED; JFormattedTextField tf1 = new JFormattedTextField(value); assertEquals(value, tf1.getValue()); - assertEquals(JFormattedTextField.COMMIT_OR_REVERT, - tf1.getFocusLostBehavior()); + assertEquals(JFormattedTextField.COMMIT_OR_REVERT, tf1.getFocusLostBehavior()); assertTrue(tf1.getFormatter() instanceof DefaultFormatter); - assertTrue(tf1.getFormatterFactory() - instanceof DefaultFormatterFactory); - DefaultFormatterFactory factory = (DefaultFormatterFactory)tf1 - .getFormatterFactory(); + assertTrue(tf1.getFormatterFactory() instanceof DefaultFormatterFactory); + DefaultFormatterFactory factory = (DefaultFormatterFactory) tf1.getFormatterFactory(); assertTrue(factory.getDefaultFormatter() instanceof DefaultFormatter); assertNull(factory.getEditFormatter()); assertNull(factory.getDisplayFormatter()); @@ -181,13 +196,10 @@ InternationalFormatter formatter = new InternationalFormatter(); JFormattedTextField tf1 = new JFormattedTextField(formatter); assertNull(tf1.getValue()); - assertEquals(JFormattedTextField.COMMIT_OR_REVERT, - tf1.getFocusLostBehavior()); + assertEquals(JFormattedTextField.COMMIT_OR_REVERT, tf1.getFocusLostBehavior()); assertEquals(formatter, tf1.getFormatter()); - assertTrue(tf1.getFormatterFactory() - instanceof DefaultFormatterFactory); - DefaultFormatterFactory factory = (DefaultFormatterFactory)tf1 - .getFormatterFactory(); + assertTrue(tf1.getFormatterFactory() instanceof DefaultFormatterFactory); + DefaultFormatterFactory factory = (DefaultFormatterFactory) tf1.getFormatterFactory(); assertNull(factory.getDisplayFormatter()); assertNull(factory.getEditFormatter()); assertEquals(formatter, factory.getDefaultFormatter()); @@ -200,52 +212,44 @@ DefaultFormatterFactory factory; JFormattedTextField tf1 = new JFormattedTextField(format); assertNull(tf1.getValue()); - assertEquals(JFormattedTextField.COMMIT_OR_REVERT, - tf1.getFocusLostBehavior()); + assertEquals(JFormattedTextField.COMMIT_OR_REVERT, tf1.getFocusLostBehavior()); assertTrue(tf1.getFormatter() instanceof DateFormatter); - formatter = (InternationalFormatter)tf1.getFormatter(); + formatter = (InternationalFormatter) tf1.getFormatter(); assertEquals(format, formatter.getFormat()); - assertTrue(tf1.getFormatterFactory() - instanceof DefaultFormatterFactory); - factory = (DefaultFormatterFactory)tf1.getFormatterFactory(); + assertTrue(tf1.getFormatterFactory() instanceof DefaultFormatterFactory); + factory = (DefaultFormatterFactory) tf1.getFormatterFactory(); assertEquals(formatter, factory.getDefaultFormatter()); - format = new MessageFormat(""); tf1 = new JFormattedTextField(format); assertTrue(tf1.getFormatter() instanceof InternationalFormatter); - formatter = (InternationalFormatter)tf1.getFormatter(); + formatter = (InternationalFormatter) tf1.getFormatter(); assertEquals(format, formatter.getFormat()); - factory = (DefaultFormatterFactory)tf1.getFormatterFactory(); + factory = (DefaultFormatterFactory) tf1.getFormatterFactory(); assertEquals(formatter, factory.getDefaultFormatter()); - format = new DecimalFormat(); tf1 = new JFormattedTextField(format); assertTrue(tf1.getFormatter() instanceof NumberFormatter); - formatter = (InternationalFormatter)tf1.getFormatter(); + formatter = (InternationalFormatter) tf1.getFormatter(); assertEquals(format, formatter.getFormat()); - factory = (DefaultFormatterFactory)tf1.getFormatterFactory(); + factory = (DefaultFormatterFactory) tf1.getFormatterFactory(); assertEquals(formatter, factory.getDefaultFormatter()); } public void testJFormattedTextFieldAbstractFormatterFactory() { - JFormattedTextField.AbstractFormatterFactory factory = new - DefaultFormatterFactory(); + JFormattedTextField.AbstractFormatterFactory factory = new DefaultFormatterFactory(); JFormattedTextField tf1 = new JFormattedTextField(factory); assertNull(tf1.getValue()); - assertEquals(JFormattedTextField.COMMIT_OR_REVERT, - tf1.getFocusLostBehavior()); + assertEquals(JFormattedTextField.COMMIT_OR_REVERT, tf1.getFocusLostBehavior()); assertNull(tf1.getFormatter()); assertEquals(factory, tf1.getFormatterFactory()); } public void testJFormattedTextFieldAbstractFormatterFactoryObject() { Object value = Color.RED; - JFormattedTextField.AbstractFormatterFactory factory = new - DefaultFormatterFactory(); + JFormattedTextField.AbstractFormatterFactory factory = new DefaultFormatterFactory(); JFormattedTextField tf1 = new JFormattedTextField(factory, value); assertEquals(value, tf1.getValue()); - assertEquals(JFormattedTextField.COMMIT_OR_REVERT, - tf1.getFocusLostBehavior()); + assertEquals(JFormattedTextField.COMMIT_OR_REVERT, tf1.getFocusLostBehavior()); assertNull(tf1.getFormatter()); assertEquals(factory, tf1.getFormatterFactory()); } @@ -258,7 +262,6 @@ tf.setValue(value); assertEquals(value, tf.getValue()); checkEvent(propertyName, null, value); - value = "just value"; tf.setValue(value); assertEquals(value, tf.getText()); @@ -275,7 +278,6 @@ assertTrue(formatter.wasCallInstall()); assertEquals(formatter, tf.getFormatter()); checkEvent(propertyName, null, formatter); - DbgFormatter formatter1 = new DbgFormatter(); tf.setFormatter(formatter1); assertTrue(formatter1.wasCallInstall()); @@ -285,46 +287,33 @@ } public void testSetGetFocusLostBehavior() { - assertEquals(JFormattedTextField.COMMIT_OR_REVERT, - tf.getFocusLostBehavior()); - + assertEquals(JFormattedTextField.COMMIT_OR_REVERT, tf.getFocusLostBehavior()); tf.setFocusLostBehavior(JFormattedTextField.COMMIT); - assertEquals(JFormattedTextField.COMMIT, - tf.getFocusLostBehavior()); - + assertEquals(JFormattedTextField.COMMIT, tf.getFocusLostBehavior()); tf.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT); - assertEquals(JFormattedTextField.COMMIT_OR_REVERT, - tf.getFocusLostBehavior()); - + assertEquals(JFormattedTextField.COMMIT_OR_REVERT, tf.getFocusLostBehavior()); tf.setFocusLostBehavior(JFormattedTextField.REVERT); - assertEquals(JFormattedTextField.REVERT, - tf.getFocusLostBehavior()); - + assertEquals(JFormattedTextField.REVERT, tf.getFocusLostBehavior()); tf.setFocusLostBehavior(JFormattedTextField.PERSIST); - assertEquals(JFormattedTextField.PERSIST, - tf.getFocusLostBehavior()); + assertEquals(JFormattedTextField.PERSIST, tf.getFocusLostBehavior()); try { tf.setFocusLostBehavior(-2); } catch (IllegalArgumentException e) { bWasException = true; message = e.getMessage(); } - checkException("setFocusLostBehavior must be one of: " - + "JFormattedTextField.COMMIT, " - + "JFormattedTextField.COMMIT_OR_REVERT, " - + "JFormattedTextField.PERSIST " - + "or JFormattedTextField.REVERT"); + checkException("setFocusLostBehavior must be one of: " + "JFormattedTextField.COMMIT, " + + "JFormattedTextField.COMMIT_OR_REVERT, " + "JFormattedTextField.PERSIST " + + "or JFormattedTextField.REVERT"); try { tf.setFocusLostBehavior(4); } catch (IllegalArgumentException e) { bWasException = true; message = e.getMessage(); } - checkException("setFocusLostBehavior must be one of: " - + "JFormattedTextField.COMMIT, " - + "JFormattedTextField.COMMIT_OR_REVERT, " - + "JFormattedTextField.PERSIST " - + "or JFormattedTextField.REVERT"); + checkException("setFocusLostBehavior must be one of: " + "JFormattedTextField.COMMIT, " + + "JFormattedTextField.COMMIT_OR_REVERT, " + "JFormattedTextField.PERSIST " + + "or JFormattedTextField.REVERT"); } public void testSetGetFormatterFactory() { @@ -347,47 +336,39 @@ assertTrue(tf.wasCallCommitEdit()); assertEquals("667", tf.getText()); assertEquals(new Long(667), tf.getValue()); - tf.setText("34ft"); tf.processFocusEvent(FOCUS_LOST); assertEquals("34", tf.getText()); assertTrue(tf.wasCallCommitEdit()); assertEquals(new Long(34), tf.getValue()); - tf.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT); tf.setText("667"); tf.processFocusEvent(FOCUS_LOST); assertTrue(tf.wasCallCommitEdit()); assertEquals("667", tf.getText()); assertEquals(new Long(667), tf.getValue()); - tf.setText("56&"); tf.processFocusEvent(FOCUS_LOST); assertTrue(tf.wasCallCommitEdit()); assertEquals("56", tf.getText()); assertEquals(value, tf.getValue()); - tf.setFocusLostBehavior(JFormattedTextField.REVERT); tf.setText("667"); tf.processFocusEvent(FOCUS_LOST); assertFalse(tf.wasCallCommitEdit()); assertEquals("56", tf.getText()); assertEquals(value, tf.getValue()); - tf.setText("323rtft"); tf.processFocusEvent(FOCUS_LOST); assertFalse(tf.wasCallCommitEdit()); assertEquals("56", tf.getText()); assertEquals(value, tf.getValue()); - - tf.setFocusLostBehavior(JFormattedTextField.PERSIST); tf.setText("667"); tf.processFocusEvent(FOCUS_LOST); assertFalse(tf.wasCallCommitEdit()); assertEquals("667", tf.getText()); assertEquals(value, tf.getValue()); - tf.setText("67ft"); tf.processFocusEvent(FOCUS_LOST); assertFalse(tf.wasCallCommitEdit()); @@ -424,7 +405,6 @@ assertTrue(fromDefaultAction); } } - assertTrue(cancellAction instanceof TextAction); assertTrue(commitAction instanceof TextAction); //TODO check commit & cancel actions @@ -435,7 +415,7 @@ assertNull(tf.getValue()); tf.setText("678"); try { - tf.commitEdit(); + tf.commitEdit(); } catch (ParseException e) { assertTrue("Unexpected exception: ", false); } @@ -475,15 +455,14 @@ message = null; } - private DefaultFormatterFactory getFactoryIfDefault(final - JFormattedTextField.AbstractFormatterFactory - factory) { + private DefaultFormatterFactory getFactoryIfDefault( + final JFormattedTextField.AbstractFormatterFactory factory) { assertTrue(factory instanceof DefaultFormatterFactory); return (DefaultFormatterFactory) factory; } private void checkDefaultFormatter(final DefaultFormatterFactory factory) { - assertTrue(factory.getDefaultFormatter() instanceof DefaultFormatter); + assertTrue(factory.getDefaultFormatter() instanceof DefaultFormatter); assertNull(factory.getDisplayFormatter()); assertNull(factory.getEditFormatter()); assertNull(factory.getNullFormatter()); @@ -497,21 +476,17 @@ //TODO: check if factory.getDefaultFormatter() should be same to factory.getDisplayFormatter() // or factory.getEditFormatter(). assertNull(factory.getNullFormatter()); - tf.setFormatterFactory(null); tf.setValue(new Date()); - factory = getFactoryIfDefault(tf.getFormatterFactory()); - assertTrue(factory.getDefaultFormatter() instanceof DateFormatter); + assertTrue(factory.getDefaultFormatter() instanceof DateFormatter); assertNull(factory.getDisplayFormatter()); assertNull(factory.getEditFormatter()); assertNull(factory.getNullFormatter()); - tf.setFormatterFactory(null); tf.setValue("sdffsdf"); factory = getFactoryIfDefault(tf.getFormatterFactory()); checkDefaultFormatter(factory); - tf.setFormatterFactory(null); tf.setValue(Color.RED); factory = getFactoryIfDefault(tf.getFormatterFactory()); Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFormattedTextField_AbstractFormatterTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFormattedTextField_AbstractFormatterTest.java?view=diff&rev=479240&r1=479239&r2=479240 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFormattedTextField_AbstractFormatterTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFormattedTextField_AbstractFormatterTest.java Sat Nov 25 16:04:10 2006 @@ -24,37 +24,38 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.text.ParseException; - import javax.swing.plaf.UIResource; import javax.swing.text.AbstractDocument; import javax.swing.text.DocumentFilter; import javax.swing.text.NavigationFilter; import javax.swing.text.TextAction; - - public class JFormattedTextField_AbstractFormatterTest extends SwingTestCase { - static class AbstractFormatter - extends JFormattedTextField.AbstractFormatter implements Cloneable { + static class AbstractFormatter extends JFormattedTextField.AbstractFormatter implements + Cloneable { + private static final long serialVersionUID = 1L; + Action[] actions; + NavigationFilter navigationFilter; + DocumentFilter documentFilter; + @Override protected Action[] getActions() { return actions == null ? super.getActions() : actions; } + @Override protected DocumentFilter getDocumentFilter() { - return documentFilter == null ? super.getDocumentFilter() - : documentFilter; + return documentFilter == null ? super.getDocumentFilter() : documentFilter; } + @Override protected NavigationFilter getNavigationFilter() { - return navigationFilter == null ? super.getNavigationFilter() - : navigationFilter; + return navigationFilter == null ? super.getNavigationFilter() : navigationFilter; } - final void setActions(final Action[] newActions) { actions = newActions; } @@ -67,16 +68,20 @@ navigationFilter = filter; } + @Override public Object stringToValue(final String string) throws ParseException { return null; } + @Override public String valueToString(final Object value) throws ParseException { return null; } } class TextActionImpl extends TextAction { + private static final long serialVersionUID = 1L; + TextActionImpl(final String name) { super(name); } @@ -86,8 +91,10 @@ } AbstractFormatter formatter; + JFormattedTextField tf; + @Override protected void setUp() throws Exception { super.setUp(); formatter = new AbstractFormatter(); @@ -96,8 +103,11 @@ class PropertyChangeListenerImpl implements PropertyChangeListener { String name; + Object oldValue; + Object newValue; + String interestingPropertyName; public void propertyChange(final PropertyChangeEvent e) { @@ -114,7 +124,7 @@ } } - + @Override protected void tearDown() throws Exception { super.tearDown(); } @@ -128,8 +138,7 @@ assertTrue("UnexpectedException: " + e.getMessage(), false); } assertTrue(clone instanceof JFormattedTextField.AbstractFormatter); - assertNull(((JFormattedTextField.AbstractFormatter)clone) - .getFormattedTextField()); + assertNull(((JFormattedTextField.AbstractFormatter) clone).getFormattedTextField()); } public void testGetActions() { @@ -137,13 +146,13 @@ } final void printActionMap(final ActionMap actionMap) { - if (actionMap == null) { - return; - } - for (int i = 0; i < actionMap.size(); i++) { - Object key = actionMap.keys()[i]; - System.out.println(i + " " + key + " " + actionMap.get(key)); - } + if (actionMap == null) { + return; + } + for (int i = 0; i < actionMap.size(); i++) { + Object key = actionMap.keys()[i]; + System.out.println(i + " " + key + " " + actionMap.get(key)); + } } private void checkActionMap(final ActionMap map, final Action[] actions) { @@ -154,13 +163,12 @@ assertEquals(actions.length, map.size()); Object[] keys = map.keys(); for (int i = 0; i < keys.length; i++) { - String name = (String)keys[i]; + String name = (String) keys[i]; Action action = map.get(name); boolean contains = false; for (int j = 0; j < actions.length; j++) { Action a = actions[j]; - if (a.getValue(Action.NAME).equals(name) - && action == a) { + if (a.getValue(Action.NAME).equals(name) && action == a) { contains = true; break; } @@ -168,102 +176,77 @@ assertTrue(contains); } } + public void testInstallUninstall_Filters() { NavigationFilter navFilter = new NavigationFilter(); formatter.setNavigationFilter(navFilter); - DocumentFilter docFilter = new DocumentFilter(); formatter.setDocumentFilter(docFilter); - AbstractDocument doc = (AbstractDocument) tf.getDocument(); - assertNull(tf.getNavigationFilter()); assertNull(doc.getDocumentFilter()); - formatter.install(tf); - assertEquals(navFilter, tf.getNavigationFilter()); assertEquals(docFilter, doc.getDocumentFilter()); - formatter.uninstall(); - assertNull(tf.getNavigationFilter()); assertNull(doc.getDocumentFilter()); - formatter.install(tf); - assertEquals(navFilter, tf.getNavigationFilter()); assertEquals(docFilter, doc.getDocumentFilter()); - formatter.install(null); assertNull(tf.getNavigationFilter()); assertNull(doc.getDocumentFilter()); } - public void testInstallUninstall_Actions() { - Action[] actions = new Action[] {new TextActionImpl("1"), - new TextActionImpl("2")}; + Action[] actions = new Action[] { new TextActionImpl("1"), new TextActionImpl("2") }; formatter.setActions(actions); - AbstractDocument doc = (AbstractDocument) tf.getDocument(); ActionMap map1 = tf.getActionMap(); ActionMap map2 = map1.getParent(); //keymap ActionMap map3 = map2.getParent(); //uiActionMap assertTrue(map3 instanceof UIResource); - assertNull(tf.getNavigationFilter()); assertNull(doc.getDocumentFilter()); - formatter.install(tf); - ActionMap _map1 = tf.getActionMap(); ActionMap _map2 = _map1.getParent(); //keymap ActionMap _map3 = _map2.getParent(); //formatter ActionMap _map4 = _map3.getParent(); - assertEquals(map1, _map1); assertEquals(map2, _map2); assertEquals(map3, _map4); checkActionMap(_map3, actions); - //TODO: Decide if uninstall() & install(null) should reset remove actions //installed by formatter. formatter.install(null); - _map1 = tf.getActionMap(); _map2 = _map1.getParent(); _map3 = _map2.getParent(); _map4 = _map3.getParent(); - assertEquals(map1, _map1); assertEquals(map2, _map2); if (isHarmony()) { - assertEquals(map3, _map3); + assertEquals(map3, _map3); } else { - assertEquals(map3, _map4); - checkActionMap(_map3, null); + assertEquals(map3, _map4); + checkActionMap(_map3, null); } - formatter.install(tf); - _map1 = tf.getActionMap(); _map2 = _map1.getParent(); _map3 = _map2.getParent(); _map4 = _map3.getParent(); - assertEquals(map1, _map1); assertEquals(map2, _map2); assertEquals(map3, _map4); checkActionMap(_map3, actions); - formatter.uninstall(); - _map1 = tf.getActionMap(); _map2 = _map1.getParent(); _map3 = _map2.getParent(); _map4 = _map3.getParent(); - assertEquals(map1, _map1); assertEquals(map2, _map2); if (isHarmony()) { Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFormattedTextField_CommitActionRTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFormattedTextField_CommitActionRTest.java?view=diff&rev=479240&r1=479239&r2=479240 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFormattedTextField_CommitActionRTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFormattedTextField_CommitActionRTest.java Sat Nov 25 16:04:10 2006 @@ -26,21 +26,22 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; - import junit.framework.TestCase; public class JFormattedTextField_CommitActionRTest extends TestCase { - private JFrame frame; + private JPanel c; + private JTextField textField; + @Override protected void setUp() throws Exception { super.setUp(); - frame = new JFrame(); } + @Override protected void tearDown() throws Exception { if (frame != null) { frame.dispose(); @@ -58,7 +59,6 @@ parent.add(textField); frame.pack(); frame.setVisible(true); - final Rectangle flag = new Rectangle(); final ActionListener parentListener = new ActionListener() { public void actionPerformed(final ActionEvent event) { @@ -70,24 +70,16 @@ flag.y = 100; } }; - c.registerKeyboardAction(parentListener, - KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), - JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - + c.registerKeyboardAction(parentListener, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); SwingWaitTestCase.requestFocusInWindowForComponent(textField); - - textField.dispatchEvent(new KeyEvent(textField, - KeyEvent.KEY_PRESSED, - 0, 0, - KeyEvent.VK_ENTER, (char)13)); + textField.dispatchEvent(new KeyEvent(textField, KeyEvent.KEY_PRESSED, 0, 0, + KeyEvent.VK_ENTER, (char) 13)); assertEquals("parent's action hasn't been fired", 0, flag.x); assertEquals("textFields action hasn't been fired", 0, flag.y); - textField.addActionListener(textFieldListener); - textField.dispatchEvent(new KeyEvent(textField, - KeyEvent.KEY_PRESSED, - 0, 0, - KeyEvent.VK_ENTER, (char)13)); + textField.dispatchEvent(new KeyEvent(textField, KeyEvent.KEY_PRESSED, 0, 0, + KeyEvent.VK_ENTER, (char) 13)); assertEquals("parent's action hasn't been fired", 0, flag.x); assertEquals("textFields action has been fired", 100, flag.y); } Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFrameRTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFrameRTest.java?view=diff&rev=479240&r1=479239&r2=479240 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFrameRTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFrameRTest.java Sat Nov 25 16:04:10 2006 @@ -29,15 +29,16 @@ public void testInitDecorations() throws Exception { UIManager.setLookAndFeel(new MetalLookAndFeel() { + private static final long serialVersionUID = 1L; + + @Override public boolean getSupportsWindowDecorations() { return false; } }); - JFrame.setDefaultLookAndFeelDecorated(true); JFrame f = new JFrame(); assertFalse(f.isUndecorated()); - JDialog.setDefaultLookAndFeelDecorated(true); JDialog d = new JDialog(); assertFalse(d.isUndecorated()); Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFrameTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFrameTest.java?view=diff&rev=479240&r1=479239&r2=479240 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFrameTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFrameTest.java Sat Nov 25 16:04:10 2006 @@ -14,12 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /** * @author Vadim L. Bogdanov * @version $Revision$ */ - package javax.swing; import java.awt.BorderLayout; @@ -30,36 +28,36 @@ import java.awt.Image; import java.awt.KeyboardFocusManager; import java.awt.LayoutManager; - import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; - import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; - import java.security.Permission; - import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleState; - import org.apache.harmony.x.swing.StringConstants; - public class JFrameTest extends SwingTestCase { /* * This class is used to test that some methods were called. */ private static class TestFrame extends JFrame { + private static final long serialVersionUID = 1L; + public static boolean createRootPaneCalled = false; + public static boolean setRootPaneCalled = false; + public boolean disposeCalled = false; + @Override public JRootPane createRootPane() { createRootPaneCalled = true; return super.createRootPane(); } + @Override public void setRootPane(final JRootPane root) { setRootPaneCalled = true; super.setRootPane(root); @@ -70,6 +68,7 @@ setRootPaneCalled = false; } + @Override public void dispose() { disposeCalled = true; super.dispose(); @@ -100,6 +99,7 @@ /* * @see TestCase#setUp() */ + @Override protected void setUp() throws Exception { super.setUp(); frame = new JFrame(); @@ -109,6 +109,7 @@ /* * @see TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { super.tearDown(); if (frame.isDisplayable()) { @@ -124,7 +125,6 @@ assertEquals("title is empty", "", frame.getTitle()); assertFalse("JFrame is invisible by default", frame.isVisible()); assertTrue(frame.getLocale() == JComponent.getDefaultLocale()); - // how to test throwing of HeadlessException // when GraphicsEnvironment.isHeadless() returns true // it is not critical because the exception is actually thrown by Frame() constructor @@ -132,33 +132,31 @@ public void testFrameInit() { TestFrame frame = new TestFrame(); - assertTrue("rootPaneCheckingEnabled is true", frame.isRootPaneCheckingEnabled()); assertTrue("layout is not null", frame.getLayout() != null); assertTrue("rootPane is not null", frame.getRootPane() != null); assertTrue("locale is set", frame.getLocale() == JComponent.getDefaultLocale()); - assertTrue("background is set", - frame.getBackground() == frame.getContentPane().getBackground()); - assertFalse("defaultLookAndFeelDecorated is false", JFrame.isDefaultLookAndFeelDecorated()); + assertTrue("background is set", frame.getBackground() == frame.getContentPane() + .getBackground()); + assertFalse("defaultLookAndFeelDecorated is false", JFrame + .isDefaultLookAndFeelDecorated()); assertFalse("isUndecorated is false", frame.isUndecorated()); - assertTrue("rootPane.windowDecorationStyle is NONE", - frame.getRootPane().getWindowDecorationStyle() == JRootPane.NONE); - + assertTrue("rootPane.windowDecorationStyle is NONE", frame.getRootPane() + .getWindowDecorationStyle() == JRootPane.NONE); // test that defaultFocusTraversalPolicy is set //frame.setFocusTraversalPolicy(null); //frame.frameInit(); - assertTrue("focusTraversalPolicy is set correctly", frame.getFocusTraversalPolicy() == KeyboardFocusManager. - getCurrentKeyboardFocusManager().getDefaultFocusTraversalPolicy()); + assertTrue("focusTraversalPolicy is set correctly", + frame.getFocusTraversalPolicy() == KeyboardFocusManager + .getCurrentKeyboardFocusManager().getDefaultFocusTraversalPolicy()); assertTrue("focusTraversalPolicy is set", frame.isFocusTraversalPolicySet()); assertTrue(frame.isFocusCycleRoot()); assertFalse(frame.isFocusTraversalPolicyProvider()); - JFrame.setDefaultLookAndFeelDecorated(true); frame.frameInit(); assertTrue("isUndecorated is true", frame.isUndecorated()); - assertTrue("rootPane.windowDecorationStyle is FRAME", - frame.getRootPane().getWindowDecorationStyle() == JRootPane.FRAME); - + assertTrue("rootPane.windowDecorationStyle is FRAME", frame.getRootPane() + .getWindowDecorationStyle() == JRootPane.FRAME); // restore default value JFrame.setDefaultLookAndFeelDecorated(false); } @@ -170,15 +168,13 @@ */ public void testSetGetDefaultCloseOperation() { // default value is JFrame.HIDE_ON_CLOSE - assertEquals(JFrame.HIDE_ON_CLOSE, frame.getDefaultCloseOperation()); - + assertEquals(WindowConstants.HIDE_ON_CLOSE, frame.getDefaultCloseOperation()); // test setting valid value MyPropertyChangeListener listener = new MyPropertyChangeListener(); frame.addPropertyChangeListener("defaultCloseOperation", listener); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - assertEquals(JFrame.DISPOSE_ON_CLOSE, frame.getDefaultCloseOperation()); + frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + assertEquals(WindowConstants.DISPOSE_ON_CLOSE, frame.getDefaultCloseOperation()); assertTrue("defaultCloseOperation is a bound property", listener.ok); - // test setting invalid value boolean ok = false; try { @@ -188,14 +184,16 @@ } finally { assertTrue(ok); } - // if JFrame.EXIT_ON_CLOSE has been specified and the SecurityManager // will not allow the caller to invoke System.exit then SecurityException is thrown class MySecurityManager extends SecurityManager { + @Override public void checkExit(final int status) { // exit is not allowed throw new SecurityException(); } + + @Override public void checkPermission(final Permission perm) { // allow changing the security manager } @@ -219,13 +217,11 @@ * static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) * static boolean isDefaultLookAndFeelDecorated() */ - public void testSetIsDefaultLookAndFeelDecorated() { - // test for default value - assertFalse(JFrame.isDefaultLookAndFeelDecorated()); - - JFrame.setDefaultLookAndFeelDecorated(true); - assertTrue(JFrame.isDefaultLookAndFeelDecorated()); - + public void testSetIsDefaultLookAndFeelDecorated() { + // test for default value + assertFalse(JFrame.isDefaultLookAndFeelDecorated()); + JFrame.setDefaultLookAndFeelDecorated(true); + assertTrue(JFrame.isDefaultLookAndFeelDecorated()); // restore default value JFrame.setDefaultLookAndFeelDecorated(false); } @@ -237,11 +233,11 @@ */ public void testSetIsRootPaneCheckingEnabled() { TestFrame frame = new TestFrame(); - - assertTrue("rootPaneCheckingEnabled is true by default", frame.isRootPaneCheckingEnabled()); - + assertTrue("rootPaneCheckingEnabled is true by default", frame + .isRootPaneCheckingEnabled()); frame.setRootPaneCheckingEnabled(false); - assertFalse("rootPaneCheckingEnabled is set to false", frame.isRootPaneCheckingEnabled()); + assertFalse("rootPaneCheckingEnabled is set to false", frame + .isRootPaneCheckingEnabled()); } /* @@ -249,9 +245,8 @@ */ public void testJFrameStringGraphicsConfiguration() { final String title = "Test frame."; - final GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment(). - getDefaultScreenDevice().getDefaultConfiguration(); - + final GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getDefaultScreenDevice().getDefaultConfiguration(); // test with valid title, valid gc // would be nice to test non-default gc here frame = new JFrame(title, gc); @@ -259,13 +254,11 @@ assertFalse("JFrame is invisible by default", frame.isVisible()); assertTrue(frame.getLocale() == JComponent.getDefaultLocale()); assertTrue(frame.getGraphicsConfiguration() == gc); - frame = new JFrame(null, null); assertNull("null instead of title can be used", frame.getTitle()); assertFalse("JFrame is invisible by default", frame.isVisible()); assertTrue(frame.getLocale() == JComponent.getDefaultLocale()); assertTrue(frame.getGraphicsConfiguration() == gc); - // how to test throwing of HeadlessException // when GraphicsEnvironment.isHeadless() returns true // it is not critical because the exception is actually thrown by Frame() constructor @@ -276,18 +269,15 @@ */ public void testJFrameString() { final String title = "Test frame."; - // test with valid title frame = new JFrame(title); assertEquals("Title is set properly", title, frame.getTitle()); assertFalse("JFrame is invisible by default", frame.isVisible()); assertTrue(frame.getLocale() == JComponent.getDefaultLocale()); - - frame = new JFrame((String)null); + frame = new JFrame((String) null); assertNull("null instead of title can be used", frame.getTitle()); assertFalse("JFrame is invisible by default", frame.isVisible()); assertTrue(frame.getLocale() == JComponent.getDefaultLocale()); - // how to test throwing of HeadlessException // when GraphicsEnvironment.isHeadless() returns true // it is not critical because the exception is actually thrown by Frame() constructor @@ -297,9 +287,8 @@ * Class under test for void JFrame(GraphicsConfiguration) */ public void testJFrameGraphicsConfiguration() { - final GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment(). - getDefaultScreenDevice().getDefaultConfiguration(); - + final GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getDefaultScreenDevice().getDefaultConfiguration(); // test with valid gc // would be nice to test non-default gc here frame = new JFrame(gc); @@ -307,13 +296,11 @@ assertFalse("JFrame is invisible by default", frame.isVisible()); assertTrue(frame.getLocale() == JComponent.getDefaultLocale()); assertTrue(frame.getGraphicsConfiguration() == gc); - - frame = new JFrame((GraphicsConfiguration)null); + frame = new JFrame((GraphicsConfiguration) null); assertEquals("title is empty", "", frame.getTitle()); assertFalse("JFrame is invisible by default", frame.isVisible()); assertTrue(frame.getLocale() == JComponent.getDefaultLocale()); assertTrue(frame.getGraphicsConfiguration() == gc); - // how to test throwing of HeadlessException // when GraphicsEnvironment.isHeadless() returns true // it is not critical because the exception is actually thrown by Frame() constructor @@ -324,7 +311,6 @@ */ public void testAddImpl() { JComponent comp = new JPanel(); - // rootPaneCheckingEnabled is true, exception must be thrown frame.setRootPaneCheckingEnabled(true); boolean ok = false; @@ -334,10 +320,9 @@ ok = true; } finally { assertFalse("no exception", ok); - assertTrue("The component is added to contentPane", - comp.getParent() == frame.getContentPane()); + assertTrue("The component is added to contentPane", comp.getParent() == frame + .getContentPane()); } - // rootPaneCheckingEnabled is false, exception may not be thrown frame.setRootPaneCheckingEnabled(false); ok = false; @@ -347,10 +332,8 @@ ok = true; } finally { assertFalse("no exception", ok); - assertTrue("the component is added to JWindow", - comp.getParent() == frame); - assertTrue("index of the component is 0", - frame.getComponent(0) == comp); + assertTrue("the component is added to JWindow", comp.getParent() == frame); + assertTrue("index of the component is 0", frame.getComponent(0) == comp); } } @@ -361,16 +344,13 @@ */ public void testSetGetRootPane() { TestFrame frame = new TestFrame(); - assertTrue("setRootPane() is called from the constructor", - TestFrame.setRootPaneCalled); - + assertTrue("setRootPane() is called from the constructor", TestFrame.setRootPaneCalled); MyPropertyChangeListener listener = new MyPropertyChangeListener(); frame.addPropertyChangeListener("rootPane", listener); JRootPane root = new JRootPane(); frame.setRootPane(root); assertTrue(frame.getRootPane() == root); assertFalse("rootPane is not a bound property", listener.ok); - // test setting rootPane to null frame.setRootPane(null); assertNull(frame.getRootPane()); @@ -384,7 +364,6 @@ TestFrame frame = new TestFrame(); assertTrue("createRootPane() is called from the constructor", TestFrame.createRootPaneCalled); - JRootPane root = frame.createRootPane(); assertTrue("createRootPane() cannot return null", root != null); } @@ -396,11 +375,9 @@ */ public void testSetGetJMenuBar() { assertNull(frame.getJMenuBar()); - JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); assertTrue(frame.getJMenuBar() == menuBar); - frame.setJMenuBar(null); assertNull(frame.getJMenuBar()); } @@ -413,12 +390,10 @@ public void testSetGetLayeredPane() { MyPropertyChangeListener listener = new MyPropertyChangeListener(); frame.addPropertyChangeListener("layeredPane", listener); - JLayeredPane pane = new JLayeredPane(); frame.setLayeredPane(pane); assertTrue(frame.getLayeredPane() == pane); assertFalse("layeredPane is not a bound property", listener.ok); - // test throwing exception if the parameter is null boolean ok = false; try { @@ -430,7 +405,6 @@ } // layeredPane cannot be null, even after setLayeredPane(null) assertTrue(frame.getLayeredPane() != null); - // setLayeredPane() method is not called by the constructor // (seems that there is an error in docs) } @@ -440,24 +414,17 @@ */ public void testGetAccessibleContext() { AccessibleContext c = frame.getAccessibleContext(); - assertTrue("class is ok", c instanceof JFrame.AccessibleJFrame); - assertTrue("AccessibleRole is ok", - c.getAccessibleRole() == AccessibleRole.FRAME); - assertNull("AccessibleDescription is ok", - c.getAccessibleDescription()); - assertTrue("AccessibleChildrenCount == 1", - c.getAccessibleChildrenCount() == 1); - + assertTrue("AccessibleRole is ok", c.getAccessibleRole() == AccessibleRole.FRAME); + assertNull("AccessibleDescription is ok", c.getAccessibleDescription()); + assertTrue("AccessibleChildrenCount == 1", c.getAccessibleChildrenCount() == 1); // test getAccessibleName() assertTrue("AccessibleName is ok", c.getAccessibleName() == ""); frame.setTitle("aa"); assertTrue("AccessibleName is ok", c.getAccessibleName() == "aa"); - // test getAccessibleStateSet() AccessibleState[] states = c.getAccessibleStateSet().toArray(); assertTrue("more than 2 states", states.length > 2); - frame.setVisible(true); states = c.getAccessibleStateSet().toArray(); assertTrue("more than 4 states", states.length > 4); @@ -478,29 +445,25 @@ TestFrame frame = new TestFrame(); frame.setVisible(true); WindowEvent e = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING); - // test DO_NOTHING_ON_CLOSE - frame.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.disposeCalled = false; frame.processWindowEvent(e); assertFalse("didn't call dispose()", frame.disposeCalled); assertTrue("is visible", frame.isVisible()); - // test HIDE_ON_CLOSE - frame.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); + frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); frame.disposeCalled = false; frame.processWindowEvent(e); assertFalse("didn't call dispose()", frame.disposeCalled); assertFalse("is not visible", frame.isVisible()); - // test DISPOSE_ON_CLOSE - frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.disposeCalled = false; frame.setVisible(true); frame.processWindowEvent(e); assertTrue("called dispose()", frame.disposeCalled); assertFalse("is not visible", frame.isVisible()); - // could test EXIT_ON_CLOSE but it's rather hard } @@ -511,7 +474,6 @@ TestFrame frame = new TestFrame(); LayoutManager contentLayout = frame.getContentPane().getLayout(); LayoutManager frameLayout = frame.getLayout(); - // rootPaneCheckingEnabled is true, no exception since 1.5 frame.setRootPaneCheckingEnabled(true); boolean ok = false; @@ -522,12 +484,10 @@ } finally { assertFalse("no exception since 1.5", ok); assertTrue("contentPane layout is changed", - frame.getContentPane().getLayout() != contentLayout); - assertTrue("Frame layout shouldn't be changed", - frame.getLayout() == frameLayout); + frame.getContentPane().getLayout() != contentLayout); + assertTrue("Frame layout shouldn't be changed", frame.getLayout() == frameLayout); frame.getContentPane().setLayout(contentLayout); } - // rootPaneCheckingEnabled is false frame.setRootPaneCheckingEnabled(false); ok = false; @@ -537,10 +497,9 @@ ok = true; } finally { assertFalse("no exception", ok); - assertTrue("contentPane layout shouldn't be changed", - frame.getContentPane().getLayout() == contentLayout); - assertTrue("Frame layout is changed", - frame.getLayout() != frameLayout); + assertTrue("contentPane layout shouldn't be changed", frame.getContentPane() + .getLayout() == contentLayout); + assertTrue("Frame layout is changed", frame.getLayout() != frameLayout); } } @@ -559,12 +518,10 @@ public void testSetGetContentPane() { MyPropertyChangeListener listener = new MyPropertyChangeListener(); frame.addPropertyChangeListener("contentPane", listener); - JPanel pane = new JPanel(); frame.setContentPane(pane); assertTrue(frame.getContentPane() == pane); assertFalse("contentPane is not a bound property", listener.ok); - // test throwing exception if the parameter is null boolean ok = false; try { @@ -576,7 +533,6 @@ } // contentPane cannot be null, even after setContentPane(null) assertTrue(frame.getContentPane() != null); - // setContentPane() method is not called by the constructor // (seems that there is an error in docs) } @@ -589,12 +545,10 @@ public void testSetGetGlassPane() { MyPropertyChangeListener listener = new MyPropertyChangeListener(); frame.addPropertyChangeListener("glassPane", listener); - JPanel pane = new JPanel(); frame.setGlassPane(pane); assertTrue(frame.getGlassPane() == pane); assertFalse("glassPane is not a bound property", listener.ok); - // test throwing exception if the parameter is null boolean ok = false; try { @@ -606,7 +560,6 @@ } // glassPane cannot be null, even after setGlassPane(null) assertTrue(frame.getGlassPane() != null); - // setGlassPane() method is not called by the constructor // (seems that there is an error in docs) } @@ -621,28 +574,24 @@ assertTrue("label is in contentPane", frame.isAncestorOf(comp)); frame.remove(comp); assertFalse("label is removed from contentPane", frame.isAncestorOf(comp)); - - ((JPanel)frame.getGlassPane()).add(comp); + ((JPanel) frame.getGlassPane()).add(comp); frame.remove(comp); assertTrue("label is not removed from glassPane", frame.isAncestorOf(comp)); - // test removing from JFrame frame.setRootPaneCheckingEnabled(false); frame.add(comp, BorderLayout.EAST); assertTrue("added", comp.getParent() == frame); frame.remove(comp); assertTrue("not removed", comp.getParent() == frame); - // test removing null -// boolean ok = false; -// try { -// frame.remove((Component)null); -// } catch (NullPointerException e) { -// ok = true; -// } finally { -// assertTrue("exception", ok); -// } - + // boolean ok = false; + // try { + // frame.remove((Component)null); + // } catch (NullPointerException e) { + // ok = true; + // } finally { + // assertTrue("exception", ok); + // } // test removing rootPane assertTrue(frame.isAncestorOf(frame.getRootPane())); frame.remove(frame.getRootPane()); @@ -659,7 +608,6 @@ Image image = new BufferedImage(5, 5, BufferedImage.TYPE_BYTE_INDEXED); PropertyChangeController cont = new PropertyChangeController(); frame.addPropertyChangeListener(cont); - frame.setIconImage(image); assertEquals(image, frame.getIconImage()); assertTrue(cont.isChanged(StringConstants.ICON_IMAGE_PROPERTY)); Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JInternalFrame$JDesktopIconTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JInternalFrame%24JDesktopIconTest.java?view=diff&rev=479240&r1=479239&r2=479240 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JInternalFrame$JDesktopIconTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JInternalFrame$JDesktopIconTest.java Sat Nov 25 16:04:10 2006 @@ -14,24 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /** * @author Vadim L. Bogdanov * @version $Revision$ */ - package javax.swing; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyVetoException; - import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleValue; - import javax.swing.plaf.ComponentUI; - import javax.swing.plaf.basic.BasicDesktopIconUI; public class JInternalFrame$JDesktopIconTest extends SwingTestCase { @@ -51,17 +46,19 @@ } private JInternalFrame.JDesktopIcon icon; + private JInternalFrame frame; public JInternalFrame$JDesktopIconTest(final String name) { super(name); } + //public static void main(String[] args) { //} - /* * @see TestCase#setUp() */ + @Override protected void setUp() throws Exception { super.setUp(); frame = new JInternalFrame(); @@ -71,6 +68,7 @@ /* * @see TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { super.tearDown(); } @@ -81,14 +79,12 @@ public void testUpdateUI() { icon.setBounds(0, 0, 0, 0); icon.updateUI(); - ComponentUI ui1 = frame.getUI(); ComponentUI ui2 = UIManager.getUI(frame); // at least names of classes must be the same assertEquals(ui2.getClass().getName(), ui1.getClass().getName()); - assertTrue("size is set to preferred", - icon.getSize().equals(icon.getPreferredSize())); - } + assertTrue("size is set to preferred", icon.getSize().equals(icon.getPreferredSize())); + } /* * Class under test for void JDesktopIcon(JInternalFrame) @@ -98,8 +94,7 @@ icon = new JInternalFrame.JDesktopIcon(frame); assertTrue("frame is set", icon.getInternalFrame() == frame); assertTrue("ui != null", icon.getUI() != null); - assertTrue("size is set to preferred", - icon.getSize().equals(icon.getPreferredSize())); + assertTrue("size is set to preferred", icon.getSize().equals(icon.getPreferredSize())); assertFalse("isVisible", icon.isVisible()); } @@ -123,12 +118,10 @@ MyPropertyChangeListener l = new MyPropertyChangeListener(); icon.addPropertyChangeListener(l); // test valid set - frame = new JInternalFrame(); icon.setInternalFrame(frame); assertTrue(icon.getInternalFrame() == frame); assertFalse("internalFrame is not a bound property", l.ok); - // test set to null icon.setInternalFrame(null); assertNull(icon.getInternalFrame()); @@ -139,12 +132,10 @@ */ public void testGetDesktopPane() { assertNull("null by default", icon.getDesktopPane()); - // test when not iconified JDesktopPane desktop = new JDesktopPane(); desktop.add(frame); assertTrue("desktop is set", icon.getDesktopPane() == desktop); - // test when iconified try { frame.setIcon(true); @@ -159,48 +150,36 @@ */ public void testGetAccessibleContext() { AccessibleContext c = icon.getAccessibleContext(); - assertTrue("instanceof AccessibleJDesktopIcon", - c instanceof JInternalFrame.JDesktopIcon.AccessibleJDesktopIcon); - + c instanceof JInternalFrame.JDesktopIcon.AccessibleJDesktopIcon); // test getAccessibleRole() - assertTrue("AccessibleRole ok", - c.getAccessibleRole() == AccessibleRole.DESKTOP_ICON); - + assertTrue("AccessibleRole ok", c.getAccessibleRole() == AccessibleRole.DESKTOP_ICON); // test getAccessibleValue() assertTrue("AccessibleValue ok", c.getAccessibleValue() == c); - // test setCurrentAccessibleValue(), getCurrentAccessibleValue() AccessibleValue value = c.getAccessibleValue(); assertTrue("currentAccessibleValue == 0", value.getCurrentAccessibleValue().intValue() == 0); - Integer currentAccessibleValue = new Integer(4); - boolean set = value.setCurrentAccessibleValue(currentAccessibleValue); - assertTrue("setCurrentAccessibleValue returns true", set); - set = value.setCurrentAccessibleValue(new Float(5)); - assertTrue("setCurrentAccessibleValue returns true", set); - - assertTrue("currentAccessibleValue == 5", - value.getCurrentAccessibleValue().intValue() == 5); - assertTrue("the object is not the same", - value.getCurrentAccessibleValue() != currentAccessibleValue); - - set = value.setCurrentAccessibleValue(null); - assertFalse("setCurrentAccessibleValue returns false", set); - + Integer currentAccessibleValue = new Integer(4); + boolean set = value.setCurrentAccessibleValue(currentAccessibleValue); + assertTrue("setCurrentAccessibleValue returns true", set); + set = value.setCurrentAccessibleValue(new Float(5)); + assertTrue("setCurrentAccessibleValue returns true", set); + assertTrue("currentAccessibleValue == 5", + value.getCurrentAccessibleValue().intValue() == 5); + assertTrue("the object is not the same", + value.getCurrentAccessibleValue() != currentAccessibleValue); + set = value.setCurrentAccessibleValue(null); + assertFalse("setCurrentAccessibleValue returns false", set); // test getMinimumAccessibleValue() assertTrue("minimumAccessibleValue ok", - value.getMinimumAccessibleValue().intValue() == Integer.MIN_VALUE); - + value.getMinimumAccessibleValue().intValue() == Integer.MIN_VALUE); // test getMaximumAccessibleValue() assertTrue("maximumAccessibleValue ok", - value.getMaximumAccessibleValue().intValue() == Integer.MAX_VALUE); - + value.getMaximumAccessibleValue().intValue() == Integer.MAX_VALUE); // test other methods - assertNull("AccessibleDescription is ok", - c.getAccessibleDescription()); - assertTrue("AccessibleChildrenCount == 2", - c.getAccessibleChildrenCount() == 2); + assertNull("AccessibleDescription is ok", c.getAccessibleDescription()); + assertTrue("AccessibleChildrenCount == 2", c.getAccessibleChildrenCount() == 2); } /*