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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/chromeos/policy/affiliated_invalidation_service_provide r_impl.h" 5 #include "chrome/browser/chromeos/policy/affiliated_invalidation_service_provide r_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 // Indicate that the second user's per-profile invalidation service has 618 // Indicate that the second user's per-profile invalidation service has
619 // connected. Verify that the consumer is not called back. 619 // connected. Verify that the consumer is not called back.
620 second_profile_invalidation_service->SetInvalidatorState( 620 second_profile_invalidation_service->SetInvalidatorState(
621 syncer::INVALIDATIONS_ENABLED); 621 syncer::INVALIDATIONS_ENABLED);
622 EXPECT_EQ(0, consumer_->GetAndClearInvalidationServiceSetCount()); 622 EXPECT_EQ(0, consumer_->GetAndClearInvalidationServiceSetCount());
623 623
624 // Verify that the device-global invalidation service still does not exist. 624 // Verify that the device-global invalidation service still does not exist.
625 EXPECT_FALSE(provider_->GetDeviceInvalidationServiceForTest()); 625 EXPECT_FALSE(provider_->GetDeviceInvalidationServiceForTest());
626 } 626 }
627 627
628 // A consumer is registered with the AffiliatedInvalidationServiceProviderImpl.
629 // A device-global invalidation service exists, is connected and is made
630 // available to the consumer. Verifies that when the provider is shut down, the
631 // consumer is informed that no invalidation service is available for use
632 // anymore before the device-global invalidation service is destroyed.
633 // This is a regression test for http://crbug.com/455504.
634 TEST_F(AffiliatedInvalidationServiceProviderImplTest,
635 ConnectedDeviceGlobalInvalidationServiceOnShutdown) {
636 consumer_.reset(new FakeConsumer(provider_.get()));
637
638 // Verify that a device-global invalidation service has been created.
639 EXPECT_TRUE(provider_->GetDeviceInvalidationServiceForTest());
640
641 // Indicate that the device-global invalidation service connected. Verify that
642 // that the consumer is informed about this.
643 ConnectDeviceGlobalInvalidationService();
644
645 // Shut down the |provider_|. Verify that the |consumer_| is informed that no
646 // invalidation service is available for use anymore. This also serves as a
647 // regression test which verifies that the invalidation service is not
648 // destroyed until the |consumer_| has been informed: If the invalidation
649 // service was destroyed too early, the |consumer_| would still be registered
650 // as an observer and the invalidation service's destructor would DCHECK().
651 EXPECT_EQ(0, consumer_->GetAndClearInvalidationServiceSetCount());
652 provider_->Shutdown();
653 EXPECT_EQ(1, consumer_->GetAndClearInvalidationServiceSetCount());
654 EXPECT_EQ(nullptr, consumer_->GetInvalidationService());
655
656 // Verify that the device-global invalidation service has been destroyed.
657 EXPECT_FALSE(provider_->GetDeviceInvalidationServiceForTest());
658 }
659
628 } // namespace policy 660 } // namespace policy
OLDNEW
« 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