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/device_local_account_policy_service.h" | 5 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 | 519 |
520 DeviceLocalAccountPolicyExtensionCacheTest:: | 520 DeviceLocalAccountPolicyExtensionCacheTest:: |
521 DeviceLocalAccountPolicyExtensionCacheTest() { | 521 DeviceLocalAccountPolicyExtensionCacheTest() { |
522 } | 522 } |
523 | 523 |
524 void DeviceLocalAccountPolicyExtensionCacheTest::SetUp() { | 524 void DeviceLocalAccountPolicyExtensionCacheTest::SetUp() { |
525 DeviceLocalAccountPolicyServiceTestBase::SetUp(); | 525 DeviceLocalAccountPolicyServiceTestBase::SetUp(); |
526 ASSERT_TRUE(cache_root_dir_.CreateUniqueTempDir()); | 526 ASSERT_TRUE(cache_root_dir_.CreateUniqueTempDir()); |
527 cache_root_dir_override_.reset(new base::ScopedPathOverride( | 527 cache_root_dir_override_.reset(new base::ScopedPathOverride( |
528 chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, | 528 chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, |
529 cache_root_dir_.path())); | 529 cache_root_dir_.GetPath())); |
530 | 530 |
531 cache_dir_1_ = GetCacheDirectoryForAccountID(kAccount1); | 531 cache_dir_1_ = GetCacheDirectoryForAccountID(kAccount1); |
532 cache_dir_2_ = GetCacheDirectoryForAccountID(kAccount2); | 532 cache_dir_2_ = GetCacheDirectoryForAccountID(kAccount2); |
533 cache_dir_3_ = GetCacheDirectoryForAccountID(kAccount3); | 533 cache_dir_3_ = GetCacheDirectoryForAccountID(kAccount3); |
534 | 534 |
535 em::StringList* forcelist = device_local_account_policy_.payload() | 535 em::StringList* forcelist = device_local_account_policy_.payload() |
536 .mutable_extensioninstallforcelist()->mutable_value(); | 536 .mutable_extensioninstallforcelist()->mutable_value(); |
537 forcelist->add_entries(base::StringPrintf("%s;%s", kExtensionID, kUpdateURL)); | 537 forcelist->add_entries(base::StringPrintf("%s;%s", kExtensionID, kUpdateURL)); |
538 } | 538 } |
539 | 539 |
540 base::FilePath DeviceLocalAccountPolicyExtensionCacheTest:: | 540 base::FilePath DeviceLocalAccountPolicyExtensionCacheTest:: |
541 GetCacheDirectoryForAccountID(const std::string& account_id) { | 541 GetCacheDirectoryForAccountID(const std::string& account_id) { |
542 return cache_root_dir_.path().Append(base::HexEncode(account_id.c_str(), | 542 return cache_root_dir_.GetPath().Append( |
543 account_id.size())); | 543 base::HexEncode(account_id.c_str(), account_id.size())); |
544 } | 544 } |
545 | 545 |
546 // Verifies that during startup, orphaned cache directories are deleted, | 546 // Verifies that during startup, orphaned cache directories are deleted, |
547 // cache directories belonging to an existing account are preserved and missing | 547 // cache directories belonging to an existing account are preserved and missing |
548 // cache directories are created. Also verifies that when startup is complete, | 548 // cache directories are created. Also verifies that when startup is complete, |
549 // the caches for all existing accounts are running. | 549 // the caches for all existing accounts are running. |
550 TEST_F(DeviceLocalAccountPolicyExtensionCacheTest, Startup) { | 550 TEST_F(DeviceLocalAccountPolicyExtensionCacheTest, Startup) { |
551 base::FilePath test_data_dir; | 551 base::FilePath test_data_dir; |
552 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); | 552 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); |
553 const base::FilePath source_crx_file = | 553 const base::FilePath source_crx_file = |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 em::DeviceManagementResponse response; | 970 em::DeviceManagementResponse response; |
971 device_local_account_policy_.Build(); | 971 device_local_account_policy_.Build(); |
972 response.mutable_policy_response()->add_response()->CopyFrom( | 972 response.mutable_policy_response()->add_response()->CopyFrom( |
973 device_local_account_policy_.policy()); | 973 device_local_account_policy_.policy()); |
974 request_job->SendResponse(DM_STATUS_SUCCESS, response); | 974 request_job->SendResponse(DM_STATUS_SUCCESS, response); |
975 FlushDeviceSettings(); | 975 FlushDeviceSettings(); |
976 Mock::VerifyAndClearExpectations(&provider_observer_); | 976 Mock::VerifyAndClearExpectations(&provider_observer_); |
977 } | 977 } |
978 | 978 |
979 } // namespace policy | 979 } // namespace policy |
OLD | NEW |