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: components/policy/core/common/cloud/cloud_policy_service_unittest.cc

Issue 751703003: Implemented consumer management unenrollment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dcpm
Patch Set: Created 6 years, 1 month 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
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.

Powered by Google App Engine
This is Rietveld 408576698