OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/policy/cloud_policy_controller.h" | 5 #include "chrome/browser/policy/cloud_policy_controller.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/memory/scoped_ptr.h" |
8 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
9 #include "chrome/browser/policy/cloud_policy_data_store.h" | 10 #include "chrome/browser/policy/cloud_policy_data_store.h" |
10 #include "chrome/browser/policy/device_token_fetcher.h" | 11 #include "chrome/browser/policy/device_token_fetcher.h" |
11 #include "chrome/browser/policy/logging_work_scheduler.h" | 12 #include "chrome/browser/policy/logging_work_scheduler.h" |
12 #include "chrome/browser/policy/mock_device_management_backend.h" | 13 #include "chrome/browser/policy/mock_device_management_backend.h" |
13 #include "chrome/browser/policy/mock_device_management_service.h" | 14 #include "chrome/browser/policy/mock_device_management_service.h" |
14 #include "chrome/browser/policy/policy_notifier.h" | 15 #include "chrome/browser/policy/policy_notifier.h" |
15 #include "chrome/browser/policy/user_policy_cache.h" | 16 #include "chrome/browser/policy/user_policy_cache.h" |
16 #include "content/browser/browser_thread.h" | 17 #include "content/browser/browser_thread.h" |
17 #include "policy/policy_constants.h" | 18 #include "policy/policy_constants.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 namespace policy { | 22 namespace policy { |
22 | 23 |
23 using ::testing::AnyNumber; | 24 using ::testing::AnyNumber; |
24 using ::testing::AtLeast; | |
25 using ::testing::InSequence; | 25 using ::testing::InSequence; |
26 using ::testing::Mock; | |
27 using ::testing::Return; | |
28 using ::testing::_; | 26 using ::testing::_; |
29 | 27 |
30 class MockDeviceTokenFetcher : public DeviceTokenFetcher { | 28 class MockDeviceTokenFetcher : public DeviceTokenFetcher { |
31 public: | 29 public: |
32 explicit MockDeviceTokenFetcher(CloudPolicyCacheBase* cache) | 30 explicit MockDeviceTokenFetcher(CloudPolicyCacheBase* cache) |
33 : DeviceTokenFetcher(NULL, cache, NULL, NULL) {} | 31 : DeviceTokenFetcher(NULL, cache, NULL, NULL) {} |
34 virtual ~MockDeviceTokenFetcher() {} | 32 virtual ~MockDeviceTokenFetcher() {} |
35 | 33 |
36 MOCK_METHOD0(FetchToken, void()); | 34 MOCK_METHOD0(FetchToken, void()); |
37 MOCK_METHOD0(SetUnmanagedState, void()); | 35 MOCK_METHOD0(SetUnmanagedState, void()); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 TEST_F(CloudPolicyControllerTest, InvalidSerialNumber) { | 230 TEST_F(CloudPolicyControllerTest, InvalidSerialNumber) { |
233 data_store_->SetupForTesting("device_token", "device_id", | 231 data_store_->SetupForTesting("device_token", "device_id", |
234 "who@what.com", "auth", true); | 232 "who@what.com", "auth", true); |
235 EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _, _)).WillOnce( | 233 EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _, _)).WillOnce( |
236 MockDeviceManagementBackendFailPolicy( | 234 MockDeviceManagementBackendFailPolicy( |
237 DeviceManagementBackend::kErrorServiceInvalidSerialNumber)); | 235 DeviceManagementBackend::kErrorServiceInvalidSerialNumber)); |
238 EXPECT_CALL(*token_fetcher_.get(), SetSerialNumberInvalidState()).Times(1); | 236 EXPECT_CALL(*token_fetcher_.get(), SetSerialNumberInvalidState()).Times(1); |
239 CreateNewController(); | 237 CreateNewController(); |
240 loop_.RunAllPending(); | 238 loop_.RunAllPending(); |
241 } | 239 } |
| 240 |
242 } // namespace policy | 241 } // namespace policy |
OLD | NEW |