harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apavle...@apache.org
Subject svn commit: r599359 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxEvent.java test/api/java/common/java/awt/event/MouseEventTest.java
Date Thu, 29 Nov 2007 09:57:42 GMT
Author: apavlenko
Date: Thu Nov 29 01:57:41 2007
New Revision: 599359

URL: http://svn.apache.org/viewvc?rev=599359&view=rev
Log:
Fix for HARMONY-5215

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxEvent.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/event/MouseEventTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxEvent.java?rev=599359&r1=599358&r2=599359&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxEvent.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxEvent.java
Thu Nov 29 01:57:41 2007
@@ -549,15 +549,17 @@
 
     private void translateButtonModifiers(int state) {
         translateModifiers(state);
+        
+        final int m = (mouseButton == MouseEvent.BUTTON1)
+            ? InputEvent.BUTTON1_DOWN_MASK
+            : (mouseButton == MouseEvent.BUTTON2) ? InputEvent.BUTTON2_DOWN_MASK
+            : (mouseButton == MouseEvent.BUTTON3) ? InputEvent.BUTTON3_DOWN_MASK 
+            : 0;
 
-        if (mouseButton == MouseEvent.BUTTON1) {
-            modifiers |= InputEvent.BUTTON1_DOWN_MASK;
-        }
-        if (mouseButton == MouseEvent.BUTTON2) {
-            modifiers |= InputEvent.BUTTON2_DOWN_MASK;
-        }
-        if (mouseButton == MouseEvent.BUTTON3) {
-            modifiers |= InputEvent.BUTTON3_DOWN_MASK;
+        if (eventId == MouseEvent.MOUSE_PRESSED) {
+            modifiers |= m;
+        } else if (eventId == MouseEvent.MOUSE_RELEASED) {
+            modifiers &= ~m;
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/event/MouseEventTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/event/MouseEventTest.java?rev=599359&r1=599358&r2=599359&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/event/MouseEventTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/event/MouseEventTest.java
Thu Nov 29 01:57:41 2007
@@ -22,7 +22,10 @@
 
 import java.awt.Button;
 import java.awt.Component;
+import java.awt.Frame;
+import java.awt.MouseInfo;
 import java.awt.Point;
+import java.awt.Robot;
 
 import junit.framework.TestCase;
 
@@ -144,5 +147,82 @@
         assertEquals(
                 event.paramString(),
                 "unknown type,(100,200),button=1,modifiers=Alt+Button2,extModifiers=Alt+Button2,clickCount=10");
+    }
+    
+    public void testHarmony5215() throws Exception {
+        final Frame f = new Frame();
+        final Point l = MouseInfo.getPointerInfo().getLocation();
+        final Robot r = new Robot();
+        final MouseEvent[] e = new MouseEvent[1];
+
+        f.addMouseListener(new MouseAdapter() {
+            public void mouseReleased(final MouseEvent event) {
+                synchronized (e) {
+                    e[0] = event;
+                    e.notify();
+                }
+            }
+
+            public void mousePressed(final MouseEvent event) {
+                synchronized (e) {
+                    e[0] = event;
+                    e.notify();
+                }
+            }
+        });
+
+        f.setSize(100, 100);
+        f.setVisible(true);
+        r.mouseMove(f.getX() + 50, f.getY() + 50);
+
+        try {
+            synchronized (e) {
+                r.mousePress(InputEvent.BUTTON1_MASK);
+                e.wait(5000);
+                assertEquals(InputEvent.BUTTON1_MASK, e[0].getModifiers());
+                assertEquals(InputEvent.BUTTON1_DOWN_MASK,
+                    e[0].getModifiersEx());
+
+                r.mouseRelease(InputEvent.BUTTON1_MASK);
+                e.wait(5000);
+                assertEquals(InputEvent.BUTTON1_MASK, e[0].getModifiers());
+                assertEquals(0, e[0].getModifiersEx());
+
+                r.mousePress(InputEvent.BUTTON1_MASK);
+                e.wait(5000);
+                r.mousePress(InputEvent.BUTTON2_MASK);
+                e.wait(5000);
+                assertEquals(InputEvent.BUTTON2_MASK, e[0].getModifiers());
+                assertEquals(InputEvent.BUTTON1_DOWN_MASK
+                    | InputEvent.BUTTON2_DOWN_MASK, e[0].getModifiersEx());
+
+                r.mouseRelease(InputEvent.BUTTON2_MASK);
+                e.wait(5000);
+                assertEquals(InputEvent.BUTTON2_MASK, e[0].getModifiers());
+                assertEquals(InputEvent.BUTTON1_DOWN_MASK,
+                    e[0].getModifiersEx());
+
+                r.mousePress(InputEvent.BUTTON2_MASK);
+                e.wait(5000);
+                r.mousePress(InputEvent.BUTTON3_MASK);
+                e.wait(5000);
+                assertEquals(InputEvent.BUTTON3_MASK, e[0].getModifiers());
+                assertEquals(InputEvent.BUTTON1_DOWN_MASK
+                    | InputEvent.BUTTON2_DOWN_MASK
+                    | InputEvent.BUTTON3_DOWN_MASK, e[0].getModifiersEx());
+
+                r.mouseRelease(InputEvent.BUTTON3_MASK);
+                e.wait(5000);
+                assertEquals(InputEvent.BUTTON3_MASK, e[0].getModifiers());
+                assertEquals(InputEvent.BUTTON1_DOWN_MASK
+                    | InputEvent.BUTTON2_DOWN_MASK, e[0].getModifiersEx());
+            }
+        } finally {
+            r.mouseRelease(InputEvent.BUTTON1_MASK);
+            r.mouseRelease(InputEvent.BUTTON2_MASK);
+            r.mouseRelease(InputEvent.BUTTON3_MASK);
+            r.mouseMove(l.x, l.y);
+            f.dispose();
+        }
     }
 }



Mime
View raw message