OLD | NEW |
---|---|
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/core_test.h" | 5 #include "mojo/android/javatests/core_test.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/bind.h" | |
10 #include "base/logging.h" | |
11 #include "base/message_loop/message_loop.h" | |
12 #include "base/run_loop.h" | |
13 #include "base/test/test_support_android.h" | |
9 #include "jni/CoreTest_jni.h" | 14 #include "jni/CoreTest_jni.h" |
15 #include "mojo/public/cpp/environment/environment.h" | |
16 | |
17 namespace { | |
rmcilroy
2014/05/15 22:36:51
Nit - newline between namespace and struct for cla
qsr
2014/05/19 12:12:09
Done.
| |
18 struct TestEnvironment { | |
19 mojo::Environment environment; | |
20 base::MessageLoopForUI message_loop; | |
21 }; | |
22 | |
23 void DoNothing() { | |
24 } | |
25 } | |
rmcilroy
2014/05/15 22:36:51
Ditto
qsr
2014/05/19 12:12:09
Done.
| |
10 | 26 |
11 namespace mojo { | 27 namespace mojo { |
12 namespace android { | 28 namespace android { |
13 | 29 |
14 static void InitApplicationContext(JNIEnv* env, | 30 static void InitApplicationContext(JNIEnv* env, |
15 jobject jcaller, | 31 jobject jcaller, |
16 jobject context) { | 32 jobject context) { |
17 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); | 33 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); |
18 base::android::InitApplicationContext(env, scoped_context); | 34 base::android::InitApplicationContext(env, scoped_context); |
35 base::InitAndroidTestMessageLoop(); | |
19 } | 36 } |
20 | 37 |
38 static jlong SetupTestEnvironment(JNIEnv* env, jobject jcaller) { | |
39 return reinterpret_cast<jlong>(new TestEnvironment()); | |
bulach
2014/05/15 19:32:58
nit: s/jlong/inptr_t
qsr
2014/05/19 12:12:09
Done.
| |
40 } | |
41 | |
42 static void TearDownTestEnvironment(JNIEnv* env, | |
43 jobject jcaller, | |
44 jlong test_environment) { | |
bulach
2014/05/15 19:32:58
nit: align
qsr
2014/05/19 12:12:09
Done.
| |
45 delete reinterpret_cast<TestEnvironment*>(test_environment); | |
46 } | |
47 | |
48 static void RunLoop(JNIEnv* env, jobject jcaller, jlong timeout_ms) { | |
49 base::MessageLoop::current()->PostDelayedTask( | |
50 FROM_HERE, | |
51 base::MessageLoop::QuitClosure(), | |
52 base::TimeDelta::FromMilliseconds(timeout_ms)); | |
53 base::RunLoop run_loop; | |
54 run_loop.Run(); | |
55 } | |
56 | |
57 | |
21 bool RegisterCoreTest(JNIEnv* env) { | 58 bool RegisterCoreTest(JNIEnv* env) { |
22 return RegisterNativesImpl(env); | 59 return RegisterNativesImpl(env); |
23 } | 60 } |
24 | 61 |
25 } // namespace android | 62 } // namespace android |
26 } // namespace mojo | 63 } // namespace mojo |
OLD | NEW |