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

Unified Diff: android_webview/unittestjava/src/org/chromium/android_webview/unittest/CallbackJNIBridgeUnittest.java

Issue 12313042: [android_webview] Add a generic callback JNI bridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
Index: android_webview/unittestjava/src/org/chromium/android_webview/unittest/CallbackJNIBridgeUnittest.java
diff --git a/android_webview/unittestjava/src/org/chromium/android_webview/unittest/CallbackJNIBridgeUnittest.java b/android_webview/unittestjava/src/org/chromium/android_webview/unittest/CallbackJNIBridgeUnittest.java
new file mode 100644
index 0000000000000000000000000000000000000000..a09b7301641bf7875287556cffa6ff43ce3749c0
--- /dev/null
+++ b/android_webview/unittestjava/src/org/chromium/android_webview/unittest/CallbackJNIBridgeUnittest.java
@@ -0,0 +1,50 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.android_webview.unittest;
+
+import android.webkit.ValueCallback;
+
+import org.chromium.base.CalledByNative;
+
+class CallbackJNIBridgeUnittest {
+ private CallbackJNIBridgeUnittest() {
+ }
+
+ private static class ValueCallbackInt implements ValueCallback<Integer> {
+ private boolean mHasValue;
+ private int mValue;
+
+ public boolean getHasValue() {
+ return mHasValue;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ @Override
+ public void onReceiveValue(Integer value) {
+ assert !mHasValue;
+ mHasValue = true;
+ mValue = value;
+ }
+ }
+
+ @CalledByNative
+ static ValueCallbackInt createValueCallbackInt() {
+ return new ValueCallbackInt();
+ }
+
+ @CalledByNative
+ static boolean checkValueCallbackIntValue(ValueCallbackInt callback, int expectedValue) {
+ return callback.getHasValue() && callback.getValue() == expectedValue;
+ }
+
+ @SuppressWarnings("unchecked")
+ @CalledByNative
+ static void invokeValueCallbackInt(ValueCallback callback, int value) {
+ callback.onReceiveValue(value);
+ }
+}
« android_webview/native/callback_jni_bridge.cc ('K') | « android_webview/native/webview_native.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698