summaryrefslogtreecommitdiffstats
path: root/chrome/test/ui_test_utils.cc
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-10 11:04:17 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-10 11:04:17 +0000
commitcb2509b77a6888d8c87c4ac63a5c26cb13bf5943 (patch)
treef75f277dc2ab96ddb3bd826ef73ff1a947ec1f22 /chrome/test/ui_test_utils.cc
parentc807cb19597e86144cfcc0d640c84f16c664f4d4 (diff)
downloadchromium_src-cb2509b77a6888d8c87c4ac63a5c26cb13bf5943.zip
chromium_src-cb2509b77a6888d8c87c4ac63a5c26cb13bf5943.tar.gz
chromium_src-cb2509b77a6888d8c87c4ac63a5c26cb13bf5943.tar.bz2
Add PrerenderUnload browser test to ensure that unload handlers are run on the navigated-away from page.
This test fails if the bug fix for 85350 is not in, and succeeds with it in. BUG=85350,82856 TEST=browser_tests --gtest_filter=*PrerenderUnload Review URL: http://codereview.chromium.org/7046053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui_test_utils.cc')
-rw-r--r--chrome/test/ui_test_utils.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc
index a0f2fb1..fe9cb71 100644
--- a/chrome/test/ui_test_utils.cc
+++ b/chrome/test/ui_test_utils.cc
@@ -889,6 +889,45 @@ void WindowedNotificationObserver::Observe(NotificationType type,
}
}
+TitleWatcher::TitleWatcher(TabContents* tab_contents,
+ const string16& expected_title)
+ : expected_tab_(tab_contents),
+ expected_title_(expected_title),
+ title_observed_(false),
+ quit_loop_on_observation_(false) {
+ EXPECT_TRUE(tab_contents != NULL);
+ notification_registrar_.Add(this,
+ NotificationType::TAB_CONTENTS_TITLE_UPDATED,
+ Source<TabContents>(tab_contents));
+}
+
+TitleWatcher::~TitleWatcher() {
+}
+
+bool TitleWatcher::Wait() {
+ if (title_observed_)
+ return true;
+ quit_loop_on_observation_ = true;
+ ui_test_utils::RunMessageLoop();
+ return title_observed_;
+}
+
+void TitleWatcher::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type != NotificationType::TAB_CONTENTS_TITLE_UPDATED)
+ return;
+
+ TabContents* source_contents = Source<TabContents>(source).ptr();
+ ASSERT_EQ(expected_tab_, source_contents);
+ if (source_contents->GetTitle() != expected_title_)
+ return;
+
+ title_observed_ = true;
+ if (quit_loop_on_observation_)
+ MessageLoopForUI::current()->Quit();
+}
+
DOMMessageQueue::DOMMessageQueue() {
registrar_.Add(this, NotificationType::DOM_OPERATION_RESPONSE,
NotificationService::AllSources());