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 "content/public/test/test_utils.h" | 5 #include "content/public/test/test_utils.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 void RunMessageLoop() { | 47 void RunMessageLoop() { |
48 base::RunLoop run_loop; | 48 base::RunLoop run_loop; |
49 RunThisRunLoop(&run_loop); | 49 RunThisRunLoop(&run_loop); |
50 } | 50 } |
51 | 51 |
52 void RunThisRunLoop(base::RunLoop* run_loop) { | 52 void RunThisRunLoop(base::RunLoop* run_loop) { |
53 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 53 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
54 | 54 |
55 // If we're running inside a browser test, we might need to allow the test | 55 // If we're running inside a browser test, we might need to allow the test |
56 // launcher to do extra work before/after running a nested message loop. | 56 // launcher to do extra work before/after running a nested message loop. |
57 test_launcher::TestLauncherDelegate* delegate = | 57 TestLauncherDelegate* delegate = GetCurrentTestLauncherDelegate(); |
58 test_launcher::GetCurrentTestLauncherDelegate(); | |
59 if (delegate) | 58 if (delegate) |
60 delegate->PreRunMessageLoop(run_loop); | 59 delegate->PreRunMessageLoop(run_loop); |
61 run_loop->Run(); | 60 run_loop->Run(); |
62 if (delegate) | 61 if (delegate) |
63 delegate->PostRunMessageLoop(); | 62 delegate->PostRunMessageLoop(); |
64 } | 63 } |
65 | 64 |
66 void RunAllPendingInMessageLoop() { | 65 void RunAllPendingInMessageLoop() { |
67 MessageLoop::current()->PostTask(FROM_HERE, | 66 MessageLoop::current()->PostTask(FROM_HERE, |
68 MessageLoop::QuitWhenIdleClosure()); | 67 MessageLoop::QuitWhenIdleClosure()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 details_ = details; | 138 details_ = details; |
140 seen_ = true; | 139 seen_ = true; |
141 if (!running_) | 140 if (!running_) |
142 return; | 141 return; |
143 | 142 |
144 message_loop_runner_->Quit(); | 143 message_loop_runner_->Quit(); |
145 running_ = false; | 144 running_ = false; |
146 } | 145 } |
147 | 146 |
148 } // namespace content | 147 } // namespace content |
OLD | NEW |