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

Unified Diff: device/geolocation/geolocation_provider_impl_unittest.cc

Issue 2849613002: Use ScopedTaskEnvironment instead of MessageLoopForUI in device tests. (Closed)
Patch Set: self-review Created 3 years, 8 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 | « no previous file | device/geolocation/wifi_data_provider_chromeos_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/geolocation/geolocation_provider_impl_unittest.cc
diff --git a/device/geolocation/geolocation_provider_impl_unittest.cc b/device/geolocation/geolocation_provider_impl_unittest.cc
index 1ba82a56f9709a8004f0ecb5354ea4086a3f86f0..81ba5fe0410e8892fc1901ef87642a4efc61d0f5 100644
--- a/device/geolocation/geolocation_provider_impl_unittest.cc
+++ b/device/geolocation/geolocation_provider_impl_unittest.cc
@@ -16,6 +16,8 @@
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string16.h"
+#include "base/test/scoped_task_environment.h"
+#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "device/geolocation/access_token_store.h"
#include "device/geolocation/fake_location_provider.h"
@@ -98,7 +100,10 @@ void DummyFunction(const LocationProvider* provider,
class GeolocationProviderTest : public testing::Test {
protected:
- GeolocationProviderTest() : arbitrator_(new FakeLocationProvider) {
+ GeolocationProviderTest()
+ : scoped_task_environment_(
+ base::test::ScopedTaskEnvironment::MainThreadType::UI),
+ arbitrator_(new FakeLocationProvider) {
provider()->SetArbitratorForTesting(base::WrapUnique(arbitrator_));
}
@@ -123,7 +128,9 @@ class GeolocationProviderTest : public testing::Test {
// test completes.
base::ShadowingAtExitManager at_exit_;
- base::MessageLoopForUI message_loop_;
+ base::test::ScopedTaskEnvironment scoped_task_environment_;
+
+ base::ThreadChecker thread_checker_;
// Owned by the GeolocationProviderImpl class.
FakeLocationProvider* arbitrator_;
@@ -136,7 +143,7 @@ class GeolocationProviderTest : public testing::Test {
bool GeolocationProviderTest::ProvidersStarted() {
DCHECK(provider()->IsRunning());
- DCHECK(base::MessageLoop::current() == &message_loop_);
+ DCHECK(thread_checker_.CalledOnValidThread());
provider()->task_runner()->PostTaskAndReply(
FROM_HERE, base::Bind(&GeolocationProviderTest::GetProvidersStarted,
@@ -153,7 +160,7 @@ void GeolocationProviderTest::GetProvidersStarted() {
void GeolocationProviderTest::SendMockLocation(const Geoposition& position) {
DCHECK(provider()->IsRunning());
- DCHECK(base::MessageLoop::current() == &message_loop_);
+ DCHECK(thread_checker_.CalledOnValidThread());
provider()->task_runner()->PostTask(
FROM_HERE,
base::Bind(&GeolocationProviderImpl::OnLocationUpdate,
« no previous file with comments | « no previous file | device/geolocation/wifi_data_provider_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698