Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2578)

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java

Issue 393733002: [Android] Check for Java object types covariance in Java Bridge (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated findbugs_known_bugs Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/content_tests.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
index 472b253d547142a38af69ca85b6e301793ce4a50..3afecfe9acab39b815623c2e122831a8c334bf6b 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java
@@ -153,11 +153,39 @@ public class JavaBridgeCoercionTest extends JavaBridgeTestBase {
private TestObject mTestObject;
+ private class TestController extends Controller {
+ private boolean mBooleanValue;
+
+ public synchronized void setBooleanValue(boolean x) {
+ mBooleanValue = x;
+ notifyResultIsReady();
+ }
+ public synchronized boolean waitForBooleanValue() {
+ waitForResult();
+ return mBooleanValue;
+ }
+ }
+
+ TestController mTestController;
+
+ // Note that this requires that we can pass a JavaScript boolean to Java.
+ private void assertRaisesException(String script) throws Throwable {
+ executeJavaScript("try {" +
+ script + ";" +
+ " testController.setBooleanValue(false);" +
+ "} catch (exception) {" +
+ " testController.setBooleanValue(true);" +
+ "}");
+ assertTrue(mTestController.waitForBooleanValue());
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();
mTestObject = new TestObject();
setUpContentView(mTestObject, "testObject");
+ mTestController = new TestController();
+ setUpContentView(mTestController, "testController");
}
// Test passing a 32-bit integer JavaScript number to a method of an
@@ -539,14 +567,11 @@ public class JavaBridgeCoercionTest extends JavaBridgeTestBase {
executeJavaScript("testObject.setObjectValue(testObject.getCustomTypeInstance());");
assertTrue(mTestObject.getCustomTypeInstance() == mTestObject.waitForObjectValue());
- executeJavaScript("testObject.setCustomTypeValue(testObject.getObjectInstance());");
- assertTrue(mTestObject.getObjectInstance() == mTestObject.waitForCustomTypeValue());
+ assertRaisesException("testObject.setCustomTypeValue(testObject.getObjectInstance());");
executeJavaScript("testObject.setCustomTypeValue(testObject.getCustomTypeInstance());");
assertTrue(mTestObject.getCustomTypeInstance() == mTestObject.waitForCustomTypeValue());
- // LIVECONNECT_COMPLIANCE: Should raise a JavaScript exception, as the types are unrelated.
- executeJavaScript("testObject.setCustomTypeValue(testObject.getCustomType2Instance());");
- assertTrue(mTestObject.getCustomType2Instance() ==
- (Object)mTestObject.waitForCustomTypeValue());
+ assertRaisesException(
+ "testObject.setCustomTypeValue(testObject.getCustomType2Instance());");
// LIVECONNECT_COMPLIANCE: Should call toString() on object.
executeJavaScript("testObject.setStringValue(testObject.getObjectInstance());");
« no previous file with comments | « content/content_tests.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698