summaryrefslogtreecommitdiff
path: root/qadevOOo
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-02-14 11:48:22 +0100
committerEike Rathke <erack@redhat.com>2017-02-14 11:49:35 +0100
commitcdbec91da4931be72ed4f1b28f78d83a9a0d616f (patch)
tree85802c20694ea245d33da15c7f2e883529446b09 /qadevOOo
parent8c00536d87010b14a95e9c81f2f5f1d683e5fa70 (diff)
special case TypedItemList in preparation for tdf#79250
Seems a Sequence<Any> property was never supported in the qadevOOo/tests/java/ifc/beans/_XPropertySet.java addPropertyChangeListener() tests, where the property has to be changed in ValueChanger to pass the test. However, simply generally adding a value to an empty sequence does not work as it would break other tests in turn, so special-case it to the TypedItemList property. This is all fubar. Change-Id: If6d0f45c7440e3553dc8bd293dadb21c5fb09bb5
Diffstat (limited to 'qadevOOo')
-rw-r--r--qadevOOo/runner/util/ValueChanger.java69
1 files changed, 40 insertions, 29 deletions
diff --git a/qadevOOo/runner/util/ValueChanger.java b/qadevOOo/runner/util/ValueChanger.java
index ec796aec5757..3905b4485bc3 100644
--- a/qadevOOo/runner/util/ValueChanger.java
+++ b/qadevOOo/runner/util/ValueChanger.java
@@ -28,6 +28,7 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.Array;
import com.sun.star.uno.Any;
import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
public class ValueChanger {
@@ -938,35 +939,45 @@ public class ValueChanger {
} else if (oldValue.getClass().isArray()) {
// changer for arrays : changes all elements
Class<?> arrType = oldValue.getClass().getComponentType();
- newValue = Array.newInstance(arrType, Array.getLength(oldValue));
- for (int i = 0; i < Array.getLength(newValue); i++) {
- if (!arrType.isPrimitive()) {
- Object elem = changePValue(Array.get(oldValue, i));
- Array.set(newValue, i, elem);
- } else {
- if (Boolean.TYPE.equals(arrType)) {
- Array.setBoolean(newValue, i,
- !Array.getBoolean(oldValue, i));
- } else if (Byte.TYPE.equals(arrType)) {
- Array.setByte(newValue, i,
- (byte) (Array.getByte(oldValue, i) + 1));
- } else if (Character.TYPE.equals(arrType)) {
- Array.setChar(newValue, i,
- (char) (Array.getChar(oldValue, i) + 1));
- } else if (Double.TYPE.equals(arrType)) {
- Array.setDouble(newValue, i,
- Array.getDouble(oldValue, i) + 1);
- } else if (Float.TYPE.equals(arrType)) {
- Array.setFloat(newValue, i,
- Array.getFloat(oldValue, i) + 1);
- } else if (Integer.TYPE.equals(arrType)) {
- Array.setInt(newValue, i, Array.getInt(oldValue, i) + 1);
- } else if (Long.TYPE.equals(arrType)) {
- Array.setLong(newValue, i,
- Array.getLong(oldValue, i) + 1);
- } else if (Short.TYPE.equals(arrType)) {
- Array.setShort(newValue, i,
- (short) (Array.getShort(oldValue, i) + 1));
+ int oldLen = Array.getLength(oldValue);
+ if (oldLen == 0 && "TypedItemList".equals(name) && !arrType.isPrimitive()) {
+ // This case is needed to make the Sequence<Any> property pass
+ // the addPropertyChangeListener tests, where the property has
+ // to be changed (and not stay empty ...)
+ newValue = Array.newInstance(arrType, 1);
+ Object elem = new Any(new Type(String.class), "_Any");
+ Array.set(newValue, 0, elem);
+ } else {
+ newValue = Array.newInstance(arrType, oldLen);
+ for (int i = 0; i < Array.getLength(newValue); i++) {
+ if (!arrType.isPrimitive()) {
+ Object elem = changePValue(Array.get(oldValue, i));
+ Array.set(newValue, i, elem);
+ } else {
+ if (Boolean.TYPE.equals(arrType)) {
+ Array.setBoolean(newValue, i,
+ !Array.getBoolean(oldValue, i));
+ } else if (Byte.TYPE.equals(arrType)) {
+ Array.setByte(newValue, i,
+ (byte) (Array.getByte(oldValue, i) + 1));
+ } else if (Character.TYPE.equals(arrType)) {
+ Array.setChar(newValue, i,
+ (char) (Array.getChar(oldValue, i) + 1));
+ } else if (Double.TYPE.equals(arrType)) {
+ Array.setDouble(newValue, i,
+ Array.getDouble(oldValue, i) + 1);
+ } else if (Float.TYPE.equals(arrType)) {
+ Array.setFloat(newValue, i,
+ Array.getFloat(oldValue, i) + 1);
+ } else if (Integer.TYPE.equals(arrType)) {
+ Array.setInt(newValue, i, Array.getInt(oldValue, i) + 1);
+ } else if (Long.TYPE.equals(arrType)) {
+ Array.setLong(newValue, i,
+ Array.getLong(oldValue, i) + 1);
+ } else if (Short.TYPE.equals(arrType)) {
+ Array.setShort(newValue, i,
+ (short) (Array.getShort(oldValue, i) + 1));
+ }
}
}
}