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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 account_2_user_id_(GenerateDeviceLocalAccountUserId( | 136 account_2_user_id_(GenerateDeviceLocalAccountUserId( |
137 kAccount2, | 137 kAccount2, |
138 DeviceLocalAccount::TYPE_PUBLIC_SESSION)), | 138 DeviceLocalAccount::TYPE_PUBLIC_SESSION)), |
139 cros_settings_(&device_settings_service_), | 139 cros_settings_(&device_settings_service_), |
140 extension_cache_task_runner_(new base::TestSimpleTaskRunner) { | 140 extension_cache_task_runner_(new base::TestSimpleTaskRunner) { |
141 } | 141 } |
142 | 142 |
143 void DeviceLocalAccountPolicyServiceTestBase::SetUp() { | 143 void DeviceLocalAccountPolicyServiceTestBase::SetUp() { |
144 chromeos::DeviceSettingsTestBase::SetUp(); | 144 chromeos::DeviceSettingsTestBase::SetUp(); |
145 | 145 |
146 expected_policy_map_.Set(key::kDisableSpdy, POLICY_LEVEL_MANDATORY, | 146 expected_policy_map_.Set(key::kSearchSuggestEnabled, POLICY_LEVEL_MANDATORY, |
147 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 147 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
148 base::WrapUnique(new base::FundamentalValue(true)), | 148 base::WrapUnique(new base::FundamentalValue(true)), |
149 nullptr); | 149 nullptr); |
150 | 150 |
151 device_local_account_policy_.payload().mutable_disablespdy()->set_value( | 151 device_local_account_policy_.payload() |
152 true); | 152 .mutable_searchsuggestenabled() |
| 153 ->set_value(true); |
153 device_local_account_policy_.policy_data().set_policy_type( | 154 device_local_account_policy_.policy_data().set_policy_type( |
154 dm_protocol::kChromePublicAccountPolicyType); | 155 dm_protocol::kChromePublicAccountPolicyType); |
155 } | 156 } |
156 | 157 |
157 void DeviceLocalAccountPolicyServiceTestBase::TearDown() { | 158 void DeviceLocalAccountPolicyServiceTestBase::TearDown() { |
158 service_->Shutdown(); | 159 service_->Shutdown(); |
159 service_.reset(); | 160 service_.reset(); |
160 extension_cache_task_runner_->RunUntilIdle(); | 161 extension_cache_task_runner_->RunUntilIdle(); |
161 chromeos::DeviceSettingsTestBase::TearDown(); | 162 chromeos::DeviceSettingsTestBase::TearDown(); |
162 } | 163 } |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 Mock::VerifyAndClearExpectations(&provider_observer_); | 866 Mock::VerifyAndClearExpectations(&provider_observer_); |
866 | 867 |
867 PolicyBundle expected_policy_bundle; | 868 PolicyBundle expected_policy_bundle; |
868 expected_policy_bundle.Get(PolicyNamespace( | 869 expected_policy_bundle.Get(PolicyNamespace( |
869 POLICY_DOMAIN_CHROME, std::string())).CopyFrom(expected_policy_map_); | 870 POLICY_DOMAIN_CHROME, std::string())).CopyFrom(expected_policy_map_); |
870 EXPECT_TRUE(expected_policy_bundle.Equals(provider_->policies())); | 871 EXPECT_TRUE(expected_policy_bundle.Equals(provider_->policies())); |
871 | 872 |
872 // Policy change should be reported. | 873 // Policy change should be reported. |
873 EXPECT_CALL(provider_observer_, OnUpdatePolicy(provider_.get())) | 874 EXPECT_CALL(provider_observer_, OnUpdatePolicy(provider_.get())) |
874 .Times(AtLeast(1)); | 875 .Times(AtLeast(1)); |
875 device_local_account_policy_.payload().mutable_disablespdy()->set_value( | 876 device_local_account_policy_.payload() |
876 false); | 877 .mutable_searchsuggestenabled() |
| 878 ->set_value(false); |
877 InstallDeviceLocalAccountPolicy(kAccount1); | 879 InstallDeviceLocalAccountPolicy(kAccount1); |
878 DeviceLocalAccountPolicyBroker* broker = | 880 DeviceLocalAccountPolicyBroker* broker = |
879 service_->GetBrokerForUser(account_1_user_id_); | 881 service_->GetBrokerForUser(account_1_user_id_); |
880 ASSERT_TRUE(broker); | 882 ASSERT_TRUE(broker); |
881 broker->core()->store()->Load(); | 883 broker->core()->store()->Load(); |
882 FlushDeviceSettings(); | 884 FlushDeviceSettings(); |
883 Mock::VerifyAndClearExpectations(&provider_observer_); | 885 Mock::VerifyAndClearExpectations(&provider_observer_); |
884 | 886 |
885 expected_policy_bundle | 887 expected_policy_bundle |
886 .Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 888 .Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
887 .Set(key::kDisableSpdy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 889 .Set(key::kSearchSuggestEnabled, POLICY_LEVEL_MANDATORY, |
888 POLICY_SOURCE_CLOUD, | 890 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
889 base::WrapUnique(new base::FundamentalValue(false)), nullptr); | 891 base::WrapUnique(new base::FundamentalValue(false)), nullptr); |
890 EXPECT_TRUE(expected_policy_bundle.Equals(provider_->policies())); | 892 EXPECT_TRUE(expected_policy_bundle.Equals(provider_->policies())); |
891 | 893 |
892 // Any values set for the |ShelfAutoHideBehavior|, |ShowLogoutButtonInTray| | 894 // Any values set for the |ShelfAutoHideBehavior|, |ShowLogoutButtonInTray| |
893 // and |ExtensionAllowedTypes| policies should be overridden. | 895 // and |ExtensionAllowedTypes| policies should be overridden. |
894 EXPECT_CALL(provider_observer_, OnUpdatePolicy(provider_.get())) | 896 EXPECT_CALL(provider_observer_, OnUpdatePolicy(provider_.get())) |
895 .Times(AtLeast(1)); | 897 .Times(AtLeast(1)); |
896 device_local_account_policy_.payload().mutable_shelfautohidebehavior()-> | 898 device_local_account_policy_.payload().mutable_shelfautohidebehavior()-> |
897 set_value("Always"); | 899 set_value("Always"); |
898 device_local_account_policy_.payload().mutable_showlogoutbuttonintray()-> | 900 device_local_account_policy_.payload().mutable_showlogoutbuttonintray()-> |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 em::DeviceManagementResponse response; | 970 em::DeviceManagementResponse response; |
969 device_local_account_policy_.Build(); | 971 device_local_account_policy_.Build(); |
970 response.mutable_policy_response()->add_response()->CopyFrom( | 972 response.mutable_policy_response()->add_response()->CopyFrom( |
971 device_local_account_policy_.policy()); | 973 device_local_account_policy_.policy()); |
972 request_job->SendResponse(DM_STATUS_SUCCESS, response); | 974 request_job->SendResponse(DM_STATUS_SUCCESS, response); |
973 FlushDeviceSettings(); | 975 FlushDeviceSettings(); |
974 Mock::VerifyAndClearExpectations(&provider_observer_); | 976 Mock::VerifyAndClearExpectations(&provider_observer_); |
975 } | 977 } |
976 | 978 |
977 } // namespace policy | 979 } // namespace policy |
OLD | NEW |