Chromium Code Reviews| Index: chrome/browser/policy/auto_enrollment_client_unittest.cc |
| diff --git a/chrome/browser/policy/auto_enrollment_client_unittest.cc b/chrome/browser/policy/auto_enrollment_client_unittest.cc |
| index 2cfe944793ef55b10b1764205896cd37335ba736..95e897a7fb43ea3adcca29a531c586fc1b9e5af7 100644 |
| --- a/chrome/browser/policy/auto_enrollment_client_unittest.cc |
| +++ b/chrome/browser/policy/auto_enrollment_client_unittest.cc |
| @@ -30,6 +30,7 @@ const char* kSerialHash = |
| using ::testing::InSequence; |
| using ::testing::Invoke; |
|
Joao da Silva
2012/05/22 20:59:30
Nit: not used anymore
Mattias Nissler (ping if slow)
2012/05/24 10:12:01
Done.
|
| +using ::testing::SaveArg; |
| using ::testing::_; |
| class AutoEnrollmentClientTest : public testing::Test { |
| @@ -51,9 +52,8 @@ class AutoEnrollmentClientTest : public testing::Test { |
| int power_initial, |
| int power_limit) { |
| service_ = new MockDeviceManagementService(); |
| - EXPECT_CALL(*service_, StartJob(_)) |
| - .WillRepeatedly(Invoke(this, |
| - &AutoEnrollmentClientTest::CaptureRequest)); |
| + EXPECT_CALL(*service_, StartJob(_, _, _, _, _, _, _)) |
| + .WillRepeatedly(SaveArg<6>(&last_request_)); |
| base::Closure callback = |
| base::Bind(&AutoEnrollmentClientTest::CompletionCallback, |
| base::Unretained(this)); |
| @@ -110,18 +110,18 @@ class AutoEnrollmentClientTest : public testing::Test { |
| local_state_->GetUserPref(prefs::kAutoEnrollmentPowerLimit))); |
| } |
| + const em::DeviceAutoEnrollmentRequest& auto_enrollment_request() { |
| + return last_request_.auto_enrollment_request(); |
| + } |
| + |
| ScopedTestingLocalState scoped_testing_local_state_; |
| TestingPrefService* local_state_; |
| MockDeviceManagementService* service_; |
| scoped_ptr<AutoEnrollmentClient> client_; |
| - em::DeviceAutoEnrollmentRequest last_request_; |
| + em::DeviceManagementRequest last_request_; |
| int completion_callback_count_; |
| private: |
| - void CaptureRequest(DeviceManagementRequestJob* job) { |
| - last_request_ = job->GetRequest()->auto_enrollment_request(); |
| - } |
| - |
| DISALLOW_COPY_AND_ASSIGN(AutoEnrollmentClientTest); |
| }; |
| @@ -146,10 +146,11 @@ TEST_F(AutoEnrollmentClientTest, ClientUploadsRightBits) { |
| client_->Start(); |
| EXPECT_FALSE(client_->should_auto_enroll()); |
| EXPECT_EQ(1, completion_callback_count_); |
| - EXPECT_TRUE(last_request_.has_remainder()); |
| - EXPECT_TRUE(last_request_.has_modulus()); |
| - EXPECT_EQ(16, last_request_.modulus()); |
| - EXPECT_EQ(kSerialHash[31] & 0xf, last_request_.remainder()); |
| + |
| + EXPECT_TRUE(auto_enrollment_request().has_remainder()); |
| + EXPECT_TRUE(auto_enrollment_request().has_modulus()); |
| + EXPECT_EQ(16, auto_enrollment_request().modulus()); |
| + EXPECT_EQ(kSerialHash[31] & 0xf, auto_enrollment_request().remainder()); |
| VerifyCachedResult(false, 8); |
| } |
| @@ -218,10 +219,10 @@ TEST_F(AutoEnrollmentClientTest, AskNonPowerOf2) { |
| client_->Start(); |
| EXPECT_FALSE(client_->should_auto_enroll()); |
| EXPECT_EQ(1, completion_callback_count_); |
| - EXPECT_TRUE(last_request_.has_remainder()); |
| - EXPECT_TRUE(last_request_.has_modulus()); |
| - EXPECT_EQ(128, last_request_.modulus()); |
| - EXPECT_EQ(kSerialHash[31] & 0x7f, last_request_.remainder()); |
| + EXPECT_TRUE(auto_enrollment_request().has_remainder()); |
| + EXPECT_TRUE(auto_enrollment_request().has_modulus()); |
| + EXPECT_EQ(128, auto_enrollment_request().modulus()); |
| + EXPECT_EQ(kSerialHash[31] & 0x7f, auto_enrollment_request().remainder()); |
| VerifyCachedResult(false, 8); |
| } |
| @@ -256,10 +257,10 @@ TEST_F(AutoEnrollmentClientTest, NoBitsUploaded) { |
| client_->Start(); |
| EXPECT_FALSE(client_->should_auto_enroll()); |
| EXPECT_EQ(1, completion_callback_count_); |
| - EXPECT_TRUE(last_request_.has_remainder()); |
| - EXPECT_TRUE(last_request_.has_modulus()); |
| - EXPECT_EQ(1, last_request_.modulus()); |
| - EXPECT_EQ(0, last_request_.remainder()); |
| + EXPECT_TRUE(auto_enrollment_request().has_remainder()); |
| + EXPECT_TRUE(auto_enrollment_request().has_modulus()); |
| + EXPECT_EQ(1, auto_enrollment_request().modulus()); |
| + EXPECT_EQ(0, auto_enrollment_request().remainder()); |
| VerifyCachedResult(false, 0); |
| } |
| @@ -272,10 +273,11 @@ TEST_F(AutoEnrollmentClientTest, ManyBitsUploaded) { |
| client_->Start(); |
| EXPECT_FALSE(client_->should_auto_enroll()); |
| EXPECT_EQ(1, completion_callback_count_); |
| - EXPECT_TRUE(last_request_.has_remainder()); |
| - EXPECT_TRUE(last_request_.has_modulus()); |
| - EXPECT_EQ(GG_INT64_C(1) << i, last_request_.modulus()); |
| - EXPECT_EQ(bottom62 % (GG_INT64_C(1) << i), last_request_.remainder()); |
| + EXPECT_TRUE(auto_enrollment_request().has_remainder()); |
| + EXPECT_TRUE(auto_enrollment_request().has_modulus()); |
| + EXPECT_EQ(GG_INT64_C(1) << i, auto_enrollment_request().modulus()); |
| + EXPECT_EQ(bottom62 % (GG_INT64_C(1) << i), |
| + auto_enrollment_request().remainder()); |
| VerifyCachedResult(false, i); |
| } |
| } |