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

Side by Side Diff: blimp/engine/feature/geolocation/blimp_location_provider_unittest.cc

Issue 2226143002: Gets rid of the LocationArbitrator interface, in preference for LocationProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into lai Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "blimp/engine/feature/geolocation/blimp_location_provider.h" 5 #include "blimp/engine/feature/geolocation/blimp_location_provider.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 RequestAccuracy(GeolocationSetInterestLevelMessage::HIGH_ACCURACY)) 99 RequestAccuracy(GeolocationSetInterestLevelMessage::HIGH_ACCURACY))
100 .Times(1); 100 .Times(1);
101 EXPECT_CALL(*delegate_, 101 EXPECT_CALL(*delegate_,
102 RequestAccuracy(GeolocationSetInterestLevelMessage::NO_INTEREST)) 102 RequestAccuracy(GeolocationSetInterestLevelMessage::NO_INTEREST))
103 .Times(1); 103 .Times(1);
104 104
105 location_provider_->StartProvider(true); 105 location_provider_->StartProvider(true);
106 location_provider_.reset(); 106 location_provider_.reset();
107 } 107 }
108 108
109 TEST_F(BlimpLocationProviderTest, RequestRefreshRunsCorrectly) { 109 TEST_F(BlimpLocationProviderTest, OnPermissionGranted) {
110 EXPECT_CALL(*delegate_, RequestRefresh()).Times(1); 110 EXPECT_CALL(*delegate_, RequestRefresh()).Times(1);
111 111
112 location_provider_->StartProvider(true); 112 location_provider_->StartProvider(true);
113 location_provider_->RequestRefresh();
114 }
115
116 TEST_F(BlimpLocationProviderTest, RequestRefreshHandlesNullDelegate) {
117 EXPECT_CALL(*delegate_, RequestRefresh()).Times(0);
118
119 location_provider_->StartProvider(true);
120 delegate_.reset();
121 location_provider_->RequestRefresh();
122 }
123
124 TEST_F(BlimpLocationProviderTest, OnPermissionGrantedCallsRefresh) {
125 EXPECT_CALL(*delegate_, RequestRefresh()).Times(1);
126
127 location_provider_->StartProvider(true);
128 location_provider_->OnPermissionGranted(); 113 location_provider_->OnPermissionGranted();
129 } 114 }
130 115
131 TEST_F(BlimpLocationProviderTest, OnPermissionGrantedHandlesNullDelegate) { 116 TEST_F(BlimpLocationProviderTest, OnPermissionGrantedHandlesNullDelegate) {
132 EXPECT_CALL(*delegate_, RequestRefresh()).Times(0); 117 EXPECT_CALL(*delegate_, RequestRefresh()).Times(0);
133 118
134 location_provider_->StartProvider(true); 119 location_provider_->StartProvider(true);
135 delegate_.reset(); 120 delegate_.reset();
136 location_provider_->OnPermissionGranted(); 121 location_provider_->OnPermissionGranted();
137 } 122 }
138 123
139 TEST_F(BlimpLocationProviderTest, SetUpdateCallbackPropagatesCallback) { 124 TEST_F(BlimpLocationProviderTest, SetUpdateCallbackPropagatesCallback) {
140 base::Callback<void(const device::Geoposition&)> callback; 125 base::Callback<void(const device::Geoposition&)> callback;
141 EXPECT_CALL(*delegate_, SetUpdateCallback(_)).WillOnce(SaveArg<0>(&callback)); 126 EXPECT_CALL(*delegate_, SetUpdateCallback(_)).WillOnce(SaveArg<0>(&callback));
142 EXPECT_CALL(*this, OnLocationUpdate(location_provider_.get(), _)).Times(1); 127 EXPECT_CALL(*this, OnLocationUpdate(location_provider_.get(), _)).Times(1);
143 128
144 location_provider_->SetUpdateCallback(mock_callback_); 129 location_provider_->SetUpdateCallback(mock_callback_);
145 callback.Run(device::Geoposition()); 130 callback.Run(device::Geoposition());
146 } 131 }
147 132
148 TEST_F(BlimpLocationProviderTest, SetUpdateCallbackHandlesNullDelegate) { 133 TEST_F(BlimpLocationProviderTest, SetUpdateCallbackHandlesNullDelegate) {
149 EXPECT_CALL(*delegate_, SetUpdateCallback(_)).Times(0); 134 EXPECT_CALL(*delegate_, SetUpdateCallback(_)).Times(0);
150 135
151 delegate_.reset(); 136 delegate_.reset();
152 location_provider_->SetUpdateCallback(mock_callback_); 137 location_provider_->SetUpdateCallback(mock_callback_);
153 } 138 }
154 139
155 } // namespace engine 140 } // namespace engine
156 } // namespace blimp 141 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698