Chromium Code Reviews| Index: mojo/android/javatests/core_test.cc |
| diff --git a/mojo/android/javatests/core_test.cc b/mojo/android/javatests/core_test.cc |
| index 3d4032fc52c2b9a7e873d40cc6682f783420963b..632380fe642b33880f94fb83cb42fcc3c254b513 100644 |
| --- a/mojo/android/javatests/core_test.cc |
| +++ b/mojo/android/javatests/core_test.cc |
| @@ -6,7 +6,23 @@ |
| #include "base/android/jni_android.h" |
| #include "base/android/scoped_java_ref.h" |
| +#include "base/bind.h" |
| +#include "base/logging.h" |
| +#include "base/message_loop/message_loop.h" |
| +#include "base/run_loop.h" |
| +#include "base/test/test_support_android.h" |
| #include "jni/CoreTest_jni.h" |
| +#include "mojo/public/cpp/environment/environment.h" |
| + |
| +namespace { |
|
rmcilroy
2014/05/15 22:36:51
Nit - newline between namespace and struct for cla
qsr
2014/05/19 12:12:09
Done.
|
| +struct TestEnvironment { |
| + mojo::Environment environment; |
| + base::MessageLoopForUI message_loop; |
| +}; |
| + |
| +void DoNothing() { |
| +} |
| +} |
|
rmcilroy
2014/05/15 22:36:51
Ditto
qsr
2014/05/19 12:12:09
Done.
|
| namespace mojo { |
| namespace android { |
| @@ -16,8 +32,29 @@ static void InitApplicationContext(JNIEnv* env, |
| jobject context) { |
| base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); |
| base::android::InitApplicationContext(env, scoped_context); |
| + base::InitAndroidTestMessageLoop(); |
| +} |
| + |
| +static jlong SetupTestEnvironment(JNIEnv* env, jobject jcaller) { |
| + 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.
|
| } |
| +static void TearDownTestEnvironment(JNIEnv* env, |
| + jobject jcaller, |
| + jlong test_environment) { |
|
bulach
2014/05/15 19:32:58
nit: align
qsr
2014/05/19 12:12:09
Done.
|
| + delete reinterpret_cast<TestEnvironment*>(test_environment); |
| +} |
| + |
| +static void RunLoop(JNIEnv* env, jobject jcaller, jlong timeout_ms) { |
| + base::MessageLoop::current()->PostDelayedTask( |
| + FROM_HERE, |
| + base::MessageLoop::QuitClosure(), |
| + base::TimeDelta::FromMilliseconds(timeout_ms)); |
| + base::RunLoop run_loop; |
| + run_loop.Run(); |
| +} |
| + |
| + |
| bool RegisterCoreTest(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |