| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 215 } |
| 216 | 216 |
| 217 base::FilePath token_file() { | 217 base::FilePath token_file() { |
| 218 return tmp_dir_.path().AppendASCII("token"); | 218 return tmp_dir_.path().AppendASCII("token"); |
| 219 } | 219 } |
| 220 | 220 |
| 221 base::FilePath policy_file() { | 221 base::FilePath policy_file() { |
| 222 return tmp_dir_.path().AppendASCII("policy"); | 222 return tmp_dir_.path().AppendASCII("policy"); |
| 223 } | 223 } |
| 224 | 224 |
| 225 MessageLoop loop_; | 225 base::MessageLoop loop_; |
| 226 chromeos::MockCryptohomeClient cryptohome_client_; | 226 chromeos::MockCryptohomeClient cryptohome_client_; |
| 227 chromeos::MockSessionManagerClient session_manager_client_; | 227 chromeos::MockSessionManagerClient session_manager_client_; |
| 228 UserPolicyBuilder policy_; | 228 UserPolicyBuilder policy_; |
| 229 MockCloudPolicyStoreObserver observer_; | 229 MockCloudPolicyStoreObserver observer_; |
| 230 scoped_ptr<UserCloudPolicyStoreChromeOS> store_; | 230 scoped_ptr<UserCloudPolicyStoreChromeOS> store_; |
| 231 | 231 |
| 232 private: | 232 private: |
| 233 content::TestBrowserThread ui_thread_; | 233 content::TestBrowserThread ui_thread_; |
| 234 content::TestBrowserThread file_thread_; | 234 content::TestBrowserThread file_thread_; |
| 235 base::ScopedTempDir tmp_dir_; | 235 base::ScopedTempDir tmp_dir_; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 PerformStorePolicy(&new_public_key, kDefaultHomepage, kNewHomepage)); | 515 PerformStorePolicy(&new_public_key, kDefaultHomepage, kNewHomepage)); |
| 516 VerifyPolicyMap(kNewHomepage); | 516 VerifyPolicyMap(kNewHomepage); |
| 517 | 517 |
| 518 // Verify that the legacy cache has been removed. | 518 // Verify that the legacy cache has been removed. |
| 519 EXPECT_FALSE(file_util::PathExists(policy_file())); | 519 EXPECT_FALSE(file_util::PathExists(policy_file())); |
| 520 } | 520 } |
| 521 | 521 |
| 522 } // namespace | 522 } // namespace |
| 523 | 523 |
| 524 } // namespace policy | 524 } // namespace policy |
| OLD | NEW |