summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-12 16:22:44 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-12 16:22:44 +0000
commit7ad40225da25437f7cf000c0848ab2102767209c (patch)
tree0a97d3a25bddf632cae963d4f383005a1d8493c3 /chrome/test
parent58291cf8f3232fdfe8da0d87d653cb9330c7cfb5 (diff)
downloadchromium_src-7ad40225da25437f7cf000c0848ab2102767209c.zip
chromium_src-7ad40225da25437f7cf000c0848ab2102767209c.tar.gz
chromium_src-7ad40225da25437f7cf000c0848ab2102767209c.tar.bz2
Switch the ErrorPageTest from ui tests to browser tests,
and declare them no longer flaky under Linux. These tests have a long and storied history of having varying degrees of flake. I'm hoping that switching them over to browser tests will fix most of it, particularly getting rid of the timer in "WaitForTitleMatching". It should also make any future flake a little easier to debug. TEST=ErrorPageTest.* BUG=79412 Review URL: http://codereview.chromium.org/7837043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100701 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/base/ui_test_utils.cc28
-rw-r--r--chrome/test/base/ui_test_utils.h2
2 files changed, 23 insertions, 7 deletions
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index d087e68..9a2a006 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -811,7 +811,7 @@ void WindowedNotificationObserver::Observe(int type,
TitleWatcher::TitleWatcher(TabContents* tab_contents,
const string16& expected_title)
- : expected_tab_(tab_contents),
+ : tab_contents_(tab_contents),
expected_title_observed_(false),
quit_loop_on_observation_(false) {
EXPECT_TRUE(tab_contents != NULL);
@@ -819,6 +819,16 @@ TitleWatcher::TitleWatcher(TabContents* tab_contents,
notification_registrar_.Add(this,
content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED,
Source<TabContents>(tab_contents));
+
+ // When navigating through the history, the restored NavigationEntry's title
+ // will be used. If the entry ends up having the same title after we return
+ // to it, as will usually be the case, the
+ // NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED will then be suppressed, since the
+ // NavigationEntry's title hasn't changed.
+ notification_registrar_.Add(
+ this,
+ content::NOTIFICATION_LOAD_STOP,
+ Source<NavigationController>(&tab_contents->controller()));
}
void TitleWatcher::AlsoWaitForTitle(const string16& expected_title) {
@@ -839,15 +849,21 @@ const string16& TitleWatcher::WaitAndGetTitle() {
void TitleWatcher::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
- if (type != content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED)
- return;
+ if (type == content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED) {
+ TabContents* source_contents = Source<TabContents>(source).ptr();
+ ASSERT_EQ(tab_contents_, source_contents);
+ } else if (type == content::NOTIFICATION_LOAD_STOP) {
+ NavigationController* controller =
+ Source<NavigationController>(source).ptr();
+ ASSERT_EQ(&tab_contents_->controller(), controller);
+ } else {
+ FAIL() << "Unexpected notification received.";
+ }
- TabContents* source_contents = Source<TabContents>(source).ptr();
- ASSERT_EQ(expected_tab_, source_contents);
std::vector<string16>::const_iterator it =
std::find(expected_titles_.begin(),
expected_titles_.end(),
- source_contents->GetTitle());
+ tab_contents_->GetTitle());
if (it == expected_titles_.end())
return;
observed_title_ = *it;
diff --git a/chrome/test/base/ui_test_utils.h b/chrome/test/base/ui_test_utils.h
index 07a4311..551959f 100644
--- a/chrome/test/base/ui_test_utils.h
+++ b/chrome/test/base/ui_test_utils.h
@@ -475,7 +475,7 @@ class TitleWatcher : public NotificationObserver {
const NotificationSource& source,
const NotificationDetails& details) OVERRIDE;
- TabContents* expected_tab_;
+ TabContents* tab_contents_;
std::vector<string16> expected_titles_;
NotificationRegistrar notification_registrar_;