Chromium Code Reviews| Index: components/policy/core/common/cloud/cloud_policy_service_unittest.cc |
| diff --git a/components/policy/core/common/cloud/cloud_policy_service_unittest.cc b/components/policy/core/common/cloud/cloud_policy_service_unittest.cc |
| index 005316618670f73ff4655c600a5ec9b975619b42..24ca62957f8e59119b756f3c042598a43382863b 100644 |
| --- a/components/policy/core/common/cloud/cloud_policy_service_unittest.cc |
| +++ b/components/policy/core/common/cloud/cloud_policy_service_unittest.cc |
| @@ -36,6 +36,7 @@ class CloudPolicyServiceTest : public testing::Test { |
| service_(policy_ns_key_, &client_, &store_) {} |
| MOCK_METHOD1(OnPolicyRefresh, void(bool)); |
| + MOCK_METHOD1(OnUnregister, void(bool)); |
| protected: |
| PolicyNamespaceKey policy_ns_key_; |
| @@ -210,6 +211,46 @@ TEST_F(CloudPolicyServiceTest, RefreshPolicyConcurrent) { |
| store_.NotifyStoreLoaded(); |
| } |
| +TEST_F(CloudPolicyServiceTest, UnregisterSucceeds) { |
| + EXPECT_CALL(client_, Unregister()); |
| + EXPECT_CALL(*this, OnUnregister(true)); |
| + |
| + service_.Unregister(base::Bind(&CloudPolicyServiceTest::OnUnregister, |
| + base::Unretained(this))); |
|
bartfab (slow)
2014/11/28 13:25:19
Nit: #include "base/bind_helpers.h"
davidyu
2014/12/01 17:05:23
Done.
|
| + client_.NotifyRegistrationStateChanged(); |
| +} |
| + |
| +TEST_F(CloudPolicyServiceTest, UnregisterFailsOnClientError) { |
| + EXPECT_CALL(client_, Unregister()); |
| + EXPECT_CALL(*this, OnUnregister(false)); |
| + |
| + service_.Unregister(base::Bind(&CloudPolicyServiceTest::OnUnregister, |
| + base::Unretained(this))); |
| + client_.NotifyClientError(); |
| +} |
| + |
| +TEST_F(CloudPolicyServiceTest, UnregisterRevokesAllOnGoingPolicyRefresh) { |
|
bartfab (slow)
2014/11/28 13:25:19
Nit: s/Refresh/Refreshes/
davidyu
2014/12/01 17:05:23
Done.
|
| + EXPECT_CALL(client_, Unregister()); |
| + EXPECT_CALL(*this, OnPolicyRefresh(false)).Times(2); |
| + |
| + service_.RefreshPolicy(base::Bind(&CloudPolicyServiceTest::OnPolicyRefresh, |
| + base::Unretained(this))); |
| + service_.RefreshPolicy(base::Bind(&CloudPolicyServiceTest::OnPolicyRefresh, |
| + base::Unretained(this))); |
| + service_.Unregister(base::Bind(&CloudPolicyServiceTest::OnUnregister, |
| + base::Unretained(this))); |
| +} |
| + |
| +TEST_F(CloudPolicyServiceTest, RefreshPolicyFailsWhenUnregistering) { |
| + EXPECT_CALL(client_, Unregister()); |
| + EXPECT_CALL(*this, OnPolicyRefresh(false)); |
| + |
| + service_.Unregister(base::Bind(&CloudPolicyServiceTest::OnUnregister, |
| + base::Unretained(this))); |
| + service_.RefreshPolicy(base::Bind(&CloudPolicyServiceTest::OnPolicyRefresh, |
| + base::Unretained(this))); |
| +} |
| + |
| TEST_F(CloudPolicyServiceTest, StoreAlreadyInitialized) { |
| // Service should start off initialized if the store has already loaded |
| // policy. |