harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r495719 - in /harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing: JComponentTest.java RepaintManagerTest.java
Date Fri, 12 Jan 2007 20:19:31 GMT
Author: hindessm
Date: Fri Jan 12 12:19:30 2007
New Revision: 495719

URL: http://svn.apache.org/viewvc?view=rev&rev=495719
Log:
Applied patches from "[#HARMONY-2380] [classlib][swing] Tests for
RepaintManager.addInvalidComponent()/RepaintManager.removeInvalidComponent()
should be provided".

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JComponentTest.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RepaintManagerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JComponentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JComponentTest.java?view=diff&rev=495719&r1=495718&r2=495719
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JComponentTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JComponentTest.java
Fri Jan 12 12:19:30 2007
@@ -2316,6 +2316,20 @@
         assertTrue(button.isValid());
         button.revalidate();
         assertFalse(button.isValid());
+
+        frame.getRootPane().validate();
+        assertTrue(button.isValid());
+
+        final Marker rm = new Marker();
+        RepaintManager.setCurrentManager(new RepaintManager() {
+            public void addInvalidComponent(final JComponent invalidComponent) {
+                rm.setAuxiliary(invalidComponent);
+            }
+        });
+        button.revalidate();
+        assertFalse(button.isValid());
+        assertSame(button, rm.getAuxiliary());
+
         frame.dispose();
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RepaintManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RepaintManagerTest.java?view=diff&rev=495719&r1=495718&r2=495719
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RepaintManagerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/RepaintManagerTest.java
Fri Jan 12 12:19:30 2007
@@ -24,6 +24,7 @@
 import java.awt.Button;
 import java.awt.Dimension;
 import java.awt.EventQueue;
+import java.awt.Frame;
 import java.awt.Graphics;
 import java.awt.Image;
 import java.awt.Rectangle;
@@ -72,35 +73,95 @@
         assertNotNull(RepaintManager.currentManager(null));
     }
 
-    public void testAddInvalidComponent() throws Exception {
-        if (!isHarmony()) {
-            return;
-        }
-        JPanel root = new JPanel() {
-            private static final long serialVersionUID = 1L;
-
-            @Override
-            public boolean isValidateRoot() {
-                return true;
-            }
-        };
-        final Marker marker = new Marker();
-        JPanel inner = new JPanel() {
-            private static final long serialVersionUID = 1L;
-
-            @Override
-            public void validate() {
-                super.validate();
-                marker.setOccurred();
-            }
-        };
-        JFrame f = new JFrame();
-        f.getContentPane().add(root);
-        root.add(inner);
+    public void testAddRemoveInvalidComponent() throws Exception {
+        Frame f = new Frame();
+        final JPanel rootPanel = new JPanel(new BorderLayout()) {
+                private static final long serialVersionUID = 1L;
+                
+                @Override
+                    public boolean isValidateRoot() {
+                    return true;
+                }
+            };
+        final JPanel controlled = new JPanel();
+        f.add(rootPanel);
+        rootPanel.add(controlled);
+        
+        assertFalse(controlled.isValid());
+        assertFalse(rootPanel.isValid());
+        SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    RepaintManager.currentManager(null).addInvalidComponent(controlled);
+                }
+            });
+        
+        final Marker isValid = new Marker();
+        SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    isValid.setOccurred(controlled.isValid());
+                }
+            });
+        assertFalse(isValid.isOccurred());
+        
         f.setVisible(true);
-        RepaintManager.currentManager(null).addInvalidComponent(inner);
         waitForIdle();
-        assertTrue(marker.isOccurred());
+        assertTrue(controlled.isValid());
+        SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    RepaintManager.currentManager(null).addInvalidComponent(controlled);
+                }
+            });
+        assertTrue(controlled.isValid());
+        assertTrue(rootPanel.isValid());
+        
+        isValid.reset();
+        controlled.invalidate();
+        waitForIdle();
+        assertFalse(controlled.isValid());
+        SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    RepaintManager.currentManager(null).addInvalidComponent(controlled);
+                }
+            });
+        SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    isValid.setOccurred(controlled.isValid());
+                }
+            });
+        assertTrue(isValid.isOccurred());
+        
+        isValid.reset();
+        controlled.invalidate();
+        assertFalse(controlled.isValid());
+        SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    RepaintManager.currentManager(null).addInvalidComponent(controlled);
+                    RepaintManager.currentManager(null).removeInvalidComponent(controlled);
+                }
+            });
+        SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    isValid.setOccurred(controlled.isValid());
+                }
+            });
+        assertTrue(isValid.isOccurred());
+        
+        isValid.reset();
+        controlled.invalidate();
+        assertFalse(controlled.isValid());
+        SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    RepaintManager.currentManager(null).addInvalidComponent(controlled);
+                    RepaintManager.currentManager(null).removeInvalidComponent(rootPanel);
+                }
+            });
+        SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    isValid.setOccurred(controlled.isValid());
+                }
+            });
+        assertFalse(isValid.isOccurred());
+        
         try { // Regression test for HARMONY-1725
             RepaintManager.currentManager(null).addInvalidComponent(null);
         } catch (NullPointerException e) {
@@ -109,10 +170,8 @@
     }
 
     public void testValidateInvalidComponents() throws Exception {
-        if (!isHarmony()) {
-            return;
-        }
-        JPanel root = new JPanel() {
+        Frame f = new Frame();
+        final JPanel rootPanel = new JPanel(new BorderLayout()) {
             private static final long serialVersionUID = 1L;
 
             @Override
@@ -120,24 +179,38 @@
                 return true;
             }
         };
-        final Marker marker = new Marker();
-        JPanel inner = new JPanel() {
-            private static final long serialVersionUID = 1L;
+        final JPanel controlled = new JPanel();
+        f.add(rootPanel);
+        rootPanel.add(controlled);
 
-            @Override
-            public void validate() {
-                super.validate();
-                marker.setOccurred();
-            }
-        };
-        JFrame f = new JFrame();
-        f.getContentPane().add(root);
-        root.add(inner);
         f.setVisible(true);
-        RepaintManager.currentManager(null).addInvalidComponent(inner);
-        RepaintManager.currentManager(null).validateInvalidComponents();
-        assertTrue(marker.isOccurred());
+        waitForIdle();
+        assertTrue(controlled.isValid());
+        controlled.invalidate();
+        assertFalse(controlled.isValid());
+        final Marker isValid = new Marker();
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                RepaintManager.currentManager(null).addInvalidComponent(controlled);
+                RepaintManager.currentManager(null).validateInvalidComponents();
+                isValid.setOccurred(controlled.isValid());
+            }
+        });
+        assertTrue(isValid.isOccurred());
+
         f.dispose();
+        isValid.reset();
+        controlled.invalidate();
+        assertFalse(controlled.isValid());
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                RepaintManager.currentManager(null).addInvalidComponent(controlled);
+                RepaintManager.currentManager(null).removeInvalidComponent(rootPanel);
+                RepaintManager.currentManager(null).validateInvalidComponents();
+                isValid.setOccurred(controlled.isValid());
+            }
+        });
+        assertFalse(isValid.isOccurred());
     }
 
     public void testAddDirtyRegion() throws Exception {



Mime
View raw message