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/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/scoped_temp_dir.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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 using testing::Mock; | 27 using testing::Mock; |
28 using testing::_; | 28 using testing::_; |
29 | 29 |
30 ACTION_P(VerifyRegisterRequest, known_machine_id) { | 30 ACTION_P(VerifyRegisterRequest, known_machine_id) { |
31 ASSERT_TRUE(arg0); | 31 ASSERT_TRUE(arg0); |
32 ASSERT_TRUE(arg0->GetRequest()); | 32 ASSERT_TRUE(arg0->GetRequest()); |
33 ASSERT_TRUE(arg0->GetRequest()->has_register_request()); | 33 ASSERT_TRUE(arg0->GetRequest()->has_register_request()); |
34 const em::DeviceRegisterRequest& request = | 34 const em::DeviceRegisterRequest& request = |
35 arg0->GetRequest()->register_request(); | 35 arg0->GetRequest()->register_request(); |
36 if (known_machine_id) { | 36 if (known_machine_id) { |
37 EXPECT_TRUE(request.has_known_machine_id()); | 37 EXPECT_TRUE(request.has_auto_enrolled()); |
38 EXPECT_TRUE(request.known_machine_id()); | 38 EXPECT_TRUE(request.auto_enrolled()); |
39 } else { | 39 } else { |
40 EXPECT_FALSE(request.has_known_machine_id()); | 40 EXPECT_FALSE(request.has_auto_enrolled()); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 class DeviceTokenFetcherTest : public testing::Test { | 44 class DeviceTokenFetcherTest : public testing::Test { |
45 protected: | 45 protected: |
46 DeviceTokenFetcherTest() | 46 DeviceTokenFetcherTest() |
47 : ui_thread_(BrowserThread::UI, &loop_), | 47 : ui_thread_(BrowserThread::UI, &loop_), |
48 file_thread_(BrowserThread::FILE, &loop_) { | 48 file_thread_(BrowserThread::FILE, &loop_) { |
49 EXPECT_TRUE(temp_user_data_dir_.CreateUniqueTempDir()); | 49 EXPECT_TRUE(temp_user_data_dir_.CreateUniqueTempDir()); |
50 successful_registration_response_.mutable_register_response()-> | 50 successful_registration_response_.mutable_register_response()-> |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 data_store_->set_known_machine_id(true); | 260 data_store_->set_known_machine_id(true); |
261 FetchToken(&fetcher, data_store_.get()); | 261 FetchToken(&fetcher, data_store_.get()); |
262 loop_.RunAllPending(); | 262 loop_.RunAllPending(); |
263 | 263 |
264 Mock::VerifyAndClearExpectations(&observer_); | 264 Mock::VerifyAndClearExpectations(&observer_); |
265 std::string token = data_store_->device_token(); | 265 std::string token = data_store_->device_token(); |
266 EXPECT_NE("", token); | 266 EXPECT_NE("", token); |
267 } | 267 } |
268 | 268 |
269 } // namespace policy | 269 } // namespace policy |
OLD | NEW |