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

Side by Side Diff: chrome/browser/extensions/api/storage/settings_sync_unittest.cc

Issue 2030013003: Remove ListValue::Append(new {Fundamental,String}Value(...)) pattern in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 EXPECT_EQ(0u, sync_processor_->changes().size()); 297 EXPECT_EQ(0u, sync_processor_->changes().size());
298 EXPECT_EQ(0u, GetAllSyncData(model_type).size()); 298 EXPECT_EQ(0u, GetAllSyncData(model_type).size());
299 } 299 }
300 300
301 TEST_F(ExtensionSettingsSyncTest, InSyncDataDoesNotInvokeSync) { 301 TEST_F(ExtensionSettingsSyncTest, InSyncDataDoesNotInvokeSync) {
302 syncer::ModelType model_type = syncer::APP_SETTINGS; 302 syncer::ModelType model_type = syncer::APP_SETTINGS;
303 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; 303 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP;
304 304
305 base::StringValue value1("fooValue"); 305 base::StringValue value1("fooValue");
306 base::ListValue value2; 306 base::ListValue value2;
307 value2.Append(new base::StringValue("barValue")); 307 value2.AppendString("barValue");
308 308
309 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); 309 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type);
310 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); 310 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type);
311 311
312 storage1->Set(DEFAULTS, "foo", value1); 312 storage1->Set(DEFAULTS, "foo", value1);
313 storage2->Set(DEFAULTS, "bar", value2); 313 storage2->Set(DEFAULTS, "bar", value2);
314 314
315 SettingSyncDataMultimap all_sync_data = GetAllSyncData(model_type); 315 SettingSyncDataMultimap all_sync_data = GetAllSyncData(model_type);
316 EXPECT_EQ(2u, all_sync_data.size()); 316 EXPECT_EQ(2u, all_sync_data.size());
317 EXPECT_EQ(1u, all_sync_data["s1"]->size()); 317 EXPECT_EQ(1u, all_sync_data["s1"]->size());
(...skipping 28 matching lines...) Expand all
346 346
347 GetSyncableService(model_type)->StopSyncing(model_type); 347 GetSyncableService(model_type)->StopSyncing(model_type);
348 } 348 }
349 349
350 TEST_F(ExtensionSettingsSyncTest, LocalDataWithNoSyncDataIsPushedToSync) { 350 TEST_F(ExtensionSettingsSyncTest, LocalDataWithNoSyncDataIsPushedToSync) {
351 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; 351 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS;
352 Manifest::Type type = Manifest::TYPE_EXTENSION; 352 Manifest::Type type = Manifest::TYPE_EXTENSION;
353 353
354 base::StringValue value1("fooValue"); 354 base::StringValue value1("fooValue");
355 base::ListValue value2; 355 base::ListValue value2;
356 value2.Append(new base::StringValue("barValue")); 356 value2.AppendString("barValue");
357 357
358 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); 358 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type);
359 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); 359 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type);
360 360
361 storage1->Set(DEFAULTS, "foo", value1); 361 storage1->Set(DEFAULTS, "foo", value1);
362 storage2->Set(DEFAULTS, "bar", value2); 362 storage2->Set(DEFAULTS, "bar", value2);
363 363
364 GetSyncableService(model_type) 364 GetSyncableService(model_type)
365 ->MergeDataAndStartSyncing( 365 ->MergeDataAndStartSyncing(
366 model_type, syncer::SyncDataList(), 366 model_type, syncer::SyncDataList(),
(...skipping 11 matching lines...) Expand all
378 378
379 GetSyncableService(model_type)->StopSyncing(model_type); 379 GetSyncableService(model_type)->StopSyncing(model_type);
380 } 380 }
381 381
382 TEST_F(ExtensionSettingsSyncTest, AnySyncDataOverwritesLocalData) { 382 TEST_F(ExtensionSettingsSyncTest, AnySyncDataOverwritesLocalData) {
383 syncer::ModelType model_type = syncer::APP_SETTINGS; 383 syncer::ModelType model_type = syncer::APP_SETTINGS;
384 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; 384 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP;
385 385
386 base::StringValue value1("fooValue"); 386 base::StringValue value1("fooValue");
387 base::ListValue value2; 387 base::ListValue value2;
388 value2.Append(new base::StringValue("barValue")); 388 value2.AppendString("barValue");
389 389
390 // Maintain dictionaries mirrored to the expected values of the settings in 390 // Maintain dictionaries mirrored to the expected values of the settings in
391 // each storage area. 391 // each storage area.
392 base::DictionaryValue expected1, expected2; 392 base::DictionaryValue expected1, expected2;
393 393
394 // Pre-populate one of the storage areas. 394 // Pre-populate one of the storage areas.
395 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); 395 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type);
396 storage1->Set(DEFAULTS, "overwriteMe", value1); 396 storage1->Set(DEFAULTS, "overwriteMe", value1);
397 397
398 syncer::SyncDataList sync_data; 398 syncer::SyncDataList sync_data;
(...skipping 19 matching lines...) Expand all
418 418
419 GetSyncableService(model_type)->StopSyncing(model_type); 419 GetSyncableService(model_type)->StopSyncing(model_type);
420 } 420 }
421 421
422 TEST_F(ExtensionSettingsSyncTest, ProcessSyncChanges) { 422 TEST_F(ExtensionSettingsSyncTest, ProcessSyncChanges) {
423 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; 423 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS;
424 Manifest::Type type = Manifest::TYPE_EXTENSION; 424 Manifest::Type type = Manifest::TYPE_EXTENSION;
425 425
426 base::StringValue value1("fooValue"); 426 base::StringValue value1("fooValue");
427 base::ListValue value2; 427 base::ListValue value2;
428 value2.Append(new base::StringValue("barValue")); 428 value2.AppendString("barValue");
429 429
430 // Maintain dictionaries mirrored to the expected values of the settings in 430 // Maintain dictionaries mirrored to the expected values of the settings in
431 // each storage area. 431 // each storage area.
432 base::DictionaryValue expected1, expected2; 432 base::DictionaryValue expected1, expected2;
433 433
434 // Make storage1 initialised from local data, storage2 initialised from sync. 434 // Make storage1 initialised from local data, storage2 initialised from sync.
435 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); 435 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type);
436 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); 436 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type);
437 437
438 storage1->Set(DEFAULTS, "foo", value1); 438 storage1->Set(DEFAULTS, "foo", value1);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 491
492 GetSyncableService(model_type)->StopSyncing(model_type); 492 GetSyncableService(model_type)->StopSyncing(model_type);
493 } 493 }
494 494
495 TEST_F(ExtensionSettingsSyncTest, PushToSync) { 495 TEST_F(ExtensionSettingsSyncTest, PushToSync) {
496 syncer::ModelType model_type = syncer::APP_SETTINGS; 496 syncer::ModelType model_type = syncer::APP_SETTINGS;
497 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; 497 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP;
498 498
499 base::StringValue value1("fooValue"); 499 base::StringValue value1("fooValue");
500 base::ListValue value2; 500 base::ListValue value2;
501 value2.Append(new base::StringValue("barValue")); 501 value2.AppendString("barValue");
502 502
503 // Make storage1/2 initialised from local data, storage3/4 initialised from 503 // Make storage1/2 initialised from local data, storage3/4 initialised from
504 // sync. 504 // sync.
505 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); 505 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type);
506 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); 506 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type);
507 ValueStore* storage3 = AddExtensionAndGetStorage("s3", type); 507 ValueStore* storage3 = AddExtensionAndGetStorage("s3", type);
508 ValueStore* storage4 = AddExtensionAndGetStorage("s4", type); 508 ValueStore* storage4 = AddExtensionAndGetStorage("s4", type);
509 509
510 storage1->Set(DEFAULTS, "foo", value1); 510 storage1->Set(DEFAULTS, "foo", value1);
511 storage2->Set(DEFAULTS, "foo", value1); 511 storage2->Set(DEFAULTS, "foo", value1);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 sync_processor_->GetOnlyChange("s4", "foo")->change_type()); 618 sync_processor_->GetOnlyChange("s4", "foo")->change_type());
619 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, 619 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE,
620 sync_processor_->GetOnlyChange("s4", "bar")->change_type()); 620 sync_processor_->GetOnlyChange("s4", "bar")->change_type());
621 621
622 GetSyncableService(model_type)->StopSyncing(model_type); 622 GetSyncableService(model_type)->StopSyncing(model_type);
623 } 623 }
624 624
625 TEST_F(ExtensionSettingsSyncTest, ExtensionAndAppSettingsSyncSeparately) { 625 TEST_F(ExtensionSettingsSyncTest, ExtensionAndAppSettingsSyncSeparately) {
626 base::StringValue value1("fooValue"); 626 base::StringValue value1("fooValue");
627 base::ListValue value2; 627 base::ListValue value2;
628 value2.Append(new base::StringValue("barValue")); 628 value2.AppendString("barValue");
629 629
630 // storage1 is an extension, storage2 is an app. 630 // storage1 is an extension, storage2 is an app.
631 ValueStore* storage1 = AddExtensionAndGetStorage( 631 ValueStore* storage1 = AddExtensionAndGetStorage(
632 "s1", Manifest::TYPE_EXTENSION); 632 "s1", Manifest::TYPE_EXTENSION);
633 ValueStore* storage2 = AddExtensionAndGetStorage( 633 ValueStore* storage2 = AddExtensionAndGetStorage(
634 "s2", Manifest::TYPE_LEGACY_PACKAGED_APP); 634 "s2", Manifest::TYPE_LEGACY_PACKAGED_APP);
635 635
636 storage1->Set(DEFAULTS, "foo", value1); 636 storage1->Set(DEFAULTS, "foo", value1);
637 storage2->Set(DEFAULTS, "bar", value2); 637 storage2->Set(DEFAULTS, "bar", value2);
638 638
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 settings_namespace::SYNC, 1410 settings_namespace::SYNC,
1411 base::Bind(&UnlimitedSyncStorageTestCallback)); 1411 base::Bind(&UnlimitedSyncStorageTestCallback));
1412 frontend_->RunWithStorage(extension, 1412 frontend_->RunWithStorage(extension,
1413 settings_namespace::LOCAL, 1413 settings_namespace::LOCAL,
1414 base::Bind(&UnlimitedLocalStorageTestCallback)); 1414 base::Bind(&UnlimitedLocalStorageTestCallback));
1415 1415
1416 base::MessageLoop::current()->RunUntilIdle(); 1416 base::MessageLoop::current()->RunUntilIdle();
1417 } 1417 }
1418 1418
1419 } // namespace extensions 1419 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698