RFC: fix for a test gnu/testlet/java/awt/Container/addImpl.java & its helper class gnu/testlet/java/awt/Container/DisabledEventQueue.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

RFC: fix for a test gnu/testlet/java/awt/Container/addImpl.java & its helper class gnu/testlet/java/awt/Container/DisabledEventQueue.java

Pavel Tisnovsky
Greetings,

the Mauve test gnu/testlet/java/awt/Container/addImpl.java in its current implementation
left opened frame on the desktop, which caused some other AWT-related tests to fail. Here's
a (quite obvious) fix for this test:

--- mauve/gnu/testlet/java/awt/Container/addImpl.java_old       2006-03-15 16:22:05.000000000 +0100
+++ mauve/gnu/testlet/java/awt/Container/addImpl.java   2011-09-30 13:46:05.000000000 +0200
@@ -233,7 +233,8 @@
     c.setSize(100,100);
     f.add(a);
     f.pack();
-    f.show();
+    f.show();
+
     harness.check(a.isShowing(), true);
     harness.check(c.isShowing(), true);
     harness.check(l.isShowing(), true);
@@ -241,5 +242,8 @@
     harness.check(c.isLightweight(), true);
     harness.check(a.isLightweight(), false);
     harness.check(l.isLightweight(), false);
+
+    // clean up the frame from desktop
+    f.dispose();
   }
 }

However the mentioned test uses its own implementation of EventQueue named DisabledEventQueue. This implementation
"eats" all events, including events sent by X Window system during disposing frame which means that the method
f.dispose() lock up (because the X Window can not cooperate with the frame in both directions).
As a result also DisableEventQueue class should be updated, which is quite easy because we only want to "eat" paint
events, not other events (and this class is not used by other test). Here's proposed fix:

--- mauve/gnu/testlet/java/awt/Container/DisabledEventQueue.java_old    2005-11-02 16:16:38.000000000 +0100
+++ mauve/gnu/testlet/java/awt/Container/DisabledEventQueue.java        2011-09-30 12:51:40.000000000 +0200
@@ -36,7 +36,14 @@
    */
   protected void dispatchEvent(AWTEvent ev)
   {
-    // Do nothing.
+    if (ev instanceof java.awt.event.PaintEvent)
+      {
+        // Do nothing.
+      }
+    else
+      {
+        super.dispatchEvent(ev);
+      }
   }

   /**
@@ -44,6 +51,13 @@
    */
   public void postEvent(AWTEvent ev)
   {
-    // Do nothing.
+    if (ev instanceof java.awt.event.PaintEvent)
+      {
+        // Do nothing.
+      }
+    else
+      {
+        super.postEvent(ev);
+      }
   }
 }

Can anybody please review this change? (it's been tested, of course ;)

Pavel