harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r507046 - in /harmony/enhanced/classlib/trunk/modules/awt: make/ src/main/java/common/java/awt/ src/test/api/java/common/java/awt/
Date Tue, 13 Feb 2007 15:24:59 GMT
Author: apetrenko
Date: Tue Feb 13 07:24:57 2007
New Revision: 507046

URL: http://svn.apache.org/viewvc?view=rev&rev=507046
Log:
Patch for HARMONY-1605 "[classlib][awt]Compatibility: java.awt.Window has null default Font
on RI while it hasn't on Harmony"
ComponentTest removed from exclude list.

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/make/exclude.common
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Button.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Label.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Window.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ComponentTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/make/exclude.common?view=diff&rev=507046&r1=507045&r2=507046
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/make/exclude.common (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/make/exclude.common Tue Feb 13 07:24:57 2007
@@ -19,7 +19,6 @@
 java/awt/ButtonRTest.java
 java/awt/CardLayoutTest.java
 java/awt/ChoiceTest.java
-java/awt/ComponentTest.java
 java/awt/ContainerOrderFocusTraversalPolicyTest.java
 java/awt/DialogRTest.java
 java/awt/ListTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Button.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Button.java?view=diff&rev=507046&r1=507045&r2=507046
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Button.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Button.java
Tue Feb 13 07:24:57 2007
@@ -186,11 +186,6 @@
         }
     }
 
-    @Override
-    boolean hasDefaultFont() {
-        return true;
-    }
-
     public String getLabel() {
         toolkit.lockAWT();
         try {

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java?view=diff&rev=507046&r1=507045&r2=507046
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java
Tue Feb 13 07:24:57 2007
@@ -2960,17 +2960,12 @@
     public Font getFont() {
         toolkit.lockAWT();
         try {
-            if (font == null && hasDefaultFont()) {
-                return toolkit.getDefaultFont();
-            }
-            if (font == null && parent != null) {
-                return parent.getFont();
-            }
-            return font;
+            return (font == null) && (parent != null) ? parent.getFont() : font;
         } finally {
             toolkit.unlockAWT();
         }
     }
+    
 
     public void setFont(Font f) {
         Font oldFont;
@@ -2992,9 +2987,6 @@
         }
     }
 
-    boolean hasDefaultFont() {
-        return false;
-    }
 
     /**
      * Invalidate the component if it inherits the font from the parent. This

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java?view=diff&rev=507046&r1=507045&r2=507046
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java Tue
Feb 13 07:24:57 2007
@@ -75,6 +75,8 @@
     public static final int LAYOUT_NO_START_CONTEXT = 2;
 
     public static final int LAYOUT_NO_LIMIT_CONTEXT = 4;
+    
+    static final Font DEFAULT_FONT = new Font("Dialog", Font.PLAIN, 12); //$NON-NLS-1$
 
     protected String name;
 
@@ -353,17 +355,17 @@
         // as the delimiter to avoid unexpected parse results of font face names 
         // with spaces.
         
+        if (str == null) {
+            return DEFAULT_FONT;
+        }
+        
         StringTokenizer strTokens;
         String delim = "-"; //$NON-NLS-1$
         String substr;
 
-        int fontSize = 12;
-        int fontStyle = Font.PLAIN;
-        String fontName = "dialog"; //$NON-NLS-1$
-
-        if (str == null) {
-            return new Font(fontName, fontStyle, fontSize);
-        }
+        int fontSize = DEFAULT_FONT.size;
+        int fontStyle = DEFAULT_FONT.style;
+        String fontName = DEFAULT_FONT.name;
 
         strTokens = new StringTokenizer(str.trim(), delim);
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Label.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Label.java?view=diff&rev=507046&r1=507045&r2=507046
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Label.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Label.java Tue
Feb 13 07:24:57 2007
@@ -273,11 +273,6 @@
     }
 
     @Override
-    boolean hasDefaultFont() {
-        return true;
-    }
-
-    @Override
     AccessibleContext createAccessibleContext() {
         return new AccessibleAWTLabel();
     }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Window.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Window.java?view=diff&rev=507046&r1=507045&r2=507046
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Window.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Window.java
Tue Feb 13 07:24:57 2007
@@ -539,6 +539,11 @@
             } else {
                 disposed = false;
             }
+            
+            if (getFont() == null) {
+                setFont(Font.DEFAULT_FONT);
+            }
+            
             super.show();
             toFront();
             if (!opened) {

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ComponentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ComponentTest.java?view=diff&rev=507046&r1=507045&r2=507046
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ComponentTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/ComponentTest.java
Tue Feb 13 07:24:57 2007
@@ -338,6 +338,37 @@
         assertTrue(tc.areFocusTraversalKeysSet(id));
 
     }
+    
+    public void testGetFont() {
+        // Regression for HARMONY-1605
+        final Font defaultFont = new Font("Dialog", Font.PLAIN, 12); //$NON-NLS-1$
+        final Window w = new Window(new Frame());
+        final Component c = tc;
+        final Button b = new Button();
+
+        assertNull(w.getFont());
+        assertNull(c.getFont());
+        w.add(c);
+        assertNull(c.getFont());
+        w.setVisible(true);
+        assertEquals(defaultFont, w.getFont());
+        assertEquals(defaultFont, c.getFont());
+
+        assertNull(b.getFont());
+        b.setVisible(true);
+        assertNull(b.getFont());
+        b.setVisible(false);
+        b.setVisible(true);
+        assertNull(b.getFont());
+        new Frame().add(b);
+        assertNull(b.getFont());
+        w.add(b);
+        assertEquals(defaultFont, b.getFont());
+
+        w.setVisible(false);
+        w.dispose();
+        // End of regression for HARMONY-1605
+    }
 
     private void createRobot() {
         try {



Mime
View raw message