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_BASE_UI_TEST_UTILS_H_ | 5 #ifndef CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | |
13 | 14 |
14 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
15 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
16 #include "base/scoped_temp_dir.h" | 17 #include "base/scoped_temp_dir.h" |
17 #include "base/string16.h" | 18 #include "base/string16.h" |
18 #include "chrome/browser/ui/view_ids.h" | 19 #include "chrome/browser/ui/view_ids.h" |
19 #include "chrome/test/automation/dom_element_proxy.h" | 20 #include "chrome/test/automation/dom_element_proxy.h" |
20 #include "content/common/notification_observer.h" | 21 #include "content/common/notification_observer.h" |
21 #include "content/common/notification_registrar.h" | 22 #include "content/common/notification_registrar.h" |
22 #include "content/common/notification_service.h" | 23 #include "content/common/notification_service.h" |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 | 486 |
486 // Watches title changes on a tab, blocking until an expected title is set. | 487 // Watches title changes on a tab, blocking until an expected title is set. |
487 class TitleWatcher : public NotificationObserver { | 488 class TitleWatcher : public NotificationObserver { |
488 public: | 489 public: |
489 // |tab_contents| must be non-NULL and needs to stay alive for the | 490 // |tab_contents| must be non-NULL and needs to stay alive for the |
490 // entire lifetime of |this|. |expected_title| is the title that |this| | 491 // entire lifetime of |this|. |expected_title| is the title that |this| |
491 // will wait for. | 492 // will wait for. |
492 TitleWatcher(TabContents* tab_contents, const string16& expected_title); | 493 TitleWatcher(TabContents* tab_contents, const string16& expected_title); |
493 virtual ~TitleWatcher(); | 494 virtual ~TitleWatcher(); |
494 | 495 |
495 // Waits until the title for the tab is set to the |expected_title| | 496 // Adds another title to watch for. |
496 // passed into the constructor. | 497 void AddTitle(const string16& expected_title); |
Paweł Hajdan Jr.
2011/08/02 21:45:57
nit: Let's rename this to AlsoWaitForTitle.
mmenke
2011/08/03 15:44:17
Done.
| |
497 bool Wait() WARN_UNUSED_RESULT; | 498 |
499 // Waits until the title matches either expected_title or one of the titles | |
500 // added with AddTitle. Returns the value of the most recently seen matching | |
501 // title. | |
502 const string16& Wait() WARN_UNUSED_RESULT; | |
Paweł Hajdan Jr.
2011/08/02 21:45:57
nit: Let's rename this to WaitAndGetTitle.
mmenke
2011/08/03 15:44:17
Done.
| |
498 | 503 |
499 private: | 504 private: |
500 // NotificationObserver | 505 // NotificationObserver |
501 virtual void Observe(int type, | 506 virtual void Observe(int type, |
502 const NotificationSource& source, | 507 const NotificationSource& source, |
503 const NotificationDetails& details) OVERRIDE; | 508 const NotificationDetails& details) OVERRIDE; |
504 | 509 |
505 TabContents* expected_tab_; | 510 TabContents* expected_tab_; |
506 string16 expected_title_; | 511 std::vector<string16> expected_titles_; |
507 NotificationRegistrar notification_registrar_; | 512 NotificationRegistrar notification_registrar_; |
508 bool title_observed_; | 513 |
514 // The most recently observed expected title, if any. | |
515 string16 observed_title_; | |
516 | |
517 bool expected_title_observed_; | |
509 bool quit_loop_on_observation_; | 518 bool quit_loop_on_observation_; |
510 | 519 |
511 DISALLOW_COPY_AND_ASSIGN(TitleWatcher); | 520 DISALLOW_COPY_AND_ASSIGN(TitleWatcher); |
512 }; | 521 }; |
513 | 522 |
514 // See SendKeyPressAndWait. This function additionally performs a check on the | 523 // See SendKeyPressAndWait. This function additionally performs a check on the |
515 // NotificationDetails using the provided Details<U>. | 524 // NotificationDetails using the provided Details<U>. |
516 template <class U> | 525 template <class U> |
517 bool SendKeyPressAndWaitWithDetails( | 526 bool SendKeyPressAndWaitWithDetails( |
518 const Browser* browser, | 527 const Browser* browser, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 | 600 |
592 // Takes a snapshot of the entire page, according to the width and height | 601 // 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 | 602 // properties of the DOM's document. Returns true on success. DOMAutomation |
594 // must be enabled. | 603 // must be enabled. |
595 bool TakeEntirePageSnapshot(RenderViewHost* rvh, | 604 bool TakeEntirePageSnapshot(RenderViewHost* rvh, |
596 SkBitmap* bitmap) WARN_UNUSED_RESULT; | 605 SkBitmap* bitmap) WARN_UNUSED_RESULT; |
597 | 606 |
598 } // namespace ui_test_utils | 607 } // namespace ui_test_utils |
599 | 608 |
600 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 609 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
OLD | NEW |