harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r494074 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/JMenuBar.java test/api/java/common/javax/swing/JMenuBarTest.java
Date Mon, 08 Jan 2007 13:58:16 GMT
Author: odeakin
Date: Mon Jan  8 05:58:13 2007
New Revision: 494074

URL: http://svn.apache.org/viewvc?view=rev&rev=494074
Log:
Apply patch HARMONY-2622 ([classlib][swing] Compatibility: javax.swing.JMenuBar.processKeyBinding()
for incorrect parameterds throws NPE on Harmony instead of IllegalArgumentException on RI)

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenuBar.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JMenuBarTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenuBar.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenuBar.java?view=diff&rev=494074&r1=494073&r2=494074
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenuBar.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JMenuBar.java
Mon Jan  8 05:58:13 2007
@@ -189,7 +189,7 @@
     protected boolean processKeyBinding(KeyStroke ks, KeyEvent event, int condition,
             boolean pressed) {
         MenuSelectionManager.defaultManager().processKeyEvent(event);
-        if (event.isConsumed()) {
+        if ((event != null) && event.isConsumed()) {
             return true;
         }
         if (super.processKeyBinding(ks, event, condition, pressed)) {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JMenuBarTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JMenuBarTest.java?view=diff&rev=494074&r1=494073&r2=494074
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JMenuBarTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JMenuBarTest.java
Mon Jan  8 05:58:13 2007
@@ -21,6 +21,7 @@
 package javax.swing;
 
 import java.awt.Insets;
+import java.awt.event.KeyEvent;
 import javax.accessibility.AccessibleRole;
 import javax.swing.plaf.MenuBarUI;
 import javax.swing.plaf.basic.BasicMenuBarUI;
@@ -84,7 +85,24 @@
      * Test method for 'javax.swing.JMenuBar.processKeyBinding(KeyStroke, KeyEvent, int,
boolean)'
      */
     public void testProcessKeyBinding() {
-        // TODO implement
+        JMenuBar jm = new JMenuBar() {
+            public boolean processKeyBinding(KeyStroke ks, KeyEvent e,
+                    int condition, boolean pressed) {
+                return super.processKeyBinding(ks, e, condition, pressed);
+            }
+        };
+        KeyStroke ks = KeyStroke.getKeyStroke('x');
+
+        try { // Regression test for HARMONY-2622
+            jm.processKeyBinding(ks, null, -1, true);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        } catch (NullPointerException e) {
+            fail("NullPointerException is thrown instead of IllegalArgumentException");
+        }
+
+        // TODO implement other checkings
     }
 
     /*



Mime
View raw message