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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 details_[source.map_key()] = *details_ptr; | 464 details_[source.map_key()] = *details_ptr; |
465 WindowedNotificationObserver::Observe(type, source, details); | 465 WindowedNotificationObserver::Observe(type, source, details); |
466 } | 466 } |
467 | 467 |
468 private: | 468 private: |
469 std::map<uintptr_t, U> details_; | 469 std::map<uintptr_t, U> details_; |
470 | 470 |
471 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails); | 471 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails); |
472 }; | 472 }; |
473 | 473 |
| 474 // Watches title changes on a tab, blocking until an expected title is set. |
| 475 class TitleWatcher : public NotificationObserver { |
| 476 public: |
| 477 // |tab_contents| must be non-NULL and needs to stay alive for the |
| 478 // entire lifetime of |this|. |expected_title| is the title that |this| |
| 479 // will wait for. |
| 480 TitleWatcher(TabContents* tab_contents, const string16& expected_title); |
| 481 ~TitleWatcher(); |
| 482 |
| 483 // Waits until the title for the tab is set to the |expected_title| |
| 484 // passed into the constructor. |
| 485 bool Wait() WARN_UNUSED_RESULT; |
| 486 |
| 487 private: |
| 488 // NotificationObserver |
| 489 virtual void Observe(NotificationType type, |
| 490 const NotificationSource& source, |
| 491 const NotificationDetails& details) OVERRIDE; |
| 492 |
| 493 TabContents* expected_tab_; |
| 494 string16 expected_title_; |
| 495 NotificationRegistrar notification_registrar_; |
| 496 bool title_observed_; |
| 497 bool quit_loop_on_observation_; |
| 498 |
| 499 DISALLOW_COPY_AND_ASSIGN(TitleWatcher); |
| 500 }; |
| 501 |
474 // See SendKeyPressAndWait. This function additionally performs a check on the | 502 // See SendKeyPressAndWait. This function additionally performs a check on the |
475 // NotificationDetails using the provided Details<U>. | 503 // NotificationDetails using the provided Details<U>. |
476 template <class U> | 504 template <class U> |
477 bool SendKeyPressAndWaitWithDetails( | 505 bool SendKeyPressAndWaitWithDetails( |
478 const Browser* browser, | 506 const Browser* browser, |
479 ui::KeyboardCode key, | 507 ui::KeyboardCode key, |
480 bool control, | 508 bool control, |
481 bool shift, | 509 bool shift, |
482 bool alt, | 510 bool alt, |
483 bool command, | 511 bool command, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 | 579 |
552 // Takes a snapshot of the entire page, according to the width and height | 580 // Takes a snapshot of the entire page, according to the width and height |
553 // properties of the DOM's document. Returns true on success. DOMAutomation | 581 // properties of the DOM's document. Returns true on success. DOMAutomation |
554 // must be enabled. | 582 // must be enabled. |
555 bool TakeEntirePageSnapshot(RenderViewHost* rvh, | 583 bool TakeEntirePageSnapshot(RenderViewHost* rvh, |
556 SkBitmap* bitmap) WARN_UNUSED_RESULT; | 584 SkBitmap* bitmap) WARN_UNUSED_RESULT; |
557 | 585 |
558 } // namespace ui_test_utils | 586 } // namespace ui_test_utils |
559 | 587 |
560 #endif // CHROME_TEST_UI_TEST_UTILS_H_ | 588 #endif // CHROME_TEST_UI_TEST_UTILS_H_ |
OLD | NEW |