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

Unified Diff: base/test/android/jni_test_util.cc

Issue 2735113003: Changing SpawnChild to return a struct.
Patch Set: Created 3 years, 9 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 | « base/test/android/jni_test_util.h ('k') | base/test/multiprocess_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « base/test/android/jni_test_util.h ('k') | base/test/multiprocess_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698