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

Side by Side Diff: chrome/browser/chromeos/policy/auto_enrollment_client_unittest.cc

Issue 1547093002: Switch to standard integer types in chrome/browser/chromeos/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 "chrome/browser/chromeos/policy/auto_enrollment_client.h" 5 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
12 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
13 #include "base/prefs/testing_pref_service.h" 14 #include "base/prefs/testing_pref_service.h"
14 #include "base/run_loop.h" 15 #include "base/run_loop.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" 19 #include "chrome/browser/chromeos/policy/server_backed_device_state.h"
19 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
20 #include "chrome/test/base/scoped_testing_local_state.h" 21 #include "chrome/test/base/scoped_testing_local_state.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 state_ = state; 84 state_ = state;
84 } 85 }
85 86
86 void ServerWillFail(DeviceManagementStatus error) { 87 void ServerWillFail(DeviceManagementStatus error) {
87 em::DeviceManagementResponse dummy_response; 88 em::DeviceManagementResponse dummy_response;
88 EXPECT_CALL(*service_, 89 EXPECT_CALL(*service_,
89 CreateJob(DeviceManagementRequestJob::TYPE_AUTO_ENROLLMENT, _)) 90 CreateJob(DeviceManagementRequestJob::TYPE_AUTO_ENROLLMENT, _))
90 .WillOnce(service_->FailJob(error)); 91 .WillOnce(service_->FailJob(error));
91 } 92 }
92 93
93 void ServerWillReply(int64 modulus, bool with_hashes, bool with_id_hash) { 94 void ServerWillReply(int64_t modulus, bool with_hashes, bool with_id_hash) {
94 em::DeviceManagementResponse response; 95 em::DeviceManagementResponse response;
95 em::DeviceAutoEnrollmentResponse* enrollment_response = 96 em::DeviceAutoEnrollmentResponse* enrollment_response =
96 response.mutable_auto_enrollment_response(); 97 response.mutable_auto_enrollment_response();
97 if (modulus >= 0) 98 if (modulus >= 0)
98 enrollment_response->set_expected_modulus(modulus); 99 enrollment_response->set_expected_modulus(modulus);
99 if (with_hashes) { 100 if (with_hashes) {
100 for (int i = 0; i < 10; ++i) { 101 for (int i = 0; i < 10; ++i) {
101 std::string state_key = base::StringPrintf("state_key %d", i); 102 std::string state_key = base::StringPrintf("state_key %d", i);
102 std::string hash = crypto::SHA256HashString(state_key); 103 std::string hash = crypto::SHA256HashString(state_key);
103 enrollment_response->mutable_hash()->Add()->assign(hash); 104 enrollment_response->mutable_hash()->Add()->assign(hash);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 EXPECT_EQ(AUTO_ENROLLMENT_STATE_NO_ENROLLMENT, state_); 381 EXPECT_EQ(AUTO_ENROLLMENT_STATE_NO_ENROLLMENT, state_);
381 EXPECT_TRUE(auto_enrollment_request().has_remainder()); 382 EXPECT_TRUE(auto_enrollment_request().has_remainder());
382 EXPECT_TRUE(auto_enrollment_request().has_modulus()); 383 EXPECT_TRUE(auto_enrollment_request().has_modulus());
383 EXPECT_EQ(1, auto_enrollment_request().modulus()); 384 EXPECT_EQ(1, auto_enrollment_request().modulus());
384 EXPECT_EQ(0, auto_enrollment_request().remainder()); 385 EXPECT_EQ(0, auto_enrollment_request().remainder());
385 VerifyCachedResult(false, 0); 386 VerifyCachedResult(false, 0);
386 EXPECT_FALSE(HasServerBackedState()); 387 EXPECT_FALSE(HasServerBackedState());
387 } 388 }
388 389
389 TEST_F(AutoEnrollmentClientTest, ManyBitsUploaded) { 390 TEST_F(AutoEnrollmentClientTest, ManyBitsUploaded) {
390 int64 bottom62 = INT64_C(0x386e7244d097c3e6); 391 int64_t bottom62 = INT64_C(0x386e7244d097c3e6);
391 for (int i = 0; i <= 62; ++i) { 392 for (int i = 0; i <= 62; ++i) {
392 CreateClient(kStateKey, i, i); 393 CreateClient(kStateKey, i, i);
393 ServerWillReply(-1, false, false); 394 ServerWillReply(-1, false, false);
394 client_->Start(); 395 client_->Start();
395 EXPECT_EQ(AUTO_ENROLLMENT_STATE_NO_ENROLLMENT, state_); 396 EXPECT_EQ(AUTO_ENROLLMENT_STATE_NO_ENROLLMENT, state_);
396 EXPECT_TRUE(auto_enrollment_request().has_remainder()); 397 EXPECT_TRUE(auto_enrollment_request().has_remainder());
397 EXPECT_TRUE(auto_enrollment_request().has_modulus()); 398 EXPECT_TRUE(auto_enrollment_request().has_modulus());
398 EXPECT_EQ(INT64_C(1) << i, auto_enrollment_request().modulus()); 399 EXPECT_EQ(INT64_C(1) << i, auto_enrollment_request().modulus());
399 EXPECT_EQ(bottom62 % (INT64_C(1) << i), 400 EXPECT_EQ(bottom62 % (INT64_C(1) << i),
400 auto_enrollment_request().remainder()); 401 auto_enrollment_request().remainder());
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 EXPECT_EQ(AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT, state_); 615 EXPECT_EQ(AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT, state_);
615 EXPECT_TRUE(HasCachedDecision()); 616 EXPECT_TRUE(HasCachedDecision());
616 VerifyServerBackedState("example.com", 617 VerifyServerBackedState("example.com",
617 kDeviceStateRestoreModeReEnrollmentEnforced, 618 kDeviceStateRestoreModeReEnrollmentEnforced,
618 kDisabledMessage); 619 kDisabledMessage);
619 Mock::VerifyAndClearExpectations(service_.get()); 620 Mock::VerifyAndClearExpectations(service_.get());
620 } 621 }
621 622
622 } // namespace 623 } // namespace
623 } // namespace policy 624 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/policy/auto_enrollment_client.cc ('k') | chrome/browser/chromeos/policy/blocking_login_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698