From 3aa800b9f93a99d6f25623ed24ab5f6fec213c15 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Tue, 24 Apr 2012 13:01:34 +0100 Subject: Add tests for reflection and improve JavaDoc for Java Bridge Bug: 5461416 Change-Id: Ic339b97a9424d8848f8afd47ba00cbbee4d60c9d --- .../android/webviewtests/JavaBridgeBasicsTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/WebViewTests') diff --git a/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeBasicsTest.java b/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeBasicsTest.java index c9bbb77..07d7c34 100644 --- a/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeBasicsTest.java +++ b/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeBasicsTest.java @@ -393,4 +393,23 @@ public class JavaBridgeBasicsTest extends JavaBridgeTestBase { // LIVECONNECT_COMPLIANCE: Should be able to enumerate members. assertEquals("", mTestController.waitForStringValue()); } + + // java.lang.reflect only allows access to public methods and fields. See b/6386557. + public void testReflectPublicMethod() throws Throwable { + injectObjectAndReload(new Object() { + public String method() { return "foo"; } + }, "testObject"); + assertEquals("foo", executeJavaScriptAndGetStringResult( + "testObject.getClass().getMethod('method', null).invoke(testObject, null)" + + ".toString()")); + } + + // java.lang.reflect only allows access to public methods and fields. See b/6386557. + public void testReflectPublicField() throws Throwable { + injectObjectAndReload(new Object() { + public String field = "foo"; + }, "testObject"); + assertEquals("foo", executeJavaScriptAndGetStringResult( + "testObject.getClass().getField('field').get(testObject).toString()")); + } } -- cgit v1.1