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

Unified Diff: chrome/test/base/ui_test_utils.cc

Issue 10479018: Add base::RunLoop and update ui_test_utils to use it to reduce flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: change Quit to QuitNow in places where it makes sense Created 8 years, 6 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 | « chrome/test/base/tracing.cc ('k') | chrome/test/perf/rendering/throughput_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/ui_test_utils.cc
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index c1b4619b0991e3a04420d2b399c0a210a50500ad..dd56a37a8581cd212a651ba4af6e55813fd5dc9a 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -114,12 +114,12 @@ class DOMOperationObserver : public content::NotificationObserver,
content::Details<DomOperationNotificationDetails> dom_op_details(details);
response_ = dom_op_details->json;
did_respond_ = true;
- MessageLoopForUI::current()->Quit();
+ MessageLoopForUI::current()->QuitNow();
}
// Overridden from content::WebContentsObserver:
virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE {
- MessageLoopForUI::current()->Quit();
+ MessageLoopForUI::current()->QuitNow();
}
bool GetResponse(std::string* response) WARN_UNUSED_RESULT {
@@ -163,7 +163,7 @@ class FindInPageNotificationObserver : public content::NotificationObserver {
active_match_ordinal_ = find_details->active_match_ordinal();
if (find_details->final_update()) {
number_of_matches_ = find_details->number_of_matches();
- MessageLoopForUI::current()->Quit();
+ MessageLoopForUI::current()->QuitNow();
} else {
DVLOG(1) << "Ignoring, since we only care about the final message";
}
@@ -265,7 +265,7 @@ void RunAllPendingMessageAndSendQuit(content::BrowserThread::ID thread_id) {
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
RunMessageLoop();
content::BrowserThread::PostTask(thread_id, FROM_HERE,
- MessageLoop::QuitClosure());
+ MessageLoop::QuitNowClosure());
}
} // namespace
@@ -331,7 +331,7 @@ void WaitForNavigations(NavigationController* controller,
number_of_navigations);
observer.WaitForObservation(
base::Bind(&ui_test_utils::RunMessageLoop),
- base::Bind(&MessageLoop::Quit,
+ base::Bind(&MessageLoop::QuitNow,
Paweł Hajdan Jr. 2012/06/05 11:57:44 nit: Would QuitNowClosure be slightly prettier her
jbates 2012/06/07 00:24:02 Done.
base::Unretained(MessageLoopForUI::current())));
}
@@ -391,7 +391,7 @@ void NavigateToURL(browser::NavigateParams* params) {
browser::Navigate(params);
observer.WaitForObservation(
base::Bind(&ui_test_utils::RunMessageLoop),
- base::Bind(&MessageLoop::Quit,
+ base::Bind(&MessageLoop::QuitNow,
Paweł Hajdan Jr. 2012/06/05 11:57:44 nit: Would QuitNowClosure be slightly prettier her
jbates 2012/06/07 00:24:02 Done.
base::Unretained(MessageLoopForUI::current())));
}
@@ -465,7 +465,7 @@ static void NavigateToURLWithDispositionBlockUntilNavigationsComplete(
if (disposition == CURRENT_TAB) {
same_tab_observer.WaitForObservation(
base::Bind(&ui_test_utils::RunMessageLoop),
- base::Bind(&MessageLoop::Quit,
+ base::Bind(&MessageLoop::QuitNow,
Paweł Hajdan Jr. 2012/06/05 11:57:44 nit: Would QuitNowClosure be slightly prettier her
jbates 2012/06/07 00:24:02 Done.
base::Unretained(MessageLoopForUI::current())));
return;
} else if (web_contents) {
@@ -773,11 +773,12 @@ bool SendKeyPressSync(const Browser* browser,
bool result;
result = ui_controls::SendKeyPressNotifyWhenDone(
- window, key, control, shift, alt, command, MessageLoop::QuitClosure());
+ window, key, control, shift, alt, command, MessageLoop::QuitNowClosure());
#if defined(OS_WIN)
if (!result && BringBrowserWindowToFront(browser)) {
result = ui_controls::SendKeyPressNotifyWhenDone(
- window, key, control, shift, alt, command, MessageLoop::QuitClosure());
+ window, key, control, shift, alt, command,
+ MessageLoop::QuitNowClosure());
}
#endif
if (!result) {
@@ -811,7 +812,7 @@ bool SendKeyPressAndWait(const Browser* browser,
bool SendMouseMoveSync(const gfx::Point& location) {
if (!ui_controls::SendMouseMoveNotifyWhenDone(location.x(), location.y(),
- MessageLoop::QuitClosure())) {
+ MessageLoop::QuitNowClosure())) {
return false;
}
RunMessageLoop();
@@ -820,7 +821,7 @@ bool SendMouseMoveSync(const gfx::Point& location) {
bool SendMouseEventsSync(ui_controls::MouseButton type, int state) {
if (!ui_controls::SendMouseEventsNotifyWhenDone(
- type, state, MessageLoop::QuitClosure())) {
+ type, state, MessageLoop::QuitNowClosure())) {
return false;
}
RunMessageLoop();
@@ -846,14 +847,14 @@ void TimedMessageLoopRunner::RunFor(int ms) {
void TimedMessageLoopRunner::Quit() {
quit_loop_invoked_ = true;
- loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
+ loop_->PostTask(FROM_HERE, MessageLoop::QuitNowClosure());
}
void TimedMessageLoopRunner::QuitAfter(int ms) {
quit_loop_invoked_ = true;
loop_->PostDelayedTask(
FROM_HERE,
- MessageLoop::QuitClosure(),
+ MessageLoop::QuitNowClosure(),
base::TimeDelta::FromMilliseconds(ms));
}
@@ -1031,7 +1032,7 @@ void WindowedNotificationObserver::Observe(
if (!running_)
return;
- MessageLoopForUI::current()->Quit();
+ MessageLoopForUI::current()->QuitNow();
running_ = false;
}
@@ -1109,7 +1110,7 @@ void TitleWatcher::Observe(int type,
observed_title_ = *it;
expected_title_observed_ = true;
if (quit_loop_on_observation_)
- MessageLoopForUI::current()->Quit();
+ MessageLoopForUI::current()->QuitNow();
}
BrowserAddedObserver::BrowserAddedObserver()
@@ -1144,7 +1145,7 @@ void DOMMessageQueue::Observe(int type,
message_queue_.push(dom_op_details->json);
if (waiting_for_message_) {
waiting_for_message_ = false;
- MessageLoopForUI::current()->Quit();
+ MessageLoopForUI::current()->QuitNow();
}
}
@@ -1219,7 +1220,7 @@ class SnapshotTaker {
void OnSnapshotTaken(const SkBitmap& bitmap) {
*bitmap_ = bitmap;
snapshot_taken_ = true;
- MessageLoop::current()->Quit();
+ MessageLoop::current()->QuitNow();
}
SkBitmap* bitmap_;
@@ -1252,7 +1253,7 @@ void OverrideGeolocation(double latitude, double longitude) {
position.accuracy = 0.;
position.timestamp = base::Time::Now();
content::OverrideLocationForTesting(position,
- base::Bind(MessageLoop::QuitClosure()));
+ MessageLoop::QuitNowClosure());
RunMessageLoop();
}
« no previous file with comments | « chrome/test/base/tracing.cc ('k') | chrome/test/perf/rendering/throughput_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698