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

Unified Diff: chrome/browser/policy/cloud/cloud_policy_client_unittest.cc

Issue 19733003: Implement cloud policy invalidations using the invalidation service framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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
Index: chrome/browser/policy/cloud/cloud_policy_client_unittest.cc
diff --git a/chrome/browser/policy/cloud/cloud_policy_client_unittest.cc b/chrome/browser/policy/cloud/cloud_policy_client_unittest.cc
index 527a8c6cfa05b2c66b35a5e8e0ecf48a4106554b..bafcc3dbb32e8daadc7e93c41d5ad4a16aa76048 100644
--- a/chrome/browser/policy/cloud/cloud_policy_client_unittest.cc
+++ b/chrome/browser/policy/cloud/cloud_policy_client_unittest.cc
@@ -200,6 +200,7 @@ TEST_F(CloudPolicyClientTest, Init) {
EXPECT_CALL(service_, CreateJob(_)).Times(0);
EXPECT_FALSE(client_->is_registered());
EXPECT_FALSE(client_->GetPolicyFor(policy_ns_key_));
+ EXPECT_EQ(0, client_->fetched_invalidation_version());
}
TEST_F(CloudPolicyClientTest, SetupRegistrationAndPolicyFetch) {
@@ -345,6 +346,40 @@ TEST_F(CloudPolicyClientTest, PolicyFetchWithMetaData) {
CheckPolicyResponse();
}
+TEST_F(CloudPolicyClientTest, PolicyFetchWithInvalidation) {
+ Register();
+
+ int64 previous_version = client_->fetched_invalidation_version();
+ client_->SetInvalidationInfo(12345, "12345");
+ EXPECT_EQ(previous_version, client_->fetched_invalidation_version());
+ em::PolicyFetchRequest* policy_fetch_request =
+ policy_request_.mutable_policy_request()->mutable_request(0);
+ policy_fetch_request->set_invalidation_version(12345);
+ policy_fetch_request->set_invalidation_payload("12345");
+
+ ExpectPolicyFetch(kDMToken, dm_protocol::kValueUserAffiliationNone);
+ EXPECT_CALL(observer_, OnPolicyFetched(_));
+ EXPECT_CALL(status_provider_, OnSubmittedSuccessfully());
+ client_->FetchPolicy();
+ CheckPolicyResponse();
+ EXPECT_EQ(12345, client_->fetched_invalidation_version());
+}
+
+TEST_F(CloudPolicyClientTest, PolicyFetchWithInvalidationNoPayload) {
+ Register();
+
+ int64 previous_version = client_->fetched_invalidation_version();
+ client_->SetInvalidationInfo(-12345, std::string());
+ EXPECT_EQ(previous_version, client_->fetched_invalidation_version());
+
+ ExpectPolicyFetch(kDMToken, dm_protocol::kValueUserAffiliationNone);
+ EXPECT_CALL(observer_, OnPolicyFetched(_));
+ EXPECT_CALL(status_provider_, OnSubmittedSuccessfully());
+ client_->FetchPolicy();
+ CheckPolicyResponse();
+ EXPECT_EQ(-12345, client_->fetched_invalidation_version());
+}
+
TEST_F(CloudPolicyClientTest, BadPolicyResponse) {
Register();

Powered by Google App Engine
This is Rietveld 408576698