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/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" |
| 11 #include "base/location.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" |
14 #include "base/test/test_support_android.h" | 16 #include "base/test/test_support_android.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" |
15 #include "jni/MojoTestCase_jni.h" | 18 #include "jni/MojoTestCase_jni.h" |
16 #include "mojo/message_pump/message_pump_mojo.h" | 19 #include "mojo/message_pump/message_pump_mojo.h" |
17 | 20 |
18 namespace { | 21 namespace { |
19 | 22 |
20 struct TestEnvironment { | 23 struct TestEnvironment { |
21 TestEnvironment() : message_loop(mojo::common::MessagePumpMojo::Create()) {} | 24 TestEnvironment() : message_loop(mojo::common::MessagePumpMojo::Create()) {} |
22 | 25 |
23 base::ShadowingAtExitManager at_exit; | 26 base::ShadowingAtExitManager at_exit; |
24 base::MessageLoop message_loop; | 27 base::MessageLoop message_loop; |
(...skipping 17 matching lines...) Expand all Loading... |
42 const JavaParamRef<jobject>& jcaller, | 45 const JavaParamRef<jobject>& jcaller, |
43 jlong test_environment) { | 46 jlong test_environment) { |
44 delete reinterpret_cast<TestEnvironment*>(test_environment); | 47 delete reinterpret_cast<TestEnvironment*>(test_environment); |
45 } | 48 } |
46 | 49 |
47 static void RunLoop(JNIEnv* env, | 50 static void RunLoop(JNIEnv* env, |
48 const JavaParamRef<jobject>& jcaller, | 51 const JavaParamRef<jobject>& jcaller, |
49 jlong timeout_ms) { | 52 jlong timeout_ms) { |
50 base::RunLoop run_loop; | 53 base::RunLoop run_loop; |
51 if (timeout_ms) { | 54 if (timeout_ms) { |
52 base::MessageLoop::current()->PostDelayedTask( | 55 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
53 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 56 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
54 base::TimeDelta::FromMilliseconds(timeout_ms)); | 57 base::TimeDelta::FromMilliseconds(timeout_ms)); |
55 run_loop.Run(); | 58 run_loop.Run(); |
56 } else { | 59 } else { |
57 run_loop.RunUntilIdle(); | 60 run_loop.RunUntilIdle(); |
58 } | 61 } |
59 } | 62 } |
60 | 63 |
61 bool RegisterMojoTestCase(JNIEnv* env) { | 64 bool RegisterMojoTestCase(JNIEnv* env) { |
62 return RegisterNativesImpl(env); | 65 return RegisterNativesImpl(env); |
63 } | 66 } |
64 | 67 |
65 } // namespace android | 68 } // namespace android |
66 } // namespace mojo | 69 } // namespace mojo |
OLD | NEW |