| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 public: | 74 public: |
| 75 MOCK_METHOD1(OnPolicyUpdated, void(const std::string&)); | 75 MOCK_METHOD1(OnPolicyUpdated, void(const std::string&)); |
| 76 MOCK_METHOD0(OnDeviceLocalAccountsChanged, void(void)); | 76 MOCK_METHOD0(OnDeviceLocalAccountsChanged, void(void)); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 class DeviceLocalAccountPolicyServiceTestBase | 79 class DeviceLocalAccountPolicyServiceTestBase |
| 80 : public chromeos::DeviceSettingsTestBase { | 80 : public chromeos::DeviceSettingsTestBase { |
| 81 public: | 81 public: |
| 82 DeviceLocalAccountPolicyServiceTestBase(); | 82 DeviceLocalAccountPolicyServiceTestBase(); |
| 83 | 83 |
| 84 virtual void SetUp() OVERRIDE; | 84 virtual void SetUp() override; |
| 85 virtual void TearDown() OVERRIDE; | 85 virtual void TearDown() override; |
| 86 | 86 |
| 87 void CreatePolicyService(); | 87 void CreatePolicyService(); |
| 88 | 88 |
| 89 void InstallDeviceLocalAccountPolicy(const std::string& account_id); | 89 void InstallDeviceLocalAccountPolicy(const std::string& account_id); |
| 90 void AddDeviceLocalAccountToPolicy(const std::string& account_id); | 90 void AddDeviceLocalAccountToPolicy(const std::string& account_id); |
| 91 virtual void InstallDevicePolicy(); | 91 virtual void InstallDevicePolicy(); |
| 92 | 92 |
| 93 const std::string account_1_user_id_; | 93 const std::string account_1_user_id_; |
| 94 const std::string account_2_user_id_; | 94 const std::string account_2_user_id_; |
| 95 | 95 |
| 96 PolicyMap expected_policy_map_; | 96 PolicyMap expected_policy_map_; |
| 97 UserPolicyBuilder device_local_account_policy_; | 97 UserPolicyBuilder device_local_account_policy_; |
| 98 chromeos::CrosSettings cros_settings_; | 98 chromeos::CrosSettings cros_settings_; |
| 99 scoped_refptr<base::TestSimpleTaskRunner> extension_cache_task_runner_; | 99 scoped_refptr<base::TestSimpleTaskRunner> extension_cache_task_runner_; |
| 100 MockDeviceManagementService mock_device_management_service_; | 100 MockDeviceManagementService mock_device_management_service_; |
| 101 scoped_ptr<DeviceLocalAccountPolicyService> service_; | 101 scoped_ptr<DeviceLocalAccountPolicyService> service_; |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyServiceTestBase); | 104 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyServiceTestBase); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 class DeviceLocalAccountPolicyServiceTest | 107 class DeviceLocalAccountPolicyServiceTest |
| 108 : public DeviceLocalAccountPolicyServiceTestBase { | 108 : public DeviceLocalAccountPolicyServiceTestBase { |
| 109 public: | 109 public: |
| 110 MOCK_METHOD1(OnRefreshDone, void(bool)); | 110 MOCK_METHOD1(OnRefreshDone, void(bool)); |
| 111 | 111 |
| 112 protected: | 112 protected: |
| 113 DeviceLocalAccountPolicyServiceTest(); | 113 DeviceLocalAccountPolicyServiceTest(); |
| 114 | 114 |
| 115 virtual void SetUp() OVERRIDE; | 115 virtual void SetUp() override; |
| 116 virtual void TearDown() OVERRIDE; | 116 virtual void TearDown() override; |
| 117 | 117 |
| 118 void InstallDevicePolicy() OVERRIDE; | 118 void InstallDevicePolicy() override; |
| 119 | 119 |
| 120 MockDeviceLocalAccountPolicyServiceObserver service_observer_; | 120 MockDeviceLocalAccountPolicyServiceObserver service_observer_; |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyServiceTest); | 123 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyServiceTest); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 DeviceLocalAccountPolicyServiceTestBase:: | 126 DeviceLocalAccountPolicyServiceTestBase:: |
| 127 DeviceLocalAccountPolicyServiceTestBase() | 127 DeviceLocalAccountPolicyServiceTestBase() |
| 128 : account_1_user_id_(GenerateDeviceLocalAccountUserId( | 128 : account_1_user_id_(GenerateDeviceLocalAccountUserId( |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 EXPECT_TRUE(expected_policy_map_.Equals( | 486 EXPECT_TRUE(expected_policy_map_.Equals( |
| 487 broker->core()->store()->policy_map())); | 487 broker->core()->store()->policy_map())); |
| 488 EXPECT_TRUE(service_->IsPolicyAvailableForUser(account_1_user_id_)); | 488 EXPECT_TRUE(service_->IsPolicyAvailableForUser(account_1_user_id_)); |
| 489 } | 489 } |
| 490 | 490 |
| 491 class DeviceLocalAccountPolicyExtensionCacheTest | 491 class DeviceLocalAccountPolicyExtensionCacheTest |
| 492 : public DeviceLocalAccountPolicyServiceTestBase { | 492 : public DeviceLocalAccountPolicyServiceTestBase { |
| 493 protected: | 493 protected: |
| 494 DeviceLocalAccountPolicyExtensionCacheTest(); | 494 DeviceLocalAccountPolicyExtensionCacheTest(); |
| 495 | 495 |
| 496 virtual void SetUp() OVERRIDE; | 496 virtual void SetUp() override; |
| 497 | 497 |
| 498 base::FilePath GetCacheDirectoryForAccountID(const std::string& account_id); | 498 base::FilePath GetCacheDirectoryForAccountID(const std::string& account_id); |
| 499 | 499 |
| 500 base::ScopedTempDir cache_root_dir_; | 500 base::ScopedTempDir cache_root_dir_; |
| 501 scoped_ptr<base::ScopedPathOverride> cache_root_dir_override_; | 501 scoped_ptr<base::ScopedPathOverride> cache_root_dir_override_; |
| 502 | 502 |
| 503 base::FilePath cache_dir_1_; | 503 base::FilePath cache_dir_1_; |
| 504 base::FilePath cache_dir_2_; | 504 base::FilePath cache_dir_2_; |
| 505 base::FilePath cache_dir_3_; | 505 base::FilePath cache_dir_3_; |
| 506 | 506 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 | 765 |
| 766 // Verify that the cache directory for account 1 was deleted. | 766 // Verify that the cache directory for account 1 was deleted. |
| 767 EXPECT_FALSE(base::DirectoryExists(cache_dir_1_)); | 767 EXPECT_FALSE(base::DirectoryExists(cache_dir_1_)); |
| 768 } | 768 } |
| 769 | 769 |
| 770 class DeviceLocalAccountPolicyProviderTest | 770 class DeviceLocalAccountPolicyProviderTest |
| 771 : public DeviceLocalAccountPolicyServiceTestBase { | 771 : public DeviceLocalAccountPolicyServiceTestBase { |
| 772 protected: | 772 protected: |
| 773 DeviceLocalAccountPolicyProviderTest(); | 773 DeviceLocalAccountPolicyProviderTest(); |
| 774 | 774 |
| 775 virtual void SetUp() OVERRIDE; | 775 virtual void SetUp() override; |
| 776 virtual void TearDown() OVERRIDE; | 776 virtual void TearDown() override; |
| 777 | 777 |
| 778 SchemaRegistry schema_registry_; | 778 SchemaRegistry schema_registry_; |
| 779 scoped_ptr<DeviceLocalAccountPolicyProvider> provider_; | 779 scoped_ptr<DeviceLocalAccountPolicyProvider> provider_; |
| 780 MockConfigurationPolicyObserver provider_observer_; | 780 MockConfigurationPolicyObserver provider_observer_; |
| 781 | 781 |
| 782 private: | 782 private: |
| 783 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyProviderTest); | 783 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyProviderTest); |
| 784 }; | 784 }; |
| 785 | 785 |
| 786 DeviceLocalAccountPolicyProviderTest::DeviceLocalAccountPolicyProviderTest() { | 786 DeviceLocalAccountPolicyProviderTest::DeviceLocalAccountPolicyProviderTest() { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 em::DeviceManagementResponse response; | 966 em::DeviceManagementResponse response; |
| 967 device_local_account_policy_.Build(); | 967 device_local_account_policy_.Build(); |
| 968 response.mutable_policy_response()->add_response()->CopyFrom( | 968 response.mutable_policy_response()->add_response()->CopyFrom( |
| 969 device_local_account_policy_.policy()); | 969 device_local_account_policy_.policy()); |
| 970 request_job->SendResponse(DM_STATUS_SUCCESS, response); | 970 request_job->SendResponse(DM_STATUS_SUCCESS, response); |
| 971 FlushDeviceSettings(); | 971 FlushDeviceSettings(); |
| 972 Mock::VerifyAndClearExpectations(&provider_observer_); | 972 Mock::VerifyAndClearExpectations(&provider_observer_); |
| 973 } | 973 } |
| 974 | 974 |
| 975 } // namespace policy | 975 } // namespace policy |
| OLD | NEW |