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

Unified Diff: content/browser/geofencing/geofencing_manager_unittest.cc

Issue 701953007: Expose mock geofencing service via testRunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mention unifying bug in a comment Created 6 years 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 | « content/browser/geofencing/geofencing_manager.cc ('k') | content/browser/geofencing/geofencing_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/geofencing/geofencing_manager_unittest.cc
diff --git a/content/browser/geofencing/geofencing_manager_unittest.cc b/content/browser/geofencing/geofencing_manager_unittest.cc
index cf64b9faa047167783ae3055794e94a63b13a435..9959033f463637bb8585d8088e8a04e33b06602b 100644
--- a/content/browser/geofencing/geofencing_manager_unittest.cc
+++ b/content/browser/geofencing/geofencing_manager_unittest.cc
@@ -411,4 +411,59 @@ TEST_F(GeofencingManagerTest, ShutdownCleansRegistrations) {
runner->Run();
}
+TEST_F(GeofencingManagerTest, RegisterRegion_MockedNoService) {
+ manager_->SetMockProvider(GeofencingMockState::SERVICE_UNAVAILABLE);
+ // Make sure real service doesn't get called.
+ EXPECT_CALL(*service_, IsServiceAvailable()).Times(0);
+
+ EXPECT_EQ(GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE,
+ RegisterRegionSync(kTestServiceWorkerRegistrationId, kTestRegionId,
+ test_region_));
+}
+
+TEST_F(GeofencingManagerTest, UnregisterRegion_MockedNoService) {
+ manager_->SetMockProvider(GeofencingMockState::SERVICE_UNAVAILABLE);
+ // Make sure real service doesn't get called.
+ EXPECT_CALL(*service_, IsServiceAvailable()).Times(0);
+
+ EXPECT_EQ(GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE,
+ UnregisterRegionSync(kTestServiceWorkerRegistrationId,
+ kTestRegionId, false));
+}
+
+TEST_F(GeofencingManagerTest, GetRegisteredRegions_MockedNoService) {
+ manager_->SetMockProvider(GeofencingMockState::SERVICE_UNAVAILABLE);
+ // Make sure real service doesn't get called.
+ EXPECT_CALL(*service_, IsServiceAvailable()).Times(0);
+
+ RegionMap regions;
+ EXPECT_EQ(GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE,
+ manager_->GetRegisteredRegions(kTestServiceWorkerRegistrationId,
+ &regions));
+ EXPECT_TRUE(regions.empty());
+}
+
+TEST_F(GeofencingManagerTest, RegisterRegion_MockedService) {
+ manager_->SetMockProvider(GeofencingMockState::SERVICE_AVAILABLE);
+
+ EXPECT_EQ(GEOFENCING_STATUS_OK,
+ RegisterRegionSync(kTestServiceWorkerRegistrationId, kTestRegionId,
+ test_region_));
+ VerifyRegions(kTestServiceWorkerRegistrationId, expected_regions_);
+}
+
+TEST_F(GeofencingManagerTest, SetMockProviderClearsRegistrations) {
+ SetHasProviderForTests();
+ EXPECT_EQ(GEOFENCING_STATUS_OK,
+ RegisterRegionSyncWithServiceResult(
+ kTestServiceWorkerRegistrationId, kTestRegionId, test_region_,
+ GEOFENCING_STATUS_OK, kTestGeofencingRegistrationId));
+ VerifyRegions(kTestServiceWorkerRegistrationId, expected_regions_);
+
+ EXPECT_CALL(*service_, UnregisterRegion(kTestGeofencingRegistrationId));
+
+ manager_->SetMockProvider(GeofencingMockState::SERVICE_AVAILABLE);
+ VerifyRegions(kTestServiceWorkerRegistrationId, RegionMap());
+}
+
} // namespace content
« no previous file with comments | « content/browser/geofencing/geofencing_manager.cc ('k') | content/browser/geofencing/geofencing_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698