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

Side by Side Diff: content/browser/geolocation/geolocation_provider_impl_unittest.cc

Issue 1398153002: Don't use base::MessageLoop::{Quit,QuitClosure} in content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 class MockGeolocationObserver : public GeolocationObserver { 58 class MockGeolocationObserver : public GeolocationObserver {
59 public: 59 public:
60 MOCK_METHOD1(OnLocationUpdate, void(const Geoposition& position)); 60 MOCK_METHOD1(OnLocationUpdate, void(const Geoposition& position));
61 }; 61 };
62 62
63 class AsyncMockGeolocationObserver : public MockGeolocationObserver { 63 class AsyncMockGeolocationObserver : public MockGeolocationObserver {
64 public: 64 public:
65 void OnLocationUpdate(const Geoposition& position) override { 65 void OnLocationUpdate(const Geoposition& position) override {
66 MockGeolocationObserver::OnLocationUpdate(position); 66 MockGeolocationObserver::OnLocationUpdate(position);
67 base::MessageLoop::current()->Quit(); 67 base::MessageLoop::current()->QuitWhenIdle();
68 } 68 }
69 }; 69 };
70 70
71 class MockGeolocationCallbackWrapper { 71 class MockGeolocationCallbackWrapper {
72 public: 72 public:
73 MOCK_METHOD1(Callback, void(const Geoposition& position)); 73 MOCK_METHOD1(Callback, void(const Geoposition& position));
74 }; 74 };
75 75
76 class GeopositionEqMatcher 76 class GeopositionEqMatcher
77 : public MatcherInterface<const Geoposition&> { 77 : public MatcherInterface<const Geoposition&> {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 }; 137 };
138 138
139 139
140 bool GeolocationProviderTest::ProvidersStarted() { 140 bool GeolocationProviderTest::ProvidersStarted() {
141 DCHECK(provider_->IsRunning()); 141 DCHECK(provider_->IsRunning());
142 DCHECK(base::MessageLoop::current() == &message_loop_); 142 DCHECK(base::MessageLoop::current() == &message_loop_);
143 bool started; 143 bool started;
144 provider_->task_runner()->PostTaskAndReply( 144 provider_->task_runner()->PostTaskAndReply(
145 FROM_HERE, base::Bind(&GeolocationProviderTest::GetProvidersStarted, 145 FROM_HERE, base::Bind(&GeolocationProviderTest::GetProvidersStarted,
146 base::Unretained(this), &started), 146 base::Unretained(this), &started),
147 base::MessageLoop::QuitClosure()); 147 base::MessageLoop::QuitWhenIdleClosure());
148 message_loop_.Run(); 148 message_loop_.Run();
149 return started; 149 return started;
150 } 150 }
151 151
152 void GeolocationProviderTest::GetProvidersStarted(bool* started) { 152 void GeolocationProviderTest::GetProvidersStarted(bool* started) {
153 DCHECK(base::MessageLoop::current() == provider_->message_loop()); 153 DCHECK(base::MessageLoop::current() == provider_->message_loop());
154 *started = provider_->mock_arbitrator()->providers_started(); 154 *started = provider_->mock_arbitrator()->providers_started();
155 } 155 }
156 156
157 void GeolocationProviderTest::SendMockLocation(const Geoposition& position) { 157 void GeolocationProviderTest::SendMockLocation(const Geoposition& position) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 &MockGeolocationObserver::OnLocationUpdate, 246 &MockGeolocationObserver::OnLocationUpdate,
247 base::Unretained(&mock_observer)); 247 base::Unretained(&mock_observer));
248 scoped_ptr<content::GeolocationProvider::Subscription> subscription = 248 scoped_ptr<content::GeolocationProvider::Subscription> subscription =
249 provider()->AddLocationUpdateCallback(callback, false); 249 provider()->AddLocationUpdateCallback(callback, false);
250 subscription.reset(); 250 subscription.reset();
251 // Wait for the providers to be stopped now that all clients are gone. 251 // Wait for the providers to be stopped now that all clients are gone.
252 EXPECT_FALSE(ProvidersStarted()); 252 EXPECT_FALSE(ProvidersStarted());
253 } 253 }
254 254
255 } // namespace content 255 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698