Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(745)

Side by Side Diff: chrome/test/base/ui_test_utils.h

Issue 10815025: Move TitleWatcher from ui_test_utils.h to browser_test_utils.h so it can be reused by content_brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/unload_browsertest.cc ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 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 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <set> 10 #include <set>
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 details_[source.map_key()] = *details_ptr; 418 details_[source.map_key()] = *details_ptr;
419 content::WindowedNotificationObserver::Observe(type, source, details); 419 content::WindowedNotificationObserver::Observe(type, source, details);
420 } 420 }
421 421
422 private: 422 private:
423 std::map<uintptr_t, U> details_; 423 std::map<uintptr_t, U> details_;
424 424
425 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails); 425 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails);
426 }; 426 };
427 427
428 // Watches title changes on a tab, blocking until an expected title is set.
429 class TitleWatcher : public content::NotificationObserver {
430 public:
431 // |web_contents| must be non-NULL and needs to stay alive for the
432 // entire lifetime of |this|. |expected_title| is the title that |this|
433 // will wait for.
434 TitleWatcher(content::WebContents* web_contents,
435 const string16& expected_title);
436 virtual ~TitleWatcher();
437
438 // Adds another title to watch for.
439 void AlsoWaitForTitle(const string16& expected_title);
440
441 // Waits until the title matches either expected_title or one of the titles
442 // added with AlsoWaitForTitle. Returns the value of the most recently
443 // observed matching title.
444 const string16& WaitAndGetTitle() WARN_UNUSED_RESULT;
445
446 private:
447 // content::NotificationObserver
448 virtual void Observe(int type,
449 const content::NotificationSource& source,
450 const content::NotificationDetails& details) OVERRIDE;
451
452 content::WebContents* web_contents_;
453 std::vector<string16> expected_titles_;
454 content::NotificationRegistrar notification_registrar_;
455 scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
456
457 // The most recently observed expected title, if any.
458 string16 observed_title_;
459
460 bool expected_title_observed_;
461 bool quit_loop_on_observation_;
462
463 DISALLOW_COPY_AND_ASSIGN(TitleWatcher);
464 };
465
466 // Convenience class for waiting for a new browser to be created. 428 // Convenience class for waiting for a new browser to be created.
467 // Like WindowedNotificationObserver, this class provides a safe, non-racey 429 // Like WindowedNotificationObserver, this class provides a safe, non-racey
468 // way to wait for a new browser to be created. 430 // way to wait for a new browser to be created.
469 class BrowserAddedObserver { 431 class BrowserAddedObserver {
470 public: 432 public:
471 BrowserAddedObserver(); 433 BrowserAddedObserver();
472 ~BrowserAddedObserver(); 434 ~BrowserAddedObserver();
473 435
474 // Wait for a new browser to be created, and return a pointer to it. 436 // Wait for a new browser to be created, and return a pointer to it.
475 Browser* WaitForSingleNewBrowser(); 437 Browser* WaitForSingleNewBrowser();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 // ui_controls_linux.cc and ui_controls_mac.cc 566 // ui_controls_linux.cc and ui_controls_mac.cc
605 void ClickTask(ui_controls::MouseButton button, 567 void ClickTask(ui_controls::MouseButton button,
606 int state, 568 int state,
607 const base::Closure& followup); 569 const base::Closure& followup);
608 570
609 } // namespace internal 571 } // namespace internal
610 572
611 } // namespace ui_test_utils 573 } // namespace ui_test_utils
612 574
613 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_ 575 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « chrome/browser/unload_browsertest.cc ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698