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 #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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 bool case_sensitive, | 222 bool case_sensitive, |
223 int* ordinal); | 223 int* ordinal); |
224 | 224 |
225 // Returns true if the View is focused. | 225 // Returns true if the View is focused. |
226 bool IsViewFocused(const Browser* browser, ViewID vid); | 226 bool IsViewFocused(const Browser* browser, ViewID vid); |
227 | 227 |
228 // Simulates a mouse click on a View in the browser. | 228 // Simulates a mouse click on a View in the browser. |
229 void ClickOnView(const Browser* browser, ViewID vid); | 229 void ClickOnView(const Browser* browser, ViewID vid); |
230 | 230 |
231 // Blocks until a notification for given |type| is received. | 231 // Blocks until a notification for given |type| is received. |
232 // TODO(gbillock): remove this race hazard. | |
233 // Use WindowedNotificationObserver instead. | |
232 void WaitForNotification(int type); | 234 void WaitForNotification(int type); |
233 | 235 |
234 // Blocks until a notification for given |type| from the specified |source| | 236 // Blocks until a notification for given |type| from the specified |source| |
235 // is received. | 237 // is received. |
238 // TODO(gbillock): remove this race hazard. | |
239 // Use WindowedNotificationObserver instead. | |
236 void WaitForNotificationFrom(int type, | 240 void WaitForNotificationFrom(int type, |
237 const NotificationSource& source); | 241 const NotificationSource& source); |
238 | 242 |
239 // Register |observer| for the given |type| and |source| and run | 243 // Register |observer| for the given |type| and |source| and run |
240 // the message loop until the observer posts a quit task. | 244 // the message loop until the observer posts a quit task. |
241 void RegisterAndWait(NotificationObserver* observer, | 245 void RegisterAndWait(NotificationObserver* observer, |
242 int type, | 246 int type, |
243 const NotificationSource& source); | 247 const NotificationSource& source); |
244 | 248 |
245 // Blocks until |model| finishes loading. | 249 // Blocks until |model| finishes loading. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 // WindowedNotificationObserver signal(...) | 401 // WindowedNotificationObserver signal(...) |
398 // PerformAction() | 402 // PerformAction() |
399 // signal.Wait() | 403 // signal.Wait() |
400 class WindowedNotificationObserver : public NotificationObserver { | 404 class WindowedNotificationObserver : public NotificationObserver { |
401 public: | 405 public: |
402 // Register to listen for notifications of the given type from either a | 406 // Register to listen for notifications of the given type from either a |
403 // specific source, or from all sources if |source| is | 407 // specific source, or from all sources if |source| is |
404 // NotificationService::AllSources(). | 408 // NotificationService::AllSources(). |
405 WindowedNotificationObserver(int notification_type, | 409 WindowedNotificationObserver(int notification_type, |
406 const NotificationSource& source); | 410 const NotificationSource& source); |
411 | |
412 // Convenience constructor which will use the given NavigationController. | |
413 // Waits for a NOTIFICATION_LOAD_STOP event. | |
414 explicit WindowedNotificationObserver(const NavigationController& controller); | |
415 | |
416 // Convenience constructor which will use the NavigationController from | |
417 // the active tab in the given browser. | |
418 // Waits for a NOTIFICATION_LOAD_STOP event. | |
419 explicit WindowedNotificationObserver(const Browser& browser); | |
Paweł Hajdan Jr.
2011/07/25 18:06:13
Please don't add those "magic constructors" here,
Greg Billock
2011/08/02 18:11:33
I can do that. Shall I make two new subclasses her
Paweł Hajdan Jr.
2011/08/02 20:11:19
Well, do we actually need those ctors? Why not do
| |
420 | |
407 virtual ~WindowedNotificationObserver(); | 421 virtual ~WindowedNotificationObserver(); |
408 | 422 |
409 // Wait until the specified notification occurs. If the notification was | 423 // Wait until the specified notification occurs. If the notification was |
410 // emitted between the construction of this object and this call then it | 424 // emitted between the construction of this object and this call then it |
411 // returns immediately. | 425 // returns immediately. |
412 void Wait(); | 426 void Wait(); |
413 | 427 |
414 // WaitFor waits until the given notification type is received from the | 428 // WaitFor waits until the given notification type is received from the |
415 // given object. If the notification was emitted between the construction of | 429 // given object. If the notification was emitted between the construction of |
416 // this object and this call then it returns immediately. | 430 // this object and this call then it returns immediately. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 | 605 |
592 // Takes a snapshot of the entire page, according to the width and height | 606 // Takes a snapshot of the entire page, according to the width and height |
593 // properties of the DOM's document. Returns true on success. DOMAutomation | 607 // properties of the DOM's document. Returns true on success. DOMAutomation |
594 // must be enabled. | 608 // must be enabled. |
595 bool TakeEntirePageSnapshot(RenderViewHost* rvh, | 609 bool TakeEntirePageSnapshot(RenderViewHost* rvh, |
596 SkBitmap* bitmap) WARN_UNUSED_RESULT; | 610 SkBitmap* bitmap) WARN_UNUSED_RESULT; |
597 | 611 |
598 } // namespace ui_test_utils | 612 } // namespace ui_test_utils |
599 | 613 |
600 #endif // CHROME_TEST_UI_TEST_UTILS_H_ | 614 #endif // CHROME_TEST_UI_TEST_UTILS_H_ |
OLD | NEW |