From 2bd65db15fa6a265ccc4023161611088bc791b4e Mon Sep 17 00:00:00 2001 From: Deepanshu Gupta Date: Tue, 15 Apr 2014 19:30:35 -0700 Subject: [PATCH] Layoutlib tests now check methods return value [DO NOT MERGE] The change is a cherry-pick from klp-dev. The change also fixes the errors found by fixing the tests. Change-Id: I87cef323c4eaee4e9f60475f01156b276593fa50 (cherry-picked from commit 89fdc0c556cf0fe2562fb8f0476e03cd51045164) --- .../bridge/src/android/graphics/Bitmap_Delegate.java | 3 ++- .../src/com/android/layoutlib/bridge/TestDelegates.java | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java index 96616aaeca4fb..9c7a0ccec9b8a 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java @@ -253,8 +253,9 @@ public final class Bitmap_Delegate { } @LayoutlibDelegate - /*package*/ static void nativeRecycle(int nativeBitmap) { + /*package*/ static boolean nativeRecycle(int nativeBitmap) { sManager.removeJavaReferenceFor(nativeBitmap); + 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 d3218dbd5bd3d..7c0bc84218d56 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 @@ -129,6 +129,15 @@ public class TestDelegates extends TestCase { originalClass.getName()), delegateMethod.getAnnotation(LayoutlibDelegate.class)); + // 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 is static assertTrue( String.format(