OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/location.h" |
7 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
8 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/single_thread_task_runner.h" |
10 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
| 13 #include "base/thread_task_runner_handle.h" |
11 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
12 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
13 #include "chrome/browser/sync/glue/browser_thread_model_worker.h" | 16 #include "chrome/browser/sync/glue/browser_thread_model_worker.h" |
14 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
16 | 19 |
17 using base::OneShotTimer; | 20 using base::OneShotTimer; |
18 using base::Thread; | 21 using base::Thread; |
19 using base::TimeDelta; | 22 using base::TimeDelta; |
20 using content::BrowserThread; | 23 using content::BrowserThread; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 bool did_do_work_; | 85 bool did_do_work_; |
83 scoped_refptr<BrowserThreadModelWorker> worker_; | 86 scoped_refptr<BrowserThreadModelWorker> worker_; |
84 OneShotTimer<SyncBrowserThreadModelWorkerTest> timer_; | 87 OneShotTimer<SyncBrowserThreadModelWorkerTest> timer_; |
85 | 88 |
86 content::TestBrowserThreadBundle thread_bundle_; | 89 content::TestBrowserThreadBundle thread_bundle_; |
87 | 90 |
88 base::WeakPtrFactory<SyncBrowserThreadModelWorkerTest> weak_factory_; | 91 base::WeakPtrFactory<SyncBrowserThreadModelWorkerTest> weak_factory_; |
89 }; | 92 }; |
90 | 93 |
91 TEST_F(SyncBrowserThreadModelWorkerTest, DoesWorkOnDatabaseThread) { | 94 TEST_F(SyncBrowserThreadModelWorkerTest, DoesWorkOnDatabaseThread) { |
92 base::MessageLoop::current()->PostTask(FROM_HERE, | 95 base::ThreadTaskRunnerHandle::Get()->PostTask( |
93 base::Bind(&SyncBrowserThreadModelWorkerTest::ScheduleWork, | 96 FROM_HERE, base::Bind(&SyncBrowserThreadModelWorkerTest::ScheduleWork, |
94 factory()->GetWeakPtr())); | 97 factory()->GetWeakPtr())); |
95 base::MessageLoop::current()->Run(); | 98 base::MessageLoop::current()->Run(); |
96 EXPECT_TRUE(did_do_work()); | 99 EXPECT_TRUE(did_do_work()); |
97 } | 100 } |
98 | 101 |
99 } // namespace | 102 } // namespace |
100 | 103 |
101 } // namespace browser_sync | 104 } // namespace browser_sync |
OLD | NEW |