| Index: base/test/android/jni_test_util.cc
|
| diff --git a/base/test/android/jni_test_util.cc b/base/test/android/jni_test_util.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..76a36e350753978c45fad7a5fff0a83f2de72e2b
|
| --- /dev/null
|
| +++ b/base/test/android/jni_test_util.cc
|
| @@ -0,0 +1,45 @@
|
| +// Copyright 2017 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.
|
| +
|
| +#include "base/test/android/jni_test_util.h"
|
| +
|
| +#include "base/android/jni_android.h"
|
| +
|
| +namespace base {
|
| +namespace android {
|
| +namespace test {
|
| +
|
| +ScopedJavaLocalRef<jobject> CreateJavaPoint(jint x, jint y) {
|
| + JNIEnv* env = AttachCurrentThread();
|
| +
|
| + ScopedJavaLocalRef<jclass> point_jclass =
|
| + GetClass(env, "android/graphics/Point");
|
| +
|
| + jmethodID point_constructor = MethodID::Get<MethodID::TYPE_INSTANCE>(
|
| + env, point_jclass.obj(), "<init>", "(II)V");
|
| +
|
| + jobject point_obj =
|
| + env->NewObject(point_jclass.obj(), point_constructor, x, y);
|
| + return ScopedJavaLocalRef<jobject>(env, point_obj);
|
| +}
|
| +
|
| +bool AreJavaObjectsEqual(jobject object1, jobject object2) {
|
| + if (object1 == nullptr || object2 == nullptr)
|
| + return object1 == object2;
|
| +
|
| + JNIEnv* env = AttachCurrentThread();
|
| +
|
| + ScopedJavaLocalRef<jclass> object_jclass = GetClass(env, "java/lang/Object");
|
| +
|
| + jmethodID equal_method_id = MethodID::Get<MethodID::TYPE_INSTANCE>(
|
| + env, object_jclass.obj(), "equals", "(Ljava/lang/Object;)Z");
|
| +
|
| + bool result = env->CallBooleanMethod(object1, equal_method_id, object2);
|
| + CheckException(env);
|
| + return result;
|
| +}
|
| +
|
| +} // namespace test
|
| +} // namespace android
|
| +} // namespace base
|
|
|