Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_provider_unittest.cc

Issue 10950032: Fix queued writes in DeviceSettingsProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove redundant EXPECT_CALL. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/settings/device_settings_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
214 base::StringValue value1("beta");
215 provider_->Set(kReleaseChannel, value1);
216 base::StringValue value2("dev");
217 provider_->Set(kReleaseChannel, value2);
218
219 // Let the changes propagate through the system.
220 device_settings_test_helper_.set_policy_blob(std::string());
221 device_settings_test_helper_.Flush();
222
223 // Verify the second change has been applied.
224 const base::Value* saved_value = provider_->Get(kReleaseChannel);
225 EXPECT_TRUE(value2.Equals(saved_value));
226
227 Mock::VerifyAndClearExpectations(this);
228 }
229
207 TEST_F(DeviceSettingsProviderTest, PolicyRetrievalFailedBadSignature) { 230 TEST_F(DeviceSettingsProviderTest, PolicyRetrievalFailedBadSignature) {
208 owner_key_util_->SetPublicKeyFromPrivateKey(policy_.signing_key()); 231 owner_key_util_->SetPublicKeyFromPrivateKey(policy_.signing_key());
209 policy_.policy().set_policy_data_signature("bad signature"); 232 policy_.policy().set_policy_data_signature("bad signature");
210 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); 233 device_settings_test_helper_.set_policy_blob(policy_.GetBlob());
211 234
212 device_settings_service_.Load(); 235 device_settings_service_.Load();
213 device_settings_test_helper_.Flush(); 236 device_settings_test_helper_.Flush();
214 237
215 // Verify that the cached settings blob is not "trusted". 238 // Verify that the cached settings blob is not "trusted".
216 EXPECT_EQ(DeviceSettingsService::STORE_VALIDATION_ERROR, 239 EXPECT_EQ(DeviceSettingsService::STORE_VALIDATION_ERROR,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 300
278 // Verify that migration has kicked in. 301 // Verify that migration has kicked in.
279 const base::Value* saved_value = provider_->Get(kStatsReportingPref); 302 const base::Value* saved_value = provider_->Get(kStatsReportingPref);
280 ASSERT_TRUE(saved_value); 303 ASSERT_TRUE(saved_value);
281 bool bool_value; 304 bool bool_value;
282 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value)); 305 EXPECT_TRUE(saved_value->GetAsBoolean(&bool_value));
283 EXPECT_FALSE(bool_value); 306 EXPECT_FALSE(bool_value);
284 } 307 }
285 308
286 } // namespace chromeos 309 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/settings/device_settings_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698