Chromium Code Reviews| 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/settings/device_settings_provider.h" | 5 #include "chrome/browser/chromeos/settings/device_settings_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 metrics_enabled().metrics_enabled()); | 197 metrics_enabled().metrics_enabled()); |
| 198 | 198 |
| 199 // Verify the change has been applied. | 199 // Verify the change has been applied. |
| 200 const base::Value* saved_value = provider_->Get(kStatsReportingPref); | 200 const base::Value* saved_value = provider_->Get(kStatsReportingPref); |
| 201 ASSERT_TRUE(saved_value); | 201 ASSERT_TRUE(saved_value); |
| 202 bool bool_value; | 202 bool bool_value; |
| 203 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value)); | 203 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value)); |
| 204 EXPECT_TRUE(bool_value); | 204 EXPECT_TRUE(bool_value); |
| 205 } | 205 } |
| 206 | 206 |
| 207 TEST_F(DeviceSettingsProviderTest, SetPrefTwice) { | |
| 208 owner_key_util_->SetPrivateKey(policy_.signing_key()); | |
| 209 device_settings_service_.SetUsername(policy_.policy_data().username()); | |
| 210 device_settings_test_helper_.Flush(); | |
| 211 | |
| 212 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); | |
| 213 EXPECT_CALL(*this, SettingChanged(_)).Times(AnyNumber()); | |
|
pastarmovj
2012/09/20 08:30:07
If you expect any number why do you have this line
Mattias Nissler (ping if slow)
2012/09/20 09:47:02
I intended to have only one line :) Fixed.
I don'
| |
| 214 | |
| 215 base::StringValue value1("beta"); | |
| 216 provider_->Set(kReleaseChannel, value1); | |
| 217 base::StringValue value2("dev"); | |
| 218 provider_->Set(kReleaseChannel, value2); | |
| 219 | |
| 220 // Let the changes propagate through the system. | |
| 221 device_settings_test_helper_.set_policy_blob(std::string()); | |
| 222 device_settings_test_helper_.Flush(); | |
| 223 | |
| 224 // Verify the second change has been applied. | |
| 225 const base::Value* saved_value = provider_->Get(kReleaseChannel); | |
| 226 EXPECT_TRUE(value2.Equals(saved_value)); | |
| 227 | |
| 228 Mock::VerifyAndClearExpectations(this); | |
| 229 } | |
| 230 | |
| 207 TEST_F(DeviceSettingsProviderTest, PolicyRetrievalFailedBadSignature) { | 231 TEST_F(DeviceSettingsProviderTest, PolicyRetrievalFailedBadSignature) { |
| 208 owner_key_util_->SetPublicKeyFromPrivateKey(policy_.signing_key()); | 232 owner_key_util_->SetPublicKeyFromPrivateKey(policy_.signing_key()); |
| 209 policy_.policy().set_policy_data_signature("bad signature"); | 233 policy_.policy().set_policy_data_signature("bad signature"); |
| 210 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); | 234 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); |
| 211 | 235 |
| 212 device_settings_service_.Load(); | 236 device_settings_service_.Load(); |
| 213 device_settings_test_helper_.Flush(); | 237 device_settings_test_helper_.Flush(); |
| 214 | 238 |
| 215 // Verify that the cached settings blob is not "trusted". | 239 // Verify that the cached settings blob is not "trusted". |
| 216 EXPECT_EQ(DeviceSettingsService::STORE_VALIDATION_ERROR, | 240 EXPECT_EQ(DeviceSettingsService::STORE_VALIDATION_ERROR, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 | 301 |
| 278 // Verify that migration has kicked in. | 302 // Verify that migration has kicked in. |
| 279 const base::Value* saved_value = provider_->Get(kStatsReportingPref); | 303 const base::Value* saved_value = provider_->Get(kStatsReportingPref); |
| 280 ASSERT_TRUE(saved_value); | 304 ASSERT_TRUE(saved_value); |
| 281 bool bool_value; | 305 bool bool_value; |
| 282 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value)); | 306 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value)); |
| 283 EXPECT_FALSE(bool_value); | 307 EXPECT_FALSE(bool_value); |
| 284 } | 308 } |
| 285 | 309 |
| 286 } // namespace chromeos | 310 } // namespace chromeos |
| OLD | NEW |