OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 this, | 50 this, |
51 &BrowserThreadModelWorkerTest::Timeout); | 51 &BrowserThreadModelWorkerTest::Timeout); |
52 worker()->DoWorkAndWaitUntilDone(c); | 52 worker()->DoWorkAndWaitUntilDone(c); |
53 } | 53 } |
54 | 54 |
55 // This is the work that will be scheduled to be done on the DB thread. | 55 // This is the work that will be scheduled to be done on the DB thread. |
56 UnrecoverableErrorInfo DoWork() { | 56 UnrecoverableErrorInfo DoWork() { |
57 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 57 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
58 timer_.Stop(); // Stop the failure timer so the test succeeds. | 58 timer_.Stop(); // Stop the failure timer so the test succeeds. |
59 BrowserThread::PostTask( | 59 BrowserThread::PostTask( |
60 BrowserThread::IO, FROM_HERE, new MessageLoop::QuitTask()); | 60 BrowserThread::IO, FROM_HERE, MessageLoop::QuitClosure()); |
61 did_do_work_ = true; | 61 did_do_work_ = true; |
62 return UnrecoverableErrorInfo(); | 62 return UnrecoverableErrorInfo(); |
63 } | 63 } |
64 | 64 |
65 // This will be called by the OneShotTimer and make the test fail unless | 65 // This will be called by the OneShotTimer and make the test fail unless |
66 // DoWork is called first. | 66 // DoWork is called first. |
67 void Timeout() { | 67 void Timeout() { |
68 ADD_FAILURE() << "Timed out waiting for work to be done on the DB thread."; | 68 ADD_FAILURE() << "Timed out waiting for work to be done on the DB thread."; |
69 BrowserThread::PostTask( | 69 BrowserThread::PostTask( |
70 BrowserThread::IO, FROM_HERE, new MessageLoop::QuitTask()); | 70 BrowserThread::IO, FROM_HERE, MessageLoop::QuitClosure()); |
71 } | 71 } |
72 | 72 |
73 protected: | 73 protected: |
74 virtual void SetUp() { | 74 virtual void SetUp() { |
75 db_thread_.Start(); | 75 db_thread_.Start(); |
76 worker_ = new DatabaseModelWorker(); | 76 worker_ = new DatabaseModelWorker(); |
77 } | 77 } |
78 | 78 |
79 virtual void Teardown() { | 79 virtual void Teardown() { |
80 worker_.release(); | 80 worker_.release(); |
(...skipping 15 matching lines...) Expand all Loading... |
96 TEST_F(BrowserThreadModelWorkerTest, DoesWorkOnDatabaseThread) { | 96 TEST_F(BrowserThreadModelWorkerTest, DoesWorkOnDatabaseThread) { |
97 MessageLoop::current()->PostTask(FROM_HERE, factory()->NewRunnableMethod( | 97 MessageLoop::current()->PostTask(FROM_HERE, factory()->NewRunnableMethod( |
98 &BrowserThreadModelWorkerTest::ScheduleWork)); | 98 &BrowserThreadModelWorkerTest::ScheduleWork)); |
99 MessageLoop::current()->Run(); | 99 MessageLoop::current()->Run(); |
100 EXPECT_TRUE(did_do_work()); | 100 EXPECT_TRUE(did_do_work()); |
101 } | 101 } |
102 | 102 |
103 } // namespace | 103 } // namespace |
104 | 104 |
105 } // namespace browser_sync | 105 } // namespace browser_sync |
OLD | NEW |