diff options
author | Ben Murdoch <benm@google.com> | 2010-04-01 15:07:41 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-04-01 15:07:41 +0100 |
commit | 940e57fdd2fc09398c84fd3b8f3e993bc6fee4a0 (patch) | |
tree | fd4d7be7496d32e24ec6f6fa6ee004db63a99cf7 /tests | |
parent | 1e915b09465b17738129e62a30a65a2d30860906 (diff) | |
download | packages_apps_browser-940e57fdd2fc09398c84fd3b8f3e993bc6fee4a0.zip packages_apps_browser-940e57fdd2fc09398c84fd3b8f3e993bc6fee4a0.tar.gz packages_apps_browser-940e57fdd2fc09398c84fd3b8f3e993bc6fee4a0.tar.bz2 |
Update the JNI bindings unit test in light of b/2540502
Change-Id: I166331ce198fba188df5365695a20588870374c4
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/assets/bindings_test.html | 10 | ||||
-rw-r--r-- | tests/src/com/android/browser/JNIBindingsTest.java | 18 | ||||
-rw-r--r-- | tests/src/com/android/browser/JNIBindingsTestApp.java | 3 |
3 files changed, 30 insertions, 1 deletions
diff --git a/tests/assets/bindings_test.html b/tests/assets/bindings_test.html index 93dbff1..c20ccec 100755 --- a/tests/assets/bindings_test.html +++ b/tests/assets/bindings_test.html @@ -163,6 +163,10 @@ function getIfaceProperties() { return true; } +function testParameterTypeMismatch() { + return JNIBindingsTest.testParameterTypeMismatch("dog"); +} + function appendLog(msg) { var log = document.getElementById("status"); log.innerHTML += "<br/>" + msg; @@ -221,6 +225,12 @@ function runTests() { appendLog("getIfaceProperties failed!"); } + if (testParameterTypeMismatch()) { + appendLog("testParameterTypeMismatch passed!"); + } else { + appendLog("testParameterTypeMismatch failed!"); + } + JNIBindingsTest.testComplete(); } </script> diff --git a/tests/src/com/android/browser/JNIBindingsTest.java b/tests/src/com/android/browser/JNIBindingsTest.java index d2220f6..bfa3ac1 100644 --- a/tests/src/com/android/browser/JNIBindingsTest.java +++ b/tests/src/com/android/browser/JNIBindingsTest.java @@ -139,6 +139,7 @@ public class JNIBindingsTest extends AndroidTestCase { public boolean testObjectArray(String[] stringArray, Object[] emptyArray, Object[] objectArray) { String[] expectedStringArray = {"Hello", "World", "!"}; + String expectedStringArrayClassName = "[Ljava.lang.String;"; Object[] expectedObjectArray = {}; try { @@ -150,10 +151,13 @@ public class JNIBindingsTest extends AndroidTestCase { assertNull(objectArray); assertEquals(Arrays.toString(expectedStringArray), Arrays.toString(stringArray)); + assertEquals(expectedStringArrayClassName, stringArray.getClass().getName()); // EMULATE_JSC_BINDINGS // assertEquals(Arrays.toString(expectedObjectArray), Arrays.toString(emptyArray)); + // assertEquals(expectedObjectArrayClassName, emptyArray.getClass().getName()); // assertEquals(Arrays.toString(expectedObjectArray), Arrays.toString(objectArray)); + // assertEquals(expectedStringObjectClassName, objectArray.getClass().getName()); } catch (AssertionFailedError e) { printAssertionFailed(e); @@ -177,6 +181,7 @@ public class JNIBindingsTest extends AndroidTestCase { String expectedStringParam = "Hello World"; int[] expectedIntArray = {1,2,3}; String[] expectedStringArrayParam = {"foo", "bar", "baz"}; + String expectedStringArrayClassName = "[Ljava.lang.String;"; try { assertEquals(expectedBoolParam, boolParam); @@ -194,6 +199,7 @@ public class JNIBindingsTest extends AndroidTestCase { assertEquals(Arrays.toString(expectedIntArray), Arrays.toString(intArrayParam)); assertEquals(Arrays.toString(expectedStringArrayParam), Arrays.toString(stringArrayParam)); + assertEquals(expectedStringArrayClassName, stringArrayParam.getClass().getName()); assertNull(objectParam); } catch (AssertionFailedError e) { printAssertionFailed(e); @@ -238,6 +244,18 @@ public class JNIBindingsTest extends AndroidTestCase { return true; } + public boolean testParameterTypeMismatch(String[] stringArrayParam) { + // The JS test will pass a string, not an array to this test. + try { + assertNull(stringArrayParam); + } catch (AssertionFailedError e) { + printAssertionFailed(e); + return false; + } + + return true; + } + public boolean returnBool() { return true; } public byte returnByte() { return 1; } public char returnChar() { return 'b'; } diff --git a/tests/src/com/android/browser/JNIBindingsTestApp.java b/tests/src/com/android/browser/JNIBindingsTestApp.java index cb38cbc..e01aca2 100644 --- a/tests/src/com/android/browser/JNIBindingsTestApp.java +++ b/tests/src/com/android/browser/JNIBindingsTestApp.java @@ -53,7 +53,8 @@ public class JNIBindingsTestApp extends ActivityInstrumentationTestCase2<Browser "testObjectMembers passed!\n" + "testJSPrimitivesToStringsInJava passed!\n" + "testJavaReturnTypes passed!\n" + - "getIfaceProperties passed!\n"; + "getIfaceProperties passed!\n" + + "testParameterTypeMismatch passed!\n"; private class GetWebKitDataThread extends Thread { |