diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-10-22 12:39:54 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-10-22 12:53:27 +0200 |
commit | c546fbca07b0085f569d72f21ed0b43e4c49e50c (patch) | |
tree | d70ae0ea0d2759bb2bf21dc0f6e9fed7c4c7a375 /qadevOOo | |
parent | eda5f1fca8a8a1ed5c98bb6d7486283cccb08b37 (diff) |
Print content of arrays and UNO structs
Change-Id: Ib585408c26e14b83e896861c2793ff3229dba7d1
Diffstat (limited to 'qadevOOo')
-rw-r--r-- | qadevOOo/runner/lib/MultiPropertyTest.java | 38 | ||||
-rw-r--r-- | qadevOOo/runner/util/ValueChanger.java | 2 |
2 files changed, 38 insertions, 2 deletions
diff --git a/qadevOOo/runner/lib/MultiPropertyTest.java b/qadevOOo/runner/lib/MultiPropertyTest.java index 57a82fff86be..ac17634e03fc 100644 --- a/qadevOOo/runner/lib/MultiPropertyTest.java +++ b/qadevOOo/runner/lib/MultiPropertyTest.java @@ -28,7 +28,10 @@ import com.sun.star.lang.IllegalArgumentException; import com.sun.star.lang.WrappedTargetException; import com.sun.star.uno.UnoRuntime; +import java.lang.reflect.Array; +import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import util.ValueChanger; import util.ValueComparer; @@ -570,6 +573,39 @@ public class MultiPropertyTest extends MultiMethodTest */ protected String toString(Object obj) { - return obj == null ? "null" : obj.toString(); + if (obj == null) { + return "null"; + } + StringBuilder s = new StringBuilder(obj.toString()); + if (obj.getClass().isArray()) { + int n = Array.getLength(obj); + s.append('[').append(n).append("]{"); + for (int i = 0; i != n; ++i) { + if (i != 0) { + s.append(", "); + } + s.append(toString(Array.get(obj, i))); + } + s.append('}'); + } else if (ValueChanger.isStructure(obj)) { + s.append('{'); + Field[] fields = obj.getClass().getFields(); + boolean first = true; + for (int i = 0; i != fields.length; ++i) { + if ((fields[i].getModifiers() & Modifier.STATIC) == 0) { + if (!first) { + s.append(", "); + } + first = false; + try { + s.append(toString(fields[i].get(obj))); + } catch (IllegalAccessException e) { + throw new RuntimeException("unexpected " + e, e); + } + } + } + s.append('}'); + } + return s.toString(); } } diff --git a/qadevOOo/runner/util/ValueChanger.java b/qadevOOo/runner/util/ValueChanger.java index 14e10f97f326..f901a595beec 100644 --- a/qadevOOo/runner/util/ValueChanger.java +++ b/qadevOOo/runner/util/ValueChanger.java @@ -1036,7 +1036,7 @@ public class ValueChanger { * the value to be checked. * @return <code>true</code> if the value is assumed to be a structure. */ - private static boolean isStructure(Object val) { + public static boolean isStructure(Object val) { boolean result = true; Class<?> clazz = val.getClass(); |