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 #ifndef CONTENT_PUBLIC_TEST_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_TEST_UTILS_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "content/public/browser/notification_details.h" | 11 #include "content/public/browser/notification_details.h" |
12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
14 #include "content/public/browser/notification_source.h" | 14 #include "content/public/browser/notification_source.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 | 16 |
17 // A collections of functions designed for use with unit and browser tests. | 17 // A collections of functions designed for use with unit and browser tests. |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
| 21 // Turns on nestable tasks, runs the message loop, then resets nestable tasks |
| 22 // to what they were originally. Prefer this over MessageLoop::Run for in |
| 23 // process browser tests that need to block until a condition is met. |
| 24 void RunMessageLoop(); |
| 25 |
21 // Variant of RunMessageLoop that takes RunLoop. | 26 // Variant of RunMessageLoop that takes RunLoop. |
22 void RunThisRunLoop(base::RunLoop* run_loop); | 27 void RunThisRunLoop(base::RunLoop* run_loop); |
23 | 28 |
24 // Get task to quit the given RunLoop. It allows a few generations of pending | 29 // Get task to quit the given RunLoop. It allows a few generations of pending |
25 // tasks to run as opposed to run_loop->QuitClosure(). | 30 // tasks to run as opposed to run_loop->QuitClosure(). |
26 base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop); | 31 base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop); |
27 | 32 |
28 // Helper class to Run and Quit the message loop. Run and Quit can only happen | 33 // Helper class to Run and Quit the message loop. Run and Quit can only happen |
29 // once per instance. Make a new instance for each use. Calling Quit after Run | 34 // once per instance. Make a new instance for each use. Calling Quit after Run |
30 // has returned is safe and has no effect. | 35 // has returned is safe and has no effect. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 NotificationSource source_; | 108 NotificationSource source_; |
104 NotificationDetails details_; | 109 NotificationDetails details_; |
105 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 110 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
106 | 111 |
107 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserver); | 112 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserver); |
108 }; | 113 }; |
109 | 114 |
110 } // namespace content | 115 } // namespace content |
111 | 116 |
112 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ | 117 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ |
OLD | NEW |