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