You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ap...@apache.org on 2007/01/30 18:30:26 UTC

svn commit: r501480 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/ScrollPaneLayout.java test/api/java/common/javax/swing/ScrollPaneLayoutTest.java

Author: apetrenko
Date: Tue Jan 30 09:30:24 2007
New Revision: 501480

URL: http://svn.apache.org/viewvc?view=rev&rev=501480
Log:
Patch for HARMONY-1737 "[classlib][swing] javax.swing.ScrollPaneLayout.setHorisontalScrollBarPolicy(int) does not throw specified IllegalArgumentException"

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ScrollPaneLayout.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ScrollPaneLayoutTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ScrollPaneLayout.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ScrollPaneLayout.java?view=diff&rev=501480&r1=501479&r2=501480
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ScrollPaneLayout.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/ScrollPaneLayout.java Tue Jan 30 09:30:24 2007
@@ -30,6 +30,7 @@
 import java.awt.Rectangle;
 import java.io.Serializable;
 
+import javax.swing.ScrollPaneConstants;
 import javax.swing.border.Border;
 
 public class ScrollPaneLayout implements Serializable, LayoutManager, ScrollPaneConstants {
@@ -119,6 +120,13 @@
     }
 
     public void setVerticalScrollBarPolicy(final int x) {
+        boolean isVertical = ((x == ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED)
+                | (x == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) 
+                | (x == ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER));
+        if (!isVertical) {
+            throw new IllegalArgumentException(
+                    "invalid verticalScrollBarPolicy");
+        }
         vsbPolicy = x;
     }
 
@@ -127,6 +135,13 @@
     }
 
     public void setHorizontalScrollBarPolicy(final int x) {
+        boolean isHorisontal = ((x == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED)
+                | (x == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) 
+                | (x == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS));
+        if (!isHorisontal) {
+            throw new IllegalArgumentException(
+                    "invalid horizontalScrollBarPolicy");
+        }
         hsbPolicy = x;
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ScrollPaneLayoutTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ScrollPaneLayoutTest.java?view=diff&rev=501480&r1=501479&r2=501480
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ScrollPaneLayoutTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/ScrollPaneLayoutTest.java Tue Jan 30 09:30:24 2007
@@ -98,6 +98,13 @@
         layout.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
         assertEquals(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, layout
                 .getHorizontalScrollBarPolicy());
+        // regression 1 for HARMONY-1737
+        try{
+            layout.setHorizontalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
+            fail("No expected IllegalArgumentException");
+        }catch(IllegalArgumentException e){
+         //expected 
+        }
     }
 
     public void testSetVerticalPolicy() throws Exception {
@@ -110,6 +117,13 @@
         layout.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
         assertEquals(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, layout
                 .getVerticalScrollBarPolicy());
+        // regression 2 for HARMONY-1737
+        try{
+            layout.setVerticalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+            fail("No expected IllegalArgumentException");
+        }catch(IllegalArgumentException e){
+        //expected 
+        } 
     }
 
     public void testGetViewport() throws Exception {