OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/test/android/jni_test_util.h" |
| 6 |
| 7 #include "base/android/jni_android.h" |
| 8 |
| 9 namespace base { |
| 10 namespace android { |
| 11 namespace test { |
| 12 |
| 13 ScopedJavaLocalRef<jobject> CreateJavaPoint(jint x, jint y) { |
| 14 JNIEnv* env = AttachCurrentThread(); |
| 15 |
| 16 ScopedJavaLocalRef<jclass> point_jclass = |
| 17 GetClass(env, "android/graphics/Point"); |
| 18 |
| 19 jmethodID point_constructor = MethodID::Get<MethodID::TYPE_INSTANCE>( |
| 20 env, point_jclass.obj(), "<init>", "(II)V"); |
| 21 |
| 22 jobject point_obj = |
| 23 env->NewObject(point_jclass.obj(), point_constructor, x, y); |
| 24 return ScopedJavaLocalRef<jobject>(env, point_obj); |
| 25 } |
| 26 |
| 27 bool AreJavaObjectsEqual(jobject object1, jobject object2) { |
| 28 if (object1 == nullptr || object2 == nullptr) |
| 29 return object1 == object2; |
| 30 |
| 31 JNIEnv* env = AttachCurrentThread(); |
| 32 |
| 33 ScopedJavaLocalRef<jclass> object_jclass = GetClass(env, "java/lang/Object"); |
| 34 |
| 35 jmethodID equal_method_id = MethodID::Get<MethodID::TYPE_INSTANCE>( |
| 36 env, object_jclass.obj(), "equals", "(Ljava/lang/Object;)Z"); |
| 37 |
| 38 bool result = env->CallBooleanMethod(object1, equal_method_id, object2); |
| 39 CheckException(env); |
| 40 return result; |
| 41 } |
| 42 |
| 43 } // namespace test |
| 44 } // namespace android |
| 45 } // namespace base |
OLD | NEW |