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

Side by Side 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 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/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/service_worker_context_wrapper.h" 9 #include "content/browser/service_worker/service_worker_context_wrapper.h"
10 #include "content/public/test/test_browser_thread_bundle.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 test_region_, 404 test_region_,
405 GEOFENCING_STATUS_OK, 405 GEOFENCING_STATUS_OK,
406 kTestGeofencingRegistrationId)); 406 kTestGeofencingRegistrationId));
407 407
408 EXPECT_CALL(*service_, UnregisterRegion(kTestGeofencingRegistrationId)) 408 EXPECT_CALL(*service_, UnregisterRegion(kTestGeofencingRegistrationId))
409 .WillOnce(QuitRunner(runner)); 409 .WillOnce(QuitRunner(runner));
410 manager_->Shutdown(); 410 manager_->Shutdown();
411 runner->Run(); 411 runner->Run();
412 } 412 }
413 413
414 TEST_F(GeofencingManagerTest, RegisterRegion_MockedNoService) {
415 manager_->SetMockProvider(GeofencingMockState::SERVICE_UNAVAILABLE);
416 // Make sure real service doesn't get called.
417 EXPECT_CALL(*service_, IsServiceAvailable()).Times(0);
418
419 EXPECT_EQ(GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE,
420 RegisterRegionSync(kTestServiceWorkerRegistrationId, kTestRegionId,
421 test_region_));
422 }
423
424 TEST_F(GeofencingManagerTest, UnregisterRegion_MockedNoService) {
425 manager_->SetMockProvider(GeofencingMockState::SERVICE_UNAVAILABLE);
426 // Make sure real service doesn't get called.
427 EXPECT_CALL(*service_, IsServiceAvailable()).Times(0);
428
429 EXPECT_EQ(GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE,
430 UnregisterRegionSync(kTestServiceWorkerRegistrationId,
431 kTestRegionId, false));
432 }
433
434 TEST_F(GeofencingManagerTest, GetRegisteredRegions_MockedNoService) {
435 manager_->SetMockProvider(GeofencingMockState::SERVICE_UNAVAILABLE);
436 // Make sure real service doesn't get called.
437 EXPECT_CALL(*service_, IsServiceAvailable()).Times(0);
438
439 RegionMap regions;
440 EXPECT_EQ(GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE,
441 manager_->GetRegisteredRegions(kTestServiceWorkerRegistrationId,
442 &regions));
443 EXPECT_TRUE(regions.empty());
444 }
445
446 TEST_F(GeofencingManagerTest, RegisterRegion_MockedService) {
447 manager_->SetMockProvider(GeofencingMockState::SERVICE_AVAILABLE);
448
449 EXPECT_EQ(GEOFENCING_STATUS_OK,
450 RegisterRegionSync(kTestServiceWorkerRegistrationId, kTestRegionId,
451 test_region_));
452 VerifyRegions(kTestServiceWorkerRegistrationId, expected_regions_);
453 }
454
455 TEST_F(GeofencingManagerTest, SetMockProviderClearsRegistrations) {
456 SetHasProviderForTests();
457 EXPECT_EQ(GEOFENCING_STATUS_OK,
458 RegisterRegionSyncWithServiceResult(
459 kTestServiceWorkerRegistrationId, kTestRegionId, test_region_,
460 GEOFENCING_STATUS_OK, kTestGeofencingRegistrationId));
461 VerifyRegions(kTestServiceWorkerRegistrationId, expected_regions_);
462
463 EXPECT_CALL(*service_, UnregisterRegion(kTestGeofencingRegistrationId));
464
465 manager_->SetMockProvider(GeofencingMockState::SERVICE_AVAILABLE);
466 VerifyRegions(kTestServiceWorkerRegistrationId, RegionMap());
467 }
468
414 } // namespace content 469 } // namespace content
OLDNEW
« 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