[Libreoffice-commits] core.git: forms/source qadevOOo/runner qadevOOo/tests

Stephan Bergmann sbergman at redhat.com
Tue Jan 13 06:17:48 PST 2015


 forms/source/component/refvaluecomponent.cxx         |   11 +++
 qadevOOo/runner/util/ValueChanger.java               |   17 ++++-
 qadevOOo/tests/java/ifc/beans/_XFastPropertySet.java |   54 +++++++++++--------
 qadevOOo/tests/java/ifc/beans/_XPropertySet.java     |    2 
 4 files changed, 58 insertions(+), 26 deletions(-)

New commits:
commit 7ca657e5eeb883d2a90ef80456f48a7df6e27cba
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 13 15:14:07 2015 +0100

    css.form.component.{CheckBox,RadioButton} DefaultState property values
    
    ...must be in the range 0--2; avoid setting bad values from generic qadevOOo
    property set tests, and throw an IllegalArgumentException if bad values do
    get set.
    
    Change-Id: Ia4a97d0fac326b3ca2ce254946dc4d418e9dd5a7

diff --git a/forms/source/component/refvaluecomponent.cxx b/forms/source/component/refvaluecomponent.cxx
index b3f4afe..0be4706 100644
--- a/forms/source/component/refvaluecomponent.cxx
+++ b/forms/source/component/refvaluecomponent.cxx
@@ -103,8 +103,15 @@ namespace frm
 
         case PROPERTY_ID_DEFAULT_STATE:
         {
-            sal_Int16 nDefaultChecked( (sal_Int16)TRISTATE_FALSE );
-            OSL_VERIFY( _rValue >>= nDefaultChecked );
+            sal_Int16 nDefaultChecked;
+            if (!(_rValue >>= nDefaultChecked) || nDefaultChecked < 0
+                || nDefaultChecked > 2)
+            {
+                throw css::lang::IllegalArgumentException(
+                    ("DefaultState property value must be a SHORT in the range"
+                     " 0--2"),
+                    css::uno::Reference<css::uno::XInterface>(), -1);
+            }
             m_eDefaultChecked = (ToggleState)nDefaultChecked;
             resetNoBroadcast();
         }
diff --git a/qadevOOo/runner/util/ValueChanger.java b/qadevOOo/runner/util/ValueChanger.java
index 87cc2e7..197de43 100644
--- a/qadevOOo/runner/util/ValueChanger.java
+++ b/qadevOOo/runner/util/ValueChanger.java
@@ -32,7 +32,7 @@ import com.sun.star.uno.AnyConverter;
 public class ValueChanger {
 
     // Method to change a Value, thought for properties
-    public static Object changePValue(Object oldValue) {
+    public static Object changePValue(Object oldValue, String name) {
 
         Object newValue = null;
 
@@ -57,8 +57,15 @@ public class ValueChanger {
             long oldlong = ((Long) oldValue).longValue();
             newValue = Long.valueOf(oldlong + 15);
         } else if (oldValue instanceof Short) {
-            short oldshort = ((Short) oldValue).shortValue();
-            newValue = Short.valueOf((short) (oldshort + 1));
+            short n = ((Short) oldValue).shortValue();
+            // css.form.component.{CheckBox,RadioButton} DefaultState properties
+            // must have values in the range 0--2:
+            if ("DefaultState".equals(name) && n == 2) {
+                --n;
+            } else {
+                ++n;
+            }
+            newValue = Short.valueOf(n);
         } else if (oldValue instanceof Byte) {
             byte oldbyte = ((Byte) oldValue).byteValue();
             newValue = Byte.valueOf((byte) (oldbyte + 1));
@@ -1000,6 +1007,10 @@ public class ValueChanger {
 
     } // end of Change PValue
 
+    public static Object changePValue(Object oldValue) {
+        return changePValue(oldValue, null);
+    }
+
     /**
      * Checks if the passed value is the API structure. The value assumed to be
      * a structure if there are no public methods, and all public fields are not
diff --git a/qadevOOo/tests/java/ifc/beans/_XFastPropertySet.java b/qadevOOo/tests/java/ifc/beans/_XFastPropertySet.java
index 925b20e..b0b645a 100644
--- a/qadevOOo/tests/java/ifc/beans/_XFastPropertySet.java
+++ b/qadevOOo/tests/java/ifc/beans/_XFastPropertySet.java
@@ -53,10 +53,24 @@ import com.sun.star.uno.UnoRuntime;
 * @see com.sun.star.beans.XFastPropertySet
 */
 public class _XFastPropertySet extends MultiMethodTest {
+    private static final class Prop {
+        public final int handle;
+        public final String name;
+
+        public Prop() {
+            handle = -1;
+            name = null;
+        }
+
+        public Prop(int handle, String name) {
+            this.handle = handle;
+            this.name = name;
+        }
+    };
 
     public XFastPropertySet oObj = null;
-    private final List<Integer> handles = new ArrayList<Integer>();
-    private int handle = -1;
+    private final List<Prop> props = new ArrayList<Prop>();
+    private Prop prop;
     private Set<String> exclude = null ;
 
     /**
@@ -91,26 +105,26 @@ public class _XFastPropertySet extends MultiMethodTest {
         Object gValue = null;
         Object sValue = null;
 
-        if ( handle == -1) {
+        if ( prop.handle == -1) {
             log.println("*** No changeable properties found ***");
             tRes.tested("setFastPropertyValue()", false) ;
         } else {
             try {
-                gValue = oObj.getFastPropertyValue(handle);
-                sValue = ValueChanger.changePValue(gValue);
-                oObj.setFastPropertyValue(handle, sValue);
-                sValue = oObj.getFastPropertyValue(handle);
+                gValue = oObj.getFastPropertyValue(prop.handle);
+                sValue = ValueChanger.changePValue(gValue, prop.name);
+                oObj.setFastPropertyValue(prop.handle, sValue);
+                sValue = oObj.getFastPropertyValue(prop.handle);
             } catch (com.sun.star.beans.UnknownPropertyException e) {
-                log.println("Exception occurred while trying to change property with handle = " + handle);
+                log.println("Exception occurred while trying to change property with handle = " + prop.handle);
                 e.printStackTrace(log);
             } catch (com.sun.star.lang.WrappedTargetException e) {
-                log.println("Exception occurred while trying to change property with handle = " + handle);
+                log.println("Exception occurred while trying to change property with handle = " + prop.handle);
                 e.printStackTrace(log);
             } catch (com.sun.star.beans.PropertyVetoException e) {
-                log.println("Exception occurred while trying to change property with handle = " + handle);
+                log.println("Exception occurred while trying to change property with handle = " + prop.handle);
                 e.printStackTrace(log);
             }  catch (com.sun.star.lang.IllegalArgumentException e) {
-                log.println("Exception occurred while trying to change property with handle = " + handle);
+                log.println("Exception occurred while trying to change property with handle = " + prop.handle);
                 e.printStackTrace(log);
             }
 
@@ -137,16 +151,16 @@ public class _XFastPropertySet extends MultiMethodTest {
         getPropsToTest(propertySetInfo);
 
         try {
-            oObj.getFastPropertyValue(handle);
+            oObj.getFastPropertyValue(prop.handle);
             tRes.tested("getFastPropertyValue()",true);
         } catch (com.sun.star.beans.UnknownPropertyException e) {
             log.println("Exception occurred while trying to get property '"
-                + handle +"'");
+                + prop.handle +"'");
             e.printStackTrace(log);
             tRes.tested("getFastPropertyValue()",false);
         } catch (com.sun.star.lang.WrappedTargetException e) {
             log.println("Exception occurred while trying to get property '"
-                + handle +"'");
+                + prop.handle +"'");
             e.printStackTrace(log);
             tRes.tested("getFastPropertyValue()",false);
         }
@@ -170,24 +184,24 @@ public class _XFastPropertySet extends MultiMethodTest {
                 ((property.Attributes & PropertyAttribute.MAYBEVOID) == 0);
             boolean canChange = false;
             if ( isWritable && isNotNull )
-                canChange = isChangeable(handle);
+                canChange = isChangeable(handle, name);
             if ( isWritable && isNotNull && canChange)
-                handles.add(Integer.valueOf(handle));
+                props.add(new Prop(handle, name));
         } // endfor
 
         Random rnd = new Random();
-        int nr = rnd.nextInt(handles.size());
-        handle = handles.get(nr).intValue();
+        int nr = rnd.nextInt(props.size());
+        prop = props.get(nr);
     }
 
-    private boolean isChangeable(int handle) {
+    private boolean isChangeable(int handle, String name) {
         boolean hasChanged = false;
         try {
             Object getProp = oObj.getFastPropertyValue(handle);
             Object setValue = null;
 
             if (getProp != null)
-                setValue = ValueChanger.changePValue(getProp);
+                setValue = ValueChanger.changePValue(getProp, name);
             else
                 log.println("Property with handle = " + handle
                     + " is null but 'MAYBEVOID' isn't set");
diff --git a/qadevOOo/tests/java/ifc/beans/_XPropertySet.java b/qadevOOo/tests/java/ifc/beans/_XPropertySet.java
index 630983c..76aac03 100644
--- a/qadevOOo/tests/java/ifc/beans/_XPropertySet.java
+++ b/qadevOOo/tests/java/ifc/beans/_XPropertySet.java
@@ -281,7 +281,7 @@ public class _XPropertySet extends MultiMethodTest {
                 try {
                     log.println("try to change value of property '" + propertyName + "'" );
                     gValue = oObj.getPropertyValue(propertyName);
-                    sValue = ValueChanger.changePValue(gValue);
+                    sValue = ValueChanger.changePValue(gValue, propertyName);
                     oObj.setPropertyValue(propertyName, sValue);
                     sValue = oObj.getPropertyValue(propertyName);
                 } catch (com.sun.star.beans.PropertyVetoException e) {


More information about the Libreoffice-commits mailing list