diff options
Diffstat (limited to 'base/test')
-rw-r--r-- | base/test/launcher/test_launcher.cc | 47 | ||||
-rw-r--r-- | base/test/launcher/unit_test_launcher.cc | 21 | ||||
-rw-r--r-- | base/test/sequenced_worker_pool_owner.cc | 6 | ||||
-rw-r--r-- | base/test/task_runner_test_template.h | 4 | ||||
-rw-r--r-- | base/test/thread_test_helper.cc | 4 | ||||
-rw-r--r-- | base/test/thread_test_helper.h | 6 |
6 files changed, 50 insertions, 38 deletions
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc index 7f258f5..521f69c 100644 --- a/base/test/launcher/test_launcher.cc +++ b/base/test/launcher/test_launcher.cc @@ -18,13 +18,11 @@ #include "base/format_macros.h" #include "base/hash.h" #include "base/lazy_instance.h" -#include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/process/kill.h" #include "base/process/launch.h" -#include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" @@ -36,7 +34,6 @@ #include "base/test/sequenced_worker_pool_owner.h" #include "base/test/test_switches.h" #include "base/test/test_timeouts.h" -#include "base/thread_task_runner_handle.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" #include "testing/gtest/include/gtest/gtest.h" @@ -352,7 +349,7 @@ void DoLaunchChildTestProcess( TimeDelta timeout, int flags, bool redirect_stdio, - SingleThreadTaskRunner* task_runner, + scoped_refptr<MessageLoopProxy> message_loop_proxy, const TestLauncher::LaunchChildGTestProcessCallback& callback) { TimeTicks start_time = TimeTicks::Now(); @@ -426,9 +423,14 @@ void DoLaunchChildTestProcess( // Run target callback on the thread it was originating from, not on // a worker pool thread. - task_runner->PostTask(FROM_HERE, Bind(&RunCallback, callback, exit_code, - TimeTicks::Now() - start_time, - was_timeout, output_file_contents)); + message_loop_proxy->PostTask( + FROM_HERE, + Bind(&RunCallback, + callback, + exit_code, + TimeTicks::Now() - start_time, + was_timeout, + output_file_contents)); } } // namespace @@ -502,8 +504,9 @@ bool TestLauncher::Run() { // Start the watchdog timer. watchdog_timer_.Reset(); - ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, Bind(&TestLauncher::RunTestIteration, Unretained(this))); + MessageLoop::current()->PostTask( + FROM_HERE, + Bind(&TestLauncher::RunTestIteration, Unretained(this))); MessageLoop::current()->Run(); @@ -533,10 +536,16 @@ void TestLauncher::LaunchChildGTestProcess( bool redirect_stdio = (parallel_jobs_ > 1) || BotModeEnabled(); worker_pool_owner_->pool()->PostWorkerTask( - FROM_HERE, Bind(&DoLaunchChildTestProcess, new_command_line, timeout, - flags, redirect_stdio, ThreadTaskRunnerHandle::Get(), - Bind(&TestLauncher::OnLaunchTestProcessFinished, - Unretained(this), callback))); + FROM_HERE, + Bind(&DoLaunchChildTestProcess, + new_command_line, + timeout, + flags, + redirect_stdio, + MessageLoopProxy::current(), + Bind(&TestLauncher::OnLaunchTestProcessFinished, + Unretained(this), + callback))); } void TestLauncher::OnTestFinished(const TestResult& result) { @@ -948,8 +957,9 @@ void TestLauncher::RunTests() { fflush(stdout); // No tests have actually been started, so kick off the next iteration. - ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, Bind(&TestLauncher::RunTestIteration, Unretained(this))); + MessageLoop::current()->PostTask( + FROM_HERE, + Bind(&TestLauncher::RunTestIteration, Unretained(this))); } } @@ -970,7 +980,7 @@ void TestLauncher::RunTestIteration() { tests_to_retry_.clear(); results_tracker_.OnTestIterationStarting(); - ThreadTaskRunnerHandle::Get()->PostTask( + MessageLoop::current()->PostTask( FROM_HERE, Bind(&TestLauncher::RunTests, Unretained(this))); } @@ -1017,8 +1027,9 @@ void TestLauncher::OnTestIterationFinished() { results_tracker_.PrintSummaryOfCurrentIteration(); // Kick off the next iteration. - ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, Bind(&TestLauncher::RunTestIteration, Unretained(this))); + MessageLoop::current()->PostTask( + FROM_HERE, + Bind(&TestLauncher::RunTestIteration, Unretained(this))); } void TestLauncher::OnOutputTimeout() { diff --git a/base/test/launcher/unit_test_launcher.cc b/base/test/launcher/unit_test_launcher.cc index ab6fa72..1b3a162 100644 --- a/base/test/launcher/unit_test_launcher.cc +++ b/base/test/launcher/unit_test_launcher.cc @@ -12,9 +12,7 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/format_macros.h" -#include "base/location.h" #include "base/message_loop/message_loop.h" -#include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" @@ -24,7 +22,6 @@ #include "base/test/test_switches.h" #include "base/test/test_timeouts.h" #include "base/third_party/dynamic_annotations/dynamic_annotations.h" -#include "base/thread_task_runner_handle.h" #include "base/threading/thread_checker.h" #include "testing/gtest/include/gtest/gtest.h" @@ -408,10 +405,13 @@ void SerialGTestCallback( // The temporary file's directory is also temporary. DeleteFile(callback_state.output_file.DirName(), true); - ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, Bind(&RunUnitTestsSerially, callback_state.test_launcher, - callback_state.platform_delegate, test_names, - callback_state.launch_flags)); + MessageLoop::current()->PostTask( + FROM_HERE, + Bind(&RunUnitTestsSerially, + callback_state.test_launcher, + callback_state.platform_delegate, + test_names, + callback_state.launch_flags)); } } // namespace @@ -576,9 +576,12 @@ size_t UnitTestLauncherDelegate::RunTests( size_t UnitTestLauncherDelegate::RetryTests( TestLauncher* test_launcher, const std::vector<std::string>& test_names) { - ThreadTaskRunnerHandle::Get()->PostTask( + MessageLoop::current()->PostTask( FROM_HERE, - Bind(&RunUnitTestsSerially, test_launcher, platform_delegate_, test_names, + Bind(&RunUnitTestsSerially, + test_launcher, + platform_delegate_, + test_names, use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0)); return test_names.size(); } diff --git a/base/test/sequenced_worker_pool_owner.cc b/base/test/sequenced_worker_pool_owner.cc index b0d8b7a..4486323 100644 --- a/base/test/sequenced_worker_pool_owner.cc +++ b/base/test/sequenced_worker_pool_owner.cc @@ -6,7 +6,6 @@ #include "base/location.h" #include "base/message_loop/message_loop.h" -#include "base/single_thread_task_runner.h" namespace base { @@ -51,8 +50,9 @@ void SequencedWorkerPoolOwner::WillWaitForShutdown() { } void SequencedWorkerPoolOwner::OnDestruct() { - constructor_message_loop_->task_runner()->PostTask( - FROM_HERE, constructor_message_loop_->QuitWhenIdleClosure()); + constructor_message_loop_->PostTask( + FROM_HERE, + constructor_message_loop_->QuitWhenIdleClosure()); } } // namespace base diff --git a/base/test/task_runner_test_template.h b/base/test/task_runner_test_template.h index ee2b876..9bcf70b 100644 --- a/base/test/task_runner_test_template.h +++ b/base/test/task_runner_test_template.h @@ -53,9 +53,7 @@ #include "base/basictypes.h" #include "base/bind.h" #include "base/callback.h" -#include "base/location.h" #include "base/memory/ref_counted.h" -#include "base/single_thread_task_runner.h" #include "base/synchronization/condition_variable.h" #include "base/synchronization/lock.h" #include "base/task_runner.h" @@ -197,7 +195,7 @@ TYPED_TEST_P(TaskRunnerTest, RunsTasksOnCurrentThread) { i); for (int j = 0; j < i + 1; ++j) { task_runner->PostTask(FROM_HERE, ith_task_runner_task); - thread.task_runner()->PostTask(FROM_HERE, ith_non_task_runner_task); + thread.message_loop()->PostTask(FROM_HERE, ith_non_task_runner_task); expected_task_run_counts[i] += 2; } } diff --git a/base/test/thread_test_helper.cc b/base/test/thread_test_helper.cc index 6a12190..2bd3ba5 100644 --- a/base/test/thread_test_helper.cc +++ b/base/test/thread_test_helper.cc @@ -11,9 +11,9 @@ namespace base { ThreadTestHelper::ThreadTestHelper( - scoped_refptr<SingleThreadTaskRunner> target_thread) + const scoped_refptr<MessageLoopProxy>& target_thread) : test_result_(false), - target_thread_(target_thread.Pass()), + target_thread_(target_thread), done_event_(false, false) { } diff --git a/base/test/thread_test_helper.h b/base/test/thread_test_helper.h index 926da73..f6817b5 100644 --- a/base/test/thread_test_helper.h +++ b/base/test/thread_test_helper.h @@ -7,7 +7,7 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" -#include "base/single_thread_task_runner.h" +#include "base/message_loop/message_loop_proxy.h" #include "base/synchronization/waitable_event.h" namespace base { @@ -19,7 +19,7 @@ namespace base { class ThreadTestHelper : public RefCountedThreadSafe<ThreadTestHelper> { public: explicit ThreadTestHelper( - scoped_refptr<SingleThreadTaskRunner> target_thread); + const scoped_refptr<MessageLoopProxy>& target_thread); // True if RunTest() was successfully executed on the target thread. bool Run() WARN_UNUSED_RESULT; @@ -38,7 +38,7 @@ class ThreadTestHelper : public RefCountedThreadSafe<ThreadTestHelper> { void RunInThread(); bool test_result_; - scoped_refptr<SingleThreadTaskRunner> target_thread_; + scoped_refptr<MessageLoopProxy> target_thread_; WaitableEvent done_event_; DISALLOW_COPY_AND_ASSIGN(ThreadTestHelper); |