| 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);
|
| + }
|
| +}
|
|
|