| 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 "chrome/browser/sync_file_system/drive_backend/callback_helper.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/callback_helper.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/thread_task_runner_handle.h" |
| 9 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 12 namespace sync_file_system { | 13 namespace sync_file_system { |
| 13 namespace drive_backend { | 14 namespace drive_backend { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 void SimpleCallback(bool* called, int) { | 18 void SimpleCallback(bool* called, int) { |
| 18 ASSERT_TRUE(called); | 19 ASSERT_TRUE(called); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 EXPECT_FALSE(called); | 58 EXPECT_FALSE(called); |
| 58 base::RunLoop().RunUntilIdle(); | 59 base::RunLoop().RunUntilIdle(); |
| 59 EXPECT_TRUE(called); | 60 EXPECT_TRUE(called); |
| 60 } | 61 } |
| 61 | 62 |
| 62 TEST(DriveBackendCallbackHelperTest, RunOnOtherThreadTest) { | 63 TEST(DriveBackendCallbackHelperTest, RunOnOtherThreadTest) { |
| 63 base::MessageLoop message_loop; | 64 base::MessageLoop message_loop; |
| 64 base::Thread thread("WorkerThread"); | 65 base::Thread thread("WorkerThread"); |
| 65 thread.Start(); | 66 thread.Start(); |
| 66 | 67 |
| 67 scoped_refptr<base::MessageLoopProxy> ui_task_runner = | 68 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner = |
| 68 base::MessageLoopProxy::current(); | 69 base::ThreadTaskRunnerHandle::Get(); |
| 69 scoped_refptr<base::MessageLoopProxy> worker_task_runner = | 70 scoped_refptr<base::SequencedTaskRunner> worker_task_runner = |
| 70 thread.message_loop_proxy(); | 71 thread.message_loop_proxy(); |
| 71 | 72 |
| 72 bool called = false; | 73 bool called = false; |
| 73 base::RunLoop run_loop; | 74 base::RunLoop run_loop; |
| 74 worker_task_runner->PostTask( | 75 worker_task_runner->PostTask( |
| 75 FROM_HERE, | 76 FROM_HERE, |
| 76 RelayCallbackToTaskRunner( | 77 RelayCallbackToTaskRunner( |
| 77 ui_task_runner, FROM_HERE, | 78 ui_task_runner, FROM_HERE, |
| 78 base::Bind(&VerifyCalledOnTaskRunner, | 79 base::Bind(&VerifyCalledOnTaskRunner, |
| 79 ui_task_runner, &called))); | 80 ui_task_runner, &called))); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 92 TEST(DriveBackendCallbackHelperTest, PassNullFunctionTest) { | 93 TEST(DriveBackendCallbackHelperTest, PassNullFunctionTest) { |
| 93 base::MessageLoop message_loop; | 94 base::MessageLoop message_loop; |
| 94 base::Closure closure = RelayCallbackToCurrentThread( | 95 base::Closure closure = RelayCallbackToCurrentThread( |
| 95 FROM_HERE, | 96 FROM_HERE, |
| 96 base::Closure()); | 97 base::Closure()); |
| 97 EXPECT_TRUE(closure.is_null()); | 98 EXPECT_TRUE(closure.is_null()); |
| 98 } | 99 } |
| 99 | 100 |
| 100 } // namespace drive_backend | 101 } // namespace drive_backend |
| 101 } // namespace sync_file_system | 102 } // namespace sync_file_system |
| OLD | NEW |