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

Side by Side Diff: mojo/android/javatests/mojo_test_case.cc

Issue 1312153003: jni_generator: Pass object parameters as JavaParamRef. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/android/javatests/mojo_test_case.h" 5 #include "mojo/android/javatests/mojo_test_case.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 13 matching lines...) Expand all
24 base::ShadowingAtExitManager at_exit; 24 base::ShadowingAtExitManager at_exit;
25 base::MessageLoop message_loop; 25 base::MessageLoop message_loop;
26 }; 26 };
27 27
28 } // namespace 28 } // namespace
29 29
30 namespace mojo { 30 namespace mojo {
31 namespace android { 31 namespace android {
32 32
33 static void InitApplicationContext(JNIEnv* env, 33 static void InitApplicationContext(JNIEnv* env,
34 jobject jcaller, 34 const JavaParamRef<jobject>& jcaller,
35 jobject context) { 35 const JavaParamRef<jobject>& context) {
36 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); 36 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context);
37 base::android::InitApplicationContext(env, scoped_context); 37 base::android::InitApplicationContext(env, scoped_context);
38 base::InitAndroidTestMessageLoop(); 38 base::InitAndroidTestMessageLoop();
39 } 39 }
40 40
41 static jlong SetupTestEnvironment(JNIEnv* env, jobject jcaller) { 41 static jlong SetupTestEnvironment(JNIEnv* env,
42 const JavaParamRef<jobject>& jcaller) {
42 return reinterpret_cast<intptr_t>(new TestEnvironment()); 43 return reinterpret_cast<intptr_t>(new TestEnvironment());
43 } 44 }
44 45
45 static void TearDownTestEnvironment(JNIEnv* env, 46 static void TearDownTestEnvironment(JNIEnv* env,
46 jobject jcaller, 47 const JavaParamRef<jobject>& jcaller,
47 jlong test_environment) { 48 jlong test_environment) {
48 delete reinterpret_cast<TestEnvironment*>(test_environment); 49 delete reinterpret_cast<TestEnvironment*>(test_environment);
49 } 50 }
50 51
51 static void RunLoop(JNIEnv* env, jobject jcaller, jlong timeout_ms) { 52 static void RunLoop(JNIEnv* env,
53 const JavaParamRef<jobject>& jcaller,
54 jlong timeout_ms) {
52 base::RunLoop run_loop; 55 base::RunLoop run_loop;
53 if (timeout_ms) { 56 if (timeout_ms) {
54 base::MessageLoop::current()->PostDelayedTask( 57 base::MessageLoop::current()->PostDelayedTask(
55 FROM_HERE, 58 FROM_HERE,
56 base::MessageLoop::QuitClosure(), 59 base::MessageLoop::QuitClosure(),
57 base::TimeDelta::FromMilliseconds(timeout_ms)); 60 base::TimeDelta::FromMilliseconds(timeout_ms));
58 run_loop.Run(); 61 run_loop.Run();
59 } else { 62 } else {
60 run_loop.RunUntilIdle(); 63 run_loop.RunUntilIdle();
61 } 64 }
62 } 65 }
63 66
64 bool RegisterMojoTestCase(JNIEnv* env) { 67 bool RegisterMojoTestCase(JNIEnv* env) {
65 return RegisterNativesImpl(env); 68 return RegisterNativesImpl(env);
66 } 69 }
67 70
68 } // namespace android 71 } // namespace android
69 } // namespace mojo 72 } // namespace mojo
OLDNEW
« no previous file with comments | « mandoline/app/android/mandoline_activity.cc ('k') | mojo/android/javatests/validation_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698