harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r502197 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/JSlider.java test/api/java/common/javax/swing/JSliderTest.java
Date Thu, 01 Feb 2007 11:30:39 GMT
Author: ayza
Date: Thu Feb  1 03:30:38 2007
New Revision: 502197

URL: http://svn.apache.org/viewvc?view=rev&rev=502197
Log:
Applying patch from HARMONY-2535 ([classlib][swing] JSlider(int) expected IAE if orientation
is invalid)

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

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JSlider.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JSlider.java?view=diff&rev=502197&r1=502196&r2=502197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JSlider.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JSlider.java
Thu Feb  1 03:30:38 2007
@@ -116,12 +116,16 @@
     }
 
     public JSlider(final int orientation, final int min, final int max, final int value)
{
-        this(new DefaultBoundedRangeModel(value, 0, min, max));
-        this.orientation = orientation;
+        this(checkOrientation(orientation),
+             new DefaultBoundedRangeModel(value, 0, min, max));
     }
 
     public JSlider(final BoundedRangeModel brm) {
-        this.orientation = HORIZONTAL;
+        this(HORIZONTAL, brm);
+    }
+
+    private JSlider(final int orientation, final BoundedRangeModel brm) {
+        this.orientation = orientation;
         sliderModel = brm;
 
         modelChangeHandler = createChangeListener();
@@ -130,6 +134,13 @@
         eventListenerList = new EventListenerList();
 
         updateUI();
+    }
+
+    private static int checkOrientation(final int orientation) {
+        if (orientation != VERTICAL && orientation != HORIZONTAL) {
+            throw new IllegalArgumentException("orientation must be one of: VERTICAL, HORIZONTAL");
+        }
+        return orientation;
     }
 
     public SliderUI getUI() {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JSliderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JSliderTest.java?view=diff&rev=502197&r1=502196&r2=502197
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JSliderTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JSliderTest.java
Thu Feb  1 03:30:38 2007
@@ -42,6 +42,13 @@
         m.setValueIsAdjusting(true);
         slider = new JSlider(m);
         assertTrue(m == slider.getModel());
+
+        try { // Regression test for HARMONY-2535
+            new JSlider(2);
+            fail("IllegalArgumentException should have been thrown");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        }
     }
 
     public void testCreateChangeListener() throws Exception {



Mime
View raw message