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

Side by Side Diff: chrome/browser/extensions/settings/settings_sync_unittest.cc

Issue 10909239: Rename PACKAGED_APP references to LEGACY_PACKAGED_APP (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments Created 8 years, 2 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 EXPECT_EQ(0u, GetAllSyncData(model_type).size()); 293 EXPECT_EQ(0u, GetAllSyncData(model_type).size());
294 294
295 GetSyncableService(model_type)->StopSyncing(model_type); 295 GetSyncableService(model_type)->StopSyncing(model_type);
296 296
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 Extension::Type type = Extension::TYPE_PACKAGED_APP; 303 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP;
304 304
305 StringValue value1("fooValue"); 305 StringValue value1("fooValue");
306 ListValue value2; 306 ListValue value2;
307 value2.Append(StringValue::CreateStringValue("barValue")); 307 value2.Append(StringValue::CreateStringValue("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);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 EXPECT_TRUE(value1.Equals(&change.value())); 375 EXPECT_TRUE(value1.Equals(&change.value()));
376 change = sync_processor_->GetOnlyChange("s2", "bar"); 376 change = sync_processor_->GetOnlyChange("s2", "bar");
377 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, change.change_type()); 377 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, change.change_type());
378 EXPECT_TRUE(value2.Equals(&change.value())); 378 EXPECT_TRUE(value2.Equals(&change.value()));
379 379
380 GetSyncableService(model_type)->StopSyncing(model_type); 380 GetSyncableService(model_type)->StopSyncing(model_type);
381 } 381 }
382 382
383 TEST_F(ExtensionSettingsSyncTest, AnySyncDataOverwritesLocalData) { 383 TEST_F(ExtensionSettingsSyncTest, AnySyncDataOverwritesLocalData) {
384 syncer::ModelType model_type = syncer::APP_SETTINGS; 384 syncer::ModelType model_type = syncer::APP_SETTINGS;
385 Extension::Type type = Extension::TYPE_PACKAGED_APP; 385 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP;
386 386
387 StringValue value1("fooValue"); 387 StringValue value1("fooValue");
388 ListValue value2; 388 ListValue value2;
389 value2.Append(StringValue::CreateStringValue("barValue")); 389 value2.Append(StringValue::CreateStringValue("barValue"));
390 390
391 // Maintain dictionaries mirrored to the expected values of the settings in 391 // Maintain dictionaries mirrored to the expected values of the settings in
392 // each storage area. 392 // each storage area.
393 DictionaryValue expected1, expected2; 393 DictionaryValue expected1, expected2;
394 394
395 // Pre-populate one of the storage areas. 395 // Pre-populate one of the storage areas.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 expected2.Remove("foo", NULL); 488 expected2.Remove("foo", NULL);
489 489
490 EXPECT_PRED_FORMAT2(SettingsEq, expected1, storage1->Get()); 490 EXPECT_PRED_FORMAT2(SettingsEq, expected1, storage1->Get());
491 EXPECT_PRED_FORMAT2(SettingsEq, expected2, storage2->Get()); 491 EXPECT_PRED_FORMAT2(SettingsEq, expected2, storage2->Get());
492 492
493 GetSyncableService(model_type)->StopSyncing(model_type); 493 GetSyncableService(model_type)->StopSyncing(model_type);
494 } 494 }
495 495
496 TEST_F(ExtensionSettingsSyncTest, PushToSync) { 496 TEST_F(ExtensionSettingsSyncTest, PushToSync) {
497 syncer::ModelType model_type = syncer::APP_SETTINGS; 497 syncer::ModelType model_type = syncer::APP_SETTINGS;
498 Extension::Type type = Extension::TYPE_PACKAGED_APP; 498 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP;
499 499
500 StringValue value1("fooValue"); 500 StringValue value1("fooValue");
501 ListValue value2; 501 ListValue value2;
502 value2.Append(StringValue::CreateStringValue("barValue")); 502 value2.Append(StringValue::CreateStringValue("barValue"));
503 503
504 // Make storage1/2 initialised from local data, storage3/4 initialised from 504 // Make storage1/2 initialised from local data, storage3/4 initialised from
505 // sync. 505 // sync.
506 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); 506 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type);
507 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); 507 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type);
508 ValueStore* storage3 = AddExtensionAndGetStorage("s3", type); 508 ValueStore* storage3 = AddExtensionAndGetStorage("s3", type);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 637
638 TEST_F(ExtensionSettingsSyncTest, ExtensionAndAppSettingsSyncSeparately) { 638 TEST_F(ExtensionSettingsSyncTest, ExtensionAndAppSettingsSyncSeparately) {
639 StringValue value1("fooValue"); 639 StringValue value1("fooValue");
640 ListValue value2; 640 ListValue value2;
641 value2.Append(StringValue::CreateStringValue("barValue")); 641 value2.Append(StringValue::CreateStringValue("barValue"));
642 642
643 // storage1 is an extension, storage2 is an app. 643 // storage1 is an extension, storage2 is an app.
644 ValueStore* storage1 = AddExtensionAndGetStorage( 644 ValueStore* storage1 = AddExtensionAndGetStorage(
645 "s1", Extension::TYPE_EXTENSION); 645 "s1", Extension::TYPE_EXTENSION);
646 ValueStore* storage2 = AddExtensionAndGetStorage( 646 ValueStore* storage2 = AddExtensionAndGetStorage(
647 "s2", Extension::TYPE_PACKAGED_APP); 647 "s2", Extension::TYPE_LEGACY_PACKAGED_APP);
648 648
649 storage1->Set(DEFAULTS, "foo", value1); 649 storage1->Set(DEFAULTS, "foo", value1);
650 storage2->Set(DEFAULTS, "bar", value2); 650 storage2->Set(DEFAULTS, "bar", value2);
651 651
652 std::map<std::string, SettingSyncDataList> extension_sync_data = 652 std::map<std::string, SettingSyncDataList> extension_sync_data =
653 GetAllSyncData(syncer::EXTENSION_SETTINGS); 653 GetAllSyncData(syncer::EXTENSION_SETTINGS);
654 EXPECT_EQ(1u, extension_sync_data.size()); 654 EXPECT_EQ(1u, extension_sync_data.size());
655 EXPECT_EQ(1u, extension_sync_data["s1"].size()); 655 EXPECT_EQ(1u, extension_sync_data["s1"].size());
656 EXPECT_PRED_FORMAT2(ValuesEq, &value1, &extension_sync_data["s1"][0].value()); 656 EXPECT_PRED_FORMAT2(ValuesEq, &value1, &extension_sync_data["s1"][0].value());
657 657
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 DictionaryValue dict; 886 DictionaryValue dict;
887 dict.Set("bar", fooValue.DeepCopy()); 887 dict.Set("bar", fooValue.DeepCopy());
888 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); 888 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get());
889 } 889 }
890 } 890 }
891 891
892 TEST_F(ExtensionSettingsSyncTest, FailingProcessChangesDisablesSync) { 892 TEST_F(ExtensionSettingsSyncTest, FailingProcessChangesDisablesSync) {
893 // The test above tests a failing ProcessSyncChanges too, but here test with 893 // The test above tests a failing ProcessSyncChanges too, but here test with
894 // an initially passing MergeDataAndStartSyncing. 894 // an initially passing MergeDataAndStartSyncing.
895 syncer::ModelType model_type = syncer::APP_SETTINGS; 895 syncer::ModelType model_type = syncer::APP_SETTINGS;
896 Extension::Type type = Extension::TYPE_PACKAGED_APP; 896 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP;
897 897
898 StringValue fooValue("fooValue"); 898 StringValue fooValue("fooValue");
899 StringValue barValue("barValue"); 899 StringValue barValue("barValue");
900 900
901 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); 901 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory();
902 storage_factory_->Reset(testing_factory); 902 storage_factory_->Reset(testing_factory);
903 903
904 ValueStore* good = AddExtensionAndGetStorage("good", type); 904 ValueStore* good = AddExtensionAndGetStorage("good", type);
905 ValueStore* bad = AddExtensionAndGetStorage("bad", type); 905 ValueStore* bad = AddExtensionAndGetStorage("bad", type);
906 906
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 syncer::SyncChange::ACTION_ADD, 1039 syncer::SyncChange::ACTION_ADD,
1040 sync_processor_->GetOnlyChange("good", "bar").change_type()); 1040 sync_processor_->GetOnlyChange("good", "bar").change_type());
1041 EXPECT_EQ( 1041 EXPECT_EQ(
1042 syncer::SyncChange::ACTION_ADD, 1042 syncer::SyncChange::ACTION_ADD,
1043 sync_processor_->GetOnlyChange("bad", "bar").change_type()); 1043 sync_processor_->GetOnlyChange("bad", "bar").change_type());
1044 EXPECT_EQ(2u, sync_processor_->changes().size()); 1044 EXPECT_EQ(2u, sync_processor_->changes().size());
1045 } 1045 }
1046 1046
1047 TEST_F(ExtensionSettingsSyncTest, FailureToReadChangesToPushDisablesSync) { 1047 TEST_F(ExtensionSettingsSyncTest, FailureToReadChangesToPushDisablesSync) {
1048 syncer::ModelType model_type = syncer::APP_SETTINGS; 1048 syncer::ModelType model_type = syncer::APP_SETTINGS;
1049 Extension::Type type = Extension::TYPE_PACKAGED_APP; 1049 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP;
1050 1050
1051 StringValue fooValue("fooValue"); 1051 StringValue fooValue("fooValue");
1052 StringValue barValue("barValue"); 1052 StringValue barValue("barValue");
1053 1053
1054 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); 1054 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory();
1055 storage_factory_->Reset(testing_factory); 1055 storage_factory_->Reset(testing_factory);
1056 1056
1057 ValueStore* good = AddExtensionAndGetStorage("good", type); 1057 ValueStore* good = AddExtensionAndGetStorage("good", type);
1058 ValueStore* bad = AddExtensionAndGetStorage("bad", type); 1058 ValueStore* bad = AddExtensionAndGetStorage("bad", type);
1059 1059
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 sync_processor_->GetOnlyChange("good", "foo").change_type()); 1332 sync_processor_->GetOnlyChange("good", "foo").change_type());
1333 EXPECT_EQ( 1333 EXPECT_EQ(
1334 syncer::SyncChange::ACTION_UPDATE, 1334 syncer::SyncChange::ACTION_UPDATE,
1335 sync_processor_->GetOnlyChange("good", "foo").change_type()); 1335 sync_processor_->GetOnlyChange("good", "foo").change_type());
1336 EXPECT_EQ(2u, sync_processor_->changes().size()); 1336 EXPECT_EQ(2u, sync_processor_->changes().size());
1337 } 1337 }
1338 1338
1339 TEST_F(ExtensionSettingsSyncTest, 1339 TEST_F(ExtensionSettingsSyncTest,
1340 LargeOutgoingChangeRejectedButIncomingAccepted) { 1340 LargeOutgoingChangeRejectedButIncomingAccepted) {
1341 syncer::ModelType model_type = syncer::APP_SETTINGS; 1341 syncer::ModelType model_type = syncer::APP_SETTINGS;
1342 Extension::Type type = Extension::TYPE_PACKAGED_APP; 1342 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP;
1343 1343
1344 // This value should be larger than the limit in settings_backend.cc. 1344 // This value should be larger than the limit in settings_backend.cc.
1345 std::string string_5k; 1345 std::string string_5k;
1346 for (size_t i = 0; i < 5000; ++i) { 1346 for (size_t i = 0; i < 5000; ++i) {
1347 string_5k.append("a"); 1347 string_5k.append("a");
1348 } 1348 }
1349 StringValue large_value(string_5k); 1349 StringValue large_value(string_5k);
1350 1350
1351 GetSyncableService(model_type)->MergeDataAndStartSyncing( 1351 GetSyncableService(model_type)->MergeDataAndStartSyncing(
1352 model_type, 1352 model_type,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 ASSERT_EQ(1u, sync_processor_->changes().size()); 1419 ASSERT_EQ(1u, sync_processor_->changes().size());
1420 SettingSyncData sync_data = sync_processor_->changes()[0]; 1420 SettingSyncData sync_data = sync_processor_->changes()[0];
1421 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type()); 1421 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type());
1422 EXPECT_EQ("ext", sync_data.extension_id()); 1422 EXPECT_EQ("ext", sync_data.extension_id());
1423 EXPECT_EQ("key.with.spot", sync_data.key()); 1423 EXPECT_EQ("key.with.spot", sync_data.key());
1424 EXPECT_TRUE(sync_data.value().Equals(string_value.get())); 1424 EXPECT_TRUE(sync_data.value().Equals(string_value.get()));
1425 } 1425 }
1426 } 1426 }
1427 1427
1428 } // namespace extensions 1428 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698