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

Unified Diff: content/public/test/browser_test_utils.cc

Issue 2635933003: Convert more test helpers to base::RunLoop, fix page title checks. (Reland) (Closed)
Patch Set: Fix ClickModifierTests. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/public/test/test_frame_navigation_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/browser_test_utils.cc
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index 06394e01ddbe1c70b8bbfce8ed459b507e7326bc..921e8bfecd96d751ec829d7c68b91dca7f7fbc53 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -16,6 +16,7 @@
#include "base/macros.h"
#include "base/process/kill.h"
#include "base/rand_util.h"
+#include "base/stl_util.h"
#include "base/strings/pattern.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
@@ -1205,9 +1206,7 @@ void WaitForGuestSurfaceReady(content::WebContents* guest_web_contents) {
TitleWatcher::TitleWatcher(WebContents* web_contents,
const base::string16& expected_title)
- : WebContentsObserver(web_contents),
- message_loop_runner_(new MessageLoopRunner) {
- EXPECT_TRUE(web_contents != NULL);
+ : WebContentsObserver(web_contents) {
expected_titles_.push_back(expected_title);
}
@@ -1220,7 +1219,7 @@ TitleWatcher::~TitleWatcher() {
const base::string16& TitleWatcher::WaitAndGetTitle() {
TestTitle();
- message_loop_runner_->Run();
+ run_loop_.Run();
return observed_title_;
}
@@ -1237,15 +1236,11 @@ void TitleWatcher::TitleWasSet(NavigationEntry* entry, bool explicit_set) {
}
void TitleWatcher::TestTitle() {
- std::vector<base::string16>::const_iterator it =
- std::find(expected_titles_.begin(),
- expected_titles_.end(),
- web_contents()->GetTitle());
- if (it == expected_titles_.end())
- return;
-
- observed_title_ = *it;
- message_loop_runner_->Quit();
+ const base::string16& current_title = web_contents()->GetTitle();
+ if (base::ContainsValue(expected_titles_, current_title)) {
+ observed_title_ = current_title;
+ run_loop_.Quit();
+ }
}
RenderProcessHostWatcher::RenderProcessHostWatcher(
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/public/test/test_frame_navigation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698