summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorskyostil <skyostil@chromium.org>2015-04-27 10:59:37 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-27 17:59:35 +0000
commit0becb33779f8678e2703d6ff1a73ce2b45571f98 (patch)
treeca8e900931a5e71c07db40c308a7755b15de1870 /chromeos
parent6974bf71b37bddb36ca8b1feefc013b7c47c105f (diff)
downloadchromium_src-0becb33779f8678e2703d6ff1a73ce2b45571f98.zip
chromium_src-0becb33779f8678e2703d6ff1a73ce2b45571f98.tar.gz
chromium_src-0becb33779f8678e2703d6ff1a73ce2b45571f98.tar.bz2
Ensure tests have an active task runner
This patch modifies all tests to have a more realistic threading set-up by either: a) adding a TestBrowserThreadBundle b) constructing any existing TestBrowserThreadBundle earlier or c) adding a MessageLoop as appropriate. This makes it possible to later migrate base/ from MessageLoopProxy over to ThreadTaskRunnerHandle, which requires an active task runner on the current thread. BUG=465354 Review URL: https://codereview.chromium.org/1086733002 Cr-Commit-Position: refs/heads/master@{#327067}
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/services/service_provider_test_helper.cc8
-rw-r--r--chromeos/dbus/services/service_provider_test_helper.h2
2 files changed, 6 insertions, 4 deletions
diff --git a/chromeos/dbus/services/service_provider_test_helper.cc b/chromeos/dbus/services/service_provider_test_helper.cc
index c4c5c65..9b70172 100644
--- a/chromeos/dbus/services/service_provider_test_helper.cc
+++ b/chromeos/dbus/services/service_provider_test_helper.cc
@@ -20,6 +20,8 @@ namespace chromeos {
ServiceProviderTestHelper::ServiceProviderTestHelper()
: response_received_(false) {
+ if (!base::MessageLoop::current())
+ message_loop_.reset(new base::MessageLoop());
}
ServiceProviderTestHelper::~ServiceProviderTestHelper() {
@@ -129,7 +131,7 @@ dbus::Response* ServiceProviderTestHelper::MockCallMethodAndBlock(
base::Unretained(this)));
// Check for a response.
if (!response_received_)
- message_loop_.Run();
+ base::MessageLoop::current()->Run();
// Return response.
return response_.release();
}
@@ -155,8 +157,8 @@ void ServiceProviderTestHelper::OnResponse(
scoped_ptr<dbus::Response> response) {
response_ = response.Pass();
response_received_ = true;
- if (message_loop_.is_running())
- message_loop_.Quit();
+ if (base::MessageLoop::current()->is_running())
+ base::MessageLoop::current()->Quit();
}
} // namespace chromeos
diff --git a/chromeos/dbus/services/service_provider_test_helper.h b/chromeos/dbus/services/service_provider_test_helper.h
index 196f6a6..c5091b1 100644
--- a/chromeos/dbus/services/service_provider_test_helper.h
+++ b/chromeos/dbus/services/service_provider_test_helper.h
@@ -88,7 +88,7 @@ class ServiceProviderTestHelper {
scoped_refptr<dbus::MockObjectProxy> mock_object_proxy_;
dbus::ExportedObject::MethodCallCallback method_callback_;
dbus::ObjectProxy::SignalCallback on_signal_callback_;
- base::MessageLoop message_loop_;
+ scoped_ptr<base::MessageLoop> message_loop_;
bool response_received_;
scoped_ptr<dbus::Response> response_;
};