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/user_cloud_policy_store_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 namespace policy { | 38 namespace policy { |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 const char kLegacyDeviceId[] = "legacy-device-id"; | 42 const char kLegacyDeviceId[] = "legacy-device-id"; |
43 const char kLegacyToken[] = "legacy-token"; | 43 const char kLegacyToken[] = "legacy-token"; |
44 const char kSanitizedUsername[] = "0123456789ABCDEF0123456789ABCDEF012345678"; | 44 const char kSanitizedUsername[] = "0123456789ABCDEF0123456789ABCDEF012345678"; |
45 const char kDefaultHomepage[] = "http://chromium.org"; | 45 const char kDefaultHomepage[] = "http://chromium.org"; |
46 | 46 |
47 ACTION_P2(SendSanitizedUsername, call_status, sanitized_username) { | 47 ACTION_P2(SendSanitizedUsername, call_status, sanitized_username) { |
48 MessageLoop::current()->PostTask( | 48 base::MessageLoop::current()->PostTask( |
49 FROM_HERE, base::Bind(arg1, call_status, sanitized_username)); | 49 FROM_HERE, base::Bind(arg1, call_status, sanitized_username)); |
50 } | 50 } |
51 | 51 |
52 class UserCloudPolicyStoreChromeOSTest : public testing::Test { | 52 class UserCloudPolicyStoreChromeOSTest : public testing::Test { |
53 protected: | 53 protected: |
54 UserCloudPolicyStoreChromeOSTest() | 54 UserCloudPolicyStoreChromeOSTest() |
55 : loop_(MessageLoop::TYPE_UI), | 55 : loop_(base::MessageLoop::TYPE_UI), |
56 ui_thread_(content::BrowserThread::UI, &loop_), | 56 ui_thread_(content::BrowserThread::UI, &loop_), |
57 file_thread_(content::BrowserThread::FILE, &loop_) {} | 57 file_thread_(content::BrowserThread::FILE, &loop_) {} |
58 | 58 |
59 virtual void SetUp() OVERRIDE { | 59 virtual void SetUp() OVERRIDE { |
60 EXPECT_CALL(cryptohome_client_, | 60 EXPECT_CALL(cryptohome_client_, |
61 GetSanitizedUsername(PolicyBuilder::kFakeUsername, _)) | 61 GetSanitizedUsername(PolicyBuilder::kFakeUsername, _)) |
62 .Times(AnyNumber()) | 62 .Times(AnyNumber()) |
63 .WillRepeatedly( | 63 .WillRepeatedly( |
64 SendSanitizedUsername(chromeos::DBUS_METHOD_CALL_SUCCESS, | 64 SendSanitizedUsername(chromeos::DBUS_METHOD_CALL_SUCCESS, |
65 kSanitizedUsername)); | 65 kSanitizedUsername)); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 211 } |
212 | 212 |
213 base::FilePath token_file() { | 213 base::FilePath token_file() { |
214 return tmp_dir_.path().AppendASCII("token"); | 214 return tmp_dir_.path().AppendASCII("token"); |
215 } | 215 } |
216 | 216 |
217 base::FilePath policy_file() { | 217 base::FilePath policy_file() { |
218 return tmp_dir_.path().AppendASCII("policy"); | 218 return tmp_dir_.path().AppendASCII("policy"); |
219 } | 219 } |
220 | 220 |
221 MessageLoop loop_; | 221 base::MessageLoop loop_; |
222 chromeos::MockCryptohomeClient cryptohome_client_; | 222 chromeos::MockCryptohomeClient cryptohome_client_; |
223 chromeos::MockSessionManagerClient session_manager_client_; | 223 chromeos::MockSessionManagerClient session_manager_client_; |
224 UserPolicyBuilder policy_; | 224 UserPolicyBuilder policy_; |
225 MockCloudPolicyStoreObserver observer_; | 225 MockCloudPolicyStoreObserver observer_; |
226 scoped_ptr<UserCloudPolicyStoreChromeOS> store_; | 226 scoped_ptr<UserCloudPolicyStoreChromeOS> store_; |
227 | 227 |
228 private: | 228 private: |
229 content::TestBrowserThread ui_thread_; | 229 content::TestBrowserThread ui_thread_; |
230 content::TestBrowserThread file_thread_; | 230 content::TestBrowserThread file_thread_; |
231 base::ScopedTempDir tmp_dir_; | 231 base::ScopedTempDir tmp_dir_; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 PerformStorePolicy(&new_public_key, kDefaultHomepage, kNewHomepage)); | 503 PerformStorePolicy(&new_public_key, kDefaultHomepage, kNewHomepage)); |
504 VerifyPolicyMap(kNewHomepage); | 504 VerifyPolicyMap(kNewHomepage); |
505 | 505 |
506 // Verify that the legacy cache has been removed. | 506 // Verify that the legacy cache has been removed. |
507 EXPECT_FALSE(file_util::PathExists(policy_file())); | 507 EXPECT_FALSE(file_util::PathExists(policy_file())); |
508 } | 508 } |
509 | 509 |
510 } // namespace | 510 } // namespace |
511 | 511 |
512 } // namespace policy | 512 } // namespace policy |
OLD | NEW |