harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r548685 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/plaf/basic/BasicButtonUI.java test/api/java.injected/javax/swing/plaf/basic/BasicButtonUITest.java
Date Tue, 19 Jun 2007 10:38:22 GMT
Author: odeakin
Date: Tue Jun 19 03:38:21 2007
New Revision: 548685

URL: http://svn.apache.org/viewvc?view=rev&rev=548685
Log:
Apply patch HARMONY-4223 ([[classlib][swing] setTextShiftOffset getTextShiftOffset and clearTextShiftOffset
methods in BasicButtonUI are unimplemented in Harmony)

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicButtonUI.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicButtonUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicButtonUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicButtonUI.java?view=diff&rev=548685&r1=548684&r2=548685
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicButtonUI.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicButtonUI.java
Tue Jun 19 03:38:21 2007
@@ -49,6 +49,8 @@
     protected int defaultTextIconGap;
 
     protected int defaultTextShiftOffset;
+    
+    private int textShiftOffset = 0;
 
     private Color focusColor;
     private Color disabledTextColor;
@@ -120,8 +122,8 @@
         final AbstractButton b = (AbstractButton)c;
         final Color color = b.isEnabled() ? b.getForeground() : disabledTextColor;
 
-        final int textShiftOffset = getTextShiftOffset();
-        textRect.translate(textShiftOffset, textShiftOffset);
+        final int currentTextShiftOffset = getTextShiftOffset();
+        textRect.translate(currentTextShiftOffset, currentTextShiftOffset);
         ButtonCommons.paintText(g, b, textRect, text, color);
     }
 
@@ -199,13 +201,15 @@
     }
 
     protected void setTextShiftOffset() {
+        textShiftOffset = defaultTextShiftOffset;
     }
 
     protected void clearTextShiftOffset() {
+        textShiftOffset = 0;
     }
 
     protected int getTextShiftOffset() {
-        return 0;
+        return textShiftOffset;
     }
 
     private boolean isFocusPainted(final AbstractButton button) {
@@ -224,4 +228,5 @@
         return null;
     }
 }
+
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicButtonUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicButtonUITest.java?view=diff&rev=548685&r1=548684&r2=548685
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicButtonUITest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicButtonUITest.java
Tue Jun 19 03:38:21 2007
@@ -354,17 +354,27 @@
         assertEquals("prefix", "Button.", ui.getPropertyPrefix());
     }
 
-    public void testSetTextShiftOffset() {
-    }
+    /**
+     * The test verifies that getTextShiftOffset methods returns
+     * Button.textShiftOffset property if the setTextShiftOffset method is
+     * called and returns 0 if the clearTextShiftOffset method is called
+     */
+    @SuppressWarnings( { "boxing", "nls" })
+    public void testTextShiftOffest() {
 
-    public void testClearTextShiftOffset() {
-        ui.defaultTextShiftOffset = 100;
-        ui.clearTextShiftOffset();
-        assertEquals(100, ui.defaultTextShiftOffset);
-    }
+        int oldTextShiftOffset = UIManager.getInt("Button.textShiftOffset");
 
-    public void testGetTextShiftOffset() {
-        ui.defaultTextShiftOffset = 100;
-        assertEquals("offset", 0, ui.getTextShiftOffset());
+        UIManager.put("Button.textShiftOffset", 5);
+
+        BasicButtonUI currentUI = new BasicButtonUI();
+        currentUI.installUI(new JButton());
+
+        assertEquals(currentUI.getTextShiftOffset(), 0);
+        currentUI.setTextShiftOffset();
+        assertEquals(currentUI.getTextShiftOffset(), 5);
+        currentUI.clearTextShiftOffset();
+        assertEquals(currentUI.getTextShiftOffset(), 0);
+
+        UIManager.put("Button.textShiftOffset", oldTextShiftOffset);
     }
 }



Mime
View raw message