harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r530921 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/org/apache/harmony/awt/ButtonStateController.java test/api/java/common/java/awt/ButtonRTest.java
Date Fri, 20 Apr 2007 21:08:59 GMT
Author: tellison
Date: Fri Apr 20 14:08:58 2007
New Revision: 530921

URL: http://svn.apache.org/viewvc?view=rev&rev=530921
Log:
Apply patch HARMONY-3701 ([classlib][awt] java.awt.ButtonRTest fails on build machine)

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/ButtonStateController.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ButtonRTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/ButtonStateController.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/ButtonStateController.java?view=diff&rev=530921&r1=530920&r2=530921
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/ButtonStateController.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/ButtonStateController.java
Fri Apr 20 14:08:58 2007
@@ -70,13 +70,12 @@
 
     public void mousePressed(MouseEvent me) {
         if (mousePressed || keyPressed ||
-                (me.getButton() != MouseEvent.BUTTON1) ||
-                (activeComponent != null)) {
+                (me.getButton() != MouseEvent.BUTTON1) || !lock()) {
             return;
         }
 
         mousePressed = true;
-        activeComponent = component;
+        
         if (mouseInside) {
             component.repaint();
         }
@@ -87,14 +86,13 @@
     }
 
     public void mouseReleased(MouseEvent me) {
-        if (!mousePressed || (me.getButton() != MouseEvent.BUTTON1) || 
-                (activeComponent != component)) {
+        if (!mousePressed || (me.getButton() != MouseEvent.BUTTON1) || !unlock()) {
             return;
         }
 
         mousePressed = false;
         component.repaint();
-        activeComponent = null;
+        
         if (mouseInside) {
             when = me.getWhen();
             mod = me.getModifiers();
@@ -107,13 +105,11 @@
         assert focused == true : Messages.getString("awt.54"); //$NON-NLS-1$
 
         if (mousePressed || keyPressed ||
-                (ke.getKeyCode() != KeyEvent.VK_SPACE) ||
-                (activeComponent != null)) {
+                (ke.getKeyCode() != KeyEvent.VK_SPACE) || !lock()) {
             return;
         }
 
         keyPressed = true;
-        activeComponent = component;
         component.repaint();
     }
 
@@ -121,13 +117,11 @@
         // awt.54=Key event for unfocused component
         assert focused == true : Messages.getString("awt.54"); //$NON-NLS-1$
 
-        if (!keyPressed || (ke.getKeyCode() != KeyEvent.VK_SPACE) ||
-                (activeComponent != component)) {
+        if (!keyPressed || (ke.getKeyCode() != KeyEvent.VK_SPACE) || !unlock()) {
             return;
         }
 
         keyPressed = false;
-        activeComponent = null;
         component.repaint();
         when = ke.getWhen();
         mod = ke.getModifiers();
@@ -158,6 +152,7 @@
         // awt.58=Double focus lost event for component
         assert focused == true : Messages.getString("awt.58"); //$NON-NLS-1$
 
+        unlock();
         focused = false;
         keyPressed = false;
         mousePressed = false;
@@ -185,5 +180,34 @@
     }
 
     protected abstract void fireEvent();
+    
+    /**
+     * Acquires the lock for this button. If the lock is acquired no other
+     * buttons could be pressed until the lock is released.
+     * 
+     * @return true if the lock has been successfully acquired, otherwise
+     *         returns false.
+     */
+    private boolean lock() {
+        if (activeComponent != null) {
+            return false;
+        }
+
+        activeComponent = component;
+        return true;
+    }
+
+    /**
+     * Releases the lock.
+     * 
+     * @return true if the lock has been released, otherwise returns false.
+     */
+    private boolean unlock() {
+        if (activeComponent != component) {
+            return false;
+        }
 
+        activeComponent = null;
+        return true;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ButtonRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ButtonRTest.java?view=diff&rev=530921&r1=530920&r2=530921
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ButtonRTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ButtonRTest.java
Fri Apr 20 14:08:58 2007
@@ -81,6 +81,13 @@
             f.dispose();
         }
     }
+    
+    // Regression test for HARMONY-3701
+    public void testHarmony3701() throws Exception {
+        setName("testHarmony3701"); //$NON-NLS-1$
+        testHarmony2305();
+        testHarmony2305();
+    }
 
     static class AL implements ActionListener {
         ActionEvent e;



Mime
View raw message