OLD | NEW |
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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 using ::testing::_; | 41 using ::testing::_; |
42 | 42 |
43 class AutoEnrollmentClientTest : public testing::Test { | 43 class AutoEnrollmentClientTest : public testing::Test { |
44 protected: | 44 protected: |
45 AutoEnrollmentClientTest() | 45 AutoEnrollmentClientTest() |
46 : scoped_testing_local_state_( | 46 : scoped_testing_local_state_( |
47 TestingBrowserProcess::GetGlobal()), | 47 TestingBrowserProcess::GetGlobal()), |
48 local_state_(scoped_testing_local_state_.Get()), | 48 local_state_(scoped_testing_local_state_.Get()), |
49 state_(AUTO_ENROLLMENT_STATE_PENDING) {} | 49 state_(AUTO_ENROLLMENT_STATE_PENDING) {} |
50 | 50 |
51 virtual void SetUp() OVERRIDE { | 51 virtual void SetUp() override { |
52 CreateClient(kStateKey, true, 4, 8); | 52 CreateClient(kStateKey, true, 4, 8); |
53 ASSERT_FALSE(local_state_->GetUserPref(prefs::kShouldAutoEnroll)); | 53 ASSERT_FALSE(local_state_->GetUserPref(prefs::kShouldAutoEnroll)); |
54 ASSERT_FALSE(local_state_->GetUserPref(prefs::kAutoEnrollmentPowerLimit)); | 54 ASSERT_FALSE(local_state_->GetUserPref(prefs::kAutoEnrollmentPowerLimit)); |
55 } | 55 } |
56 | 56 |
57 virtual void TearDown() OVERRIDE { | 57 virtual void TearDown() override { |
58 // Flush any deletion tasks. | 58 // Flush any deletion tasks. |
59 base::RunLoop().RunUntilIdle(); | 59 base::RunLoop().RunUntilIdle(); |
60 } | 60 } |
61 | 61 |
62 void CreateClient(const std::string& state_key, | 62 void CreateClient(const std::string& state_key, |
63 bool retrieve_device_state, | 63 bool retrieve_device_state, |
64 int power_initial, | 64 int power_initial, |
65 int power_limit) { | 65 int power_limit) { |
66 state_ = AUTO_ENROLLMENT_STATE_PENDING; | 66 state_ = AUTO_ENROLLMENT_STATE_PENDING; |
67 service_.reset(new MockDeviceManagementService()); | 67 service_.reset(new MockDeviceManagementService()); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 EXPECT_CALL(*service_, | 510 EXPECT_CALL(*service_, |
511 CreateJob(DeviceManagementRequestJob::TYPE_DEVICE_STATE_RETRIEVAL, | 511 CreateJob(DeviceManagementRequestJob::TYPE_DEVICE_STATE_RETRIEVAL, |
512 _)).Times(0); | 512 _)).Times(0); |
513 client_->Start(); | 513 client_->Start(); |
514 EXPECT_EQ(AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT, state_); | 514 EXPECT_EQ(AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT, state_); |
515 VerifyCachedResult(true, 8); | 515 VerifyCachedResult(true, 8); |
516 } | 516 } |
517 | 517 |
518 } // namespace | 518 } // namespace |
519 } // namespace policy | 519 } // namespace policy |
OLD | NEW |