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

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

Issue 2630683003: Revert of Convert more test helpers to base::RunLoop, fix page title checks. (Closed)
Patch Set: 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 2a0072c65bce29a44ea4c6130ab55ed8bb26d206..5e17cb5727f336b6bf86782c1b3ba576dd69c42b 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -16,7 +16,6 @@
#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"
@@ -1193,14 +1192,11 @@
}
#endif
-TitleWatcher::TitleWatcher(WebContents* web_contents)
- : WebContentsObserver(web_contents) {
- EXPECT_TRUE(web_contents != nullptr);
-}
-
TitleWatcher::TitleWatcher(WebContents* web_contents,
const base::string16& expected_title)
- : TitleWatcher(web_contents) {
+ : WebContentsObserver(web_contents),
+ message_loop_runner_(new MessageLoopRunner) {
+ EXPECT_TRUE(web_contents != NULL);
expected_titles_.push_back(expected_title);
}
@@ -1213,7 +1209,7 @@
const base::string16& TitleWatcher::WaitAndGetTitle() {
TestTitle();
- run_loop_.Run();
+ message_loop_runner_->Run();
return observed_title_;
}
@@ -1230,12 +1226,15 @@
}
void TitleWatcher::TestTitle() {
- const base::string16& current_title = web_contents()->GetTitle();
- if ((!current_title.empty() && expected_titles_.empty()) ||
- base::ContainsValue(expected_titles_, current_title)) {
- observed_title_ = current_title;
- run_loop_.Quit();
- }
+ 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();
}
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