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

Unified Diff: chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl_unittest.cc

Issue 941633002: Add regression test for CL 897113003 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@h_1_455504_fix_crash
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl_unittest.cc
diff --git a/chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl_unittest.cc b/chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl_unittest.cc
index 071658f6c89c58642c933ae053c847b271076cfc..dedc6b4398dbb61aeef02e91ec57897ff42c8281 100644
--- a/chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl_unittest.cc
+++ b/chrome/browser/chromeos/policy/affiliated_invalidation_service_provider_impl_unittest.cc
@@ -625,4 +625,36 @@ TEST_F(AffiliatedInvalidationServiceProviderImplTest, NoServiceAfterShutdown) {
EXPECT_FALSE(provider_->GetDeviceInvalidationServiceForTest());
}
+// A consumer is registered with the AffiliatedInvalidationServiceProviderImpl.
+// A device-global invalidation service exists, is connected and is made
+// available to the consumer. Verifies that when the provider is shut down, the
+// consumer is informed that no invalidation service is available for use
+// anymore before the device-global invalidation service is destroyed.
+// This is a regression test for http://crbug.com/455504.
+TEST_F(AffiliatedInvalidationServiceProviderImplTest,
+ ConnectedDeviceGlobalInvalidationServiceOnShutdown) {
+ consumer_.reset(new FakeConsumer(provider_.get()));
+
+ // Verify that a device-global invalidation service has been created.
+ EXPECT_TRUE(provider_->GetDeviceInvalidationServiceForTest());
+
+ // Indicate that the device-global invalidation service connected. Verify that
+ // that the consumer is informed about this.
+ ConnectDeviceGlobalInvalidationService();
+
+ // Shut down the |provider_|. Verify that the |consumer_| is informed that no
+ // invalidation service is available for use anymore. This also serves as a
+ // regression test which verifies that the invalidation service is not
+ // destroyed until the |consumer_| has been informed: If the invalidation
+ // service was destroyed too early, the |consumer_| would still be registered
+ // as an observer and the invalidation service's destructor would DCHECK().
+ EXPECT_EQ(0, consumer_->GetAndClearInvalidationServiceSetCount());
+ provider_->Shutdown();
+ EXPECT_EQ(1, consumer_->GetAndClearInvalidationServiceSetCount());
+ EXPECT_EQ(nullptr, consumer_->GetInvalidationService());
+
+ // Verify that the device-global invalidation service has been destroyed.
+ EXPECT_FALSE(provider_->GetDeviceInvalidationServiceForTest());
+}
+
} // namespace policy
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698