OLD | NEW |
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 "content/browser/geofencing/geofencing_service.h" |
| 6 |
5 #include <stdint.h> | 7 #include <stdint.h> |
6 | 8 |
| 9 #include "base/memory/ptr_util.h" |
7 #include "content/browser/geofencing/geofencing_provider.h" | 10 #include "content/browser/geofencing/geofencing_provider.h" |
8 #include "content/browser/geofencing/geofencing_registration_delegate.h" | 11 #include "content/browser/geofencing/geofencing_registration_delegate.h" |
9 #include "content/browser/geofencing/geofencing_service.h" | |
10 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
11 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h" | 16 #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h" |
15 | 17 |
16 using blink::WebCircularGeofencingRegion; | 18 using blink::WebCircularGeofencingRegion; |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 test_region_.longitude = -122.084015; | 72 test_region_.longitude = -122.084015; |
71 test_region_.radius = 100; | 73 test_region_.radius = 100; |
72 } | 74 } |
73 | 75 |
74 void SetUp() override { service_ = new GeofencingServiceImpl(); } | 76 void SetUp() override { service_ = new GeofencingServiceImpl(); } |
75 | 77 |
76 void TearDown() override { delete service_; } | 78 void TearDown() override { delete service_; } |
77 | 79 |
78 void SetProviderForTests() { | 80 void SetProviderForTests() { |
79 provider_ = new MockGeofencingProvider(); | 81 provider_ = new MockGeofencingProvider(); |
80 service_->SetProviderForTesting(make_scoped_ptr(provider_)); | 82 service_->SetProviderForTesting(base::WrapUnique(provider_)); |
81 } | 83 } |
82 | 84 |
83 int RegistrationCount() { return service_->RegistrationCountForTesting(); } | 85 int RegistrationCount() { return service_->RegistrationCountForTesting(); } |
84 | 86 |
85 int64_t RegisterRegionSync(const WebCircularGeofencingRegion& region, | 87 int64_t RegisterRegionSync(const WebCircularGeofencingRegion& region, |
86 GeofencingStatus provider_status) { | 88 GeofencingStatus provider_status) { |
87 scoped_refptr<MessageLoopRunner> runner(new MessageLoopRunner()); | 89 scoped_refptr<MessageLoopRunner> runner(new MessageLoopRunner()); |
88 | 90 |
89 // The registration ID that is passed to the provider. | 91 // The registration ID that is passed to the provider. |
90 int64_t provider_registration_id = -1; | 92 int64_t provider_registration_id = -1; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // provider to be called. The delegate should not be called in this case. | 189 // provider to be called. The delegate should not be called in this case. |
188 EXPECT_CALL(delegate_, RegistrationFinished(testing::_, testing::_)).Times(0); | 190 EXPECT_CALL(delegate_, RegistrationFinished(testing::_, testing::_)).Times(0); |
189 EXPECT_CALL(*provider_, UnregisterRegion(geofencing_registration_id)) | 191 EXPECT_CALL(*provider_, UnregisterRegion(geofencing_registration_id)) |
190 .WillOnce(QuitRunner(runner)); | 192 .WillOnce(QuitRunner(runner)); |
191 callback.Run(GEOFENCING_STATUS_OK); | 193 callback.Run(GEOFENCING_STATUS_OK); |
192 runner->Run(); | 194 runner->Run(); |
193 EXPECT_EQ(0, RegistrationCount()); | 195 EXPECT_EQ(0, RegistrationCount()); |
194 } | 196 } |
195 | 197 |
196 } // namespace content | 198 } // namespace content |
OLD | NEW |