| 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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 BrowserThread::IO, FROM_HERE, MessageLoop::QuitClosure()); | 71 BrowserThread::IO, FROM_HERE, MessageLoop::QuitClosure()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 protected: | 74 protected: |
| 75 virtual void SetUp() { | 75 virtual void SetUp() { |
| 76 db_thread_.Start(); | 76 db_thread_.Start(); |
| 77 worker_ = new DatabaseModelWorker(); | 77 worker_ = new DatabaseModelWorker(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 virtual void Teardown() { | 80 virtual void Teardown() { |
| 81 worker_.release(); | 81 worker_ = NULL; |
| 82 db_thread_.Stop(); | 82 db_thread_.Stop(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 bool did_do_work_; | 86 bool did_do_work_; |
| 87 scoped_refptr<BrowserThreadModelWorker> worker_; | 87 scoped_refptr<BrowserThreadModelWorker> worker_; |
| 88 OneShotTimer<SyncBrowserThreadModelWorkerTest> timer_; | 88 OneShotTimer<SyncBrowserThreadModelWorkerTest> timer_; |
| 89 | 89 |
| 90 content::TestBrowserThread db_thread_; | 90 content::TestBrowserThread db_thread_; |
| 91 MessageLoopForIO io_loop_; | 91 MessageLoopForIO io_loop_; |
| 92 content::TestBrowserThread io_thread_; | 92 content::TestBrowserThread io_thread_; |
| 93 | 93 |
| 94 base::WeakPtrFactory<SyncBrowserThreadModelWorkerTest> weak_factory_; | 94 base::WeakPtrFactory<SyncBrowserThreadModelWorkerTest> weak_factory_; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 TEST_F(SyncBrowserThreadModelWorkerTest, DoesWorkOnDatabaseThread) { | 97 TEST_F(SyncBrowserThreadModelWorkerTest, DoesWorkOnDatabaseThread) { |
| 98 MessageLoop::current()->PostTask(FROM_HERE, | 98 MessageLoop::current()->PostTask(FROM_HERE, |
| 99 base::Bind(&SyncBrowserThreadModelWorkerTest::ScheduleWork, | 99 base::Bind(&SyncBrowserThreadModelWorkerTest::ScheduleWork, |
| 100 factory()->GetWeakPtr())); | 100 factory()->GetWeakPtr())); |
| 101 MessageLoop::current()->Run(); | 101 MessageLoop::current()->Run(); |
| 102 EXPECT_TRUE(did_do_work()); | 102 EXPECT_TRUE(did_do_work()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace | 105 } // namespace |
| 106 | 106 |
| 107 } // namespace browser_sync | 107 } // namespace browser_sync |
| OLD | NEW |