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

Unified Diff: components/policy/core/common/cloud/cloud_policy_client_unittest.cc

Issue 1258313002: Send GCM id to DMServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adopt upstream protobuf changes Created 5 years, 4 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: components/policy/core/common/cloud/cloud_policy_client_unittest.cc
diff --git a/components/policy/core/common/cloud/cloud_policy_client_unittest.cc b/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
index f61e285834169048b59167e4db20af642f819b8c..40f82a99ed9d3355d99b8650c14d4640309d7548 100644
--- a/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
+++ b/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
@@ -47,6 +47,7 @@ const char kPayload[] = "input_payload";
const char kResultPayload[] = "output_payload";
const char kAssetId[] = "fake-asset-id";
const char kLocation[] = "fake-location";
+const char kGcmID[] = "fake-gcm-id";
const int64_t kAgeOfCommand = 123123123;
const int64_t kLastCommandId = 123456789;
@@ -142,6 +143,8 @@ class CloudPolicyClientTest : public testing::Test {
attribute_update_response_.mutable_device_attribute_update_response()->
set_result(
em::DeviceAttributeUpdateResponse_ResultType_ATTRIBUTE_UPDATE_SUCCESS);
+
+ gcm_id_update_request_.mutable_gcm_id_update_request()->set_gcm_id(kGcmID);
}
void SetUp() override {
@@ -263,6 +266,17 @@ class CloudPolicyClientTest : public testing::Test {
client_id_, MatchProto(attribute_update_request_)));
}
+ void ExpectGcmIdUpdate() {
+ EXPECT_CALL(service_,
+ CreateJob(DeviceManagementRequestJob::TYPE_GCM_ID_UPDATE,
+ request_context_))
+ .WillOnce(service_.SucceedJob(gcm_id_update_response_));
+ EXPECT_CALL(service_,
+ StartJob(dm_protocol::kValueRequestGcmIdUpdate, std::string(),
+ std::string(), kDMToken, client_id_,
+ MatchProto(gcm_id_update_request_)));
+ }
+
void CheckPolicyResponse() {
ASSERT_TRUE(client_->GetPolicyFor(policy_type_, std::string()));
EXPECT_THAT(*client_->GetPolicyFor(policy_type_, std::string()),
@@ -285,6 +299,7 @@ class CloudPolicyClientTest : public testing::Test {
em::DeviceManagementRequest remote_command_request_;
em::DeviceManagementRequest attribute_update_permission_request_;
em::DeviceManagementRequest attribute_update_request_;
+ em::DeviceManagementRequest gcm_id_update_request_;
// Protobufs used in successful responses.
em::DeviceManagementResponse registration_response_;
@@ -295,6 +310,7 @@ class CloudPolicyClientTest : public testing::Test {
em::DeviceManagementResponse remote_command_response_;
em::DeviceManagementResponse attribute_update_permission_response_;
em::DeviceManagementResponse attribute_update_response_;
+ em::DeviceManagementResponse gcm_id_update_response_;
base::MessageLoop loop_;
std::string client_id_;
@@ -850,15 +866,27 @@ TEST_F(CloudPolicyClientTest, RequestDeviceAttributeUpdatePermission) {
}
TEST_F(CloudPolicyClientTest, RequestDeviceAttributeUpdate) {
- Register();
- ExpectAttributeUpdate(kOAuthToken);
- EXPECT_CALL(callback_observer_, OnCallbackComplete(true)).Times(1);
-
- CloudPolicyClient::StatusCallback callback = base::Bind(
- &MockStatusCallbackObserver::OnCallbackComplete,
- base::Unretained(&callback_observer_));
- client_->UpdateDeviceAttributes(kOAuthToken, kAssetId, kLocation, callback);
- EXPECT_EQ(DM_STATUS_SUCCESS, client_->status());
+ Register();
+ ExpectAttributeUpdate(kOAuthToken);
+ EXPECT_CALL(callback_observer_, OnCallbackComplete(true)).Times(1);
+
+ CloudPolicyClient::StatusCallback callback =
+ base::Bind(&MockStatusCallbackObserver::OnCallbackComplete,
+ base::Unretained(&callback_observer_));
+ client_->UpdateDeviceAttributes(kOAuthToken, kAssetId, kLocation, callback);
+ EXPECT_EQ(DM_STATUS_SUCCESS, client_->status());
+}
+
+TEST_F(CloudPolicyClientTest, RequestGcmIdUpdate) {
+ Register();
+ ExpectGcmIdUpdate();
+ EXPECT_CALL(callback_observer_, OnCallbackComplete(true)).Times(1);
+
+ CloudPolicyClient::StatusCallback callback =
+ base::Bind(&MockStatusCallbackObserver::OnCallbackComplete,
+ base::Unretained(&callback_observer_));
+ client_->UpdateGcmId(kGcmID, callback);
+ EXPECT_EQ(DM_STATUS_SUCCESS, client_->status());
}
} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698