| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_TEST_UI_TEST_UTILS_H_ | 5 #ifndef CHROME_TEST_UI_TEST_UTILS_H_ |
| 6 #define CHROME_TEST_UI_TEST_UTILS_H_ | 6 #define CHROME_TEST_UI_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "chrome/browser/view_ids.h" | 12 #include "chrome/browser/view_ids.h" |
| 13 #include "chrome/common/notification_observer.h" | 13 #include "chrome/common/notification_observer.h" |
| 14 #include "chrome/common/notification_type.h" | 14 #include "chrome/common/notification_type.h" |
| 15 | 15 |
| 16 class AppModalDialog; | 16 class AppModalDialog; |
| 17 class Browser; | 17 class Browser; |
| 18 class DownloadManager; | 18 class DownloadManager; |
| 19 class GURL; | 19 class GURL; |
| 20 class MessageLoop; |
| 20 class NavigationController; | 21 class NavigationController; |
| 21 class RenderViewHost; | 22 class RenderViewHost; |
| 22 class TabContents; | 23 class TabContents; |
| 23 class Value; | 24 class Value; |
| 24 | 25 |
| 25 // A collections of functions designed for use with InProcessBrowserTest. | 26 // A collections of functions designed for use with InProcessBrowserTest. |
| 26 namespace ui_test_utils { | 27 namespace ui_test_utils { |
| 27 | 28 |
| 28 // Turns on nestable tasks, runs the message loop, then resets nestable tasks | 29 // Turns on nestable tasks, runs the message loop, then resets nestable tasks |
| 29 // to what they were originally. Prefer this over MessageLoop::Run for in | 30 // to what they were originally. Prefer this over MessageLoop::Run for in |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 129 |
| 129 // Simulates a mouse click on a View in the browser. | 130 // Simulates a mouse click on a View in the browser. |
| 130 void ClickOnView(const Browser* browser, ViewID vid); | 131 void ClickOnView(const Browser* browser, ViewID vid); |
| 131 | 132 |
| 132 // Register |observer| for the given |type| and run the message loop until | 133 // Register |observer| for the given |type| and run the message loop until |
| 133 // either the observer posts a quit task or we timeout. | 134 // either the observer posts a quit task or we timeout. |
| 134 void RegisterAndWait(NotificationType::Type type, | 135 void RegisterAndWait(NotificationType::Type type, |
| 135 NotificationObserver* observer, | 136 NotificationObserver* observer, |
| 136 int64 timeout_ms); | 137 int64 timeout_ms); |
| 137 | 138 |
| 139 // Run a message loop only for the specified amount of time. |
| 140 class TimedMessageLoopRunner { |
| 141 public: |
| 142 // Create new MessageLoopForUI and attach to it. |
| 143 TimedMessageLoopRunner(); |
| 144 |
| 145 // Attach to an existing message loop. |
| 146 explicit TimedMessageLoopRunner(MessageLoop* loop) |
| 147 : loop_(loop), owned_(false) {} |
| 148 |
| 149 ~TimedMessageLoopRunner(); |
| 150 |
| 151 // Run the message loop for ms milliseconds. |
| 152 void RunFor(int ms); |
| 153 |
| 154 // Post Quit task to the message loop. |
| 155 void Quit(); |
| 156 |
| 157 // Post delayed Quit task to the message loop. |
| 158 void QuitAfter(int ms); |
| 159 |
| 160 private: |
| 161 MessageLoop* loop_; |
| 162 bool owned_; |
| 163 |
| 164 DISALLOW_COPY_AND_ASSIGN(TimedMessageLoopRunner); |
| 165 }; |
| 166 |
| 138 } // namespace ui_test_utils | 167 } // namespace ui_test_utils |
| 139 | 168 |
| 140 #endif // CHROME_TEST_UI_TEST_UTILS_H_ | 169 #endif // CHROME_TEST_UI_TEST_UTILS_H_ |
| OLD | NEW |