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

Side by Side Diff: components/policy/core/common/cloud/cloud_policy_client_unittest.cc

Issue 2830033003: Use {To/From}JavaTime for policy timestamps (Closed)
Patch Set: Rebase Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/policy/core/common/cloud/cloud_policy_client.h" 5 #include "components/policy/core/common/cloud/cloud_policy_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 Register(); 530 Register();
531 531
532 const base::Time timestamp( 532 const base::Time timestamp(
533 base::Time::UnixEpoch() + base::TimeDelta::FromDays(20)); 533 base::Time::UnixEpoch() + base::TimeDelta::FromDays(20));
534 client_->set_submit_machine_id(true); 534 client_->set_submit_machine_id(true);
535 client_->set_last_policy_timestamp(timestamp); 535 client_->set_last_policy_timestamp(timestamp);
536 client_->set_public_key_version(42); 536 client_->set_public_key_version(42);
537 em::PolicyFetchRequest* policy_fetch_request = 537 em::PolicyFetchRequest* policy_fetch_request =
538 policy_request_.mutable_policy_request()->mutable_request(0); 538 policy_request_.mutable_policy_request()->mutable_request(0);
539 policy_fetch_request->set_machine_id(kMachineID); 539 policy_fetch_request->set_machine_id(kMachineID);
540 policy_fetch_request->set_timestamp( 540 policy_fetch_request->set_timestamp(timestamp.ToJavaTime());
541 (timestamp - base::Time::UnixEpoch()).InMilliseconds());
542 policy_fetch_request->set_public_key_version(42); 541 policy_fetch_request->set_public_key_version(42);
543 542
544 ExpectPolicyFetch(kDMToken); 543 ExpectPolicyFetch(kDMToken);
545 EXPECT_CALL(observer_, OnPolicyFetched(_)); 544 EXPECT_CALL(observer_, OnPolicyFetched(_));
546 client_->FetchPolicy(); 545 client_->FetchPolicy();
547 CheckPolicyResponse(); 546 CheckPolicyResponse();
548 } 547 }
549 548
550 TEST_F(CloudPolicyClientTest, PolicyFetchWithInvalidation) { 549 TEST_F(CloudPolicyClientTest, PolicyFetchWithInvalidation) {
551 Register(); 550 Register();
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 EXPECT_CALL(callback_observer_, OnCallbackComplete(true)).Times(1); 948 EXPECT_CALL(callback_observer_, OnCallbackComplete(true)).Times(1);
950 949
951 CloudPolicyClient::StatusCallback callback = 950 CloudPolicyClient::StatusCallback callback =
952 base::Bind(&MockStatusCallbackObserver::OnCallbackComplete, 951 base::Bind(&MockStatusCallbackObserver::OnCallbackComplete,
953 base::Unretained(&callback_observer_)); 952 base::Unretained(&callback_observer_));
954 client_->UpdateGcmId(kGcmID, callback); 953 client_->UpdateGcmId(kGcmID, callback);
955 EXPECT_EQ(DM_STATUS_SUCCESS, client_->status()); 954 EXPECT_EQ(DM_STATUS_SUCCESS, client_->status());
956 } 955 }
957 956
958 } // namespace policy 957 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698