| 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 "base/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "content/browser/geofencing/geofencing_manager.h" | 7 #include "content/browser/geofencing/geofencing_manager.h" |
| 8 #include "content/browser/geofencing/geofencing_service.h" | 8 #include "content/browser/geofencing/geofencing_service.h" |
| 9 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 9 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
| 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 GURL script_url("http://www.example.com/service_worker.js"); | 150 GURL script_url("http://www.example.com/service_worker.js"); |
| 151 int64 registration_id = kInvalidServiceWorkerRegistrationId; | 151 int64 registration_id = kInvalidServiceWorkerRegistrationId; |
| 152 bool called = false; | 152 bool called = false; |
| 153 helper_->context()->RegisterServiceWorker( | 153 helper_->context()->RegisterServiceWorker( |
| 154 pattern, script_url, nullptr, | 154 pattern, script_url, nullptr, |
| 155 MakeRegisteredCallback(&called, ®istration_id)); | 155 MakeRegisteredCallback(&called, ®istration_id)); |
| 156 | 156 |
| 157 EXPECT_FALSE(called); | 157 EXPECT_FALSE(called); |
| 158 base::RunLoop().RunUntilIdle(); | 158 base::RunLoop().RunUntilIdle(); |
| 159 EXPECT_TRUE(called); | 159 EXPECT_TRUE(called); |
| 160 | 160 scoped_refptr<ServiceWorkerRegistration> worker( |
| 161 return make_scoped_refptr(new ServiceWorkerRegistration( | 161 new ServiceWorkerRegistration(pattern, registration_id, |
| 162 pattern, registration_id, helper_->context()->AsWeakPtr())); | 162 helper_->context()->AsWeakPtr())); |
| 163 // ServiceWorkerRegistration posts a notification task on construction. |
| 164 base::RunLoop().RunUntilIdle(); |
| 165 return worker; |
| 163 } | 166 } |
| 164 | 167 |
| 165 void UnregisterServiceWorker( | 168 void UnregisterServiceWorker( |
| 166 const scoped_refptr<ServiceWorkerRegistration>& registration) { | 169 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
| 167 bool called = false; | 170 bool called = false; |
| 168 helper_->context()->UnregisterServiceWorker( | 171 helper_->context()->UnregisterServiceWorker( |
| 169 registration->pattern(), MakeUnregisteredCallback(&called)); | 172 registration->pattern(), MakeUnregisteredCallback(&called)); |
| 170 | 173 |
| 171 EXPECT_FALSE(called); | 174 EXPECT_FALSE(called); |
| 172 base::RunLoop().RunUntilIdle(); | 175 base::RunLoop().RunUntilIdle(); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 GEOFENCING_STATUS_OK, kTestGeofencingRegistrationId)); | 507 GEOFENCING_STATUS_OK, kTestGeofencingRegistrationId)); |
| 505 VerifyRegions(worker1_->id(), expected_regions_); | 508 VerifyRegions(worker1_->id(), expected_regions_); |
| 506 | 509 |
| 507 EXPECT_CALL(*service_, UnregisterRegion(kTestGeofencingRegistrationId)); | 510 EXPECT_CALL(*service_, UnregisterRegion(kTestGeofencingRegistrationId)); |
| 508 | 511 |
| 509 manager_->SetMockProvider(GeofencingMockState::SERVICE_AVAILABLE); | 512 manager_->SetMockProvider(GeofencingMockState::SERVICE_AVAILABLE); |
| 510 VerifyRegions(worker1_->id(), RegionMap()); | 513 VerifyRegions(worker1_->id(), RegionMap()); |
| 511 } | 514 } |
| 512 | 515 |
| 513 } // namespace content | 516 } // namespace content |
| OLD | NEW |