summaryrefslogtreecommitdiffstats
path: root/tests/WebViewTests
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2012-04-24 13:01:34 +0100
committerSteve Block <steveblock@google.com>2012-04-24 21:34:42 +0100
commit3aa800b9f93a99d6f25623ed24ab5f6fec213c15 (patch)
tree8a9d91d359a0da899738e53e67a472173af2395f /tests/WebViewTests
parentf03f64d81036cb453345462714beb4298eac32a9 (diff)
downloadframeworks_base-3aa800b9f93a99d6f25623ed24ab5f6fec213c15.zip
frameworks_base-3aa800b9f93a99d6f25623ed24ab5f6fec213c15.tar.gz
frameworks_base-3aa800b9f93a99d6f25623ed24ab5f6fec213c15.tar.bz2
Add tests for reflection and improve JavaDoc for Java Bridge
Bug: 5461416 Change-Id: Ic339b97a9424d8848f8afd47ba00cbbee4d60c9d
Diffstat (limited to 'tests/WebViewTests')
-rw-r--r--tests/WebViewTests/src/com/android/webviewtests/JavaBridgeBasicsTest.java19
1 files changed, 19 insertions, 0 deletions
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()"));
+ }
}