summaryrefslogtreecommitdiffstats
path: root/tests/WebViewTests/src
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-11-14 18:26:03 +0000
committerSteve Block <steveblock@google.com>2011-11-16 14:28:20 +0000
commitc353abba95771ce28f1536fe36c1c705693232a8 (patch)
tree0df630812c13a73af0845cc9ed9ebada72997d6f /tests/WebViewTests/src
parent908bc4a8463e083c49909d8bce71fd016da9b5af (diff)
downloadframeworks_base-c353abba95771ce28f1536fe36c1c705693232a8.zip
frameworks_base-c353abba95771ce28f1536fe36c1c705693232a8.tar.gz
frameworks_base-c353abba95771ce28f1536fe36c1c705693232a8.tar.bz2
Add tests for multidimensional arrays in WebView's Java Bridge
Also add a test for objects with a non-numeric length property being passed to a method expecting an array. Change-Id: Ic04bbd691c55744472cab9fb732e504997c62434
Diffstat (limited to 'tests/WebViewTests/src')
-rw-r--r--tests/WebViewTests/src/com/android/webviewtests/JavaBridgeArrayTest.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeArrayTest.java b/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeArrayTest.java
index 5497990..98f2391 100644
--- a/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeArrayTest.java
+++ b/tests/WebViewTests/src/com/android/webviewtests/JavaBridgeArrayTest.java
@@ -39,6 +39,7 @@ public class JavaBridgeArrayTest extends JavaBridgeTestBase {
private String mStringValue;
private int[] mIntArray;
+ private int[][] mIntIntArray;
private boolean mWasArrayMethodCalled;
@@ -72,11 +73,19 @@ public class JavaBridgeArrayTest extends JavaBridgeTestBase {
mIntArray = x;
notifyResultIsReady();
}
+ public synchronized void setIntIntArray(int[][] x) {
+ mIntIntArray = x;
+ notifyResultIsReady();
+ }
public synchronized int[] waitForIntArray() {
waitForResult();
return mIntArray;
}
+ public synchronized int[][] waitForIntIntArray() {
+ waitForResult();
+ return mIntIntArray;
+ }
public synchronized int[] arrayMethod() {
mWasArrayMethodCalled = true;
@@ -152,6 +161,13 @@ public class JavaBridgeArrayTest extends JavaBridgeTestBase {
assertEquals(0, result[2]);
}
+ public void testNonNumericLengthProperty() throws Throwable {
+ // LIVECONNECT_COMPLIANCE: This should not count as an array, so we
+ // should raise a JavaScript exception.
+ executeJavaScript("testObject.setIntArray({length: \"foo\"});");
+ assertEquals(0, mTestObject.waitForIntArray().length);
+ }
+
public void testSparseArray() throws Throwable {
executeJavaScript("var x = [42, 43]; x[3] = 45; testObject.setIntArray(x);");
int[] result = mTestObject.waitForIntArray();
@@ -173,4 +189,19 @@ public class JavaBridgeArrayTest extends JavaBridgeTestBase {
assertTrue(mTestObject.waitForBooleanValue());
assertFalse(mTestObject.wasArrayMethodCalled());
}
+
+ public void testMultiDimensionalArrayMethod() throws Throwable {
+ // LIVECONNECT_COMPLIANCE: Should handle multi-dimensional arrays.
+ executeJavaScript("testObject.setIntIntArray([ [42, 43], [44, 45] ]);");
+ assertNull(mTestObject.waitForIntIntArray());
+ }
+
+ public void testPassMultiDimensionalArray() throws Throwable {
+ // LIVECONNECT_COMPLIANCE: Should handle multi-dimensional arrays.
+ executeJavaScript("testObject.setIntArray([ [42, 43], [44, 45] ]);");
+ int[] result = mTestObject.waitForIntArray();
+ assertEquals(2, result.length);
+ assertEquals(0, result[0]);
+ assertEquals(0, result[1]);
+ }
}