harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r573239 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/ test/api/java.injected/javax/swing/ test/api/java.injected/javax/swing/plaf/basic/
Date Thu, 06 Sep 2007 12:10:27 GMT
Author: ayza
Date: Thu Sep  6 05:10:26 2007
New Revision: 573239

URL: http://svn.apache.org/viewvc?rev=573239&view=rev
Log:
The patch from HARMONY-4655 was applied ([classlib][swing]Setting null as margin to button
don't cause to use the default margin)

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/AbstractButton.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/AbstractButtonTest.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuItemUITest.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/AbstractButton.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/AbstractButton.java?rev=573239&r1=573238&r2=573239&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/AbstractButton.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/AbstractButton.java
Thu Sep  6 05:10:26 2007
@@ -45,6 +45,8 @@
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import javax.swing.plaf.ButtonUI;
+import javax.swing.plaf.InsetsUIResource;
+import javax.swing.plaf.UIResource;
 import javax.swing.text.AttributeSet;
 
 import org.apache.harmony.x.swing.ButtonCommons;
@@ -367,6 +369,8 @@
     private int mnemonicIndex = -1;
 
     private long multiClickThreshhold;
+    
+    private InsetsUIResource defaultMargin;
 
     protected void init(String text, Icon icon) {
         if (text != null) {
@@ -707,6 +711,17 @@
     }
 
     public void setMargin(Insets margin) {
+
+        /* default values are obtained from UI (Harmony-4655) */
+        if (margin instanceof InsetsUIResource) {
+            defaultMargin = (InsetsUIResource) margin;
+        } else if (margin == null) {
+            /*
+             * According to spec if margin == null default value sets
+             * (Harmony-4655)
+             */
+            margin = defaultMargin;
+        }
         Insets oldValue = this.margin;
         this.margin = margin;
         firePropertyChange(MARGIN_CHANGED_PROPERTY, oldValue, margin);

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/AbstractButtonTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/AbstractButtonTest.java?rev=573239&r1=573238&r2=573239&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/AbstractButtonTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/AbstractButtonTest.java
Thu Sep  6 05:10:26 2007
@@ -2067,6 +2067,23 @@
             assertEquals(name, listener.eventHappened.getActionCommand());
         }
     }
+    
+    /**
+     * Regression test for H4655: setMargin(null) causes to default margin
+     * */
+    public void testH4655() {
+
+        JRadioButton rb = new JRadioButton();
+        Insets newInsets = new Insets(10, 10, 10, 10);
+        Insets defaultInsets = rb.getMargin();
+
+        rb.setMargin(null);
+        assertEquals(defaultInsets, rb.getMargin());
+        rb.setMargin(newInsets);
+        assertEquals(newInsets, rb.getMargin());
+        rb.setMargin(null);
+        assertEquals(defaultInsets, rb.getMargin());
+    }
 
     protected int find(final Object[] array, final Object value) {
         int found = 0;

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuItemUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuItemUITest.java?rev=573239&r1=573238&r2=573239&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuItemUITest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuItemUITest.java
Thu Sep  6 05:10:26 2007
@@ -223,7 +223,9 @@
         assertNull(item.getForeground());
         assertNull(item.getFont());
         assertNull(item.getBorder());
-        assertNull(item.getMargin());
+        // Assertion below has been deleted because now we are compartible with
+        // RI in this point. For details see HARMONY-4655
+        // assertNull(item.getMargin());
         assertEquals(4, menuItemUI.defaultTextIconGap);
         if (isHarmony()) {
             assertFalse(menuItemUI.oldBorderPainted);

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuUITest.java?rev=573239&r1=573238&r2=573239&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuUITest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/plaf/basic/BasicMenuUITest.java
Thu Sep  6 05:10:26 2007
@@ -160,7 +160,9 @@
         assertNull(menu.getForeground());
         assertNull(menu.getFont());
         assertNull(menu.getBorder());
-        assertNull(menu.getMargin());
+        // Assertion below has been deleted because now we are compartible with
+        // RI in this point. For details see HARMONY-4655
+        // assertNull(menu.getMargin());
         assertEquals(4, menuUI.defaultTextIconGap);
         assertTrue(menuUI.oldBorderPainted);
         assertEquals(Color.cyan, menuUI.acceleratorForeground);



Mime
View raw message