summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDeepanshu Gupta <deepanshu@google.com>2014-02-21 16:22:10 -0800
committerDeepanshu Gupta <deepanshu@google.com>2014-02-21 16:22:10 -0800
commit9be03c4e980d3058aeb3fd730da5f7d4a4a4f8a8 (patch)
tree49e610c9e45c65eb2337b30bd69489f8589a9a42 /tools
parentdc8d7db35aae71ea747457cc1073fe8d60a8b277 (diff)
downloadframeworks_base-9be03c4e980d3058aeb3fd730da5f7d4a4a4f8a8.zip
frameworks_base-9be03c4e980d3058aeb3fd730da5f7d4a4a4f8a8.tar.gz
frameworks_base-9be03c4e980d3058aeb3fd730da5f7d4a4a4f8a8.tar.bz2
Update layoutlib tests to check methods return value.
The test in layoutlib bridge has been updated to check the return value of the delegate method match the value of the overriden method. This changeset also fixes the problems found due to this change. Change-Id: I87cef323c4eaee4e9f60475f01156b276593fa50
Diffstat (limited to 'tools')
-rw-r--r--tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java4
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java8
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java18
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java2
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java7
-rw-r--r--tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/TestDelegates.java9
6 files changed, 28 insertions, 20 deletions
diff --git a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java
index ca710cd..4603b63 100644
--- a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java
@@ -48,14 +48,14 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
}
@LayoutlibDelegate
- /*package*/ static int nGetMultipleIntMethod(Class<?> targetClass, String methodName,
+ /*package*/ static long nGetMultipleIntMethod(Class<?> targetClass, String methodName,
int numParams) {
// TODO: return the right thing.
return 0;
}
@LayoutlibDelegate
- /*package*/ static int nGetMultipleFloatMethod(Class<?> targetClass, String methodName,
+ /*package*/ static long nGetMultipleFloatMethod(Class<?> targetClass, String methodName,
int numParams) {
// TODO: return the right thing.
return 0;
diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
index 1cc8ea5..bb05d45 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
@@ -344,7 +344,7 @@ public final class Canvas_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_saveLayer(long nativeCanvas, RectF bounds,
+ /*package*/ static int native_saveLayer(long nativeCanvas, RectF bounds,
long paint, int layerFlags) {
// get the delegate from the native int.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
@@ -361,7 +361,7 @@ public final class Canvas_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_saveLayer(long nativeCanvas, float l,
+ /*package*/ static int native_saveLayer(long nativeCanvas, float l,
float t, float r, float b,
long paint, int layerFlags) {
// get the delegate from the native int.
@@ -380,7 +380,7 @@ public final class Canvas_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_saveLayerAlpha(long nativeCanvas,
+ /*package*/ static int native_saveLayerAlpha(long nativeCanvas,
RectF bounds, int alpha,
int layerFlags) {
// get the delegate from the native int.
@@ -393,7 +393,7 @@ public final class Canvas_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_saveLayerAlpha(long nativeCanvas, float l,
+ /*package*/ static int native_saveLayerAlpha(long nativeCanvas, float l,
float t, float r, float b,
int alpha, int layerFlags) {
// get the delegate from the native int.
diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
index 7007b71..de2e592 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
@@ -688,7 +688,7 @@ public class Paint_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_getStyle(long native_object) {
+ /*package*/ static int native_getStyle(long native_object) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -710,7 +710,7 @@ public class Paint_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_getStrokeCap(long native_object) {
+ /*package*/ static int native_getStrokeCap(long native_object) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -732,7 +732,7 @@ public class Paint_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_getStrokeJoin(long native_object) {
+ /*package*/ static int native_getStrokeJoin(long native_object) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -889,7 +889,7 @@ public class Paint_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_getTextAlign(long native_object) {
+ /*package*/ static int native_getTextAlign(long native_object) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
if (delegate == null) {
@@ -922,7 +922,7 @@ public class Paint_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_getTextWidths(long native_object, char[] text, int index,
+ /*package*/ static int native_getTextWidths(long native_object, char[] text, int index,
int count, int bidiFlags, float[] widths) {
// get the delegate from the native int.
Paint_Delegate delegate = sManager.getDelegate(native_object);
@@ -964,14 +964,14 @@ public class Paint_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_getTextWidths(long native_object, String text, int start,
+ /*package*/ static int native_getTextWidths(long native_object, String text, int start,
int end, int bidiFlags, float[] widths) {
return native_getTextWidths(native_object, text.toCharArray(), start, end - start,
bidiFlags, widths);
}
@LayoutlibDelegate
- /* package */static long native_getTextGlyphs(long native_object, String text, int start,
+ /* package */static int native_getTextGlyphs(long native_object, String text, int start,
int end, int contextStart, int contextEnd, int flags, char[] glyphs) {
// FIXME
return 0;
@@ -1012,7 +1012,7 @@ public class Paint_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_getTextRunCursor(Paint thisPaint, long native_object, char[] text,
+ /*package*/ static int native_getTextRunCursor(Paint thisPaint, long native_object, char[] text,
int contextStart, int contextLength, int flags, int offset, int cursorOpt) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
@@ -1021,7 +1021,7 @@ public class Paint_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_getTextRunCursor(Paint thisPaint, long native_object, String text,
+ /*package*/ static int native_getTextRunCursor(Paint thisPaint, long native_object, String text,
int contextStart, int contextEnd, int flags, int offset, int cursorOpt) {
// FIXME
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
diff --git a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java
index 77468ec..6666385 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java
@@ -142,7 +142,7 @@ public final class Path_Delegate {
}
@LayoutlibDelegate
- /*package*/ static long native_getFillType(long nPath) {
+ /*package*/ static int native_getFillType(long nPath) {
Path_Delegate pathDelegate = sManager.getDelegate(nPath);
if (pathDelegate == null) {
return 0;
diff --git a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java
index ea23649..edb7025 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Region_Delegate.java
@@ -275,21 +275,20 @@ public class Region_Delegate {
}
@LayoutlibDelegate
- /*package*/ static boolean nativeSetRegion(long native_dst, long native_src) {
+ /*package*/ static void nativeSetRegion(long native_dst, long native_src) {
Region_Delegate dstRegion = sManager.getDelegate(native_dst);
if (dstRegion == null) {
- return true;
+ return;
}
Region_Delegate srcRegion = sManager.getDelegate(native_src);
if (srcRegion == null) {
- return true;
+ return;
}
dstRegion.mArea.reset();
dstRegion.mArea.add(srcRegion.mArea);
- return true;
}
@LayoutlibDelegate
diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/TestDelegates.java b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/TestDelegates.java
index d3218db..274516c 100644
--- a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/TestDelegates.java
+++ b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/TestDelegates.java
@@ -121,6 +121,15 @@ public class TestDelegates extends TestCase {
Method delegateMethod = delegateClass.getDeclaredMethod(originalMethod.getName(),
parameters);
+ // check the return type of the methods match.
+ assertTrue(
+ String.format("Delegate method %1$s.%2$s does not match the corresponding " +
+ "framework method which returns %3$s",
+ delegateClass.getName(),
+ getMethodName(delegateMethod),
+ originalMethod.getReturnType().getName()),
+ delegateMethod.getReturnType() == originalMethod.getReturnType());
+
// check that the method has the annotation
assertNotNull(
String.format(