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 <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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 GetSyncableService(model_type)->StopSyncing(model_type); | 293 GetSyncableService(model_type)->StopSyncing(model_type); |
294 | 294 |
295 EXPECT_EQ(0u, sync_processor_->changes().size()); | 295 EXPECT_EQ(0u, sync_processor_->changes().size()); |
296 EXPECT_EQ(0u, GetAllSyncData(model_type).size()); | 296 EXPECT_EQ(0u, GetAllSyncData(model_type).size()); |
297 } | 297 } |
298 | 298 |
299 TEST_F(ExtensionSettingsSyncTest, InSyncDataDoesNotInvokeSync) { | 299 TEST_F(ExtensionSettingsSyncTest, InSyncDataDoesNotInvokeSync) { |
300 syncer::ModelType model_type = syncer::APP_SETTINGS; | 300 syncer::ModelType model_type = syncer::APP_SETTINGS; |
301 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; | 301 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; |
302 | 302 |
303 base::StringValue value1("fooValue"); | 303 base::Value value1("fooValue"); |
304 base::ListValue value2; | 304 base::ListValue value2; |
305 value2.AppendString("barValue"); | 305 value2.AppendString("barValue"); |
306 | 306 |
307 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); | 307 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); |
308 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); | 308 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); |
309 | 309 |
310 storage1->Set(DEFAULTS, "foo", value1); | 310 storage1->Set(DEFAULTS, "foo", value1); |
311 storage2->Set(DEFAULTS, "bar", value2); | 311 storage2->Set(DEFAULTS, "bar", value2); |
312 | 312 |
313 SettingSyncDataMultimap all_sync_data = GetAllSyncData(model_type); | 313 SettingSyncDataMultimap all_sync_data = GetAllSyncData(model_type); |
(...skipping 28 matching lines...) Expand all Loading... |
342 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, change->change_type()); | 342 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, change->change_type()); |
343 EXPECT_TRUE(value2.Equals(&change->value())); | 343 EXPECT_TRUE(value2.Equals(&change->value())); |
344 | 344 |
345 GetSyncableService(model_type)->StopSyncing(model_type); | 345 GetSyncableService(model_type)->StopSyncing(model_type); |
346 } | 346 } |
347 | 347 |
348 TEST_F(ExtensionSettingsSyncTest, LocalDataWithNoSyncDataIsPushedToSync) { | 348 TEST_F(ExtensionSettingsSyncTest, LocalDataWithNoSyncDataIsPushedToSync) { |
349 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; | 349 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; |
350 Manifest::Type type = Manifest::TYPE_EXTENSION; | 350 Manifest::Type type = Manifest::TYPE_EXTENSION; |
351 | 351 |
352 base::StringValue value1("fooValue"); | 352 base::Value value1("fooValue"); |
353 base::ListValue value2; | 353 base::ListValue value2; |
354 value2.AppendString("barValue"); | 354 value2.AppendString("barValue"); |
355 | 355 |
356 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); | 356 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); |
357 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); | 357 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); |
358 | 358 |
359 storage1->Set(DEFAULTS, "foo", value1); | 359 storage1->Set(DEFAULTS, "foo", value1); |
360 storage2->Set(DEFAULTS, "bar", value2); | 360 storage2->Set(DEFAULTS, "bar", value2); |
361 | 361 |
362 GetSyncableService(model_type) | 362 GetSyncableService(model_type) |
(...skipping 11 matching lines...) Expand all Loading... |
374 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, change->change_type()); | 374 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, change->change_type()); |
375 EXPECT_TRUE(value2.Equals(&change->value())); | 375 EXPECT_TRUE(value2.Equals(&change->value())); |
376 | 376 |
377 GetSyncableService(model_type)->StopSyncing(model_type); | 377 GetSyncableService(model_type)->StopSyncing(model_type); |
378 } | 378 } |
379 | 379 |
380 TEST_F(ExtensionSettingsSyncTest, AnySyncDataOverwritesLocalData) { | 380 TEST_F(ExtensionSettingsSyncTest, AnySyncDataOverwritesLocalData) { |
381 syncer::ModelType model_type = syncer::APP_SETTINGS; | 381 syncer::ModelType model_type = syncer::APP_SETTINGS; |
382 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; | 382 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; |
383 | 383 |
384 base::StringValue value1("fooValue"); | 384 base::Value value1("fooValue"); |
385 base::ListValue value2; | 385 base::ListValue value2; |
386 value2.AppendString("barValue"); | 386 value2.AppendString("barValue"); |
387 | 387 |
388 // Maintain dictionaries mirrored to the expected values of the settings in | 388 // Maintain dictionaries mirrored to the expected values of the settings in |
389 // each storage area. | 389 // each storage area. |
390 base::DictionaryValue expected1, expected2; | 390 base::DictionaryValue expected1, expected2; |
391 | 391 |
392 // Pre-populate one of the storage areas. | 392 // Pre-populate one of the storage areas. |
393 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); | 393 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); |
394 storage1->Set(DEFAULTS, "overwriteMe", value1); | 394 storage1->Set(DEFAULTS, "overwriteMe", value1); |
(...skipping 19 matching lines...) Expand all Loading... |
414 EXPECT_PRED_FORMAT2(SettingsEq, expected1, storage1->Get()); | 414 EXPECT_PRED_FORMAT2(SettingsEq, expected1, storage1->Get()); |
415 EXPECT_PRED_FORMAT2(SettingsEq, expected2, storage2->Get()); | 415 EXPECT_PRED_FORMAT2(SettingsEq, expected2, storage2->Get()); |
416 | 416 |
417 GetSyncableService(model_type)->StopSyncing(model_type); | 417 GetSyncableService(model_type)->StopSyncing(model_type); |
418 } | 418 } |
419 | 419 |
420 TEST_F(ExtensionSettingsSyncTest, ProcessSyncChanges) { | 420 TEST_F(ExtensionSettingsSyncTest, ProcessSyncChanges) { |
421 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; | 421 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; |
422 Manifest::Type type = Manifest::TYPE_EXTENSION; | 422 Manifest::Type type = Manifest::TYPE_EXTENSION; |
423 | 423 |
424 base::StringValue value1("fooValue"); | 424 base::Value value1("fooValue"); |
425 base::ListValue value2; | 425 base::ListValue value2; |
426 value2.AppendString("barValue"); | 426 value2.AppendString("barValue"); |
427 | 427 |
428 // Maintain dictionaries mirrored to the expected values of the settings in | 428 // Maintain dictionaries mirrored to the expected values of the settings in |
429 // each storage area. | 429 // each storage area. |
430 base::DictionaryValue expected1, expected2; | 430 base::DictionaryValue expected1, expected2; |
431 | 431 |
432 // Make storage1 initialised from local data, storage2 initialised from sync. | 432 // Make storage1 initialised from local data, storage2 initialised from sync. |
433 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); | 433 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); |
434 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); | 434 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 EXPECT_PRED_FORMAT2(SettingsEq, expected1, storage1->Get()); | 487 EXPECT_PRED_FORMAT2(SettingsEq, expected1, storage1->Get()); |
488 EXPECT_PRED_FORMAT2(SettingsEq, expected2, storage2->Get()); | 488 EXPECT_PRED_FORMAT2(SettingsEq, expected2, storage2->Get()); |
489 | 489 |
490 GetSyncableService(model_type)->StopSyncing(model_type); | 490 GetSyncableService(model_type)->StopSyncing(model_type); |
491 } | 491 } |
492 | 492 |
493 TEST_F(ExtensionSettingsSyncTest, PushToSync) { | 493 TEST_F(ExtensionSettingsSyncTest, PushToSync) { |
494 syncer::ModelType model_type = syncer::APP_SETTINGS; | 494 syncer::ModelType model_type = syncer::APP_SETTINGS; |
495 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; | 495 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; |
496 | 496 |
497 base::StringValue value1("fooValue"); | 497 base::Value value1("fooValue"); |
498 base::ListValue value2; | 498 base::ListValue value2; |
499 value2.AppendString("barValue"); | 499 value2.AppendString("barValue"); |
500 | 500 |
501 // Make storage1/2 initialised from local data, storage3/4 initialised from | 501 // Make storage1/2 initialised from local data, storage3/4 initialised from |
502 // sync. | 502 // sync. |
503 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); | 503 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); |
504 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); | 504 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); |
505 ValueStore* storage3 = AddExtensionAndGetStorage("s3", type); | 505 ValueStore* storage3 = AddExtensionAndGetStorage("s3", type); |
506 ValueStore* storage4 = AddExtensionAndGetStorage("s4", type); | 506 ValueStore* storage4 = AddExtensionAndGetStorage("s4", type); |
507 | 507 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 sync_processor_->GetOnlyChange("s3", "bar")->change_type()); | 614 sync_processor_->GetOnlyChange("s3", "bar")->change_type()); |
615 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, | 615 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, |
616 sync_processor_->GetOnlyChange("s4", "foo")->change_type()); | 616 sync_processor_->GetOnlyChange("s4", "foo")->change_type()); |
617 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, | 617 EXPECT_EQ(syncer::SyncChange::ACTION_DELETE, |
618 sync_processor_->GetOnlyChange("s4", "bar")->change_type()); | 618 sync_processor_->GetOnlyChange("s4", "bar")->change_type()); |
619 | 619 |
620 GetSyncableService(model_type)->StopSyncing(model_type); | 620 GetSyncableService(model_type)->StopSyncing(model_type); |
621 } | 621 } |
622 | 622 |
623 TEST_F(ExtensionSettingsSyncTest, ExtensionAndAppSettingsSyncSeparately) { | 623 TEST_F(ExtensionSettingsSyncTest, ExtensionAndAppSettingsSyncSeparately) { |
624 base::StringValue value1("fooValue"); | 624 base::Value value1("fooValue"); |
625 base::ListValue value2; | 625 base::ListValue value2; |
626 value2.AppendString("barValue"); | 626 value2.AppendString("barValue"); |
627 | 627 |
628 // storage1 is an extension, storage2 is an app. | 628 // storage1 is an extension, storage2 is an app. |
629 ValueStore* storage1 = AddExtensionAndGetStorage( | 629 ValueStore* storage1 = AddExtensionAndGetStorage( |
630 "s1", Manifest::TYPE_EXTENSION); | 630 "s1", Manifest::TYPE_EXTENSION); |
631 ValueStore* storage2 = AddExtensionAndGetStorage( | 631 ValueStore* storage2 = AddExtensionAndGetStorage( |
632 "s2", Manifest::TYPE_LEGACY_PACKAGED_APP); | 632 "s2", Manifest::TYPE_LEGACY_PACKAGED_APP); |
633 | 633 |
634 storage1->Set(DEFAULTS, "foo", value1); | 634 storage1->Set(DEFAULTS, "foo", value1); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 base::MakeUnique<syncer::SyncErrorFactoryMock>()); | 673 base::MakeUnique<syncer::SyncErrorFactoryMock>()); |
674 GetSyncableService(syncer::APP_SETTINGS)-> | 674 GetSyncableService(syncer::APP_SETTINGS)-> |
675 StopSyncing(syncer::APP_SETTINGS); | 675 StopSyncing(syncer::APP_SETTINGS); |
676 EXPECT_EQ(0u, sync_processor_->changes().size()); | 676 EXPECT_EQ(0u, sync_processor_->changes().size()); |
677 } | 677 } |
678 | 678 |
679 TEST_F(ExtensionSettingsSyncTest, FailingStartSyncingDisablesSync) { | 679 TEST_F(ExtensionSettingsSyncTest, FailingStartSyncingDisablesSync) { |
680 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; | 680 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; |
681 Manifest::Type type = Manifest::TYPE_EXTENSION; | 681 Manifest::Type type = Manifest::TYPE_EXTENSION; |
682 | 682 |
683 base::StringValue fooValue("fooValue"); | 683 base::Value fooValue("fooValue"); |
684 base::StringValue barValue("barValue"); | 684 base::Value barValue("barValue"); |
685 | 685 |
686 // There is a bit of a convoluted method to get storage areas that can fail; | 686 // There is a bit of a convoluted method to get storage areas that can fail; |
687 // hand out TestingValueStore object then toggle them failing/succeeding | 687 // hand out TestingValueStore object then toggle them failing/succeeding |
688 // as necessary. | 688 // as necessary. |
689 | 689 |
690 ValueStore* good = AddExtensionAndGetStorage("good", type); | 690 ValueStore* good = AddExtensionAndGetStorage("good", type); |
691 ValueStore* bad = AddExtensionAndGetStorage("bad", type); | 691 ValueStore* bad = AddExtensionAndGetStorage("bad", type); |
692 | 692 |
693 // Make bad fail for incoming sync changes. | 693 // Make bad fail for incoming sync changes. |
694 GetExisting("bad")->set_status_code(ValueStore::CORRUPTION); | 694 GetExisting("bad")->set_status_code(ValueStore::CORRUPTION); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); | 862 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); |
863 } | 863 } |
864 } | 864 } |
865 | 865 |
866 TEST_F(ExtensionSettingsSyncTest, FailingProcessChangesDisablesSync) { | 866 TEST_F(ExtensionSettingsSyncTest, FailingProcessChangesDisablesSync) { |
867 // The test above tests a failing ProcessSyncChanges too, but here test with | 867 // The test above tests a failing ProcessSyncChanges too, but here test with |
868 // an initially passing MergeDataAndStartSyncing. | 868 // an initially passing MergeDataAndStartSyncing. |
869 syncer::ModelType model_type = syncer::APP_SETTINGS; | 869 syncer::ModelType model_type = syncer::APP_SETTINGS; |
870 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; | 870 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; |
871 | 871 |
872 base::StringValue fooValue("fooValue"); | 872 base::Value fooValue("fooValue"); |
873 base::StringValue barValue("barValue"); | 873 base::Value barValue("barValue"); |
874 | 874 |
875 ValueStore* good = AddExtensionAndGetStorage("good", type); | 875 ValueStore* good = AddExtensionAndGetStorage("good", type); |
876 ValueStore* bad = AddExtensionAndGetStorage("bad", type); | 876 ValueStore* bad = AddExtensionAndGetStorage("bad", type); |
877 | 877 |
878 // Unlike before, initially succeeding MergeDataAndStartSyncing. | 878 // Unlike before, initially succeeding MergeDataAndStartSyncing. |
879 { | 879 { |
880 syncer::SyncDataList sync_data; | 880 syncer::SyncDataList sync_data; |
881 sync_data.push_back(settings_sync_util::CreateData( | 881 sync_data.push_back(settings_sync_util::CreateData( |
882 "good", "foo", fooValue, model_type)); | 882 "good", "foo", fooValue, model_type)); |
883 sync_data.push_back(settings_sync_util::CreateData( | 883 sync_data.push_back(settings_sync_util::CreateData( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 base::DictionaryValue dict; | 954 base::DictionaryValue dict; |
955 dict.Set("foo", barValue.DeepCopy()); | 955 dict.Set("foo", barValue.DeepCopy()); |
956 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); | 956 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); |
957 } | 957 } |
958 } | 958 } |
959 | 959 |
960 TEST_F(ExtensionSettingsSyncTest, FailingGetAllSyncDataDoesntStopSync) { | 960 TEST_F(ExtensionSettingsSyncTest, FailingGetAllSyncDataDoesntStopSync) { |
961 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; | 961 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; |
962 Manifest::Type type = Manifest::TYPE_EXTENSION; | 962 Manifest::Type type = Manifest::TYPE_EXTENSION; |
963 | 963 |
964 base::StringValue fooValue("fooValue"); | 964 base::Value fooValue("fooValue"); |
965 base::StringValue barValue("barValue"); | 965 base::Value barValue("barValue"); |
966 | 966 |
967 ValueStore* good = AddExtensionAndGetStorage("good", type); | 967 ValueStore* good = AddExtensionAndGetStorage("good", type); |
968 ValueStore* bad = AddExtensionAndGetStorage("bad", type); | 968 ValueStore* bad = AddExtensionAndGetStorage("bad", type); |
969 | 969 |
970 good->Set(DEFAULTS, "foo", fooValue); | 970 good->Set(DEFAULTS, "foo", fooValue); |
971 bad->Set(DEFAULTS, "foo", fooValue); | 971 bad->Set(DEFAULTS, "foo", fooValue); |
972 | 972 |
973 // Even though bad will fail to get all sync data, sync data should still | 973 // Even though bad will fail to get all sync data, sync data should still |
974 // include that from good. | 974 // include that from good. |
975 GetExisting("bad")->set_status_code(ValueStore::CORRUPTION); | 975 GetExisting("bad")->set_status_code(ValueStore::CORRUPTION); |
(...skipping 26 matching lines...) Expand all Loading... |
1002 sync_processor_->GetOnlyChange("good", "bar")->change_type()); | 1002 sync_processor_->GetOnlyChange("good", "bar")->change_type()); |
1003 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, | 1003 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, |
1004 sync_processor_->GetOnlyChange("bad", "bar")->change_type()); | 1004 sync_processor_->GetOnlyChange("bad", "bar")->change_type()); |
1005 EXPECT_EQ(2u, sync_processor_->changes().size()); | 1005 EXPECT_EQ(2u, sync_processor_->changes().size()); |
1006 } | 1006 } |
1007 | 1007 |
1008 TEST_F(ExtensionSettingsSyncTest, FailureToReadChangesToPushDisablesSync) { | 1008 TEST_F(ExtensionSettingsSyncTest, FailureToReadChangesToPushDisablesSync) { |
1009 syncer::ModelType model_type = syncer::APP_SETTINGS; | 1009 syncer::ModelType model_type = syncer::APP_SETTINGS; |
1010 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; | 1010 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; |
1011 | 1011 |
1012 base::StringValue fooValue("fooValue"); | 1012 base::Value fooValue("fooValue"); |
1013 base::StringValue barValue("barValue"); | 1013 base::Value barValue("barValue"); |
1014 | 1014 |
1015 ValueStore* good = AddExtensionAndGetStorage("good", type); | 1015 ValueStore* good = AddExtensionAndGetStorage("good", type); |
1016 ValueStore* bad = AddExtensionAndGetStorage("bad", type); | 1016 ValueStore* bad = AddExtensionAndGetStorage("bad", type); |
1017 | 1017 |
1018 good->Set(DEFAULTS, "foo", fooValue); | 1018 good->Set(DEFAULTS, "foo", fooValue); |
1019 bad->Set(DEFAULTS, "foo", fooValue); | 1019 bad->Set(DEFAULTS, "foo", fooValue); |
1020 | 1020 |
1021 // good will successfully push foo:fooValue to sync, but bad will fail to | 1021 // good will successfully push foo:fooValue to sync, but bad will fail to |
1022 // get them so won't. | 1022 // get them so won't. |
1023 GetExisting("bad")->set_status_code(ValueStore::CORRUPTION); | 1023 GetExisting("bad")->set_status_code(ValueStore::CORRUPTION); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 sync_processor_->GetOnlyChange("good", "bar")->change_type()); | 1095 sync_processor_->GetOnlyChange("good", "bar")->change_type()); |
1096 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, | 1096 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, |
1097 sync_processor_->GetOnlyChange("good", "bar")->change_type()); | 1097 sync_processor_->GetOnlyChange("good", "bar")->change_type()); |
1098 EXPECT_EQ(2u, sync_processor_->changes().size()); | 1098 EXPECT_EQ(2u, sync_processor_->changes().size()); |
1099 } | 1099 } |
1100 | 1100 |
1101 TEST_F(ExtensionSettingsSyncTest, FailureToPushLocalStateDisablesSync) { | 1101 TEST_F(ExtensionSettingsSyncTest, FailureToPushLocalStateDisablesSync) { |
1102 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; | 1102 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; |
1103 Manifest::Type type = Manifest::TYPE_EXTENSION; | 1103 Manifest::Type type = Manifest::TYPE_EXTENSION; |
1104 | 1104 |
1105 base::StringValue fooValue("fooValue"); | 1105 base::Value fooValue("fooValue"); |
1106 base::StringValue barValue("barValue"); | 1106 base::Value barValue("barValue"); |
1107 | 1107 |
1108 ValueStore* good = AddExtensionAndGetStorage("good", type); | 1108 ValueStore* good = AddExtensionAndGetStorage("good", type); |
1109 ValueStore* bad = AddExtensionAndGetStorage("bad", type); | 1109 ValueStore* bad = AddExtensionAndGetStorage("bad", type); |
1110 | 1110 |
1111 // Only set bad; setting good will cause it to fail below. | 1111 // Only set bad; setting good will cause it to fail below. |
1112 bad->Set(DEFAULTS, "foo", fooValue); | 1112 bad->Set(DEFAULTS, "foo", fooValue); |
1113 | 1113 |
1114 sync_processor_->set_fail_all_requests(true); | 1114 sync_processor_->set_fail_all_requests(true); |
1115 GetSyncableService(model_type) | 1115 GetSyncableService(model_type) |
1116 ->MergeDataAndStartSyncing( | 1116 ->MergeDataAndStartSyncing( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 sync_processor_->GetOnlyChange("good", "foo")->change_type()); | 1177 sync_processor_->GetOnlyChange("good", "foo")->change_type()); |
1178 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, | 1178 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, |
1179 sync_processor_->GetOnlyChange("good", "foo")->change_type()); | 1179 sync_processor_->GetOnlyChange("good", "foo")->change_type()); |
1180 EXPECT_EQ(2u, sync_processor_->changes().size()); | 1180 EXPECT_EQ(2u, sync_processor_->changes().size()); |
1181 } | 1181 } |
1182 | 1182 |
1183 TEST_F(ExtensionSettingsSyncTest, FailureToPushLocalChangeDisablesSync) { | 1183 TEST_F(ExtensionSettingsSyncTest, FailureToPushLocalChangeDisablesSync) { |
1184 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; | 1184 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; |
1185 Manifest::Type type = Manifest::TYPE_EXTENSION; | 1185 Manifest::Type type = Manifest::TYPE_EXTENSION; |
1186 | 1186 |
1187 base::StringValue fooValue("fooValue"); | 1187 base::Value fooValue("fooValue"); |
1188 base::StringValue barValue("barValue"); | 1188 base::Value barValue("barValue"); |
1189 | 1189 |
1190 ValueStore* good = AddExtensionAndGetStorage("good", type); | 1190 ValueStore* good = AddExtensionAndGetStorage("good", type); |
1191 ValueStore* bad = AddExtensionAndGetStorage("bad", type); | 1191 ValueStore* bad = AddExtensionAndGetStorage("bad", type); |
1192 | 1192 |
1193 GetSyncableService(model_type) | 1193 GetSyncableService(model_type) |
1194 ->MergeDataAndStartSyncing( | 1194 ->MergeDataAndStartSyncing( |
1195 model_type, syncer::SyncDataList(), | 1195 model_type, syncer::SyncDataList(), |
1196 std::move(sync_processor_wrapper_), | 1196 std::move(sync_processor_wrapper_), |
1197 base::MakeUnique<syncer::SyncErrorFactoryMock>()); | 1197 base::MakeUnique<syncer::SyncErrorFactoryMock>()); |
1198 | 1198 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 TEST_F(ExtensionSettingsSyncTest, | 1270 TEST_F(ExtensionSettingsSyncTest, |
1271 LargeOutgoingChangeRejectedButIncomingAccepted) { | 1271 LargeOutgoingChangeRejectedButIncomingAccepted) { |
1272 syncer::ModelType model_type = syncer::APP_SETTINGS; | 1272 syncer::ModelType model_type = syncer::APP_SETTINGS; |
1273 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; | 1273 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP; |
1274 | 1274 |
1275 // This value should be larger than the limit in sync_storage_backend.cc. | 1275 // This value should be larger than the limit in sync_storage_backend.cc. |
1276 std::string string_10k; | 1276 std::string string_10k; |
1277 for (size_t i = 0; i < 10000; ++i) { | 1277 for (size_t i = 0; i < 10000; ++i) { |
1278 string_10k.append("a"); | 1278 string_10k.append("a"); |
1279 } | 1279 } |
1280 base::StringValue large_value(string_10k); | 1280 base::Value large_value(string_10k); |
1281 | 1281 |
1282 GetSyncableService(model_type) | 1282 GetSyncableService(model_type) |
1283 ->MergeDataAndStartSyncing( | 1283 ->MergeDataAndStartSyncing( |
1284 model_type, syncer::SyncDataList(), | 1284 model_type, syncer::SyncDataList(), |
1285 std::move(sync_processor_wrapper_), | 1285 std::move(sync_processor_wrapper_), |
1286 base::MakeUnique<syncer::SyncErrorFactoryMock>()); | 1286 base::MakeUnique<syncer::SyncErrorFactoryMock>()); |
1287 | 1287 |
1288 // Large local change rejected and doesn't get sent out. | 1288 // Large local change rejected and doesn't get sent out. |
1289 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); | 1289 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); |
1290 EXPECT_FALSE( | 1290 EXPECT_FALSE( |
(...skipping 21 matching lines...) Expand all Loading... |
1312 } | 1312 } |
1313 | 1313 |
1314 TEST_F(ExtensionSettingsSyncTest, Dots) { | 1314 TEST_F(ExtensionSettingsSyncTest, Dots) { |
1315 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; | 1315 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; |
1316 Manifest::Type type = Manifest::TYPE_EXTENSION; | 1316 Manifest::Type type = Manifest::TYPE_EXTENSION; |
1317 | 1317 |
1318 ValueStore* storage = AddExtensionAndGetStorage("ext", type); | 1318 ValueStore* storage = AddExtensionAndGetStorage("ext", type); |
1319 | 1319 |
1320 { | 1320 { |
1321 syncer::SyncDataList sync_data_list; | 1321 syncer::SyncDataList sync_data_list; |
1322 std::unique_ptr<base::Value> string_value(new base::StringValue("value")); | 1322 std::unique_ptr<base::Value> string_value(new base::Value("value")); |
1323 sync_data_list.push_back(settings_sync_util::CreateData( | 1323 sync_data_list.push_back(settings_sync_util::CreateData( |
1324 "ext", "key.with.dot", *string_value, model_type)); | 1324 "ext", "key.with.dot", *string_value, model_type)); |
1325 | 1325 |
1326 GetSyncableService(model_type) | 1326 GetSyncableService(model_type) |
1327 ->MergeDataAndStartSyncing( | 1327 ->MergeDataAndStartSyncing( |
1328 model_type, sync_data_list, std::move(sync_processor_wrapper_), | 1328 model_type, sync_data_list, std::move(sync_processor_wrapper_), |
1329 base::MakeUnique<syncer::SyncErrorFactoryMock>()); | 1329 base::MakeUnique<syncer::SyncErrorFactoryMock>()); |
1330 } | 1330 } |
1331 | 1331 |
1332 // Test dots in keys that come from sync. | 1332 // Test dots in keys that come from sync. |
1333 { | 1333 { |
1334 ValueStore::ReadResult data = storage->Get(); | 1334 ValueStore::ReadResult data = storage->Get(); |
1335 ASSERT_TRUE(data->status().ok()); | 1335 ASSERT_TRUE(data->status().ok()); |
1336 | 1336 |
1337 base::DictionaryValue expected_data; | 1337 base::DictionaryValue expected_data; |
1338 expected_data.SetWithoutPathExpansion( | 1338 expected_data.SetWithoutPathExpansion("key.with.dot", |
1339 "key.with.dot", | 1339 new base::Value("value")); |
1340 new base::StringValue("value")); | |
1341 EXPECT_TRUE(base::Value::Equals(&expected_data, &data->settings())); | 1340 EXPECT_TRUE(base::Value::Equals(&expected_data, &data->settings())); |
1342 } | 1341 } |
1343 | 1342 |
1344 // Test dots in keys going to sync. | 1343 // Test dots in keys going to sync. |
1345 { | 1344 { |
1346 std::unique_ptr<base::Value> string_value(new base::StringValue("spot")); | 1345 std::unique_ptr<base::Value> string_value(new base::Value("spot")); |
1347 storage->Set(DEFAULTS, "key.with.spot", *string_value); | 1346 storage->Set(DEFAULTS, "key.with.spot", *string_value); |
1348 | 1347 |
1349 ASSERT_EQ(1u, sync_processor_->changes().size()); | 1348 ASSERT_EQ(1u, sync_processor_->changes().size()); |
1350 SettingSyncData* sync_data = sync_processor_->changes()[0].get(); | 1349 SettingSyncData* sync_data = sync_processor_->changes()[0].get(); |
1351 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data->change_type()); | 1350 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data->change_type()); |
1352 EXPECT_EQ("ext", sync_data->extension_id()); | 1351 EXPECT_EQ("ext", sync_data->extension_id()); |
1353 EXPECT_EQ("key.with.spot", sync_data->key()); | 1352 EXPECT_EQ("key.with.spot", sync_data->key()); |
1354 EXPECT_TRUE(sync_data->value().Equals(string_value.get())); | 1353 EXPECT_TRUE(sync_data->value().Equals(string_value.get())); |
1355 } | 1354 } |
1356 } | 1355 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 settings_namespace::SYNC, | 1407 settings_namespace::SYNC, |
1409 base::Bind(&UnlimitedSyncStorageTestCallback)); | 1408 base::Bind(&UnlimitedSyncStorageTestCallback)); |
1410 frontend_->RunWithStorage(extension, | 1409 frontend_->RunWithStorage(extension, |
1411 settings_namespace::LOCAL, | 1410 settings_namespace::LOCAL, |
1412 base::Bind(&UnlimitedLocalStorageTestCallback)); | 1411 base::Bind(&UnlimitedLocalStorageTestCallback)); |
1413 | 1412 |
1414 base::RunLoop().RunUntilIdle(); | 1413 base::RunLoop().RunUntilIdle(); |
1415 } | 1414 } |
1416 | 1415 |
1417 } // namespace extensions | 1416 } // namespace extensions |
OLD | NEW |