harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r513750 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/event/KeyEvent.java main/java/common/org/apache/harmony/awt/internal/nls/messages.properties test/api/java/common/java/awt/event/KeyEventTest.java
Date Fri, 02 Mar 2007 13:29:48 GMT
Author: apetrenko
Date: Fri Mar  2 05:29:47 2007
New Revision: 513750

URL: http://svn.apache.org/viewvc?view=rev&rev=513750
Log:
Patch for HARMONY-2491 "[classlib][awt] java.awt.event.KeyEvent(...., int keyLocation) does
not throw IAE while RI does"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/event/KeyEvent.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/event/KeyEventTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/event/KeyEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/event/KeyEvent.java?view=diff&rev=513750&r1=513749&r2=513750
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/event/KeyEvent.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/event/KeyEvent.java
Fri Mar  2 05:29:47 2007
@@ -566,6 +566,12 @@
                 throw new IllegalArgumentException(Messages.getString("awt.192")); //$NON-NLS-1$
             }
         }
+        
+        if ((keyLocation < KEY_LOCATION_UNKNOWN)
+                || (keyLocation > KEY_LOCATION_NUMPAD)) {
+            // awt.297=Invalid keyLocation
+            throw new IllegalArgumentException(Messages.getString("awt.297")); //$NON-NLS-1$
+        }
 
         this.keyChar = keyChar;
         this.keyLocation = keyLocation;

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties?view=diff&rev=513750&r1=513749&r2=513750
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
Fri Mar  2 05:29:47 2007
@@ -485,6 +485,7 @@
 awt.294=pixel is null
 awt.295=data is null
 awt.296=can't allocate memory on video card to create new display list
+awt.297=Invalid keyLocation
 
 awt.err.00=file dialog {0} error!
 awt.err.01=error: {0}

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/event/KeyEventTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/event/KeyEventTest.java?view=diff&rev=513750&r1=513749&r2=513750
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/event/KeyEventTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/event/KeyEventTest.java
Fri Mar  2 05:29:47 2007
@@ -21,6 +21,7 @@
 package java.awt.event;
 
 import java.awt.Button;
+import java.awt.Container;
 
 import junit.framework.TestCase;
 
@@ -118,6 +119,21 @@
             typedUndefinedChar = true;
         }
         assertTrue(typedUndefinedChar);
+        
+        // Regression for HARMONY-2491
+        try {
+            new KeyEvent(new Container(), (-1), 62554L, 5, 1, '\1', -1);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+        
+        try {
+            new KeyEvent(new Container(), (-1), 62554L, 5, 1, '\1', 5);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
     }
 
     public final void testGetSetKeyCode() {
@@ -192,10 +208,5 @@
                 InputEvent.ALT_GRAPH_MASK, KeyEvent.VK_A, 'a', KeyEvent.KEY_LOCATION_NUMPAD);
         assertEquals(event.paramString(),
                 "unknown type,keyCode=65,keyChar='a',modifiers=Alt Graph,extModifiers=Alt
Graph,keyLocation=KEY_LOCATION_NUMPAD");
-        event = new KeyEvent(button, KeyEvent.KEY_PRESSED + 1024, 0l,
-                InputEvent.ALT_GRAPH_MASK, KeyEvent.VK_A, 'a', KeyEvent.KEY_LOCATION_NUMPAD
+ 1024);
-        assertEquals(event.paramString(),
-                "unknown type,keyCode=65,keyChar='a',modifiers=Alt Graph,extModifiers=Alt
Graph,keyLocation=unknown type");
     }
-
 }



Mime
View raw message