Chromium Code Reviews| Index: chrome/browser/ui/search/instant_test_utils.cc |
| diff --git a/chrome/browser/ui/search/instant_test_utils.cc b/chrome/browser/ui/search/instant_test_utils.cc |
| index 7437c44afdeb3a54a8a0ffc5834bd92f048bcdc6..ac3e17fab560e40a3c3cea9aaa75dda11d7bd5ea 100644 |
| --- a/chrome/browser/ui/search/instant_test_utils.cc |
| +++ b/chrome/browser/ui/search/instant_test_utils.cc |
| @@ -33,9 +33,10 @@ std::string WrapScript(const std::string& script) { |
| InstantTestModelObserver::InstantTestModelObserver( |
| InstantOverlayModel* model, |
| - SearchMode::Type desired_mode_type) |
| + SearchMode::Type expected_mode_type) |
| : model_(model), |
| - desired_mode_type_(desired_mode_type) { |
| + expected_mode_type_(expected_mode_type), |
| + observed_mode_type_(static_cast<SearchMode::Type>(-1)) { |
| model_->AddObserver(this); |
| } |
| @@ -43,14 +44,16 @@ InstantTestModelObserver::~InstantTestModelObserver() { |
| model_->RemoveObserver(this); |
| } |
| -void InstantTestModelObserver::WaitForDesiredOverlayState() { |
| +bool InstantTestModelObserver::WaitForExpectedOverlayState() { |
| run_loop_.Run(); |
| + return observed_mode_type_ == expected_mode_type_; |
| } |
| void InstantTestModelObserver::OverlayStateChanged( |
| const InstantOverlayModel& model) { |
| - if (model.mode().mode == desired_mode_type_) |
| - run_loop_.Quit(); |
| + observed_mode_type_ = model.mode().mode; |
|
Jered
2013/04/16 22:35:57
I'm worried that this might break some tests which
dhollowa
2013/04/16 22:50:51
Yes, I verified. No problems with this.
|
| + EXPECT_EQ(expected_mode_type_, observed_mode_type_); |
| + run_loop_.Quit(); |
| } |
| // InstantTestBase ----------------------------------------------------------- |
| @@ -140,12 +143,12 @@ void InstantTestBase::SetOmniboxText(const std::string& text) { |
| omnibox()->SetUserText(UTF8ToUTF16(text)); |
| } |
| -void InstantTestBase::SetOmniboxTextAndWaitForOverlayToShow( |
| +bool InstantTestBase::SetOmniboxTextAndWaitForOverlayToShow( |
| const std::string& text) { |
| InstantTestModelObserver observer( |
| instant()->model(), SearchMode::MODE_SEARCH_SUGGESTIONS); |
| SetOmniboxText(text); |
| - observer.WaitForDesiredOverlayState(); |
| + return observer.WaitForExpectedOverlayState(); |
| } |
| void InstantTestBase::SetOmniboxTextAndWaitForSuggestion( |