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/policy/device_token_fetcher.h" | 5 #include "chrome/browser/policy/device_token_fetcher.h" |
6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" |
7 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
8 #include "base/scoped_temp_dir.h" | |
9 #include "chrome/browser/policy/cloud_policy_data_store.h" | 9 #include "chrome/browser/policy/cloud_policy_data_store.h" |
10 #include "chrome/browser/policy/logging_work_scheduler.h" | 10 #include "chrome/browser/policy/logging_work_scheduler.h" |
11 #include "chrome/browser/policy/mock_cloud_policy_data_store.h" | 11 #include "chrome/browser/policy/mock_cloud_policy_data_store.h" |
12 #include "chrome/browser/policy/mock_device_management_service.h" | 12 #include "chrome/browser/policy/mock_device_management_service.h" |
13 #include "chrome/browser/policy/policy_notifier.h" | 13 #include "chrome/browser/policy/policy_notifier.h" |
14 #include "chrome/browser/policy/user_policy_cache.h" | 14 #include "chrome/browser/policy/user_policy_cache.h" |
15 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 EXPECT_CALL(service_, StartJob(_, _, _, _, _, _, _)) | 89 EXPECT_CALL(service_, StartJob(_, _, _, _, _, _, _)) |
90 .WillOnce(VerifyRegisterRequest(known_machine_id)); | 90 .WillOnce(VerifyRegisterRequest(known_machine_id)); |
91 } | 91 } |
92 | 92 |
93 MessageLoop loop_; | 93 MessageLoop loop_; |
94 MockDeviceManagementService service_; | 94 MockDeviceManagementService service_; |
95 scoped_ptr<CloudPolicyCacheBase> cache_; | 95 scoped_ptr<CloudPolicyCacheBase> cache_; |
96 scoped_ptr<CloudPolicyDataStore> data_store_; | 96 scoped_ptr<CloudPolicyDataStore> data_store_; |
97 MockCloudPolicyDataStoreObserver observer_; | 97 MockCloudPolicyDataStoreObserver observer_; |
98 PolicyNotifier notifier_; | 98 PolicyNotifier notifier_; |
99 ScopedTempDir temp_user_data_dir_; | 99 base::ScopedTempDir temp_user_data_dir_; |
100 em::DeviceManagementResponse successful_registration_response_; | 100 em::DeviceManagementResponse successful_registration_response_; |
101 | 101 |
102 private: | 102 private: |
103 content::TestBrowserThread ui_thread_; | 103 content::TestBrowserThread ui_thread_; |
104 content::TestBrowserThread file_thread_; | 104 content::TestBrowserThread file_thread_; |
105 }; | 105 }; |
106 | 106 |
107 TEST_F(DeviceTokenFetcherTest, FetchToken) { | 107 TEST_F(DeviceTokenFetcherTest, FetchToken) { |
108 testing::InSequence s; | 108 testing::InSequence s; |
109 SetUpSuccessfulRegistrationExpectation(false); | 109 SetUpSuccessfulRegistrationExpectation(false); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 data_store_->set_known_machine_id(true); | 254 data_store_->set_known_machine_id(true); |
255 FetchToken(&fetcher, data_store_.get()); | 255 FetchToken(&fetcher, data_store_.get()); |
256 loop_.RunAllPending(); | 256 loop_.RunAllPending(); |
257 | 257 |
258 Mock::VerifyAndClearExpectations(&observer_); | 258 Mock::VerifyAndClearExpectations(&observer_); |
259 std::string token = data_store_->device_token(); | 259 std::string token = data_store_->device_token(); |
260 EXPECT_NE("", token); | 260 EXPECT_NE("", token); |
261 } | 261 } |
262 | 262 |
263 } // namespace policy | 263 } // namespace policy |
OLD | NEW |