Index: chrome/test/base/ui_test_utils.cc |
=================================================================== |
--- chrome/test/base/ui_test_utils.cc (revision 94917) |
+++ chrome/test/base/ui_test_utils.cc (working copy) |
@@ -902,24 +902,28 @@ |
TitleWatcher::TitleWatcher(TabContents* tab_contents, |
const string16& expected_title) |
: expected_tab_(tab_contents), |
- expected_title_(expected_title), |
- title_observed_(false), |
+ expected_title_observed_(false), |
quit_loop_on_observation_(false) { |
EXPECT_TRUE(tab_contents != NULL); |
+ expected_titles_.push_back(expected_title); |
notification_registrar_.Add(this, |
content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED, |
Source<TabContents>(tab_contents)); |
} |
+void TitleWatcher::AddTitle(const string16& expected_title) { |
+ expected_titles_.push_back(expected_title); |
+} |
+ |
TitleWatcher::~TitleWatcher() { |
} |
-bool TitleWatcher::Wait() { |
- if (title_observed_) |
- return true; |
+const string16& TitleWatcher::Wait() { |
+ if (expected_title_observed_) |
+ return observed_title_; |
quit_loop_on_observation_ = true; |
ui_test_utils::RunMessageLoop(); |
- return title_observed_; |
+ return observed_title_; |
} |
void TitleWatcher::Observe(int type, |
@@ -930,12 +934,17 @@ |
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(); |
+ for (std::vector<string16>::const_iterator it = expected_titles_.begin(); |
eroman
2011/08/03 00:32:24
[optional] If you prefer, could also used std::fin
mmenke
2011/08/03 15:44:17
Good idea, done.
|
+ it != expected_titles_.end(); |
+ ++it) { |
+ if (*it == source_contents->GetTitle()) { |
+ observed_title_ = source_contents->GetTitle(); |
eroman
2011/08/03 00:32:24
BTW I don't know anything about the GetTitle() fun
mmenke
2011/08/03 15:44:17
It can't change, but switching to using .find() re
|
+ expected_title_observed_ = true; |
+ if (quit_loop_on_observation_) |
+ MessageLoopForUI::current()->Quit(); |
+ return; |
+ } |
+ } |
} |
DOMMessageQueue::DOMMessageQueue() { |