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

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: Rebase. Created 5 years, 11 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 | « components/policy/core/common/cloud/cloud_policy_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0c82bb08c30dfdf705bb049ac8f635c310ffd71a..ffb195a7da04f2903a560e80a499040f185beff4 100644
--- a/components/policy/core/common/cloud/cloud_policy_service_unittest.cc
+++ b/components/policy/core/common/cloud/cloud_policy_service_unittest.cc
@@ -5,6 +5,7 @@
#include "components/policy/core/common/cloud/cloud_policy_service.h"
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/callback.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
@@ -36,6 +37,7 @@ class CloudPolicyServiceTest : public testing::Test {
service_(policy_type_, std::string(), &client_, &store_) {}
MOCK_METHOD1(OnPolicyRefresh, void(bool));
+ MOCK_METHOD1(OnUnregister, void(bool));
protected:
std::string policy_type_;
@@ -210,6 +212,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)));
+ 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, UnregisterRevokesAllOnGoingPolicyRefreshes) {
+ 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.
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698