| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/policy/heartbeat_scheduler.h" | 5 #include "chrome/browser/chromeos/policy/heartbeat_scheduler.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 8 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/test/test_simple_task_runner.h" | 11 #include "base/test/test_simple_task_runner.h" |
| 10 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" | 12 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" |
| 11 #include "chromeos/settings/cros_settings_names.h" | 13 #include "chromeos/settings/cros_settings_names.h" |
| 12 #include "components/gcm_driver/common/gcm_messages.h" | 14 #include "components/gcm_driver/common/gcm_messages.h" |
| 13 #include "components/gcm_driver/fake_gcm_driver.h" | 15 #include "components/gcm_driver/fake_gcm_driver.h" |
| 14 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 16 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 15 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" | 17 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" |
| 16 #include "content/public/test/test_utils.h" | 18 #include "content/public/test/test_utils.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 kHeartbeatGCMAppID, gcm::GCMClient::SUCCESS); | 293 kHeartbeatGCMAppID, gcm::GCMClient::SUCCESS); |
| 292 task_runner_->RunPendingTasks(); | 294 task_runner_->RunPendingTasks(); |
| 293 | 295 |
| 294 // Heartbeats should have a time-to-live equivalent to the heartbeat frequency | 296 // Heartbeats should have a time-to-live equivalent to the heartbeat frequency |
| 295 // so we don't have more than one heartbeat queued at a time. | 297 // so we don't have more than one heartbeat queued at a time. |
| 296 EXPECT_EQ(policy::HeartbeatScheduler::kDefaultHeartbeatIntervalMs/1000, | 298 EXPECT_EQ(policy::HeartbeatScheduler::kDefaultHeartbeatIntervalMs/1000, |
| 297 message.time_to_live); | 299 message.time_to_live); |
| 298 | 300 |
| 299 // Check the values in the message payload. | 301 // Check the values in the message payload. |
| 300 EXPECT_EQ("hb", message.data["type"]); | 302 EXPECT_EQ("hb", message.data["type"]); |
| 301 int64 timestamp; | 303 int64_t timestamp; |
| 302 EXPECT_TRUE(base::StringToInt64(message.data["timestamp"], ×tamp)); | 304 EXPECT_TRUE(base::StringToInt64(message.data["timestamp"], ×tamp)); |
| 303 EXPECT_EQ(kFakeEnrollmentDomain, message.data["domain_name"]); | 305 EXPECT_EQ(kFakeEnrollmentDomain, message.data["domain_name"]); |
| 304 EXPECT_EQ(kFakeDeviceId, message.data["device_id"]); | 306 EXPECT_EQ(kFakeDeviceId, message.data["device_id"]); |
| 305 } | 307 } |
| 306 | 308 |
| 307 TEST_F(HeartbeatSchedulerTest, SendGcmIdUpdate) { | 309 TEST_F(HeartbeatSchedulerTest, SendGcmIdUpdate) { |
| 308 // Verifies that GCM id update request was sent after GCM registration. | 310 // Verifies that GCM id update request was sent after GCM registration. |
| 309 cloud_policy_client_.SetDMToken(kDMToken); | 311 cloud_policy_client_.SetDMToken(kDMToken); |
| 310 policy::CloudPolicyClient::StatusCallback callback; | 312 policy::CloudPolicyClient::StatusCallback callback; |
| 311 EXPECT_CALL(cloud_policy_client_, UpdateGcmId(kRegistrationId, _)) | 313 EXPECT_CALL(cloud_policy_client_, UpdateGcmId(kRegistrationId, _)) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 350 |
| 349 EXPECT_CALL(gcm_driver_, | 351 EXPECT_CALL(gcm_driver_, |
| 350 SendImpl(kHeartbeatGCMAppID, _, IsUpstreamNotificationMsg())) | 352 SendImpl(kHeartbeatGCMAppID, _, IsUpstreamNotificationMsg())) |
| 351 .Times(AtLeast(1)); | 353 .Times(AtLeast(1)); |
| 352 gcm_driver_.CompleteRegistration(kHeartbeatGCMAppID, gcm::GCMClient::SUCCESS); | 354 gcm_driver_.CompleteRegistration(kHeartbeatGCMAppID, gcm::GCMClient::SUCCESS); |
| 353 | 355 |
| 354 gcm_driver_.NotifyConnected(); | 356 gcm_driver_.NotifyConnected(); |
| 355 } | 357 } |
| 356 | 358 |
| 357 } // namespace | 359 } // namespace |
| OLD | NEW |