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

Unified Diff: chrome/browser/policy/auto_enrollment_client_unittest.cc

Issue 9109009: Introduce CloudPolicyClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore DCHECKS. Created 8 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/policy/cloud_policy_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..68e77555269939aca88fed2fcd56a37428562a72 100644
--- a/chrome/browser/policy/auto_enrollment_client_unittest.cc
+++ b/chrome/browser/policy/auto_enrollment_client_unittest.cc
@@ -29,7 +29,7 @@ const char* kSerialHash =
"\x6f\x02\x4a\xd7\xeb\x92\x45\xfc\xd4\xe4\x37\xa1\x55\x2b\x13\x8a";
using ::testing::InSequence;
-using ::testing::Invoke;
+using ::testing::SaveArg;
using ::testing::_;
class AutoEnrollmentClientTest : public testing::Test {
@@ -51,9 +51,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 +109,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 +145,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 +218,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 +256,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 +272,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);
}
}
« no previous file with comments | « no previous file | chrome/browser/policy/cloud_policy_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698