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

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

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory .h" 11 #include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory .h"
12 #include "chrome/browser/extensions/api/storage/settings_frontend.h" 12 #include "chrome/browser/extensions/api/storage/settings_frontend.h"
13 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h" 13 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h"
14 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" 14 #include "chrome/browser/extensions/api/storage/settings_sync_util.h"
15 #include "chrome/browser/extensions/api/storage/settings_test_util.h" 15 #include "chrome/browser/extensions/api/storage/settings_test_util.h"
16 #include "chrome/browser/extensions/api/storage/syncable_settings_storage.h" 16 #include "chrome/browser/extensions/api/storage/syncable_settings_storage.h"
17 #include "chrome/browser/extensions/extension_system.h" 17 #include "chrome/browser/extensions/extension_system.h"
18 #include "chrome/browser/extensions/test_extension_service.h" 18 #include "chrome/browser/extensions/test_extension_service.h"
19 #include "chrome/browser/value_store/testing_value_store.h" 19 #include "chrome/browser/value_store/testing_value_store.h"
20 #include "chrome/common/extensions/manifest.h"
20 #include "content/public/test/test_browser_thread.h" 21 #include "content/public/test/test_browser_thread.h"
21 #include "sync/api/sync_change_processor.h" 22 #include "sync/api/sync_change_processor.h"
22 #include "sync/api/sync_error_factory.h" 23 #include "sync/api/sync_error_factory.h"
23 #include "sync/api/sync_error_factory_mock.h" 24 #include "sync/api/sync_error_factory_mock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
26 using content::BrowserThread; 27 using content::BrowserThread;
27 28
28 namespace extensions { 29 namespace extensions {
29 30
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 frontend_.reset(); 219 frontend_.reset();
219 profile_.reset(); 220 profile_.reset();
220 // Execute any pending deletion tasks. 221 // Execute any pending deletion tasks.
221 message_loop_.RunUntilIdle(); 222 message_loop_.RunUntilIdle();
222 } 223 }
223 224
224 protected: 225 protected:
225 // Adds a record of an extension or app to the extension service, then returns 226 // Adds a record of an extension or app to the extension service, then returns
226 // its storage area. 227 // its storage area.
227 ValueStore* AddExtensionAndGetStorage( 228 ValueStore* AddExtensionAndGetStorage(
228 const std::string& id, Extension::Type type) { 229 const std::string& id, Manifest::Type type) {
229 ExtensionServiceInterface* esi = 230 ExtensionServiceInterface* esi =
230 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); 231 extensions::ExtensionSystem::Get(profile_.get())->extension_service();
231 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> 232 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)->
232 AddExtensionWithId(id, type); 233 AddExtensionWithId(id, type);
233 return util::GetStorage(id, frontend_.get()); 234 return util::GetStorage(id, frontend_.get());
234 } 235 }
235 236
236 // Gets the syncer::SyncableService for the given sync type. 237 // Gets the syncer::SyncableService for the given sync type.
237 syncer::SyncableService* GetSyncableService(syncer::ModelType model_type) { 238 syncer::SyncableService* GetSyncableService(syncer::ModelType model_type) {
238 MessageLoop::current()->RunUntilIdle(); 239 MessageLoop::current()->RunUntilIdle();
(...skipping 26 matching lines...) Expand all
265 scoped_refptr<util::ScopedSettingsStorageFactory> storage_factory_; 266 scoped_refptr<util::ScopedSettingsStorageFactory> storage_factory_;
266 scoped_ptr<MockSyncChangeProcessor> sync_processor_; 267 scoped_ptr<MockSyncChangeProcessor> sync_processor_;
267 scoped_ptr<SyncChangeProcessorDelegate> sync_processor_delegate_; 268 scoped_ptr<SyncChangeProcessorDelegate> sync_processor_delegate_;
268 }; 269 };
269 270
270 // Get a semblance of coverage for both EXTENSION_SETTINGS and APP_SETTINGS 271 // Get a semblance of coverage for both EXTENSION_SETTINGS and APP_SETTINGS
271 // sync by roughly alternative which one to test. 272 // sync by roughly alternative which one to test.
272 273
273 TEST_F(ExtensionSettingsSyncTest, NoDataDoesNotInvokeSync) { 274 TEST_F(ExtensionSettingsSyncTest, NoDataDoesNotInvokeSync) {
274 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; 275 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS;
275 Extension::Type type = Extension::TYPE_EXTENSION; 276 Manifest::Type type = Manifest::TYPE_EXTENSION;
276 277
277 EXPECT_EQ(0u, GetAllSyncData(model_type).size()); 278 EXPECT_EQ(0u, GetAllSyncData(model_type).size());
278 279
279 // Have one extension created before sync is set up, the other created after. 280 // Have one extension created before sync is set up, the other created after.
280 AddExtensionAndGetStorage("s1", type); 281 AddExtensionAndGetStorage("s1", type);
281 EXPECT_EQ(0u, GetAllSyncData(model_type).size()); 282 EXPECT_EQ(0u, GetAllSyncData(model_type).size());
282 283
283 GetSyncableService(model_type)->MergeDataAndStartSyncing( 284 GetSyncableService(model_type)->MergeDataAndStartSyncing(
284 model_type, 285 model_type,
285 syncer::SyncDataList(), 286 syncer::SyncDataList(),
286 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(), 287 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(),
287 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); 288 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
288 289
289 AddExtensionAndGetStorage("s2", type); 290 AddExtensionAndGetStorage("s2", type);
290 EXPECT_EQ(0u, GetAllSyncData(model_type).size()); 291 EXPECT_EQ(0u, GetAllSyncData(model_type).size());
291 292
292 GetSyncableService(model_type)->StopSyncing(model_type); 293 GetSyncableService(model_type)->StopSyncing(model_type);
293 294
294 EXPECT_EQ(0u, sync_processor_->changes().size()); 295 EXPECT_EQ(0u, sync_processor_->changes().size());
295 EXPECT_EQ(0u, GetAllSyncData(model_type).size()); 296 EXPECT_EQ(0u, GetAllSyncData(model_type).size());
296 } 297 }
297 298
298 TEST_F(ExtensionSettingsSyncTest, InSyncDataDoesNotInvokeSync) { 299 TEST_F(ExtensionSettingsSyncTest, InSyncDataDoesNotInvokeSync) {
299 syncer::ModelType model_type = syncer::APP_SETTINGS; 300 syncer::ModelType model_type = syncer::APP_SETTINGS;
300 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP; 301 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP;
301 302
302 StringValue value1("fooValue"); 303 StringValue value1("fooValue");
303 ListValue value2; 304 ListValue value2;
304 value2.Append(StringValue::CreateStringValue("barValue")); 305 value2.Append(StringValue::CreateStringValue("barValue"));
305 306
306 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); 307 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type);
307 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); 308 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type);
308 309
309 storage1->Set(DEFAULTS, "foo", value1); 310 storage1->Set(DEFAULTS, "foo", value1);
310 storage2->Set(DEFAULTS, "bar", value2); 311 storage2->Set(DEFAULTS, "bar", value2);
(...skipping 29 matching lines...) Expand all
340 EXPECT_EQ(1u, sync_processor_->changes().size()); 341 EXPECT_EQ(1u, sync_processor_->changes().size());
341 SettingSyncData change = sync_processor_->GetOnlyChange("s1", "foo"); 342 SettingSyncData change = sync_processor_->GetOnlyChange("s1", "foo");
342 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, change.change_type()); 343 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, change.change_type());
343 EXPECT_TRUE(value2.Equals(&change.value())); 344 EXPECT_TRUE(value2.Equals(&change.value()));
344 345
345 GetSyncableService(model_type)->StopSyncing(model_type); 346 GetSyncableService(model_type)->StopSyncing(model_type);
346 } 347 }
347 348
348 TEST_F(ExtensionSettingsSyncTest, LocalDataWithNoSyncDataIsPushedToSync) { 349 TEST_F(ExtensionSettingsSyncTest, LocalDataWithNoSyncDataIsPushedToSync) {
349 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; 350 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS;
350 Extension::Type type = Extension::TYPE_EXTENSION; 351 Manifest::Type type = Manifest::TYPE_EXTENSION;
351 352
352 StringValue value1("fooValue"); 353 StringValue value1("fooValue");
353 ListValue value2; 354 ListValue value2;
354 value2.Append(StringValue::CreateStringValue("barValue")); 355 value2.Append(StringValue::CreateStringValue("barValue"));
355 356
356 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); 357 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type);
357 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); 358 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type);
358 359
359 storage1->Set(DEFAULTS, "foo", value1); 360 storage1->Set(DEFAULTS, "foo", value1);
360 storage2->Set(DEFAULTS, "bar", value2); 361 storage2->Set(DEFAULTS, "bar", value2);
(...skipping 11 matching lines...) Expand all
372 EXPECT_TRUE(value1.Equals(&change.value())); 373 EXPECT_TRUE(value1.Equals(&change.value()));
373 change = sync_processor_->GetOnlyChange("s2", "bar"); 374 change = sync_processor_->GetOnlyChange("s2", "bar");
374 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, change.change_type()); 375 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, change.change_type());
375 EXPECT_TRUE(value2.Equals(&change.value())); 376 EXPECT_TRUE(value2.Equals(&change.value()));
376 377
377 GetSyncableService(model_type)->StopSyncing(model_type); 378 GetSyncableService(model_type)->StopSyncing(model_type);
378 } 379 }
379 380
380 TEST_F(ExtensionSettingsSyncTest, AnySyncDataOverwritesLocalData) { 381 TEST_F(ExtensionSettingsSyncTest, AnySyncDataOverwritesLocalData) {
381 syncer::ModelType model_type = syncer::APP_SETTINGS; 382 syncer::ModelType model_type = syncer::APP_SETTINGS;
382 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP; 383 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP;
383 384
384 StringValue value1("fooValue"); 385 StringValue value1("fooValue");
385 ListValue value2; 386 ListValue value2;
386 value2.Append(StringValue::CreateStringValue("barValue")); 387 value2.Append(StringValue::CreateStringValue("barValue"));
387 388
388 // Maintain dictionaries mirrored to the expected values of the settings in 389 // Maintain dictionaries mirrored to the expected values of the settings in
389 // each storage area. 390 // each storage area.
390 DictionaryValue expected1, expected2; 391 DictionaryValue expected1, expected2;
391 392
392 // Pre-populate one of the storage areas. 393 // Pre-populate one of the storage areas.
(...skipping 19 matching lines...) Expand all
412 413
413 // Sync settings should have been pushed to local settings. 414 // Sync settings should have been pushed to local settings.
414 EXPECT_PRED_FORMAT2(SettingsEq, expected1, storage1->Get()); 415 EXPECT_PRED_FORMAT2(SettingsEq, expected1, storage1->Get());
415 EXPECT_PRED_FORMAT2(SettingsEq, expected2, storage2->Get()); 416 EXPECT_PRED_FORMAT2(SettingsEq, expected2, storage2->Get());
416 417
417 GetSyncableService(model_type)->StopSyncing(model_type); 418 GetSyncableService(model_type)->StopSyncing(model_type);
418 } 419 }
419 420
420 TEST_F(ExtensionSettingsSyncTest, ProcessSyncChanges) { 421 TEST_F(ExtensionSettingsSyncTest, ProcessSyncChanges) {
421 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; 422 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS;
422 Extension::Type type = Extension::TYPE_EXTENSION; 423 Manifest::Type type = Manifest::TYPE_EXTENSION;
423 424
424 StringValue value1("fooValue"); 425 StringValue value1("fooValue");
425 ListValue value2; 426 ListValue value2;
426 value2.Append(StringValue::CreateStringValue("barValue")); 427 value2.Append(StringValue::CreateStringValue("barValue"));
427 428
428 // Maintain dictionaries mirrored to the expected values of the settings in 429 // Maintain dictionaries mirrored to the expected values of the settings in
429 // each storage area. 430 // each storage area.
430 DictionaryValue expected1, expected2; 431 DictionaryValue expected1, expected2;
431 432
432 // Make storage1 initialised from local data, storage2 initialised from sync. 433 // Make storage1 initialised from local data, storage2 initialised from sync.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 expected2.Remove("foo", NULL); 486 expected2.Remove("foo", NULL);
486 487
487 EXPECT_PRED_FORMAT2(SettingsEq, expected1, storage1->Get()); 488 EXPECT_PRED_FORMAT2(SettingsEq, expected1, storage1->Get());
488 EXPECT_PRED_FORMAT2(SettingsEq, expected2, storage2->Get()); 489 EXPECT_PRED_FORMAT2(SettingsEq, expected2, storage2->Get());
489 490
490 GetSyncableService(model_type)->StopSyncing(model_type); 491 GetSyncableService(model_type)->StopSyncing(model_type);
491 } 492 }
492 493
493 TEST_F(ExtensionSettingsSyncTest, PushToSync) { 494 TEST_F(ExtensionSettingsSyncTest, PushToSync) {
494 syncer::ModelType model_type = syncer::APP_SETTINGS; 495 syncer::ModelType model_type = syncer::APP_SETTINGS;
495 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP; 496 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP;
496 497
497 StringValue value1("fooValue"); 498 StringValue value1("fooValue");
498 ListValue value2; 499 ListValue value2;
499 value2.Append(StringValue::CreateStringValue("barValue")); 500 value2.Append(StringValue::CreateStringValue("barValue"));
500 501
501 // Make storage1/2 initialised from local data, storage3/4 initialised from 502 // Make storage1/2 initialised from local data, storage3/4 initialised from
502 // sync. 503 // sync.
503 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type); 504 ValueStore* storage1 = AddExtensionAndGetStorage("s1", type);
504 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type); 505 ValueStore* storage2 = AddExtensionAndGetStorage("s2", type);
505 ValueStore* storage3 = AddExtensionAndGetStorage("s3", type); 506 ValueStore* storage3 = AddExtensionAndGetStorage("s3", type);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 GetSyncableService(model_type)->StopSyncing(model_type); 633 GetSyncableService(model_type)->StopSyncing(model_type);
633 } 634 }
634 635
635 TEST_F(ExtensionSettingsSyncTest, ExtensionAndAppSettingsSyncSeparately) { 636 TEST_F(ExtensionSettingsSyncTest, ExtensionAndAppSettingsSyncSeparately) {
636 StringValue value1("fooValue"); 637 StringValue value1("fooValue");
637 ListValue value2; 638 ListValue value2;
638 value2.Append(StringValue::CreateStringValue("barValue")); 639 value2.Append(StringValue::CreateStringValue("barValue"));
639 640
640 // storage1 is an extension, storage2 is an app. 641 // storage1 is an extension, storage2 is an app.
641 ValueStore* storage1 = AddExtensionAndGetStorage( 642 ValueStore* storage1 = AddExtensionAndGetStorage(
642 "s1", Extension::TYPE_EXTENSION); 643 "s1", Manifest::TYPE_EXTENSION);
643 ValueStore* storage2 = AddExtensionAndGetStorage( 644 ValueStore* storage2 = AddExtensionAndGetStorage(
644 "s2", Extension::TYPE_LEGACY_PACKAGED_APP); 645 "s2", Manifest::TYPE_LEGACY_PACKAGED_APP);
645 646
646 storage1->Set(DEFAULTS, "foo", value1); 647 storage1->Set(DEFAULTS, "foo", value1);
647 storage2->Set(DEFAULTS, "bar", value2); 648 storage2->Set(DEFAULTS, "bar", value2);
648 649
649 std::map<std::string, SettingSyncDataList> extension_sync_data = 650 std::map<std::string, SettingSyncDataList> extension_sync_data =
650 GetAllSyncData(syncer::EXTENSION_SETTINGS); 651 GetAllSyncData(syncer::EXTENSION_SETTINGS);
651 EXPECT_EQ(1u, extension_sync_data.size()); 652 EXPECT_EQ(1u, extension_sync_data.size());
652 EXPECT_EQ(1u, extension_sync_data["s1"].size()); 653 EXPECT_EQ(1u, extension_sync_data["s1"].size());
653 EXPECT_PRED_FORMAT2(ValuesEq, &value1, &extension_sync_data["s1"][0].value()); 654 EXPECT_PRED_FORMAT2(ValuesEq, &value1, &extension_sync_data["s1"][0].value());
654 655
(...skipping 28 matching lines...) Expand all
683 sync_data, 684 sync_data,
684 app_settings_delegate_.PassAs<syncer::SyncChangeProcessor>(), 685 app_settings_delegate_.PassAs<syncer::SyncChangeProcessor>(),
685 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); 686 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
686 GetSyncableService(syncer::APP_SETTINGS)-> 687 GetSyncableService(syncer::APP_SETTINGS)->
687 StopSyncing(syncer::APP_SETTINGS); 688 StopSyncing(syncer::APP_SETTINGS);
688 EXPECT_EQ(0u, sync_processor_->changes().size()); 689 EXPECT_EQ(0u, sync_processor_->changes().size());
689 } 690 }
690 691
691 TEST_F(ExtensionSettingsSyncTest, FailingStartSyncingDisablesSync) { 692 TEST_F(ExtensionSettingsSyncTest, FailingStartSyncingDisablesSync) {
692 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; 693 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS;
693 Extension::Type type = Extension::TYPE_EXTENSION; 694 Manifest::Type type = Manifest::TYPE_EXTENSION;
694 695
695 StringValue fooValue("fooValue"); 696 StringValue fooValue("fooValue");
696 StringValue barValue("barValue"); 697 StringValue barValue("barValue");
697 698
698 // There is a bit of a convoluted method to get storage areas that can fail; 699 // There is a bit of a convoluted method to get storage areas that can fail;
699 // hand out TestingValueStore object then toggle them failing/succeeding 700 // hand out TestingValueStore object then toggle them failing/succeeding
700 // as necessary. 701 // as necessary.
701 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); 702 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory();
702 storage_factory_->Reset(testing_factory); 703 storage_factory_->Reset(testing_factory);
703 704
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 DictionaryValue dict; 884 DictionaryValue dict;
884 dict.Set("bar", fooValue.DeepCopy()); 885 dict.Set("bar", fooValue.DeepCopy());
885 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); 886 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get());
886 } 887 }
887 } 888 }
888 889
889 TEST_F(ExtensionSettingsSyncTest, FailingProcessChangesDisablesSync) { 890 TEST_F(ExtensionSettingsSyncTest, FailingProcessChangesDisablesSync) {
890 // The test above tests a failing ProcessSyncChanges too, but here test with 891 // The test above tests a failing ProcessSyncChanges too, but here test with
891 // an initially passing MergeDataAndStartSyncing. 892 // an initially passing MergeDataAndStartSyncing.
892 syncer::ModelType model_type = syncer::APP_SETTINGS; 893 syncer::ModelType model_type = syncer::APP_SETTINGS;
893 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP; 894 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP;
894 895
895 StringValue fooValue("fooValue"); 896 StringValue fooValue("fooValue");
896 StringValue barValue("barValue"); 897 StringValue barValue("barValue");
897 898
898 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); 899 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory();
899 storage_factory_->Reset(testing_factory); 900 storage_factory_->Reset(testing_factory);
900 901
901 ValueStore* good = AddExtensionAndGetStorage("good", type); 902 ValueStore* good = AddExtensionAndGetStorage("good", type);
902 ValueStore* bad = AddExtensionAndGetStorage("bad", type); 903 ValueStore* bad = AddExtensionAndGetStorage("bad", type);
903 904
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 } 982 }
982 { 983 {
983 DictionaryValue dict; 984 DictionaryValue dict;
984 dict.Set("foo", barValue.DeepCopy()); 985 dict.Set("foo", barValue.DeepCopy());
985 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); 986 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get());
986 } 987 }
987 } 988 }
988 989
989 TEST_F(ExtensionSettingsSyncTest, FailingGetAllSyncDataDoesntStopSync) { 990 TEST_F(ExtensionSettingsSyncTest, FailingGetAllSyncDataDoesntStopSync) {
990 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; 991 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS;
991 Extension::Type type = Extension::TYPE_EXTENSION; 992 Manifest::Type type = Manifest::TYPE_EXTENSION;
992 993
993 StringValue fooValue("fooValue"); 994 StringValue fooValue("fooValue");
994 StringValue barValue("barValue"); 995 StringValue barValue("barValue");
995 996
996 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); 997 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory();
997 storage_factory_->Reset(testing_factory); 998 storage_factory_->Reset(testing_factory);
998 999
999 ValueStore* good = AddExtensionAndGetStorage("good", type); 1000 ValueStore* good = AddExtensionAndGetStorage("good", type);
1000 ValueStore* bad = AddExtensionAndGetStorage("bad", type); 1001 ValueStore* bad = AddExtensionAndGetStorage("bad", type);
1001 1002
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 syncer::SyncChange::ACTION_ADD, 1037 syncer::SyncChange::ACTION_ADD,
1037 sync_processor_->GetOnlyChange("good", "bar").change_type()); 1038 sync_processor_->GetOnlyChange("good", "bar").change_type());
1038 EXPECT_EQ( 1039 EXPECT_EQ(
1039 syncer::SyncChange::ACTION_ADD, 1040 syncer::SyncChange::ACTION_ADD,
1040 sync_processor_->GetOnlyChange("bad", "bar").change_type()); 1041 sync_processor_->GetOnlyChange("bad", "bar").change_type());
1041 EXPECT_EQ(2u, sync_processor_->changes().size()); 1042 EXPECT_EQ(2u, sync_processor_->changes().size());
1042 } 1043 }
1043 1044
1044 TEST_F(ExtensionSettingsSyncTest, FailureToReadChangesToPushDisablesSync) { 1045 TEST_F(ExtensionSettingsSyncTest, FailureToReadChangesToPushDisablesSync) {
1045 syncer::ModelType model_type = syncer::APP_SETTINGS; 1046 syncer::ModelType model_type = syncer::APP_SETTINGS;
1046 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP; 1047 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP;
1047 1048
1048 StringValue fooValue("fooValue"); 1049 StringValue fooValue("fooValue");
1049 StringValue barValue("barValue"); 1050 StringValue barValue("barValue");
1050 1051
1051 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); 1052 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory();
1052 storage_factory_->Reset(testing_factory); 1053 storage_factory_->Reset(testing_factory);
1053 1054
1054 ValueStore* good = AddExtensionAndGetStorage("good", type); 1055 ValueStore* good = AddExtensionAndGetStorage("good", type);
1055 ValueStore* bad = AddExtensionAndGetStorage("bad", type); 1056 ValueStore* bad = AddExtensionAndGetStorage("bad", type);
1056 1057
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 syncer::SyncChange::ACTION_UPDATE, 1141 syncer::SyncChange::ACTION_UPDATE,
1141 sync_processor_->GetOnlyChange("good", "bar").change_type()); 1142 sync_processor_->GetOnlyChange("good", "bar").change_type());
1142 EXPECT_EQ( 1143 EXPECT_EQ(
1143 syncer::SyncChange::ACTION_UPDATE, 1144 syncer::SyncChange::ACTION_UPDATE,
1144 sync_processor_->GetOnlyChange("good", "bar").change_type()); 1145 sync_processor_->GetOnlyChange("good", "bar").change_type());
1145 EXPECT_EQ(2u, sync_processor_->changes().size()); 1146 EXPECT_EQ(2u, sync_processor_->changes().size());
1146 } 1147 }
1147 1148
1148 TEST_F(ExtensionSettingsSyncTest, FailureToPushLocalStateDisablesSync) { 1149 TEST_F(ExtensionSettingsSyncTest, FailureToPushLocalStateDisablesSync) {
1149 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; 1150 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS;
1150 Extension::Type type = Extension::TYPE_EXTENSION; 1151 Manifest::Type type = Manifest::TYPE_EXTENSION;
1151 1152
1152 StringValue fooValue("fooValue"); 1153 StringValue fooValue("fooValue");
1153 StringValue barValue("barValue"); 1154 StringValue barValue("barValue");
1154 1155
1155 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); 1156 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory();
1156 storage_factory_->Reset(testing_factory); 1157 storage_factory_->Reset(testing_factory);
1157 1158
1158 ValueStore* good = AddExtensionAndGetStorage("good", type); 1159 ValueStore* good = AddExtensionAndGetStorage("good", type);
1159 ValueStore* bad = AddExtensionAndGetStorage("bad", type); 1160 ValueStore* bad = AddExtensionAndGetStorage("bad", type);
1160 1161
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 syncer::SyncChange::ACTION_UPDATE, 1232 syncer::SyncChange::ACTION_UPDATE,
1232 sync_processor_->GetOnlyChange("good", "foo").change_type()); 1233 sync_processor_->GetOnlyChange("good", "foo").change_type());
1233 EXPECT_EQ( 1234 EXPECT_EQ(
1234 syncer::SyncChange::ACTION_UPDATE, 1235 syncer::SyncChange::ACTION_UPDATE,
1235 sync_processor_->GetOnlyChange("good", "foo").change_type()); 1236 sync_processor_->GetOnlyChange("good", "foo").change_type());
1236 EXPECT_EQ(2u, sync_processor_->changes().size()); 1237 EXPECT_EQ(2u, sync_processor_->changes().size());
1237 } 1238 }
1238 1239
1239 TEST_F(ExtensionSettingsSyncTest, FailureToPushLocalChangeDisablesSync) { 1240 TEST_F(ExtensionSettingsSyncTest, FailureToPushLocalChangeDisablesSync) {
1240 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; 1241 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS;
1241 Extension::Type type = Extension::TYPE_EXTENSION; 1242 Manifest::Type type = Manifest::TYPE_EXTENSION;
1242 1243
1243 StringValue fooValue("fooValue"); 1244 StringValue fooValue("fooValue");
1244 StringValue barValue("barValue"); 1245 StringValue barValue("barValue");
1245 1246
1246 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); 1247 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory();
1247 storage_factory_->Reset(testing_factory); 1248 storage_factory_->Reset(testing_factory);
1248 1249
1249 ValueStore* good = AddExtensionAndGetStorage("good", type); 1250 ValueStore* good = AddExtensionAndGetStorage("good", type);
1250 ValueStore* bad = AddExtensionAndGetStorage("bad", type); 1251 ValueStore* bad = AddExtensionAndGetStorage("bad", type);
1251 1252
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 sync_processor_->GetOnlyChange("good", "foo").change_type()); 1330 sync_processor_->GetOnlyChange("good", "foo").change_type());
1330 EXPECT_EQ( 1331 EXPECT_EQ(
1331 syncer::SyncChange::ACTION_UPDATE, 1332 syncer::SyncChange::ACTION_UPDATE,
1332 sync_processor_->GetOnlyChange("good", "foo").change_type()); 1333 sync_processor_->GetOnlyChange("good", "foo").change_type());
1333 EXPECT_EQ(2u, sync_processor_->changes().size()); 1334 EXPECT_EQ(2u, sync_processor_->changes().size());
1334 } 1335 }
1335 1336
1336 TEST_F(ExtensionSettingsSyncTest, 1337 TEST_F(ExtensionSettingsSyncTest,
1337 LargeOutgoingChangeRejectedButIncomingAccepted) { 1338 LargeOutgoingChangeRejectedButIncomingAccepted) {
1338 syncer::ModelType model_type = syncer::APP_SETTINGS; 1339 syncer::ModelType model_type = syncer::APP_SETTINGS;
1339 Extension::Type type = Extension::TYPE_LEGACY_PACKAGED_APP; 1340 Manifest::Type type = Manifest::TYPE_LEGACY_PACKAGED_APP;
1340 1341
1341 // This value should be larger than the limit in settings_backend.cc. 1342 // This value should be larger than the limit in settings_backend.cc.
1342 std::string string_5k; 1343 std::string string_5k;
1343 for (size_t i = 0; i < 5000; ++i) { 1344 for (size_t i = 0; i < 5000; ++i) {
1344 string_5k.append("a"); 1345 string_5k.append("a");
1345 } 1346 }
1346 StringValue large_value(string_5k); 1347 StringValue large_value(string_5k);
1347 1348
1348 GetSyncableService(model_type)->MergeDataAndStartSyncing( 1349 GetSyncableService(model_type)->MergeDataAndStartSyncing(
1349 model_type, 1350 model_type,
(...skipping 21 matching lines...) Expand all
1371 expected.Set("large_value", large_value.DeepCopy()); 1372 expected.Set("large_value", large_value.DeepCopy());
1372 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage1->Get()); 1373 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage1->Get());
1373 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage2->Get()); 1374 EXPECT_PRED_FORMAT2(SettingsEq, expected, storage2->Get());
1374 } 1375 }
1375 1376
1376 GetSyncableService(model_type)->StopSyncing(model_type); 1377 GetSyncableService(model_type)->StopSyncing(model_type);
1377 } 1378 }
1378 1379
1379 TEST_F(ExtensionSettingsSyncTest, Dots) { 1380 TEST_F(ExtensionSettingsSyncTest, Dots) {
1380 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS; 1381 syncer::ModelType model_type = syncer::EXTENSION_SETTINGS;
1381 Extension::Type type = Extension::TYPE_EXTENSION; 1382 Manifest::Type type = Manifest::TYPE_EXTENSION;
1382 1383
1383 ValueStore* storage = AddExtensionAndGetStorage("ext", type); 1384 ValueStore* storage = AddExtensionAndGetStorage("ext", type);
1384 1385
1385 { 1386 {
1386 syncer::SyncDataList sync_data_list; 1387 syncer::SyncDataList sync_data_list;
1387 scoped_ptr<Value> string_value(Value::CreateStringValue("value")); 1388 scoped_ptr<Value> string_value(Value::CreateStringValue("value"));
1388 sync_data_list.push_back(settings_sync_util::CreateData( 1389 sync_data_list.push_back(settings_sync_util::CreateData(
1389 "ext", "key.with.dot", *string_value, model_type)); 1390 "ext", "key.with.dot", *string_value, model_type));
1390 1391
1391 GetSyncableService(model_type)->MergeDataAndStartSyncing( 1392 GetSyncableService(model_type)->MergeDataAndStartSyncing(
(...skipping 24 matching lines...) Expand all
1416 ASSERT_EQ(1u, sync_processor_->changes().size()); 1417 ASSERT_EQ(1u, sync_processor_->changes().size());
1417 SettingSyncData sync_data = sync_processor_->changes()[0]; 1418 SettingSyncData sync_data = sync_processor_->changes()[0];
1418 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type()); 1419 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type());
1419 EXPECT_EQ("ext", sync_data.extension_id()); 1420 EXPECT_EQ("ext", sync_data.extension_id());
1420 EXPECT_EQ("key.with.spot", sync_data.key()); 1421 EXPECT_EQ("key.with.spot", sync_data.key());
1421 EXPECT_TRUE(sync_data.value().Equals(string_value.get())); 1422 EXPECT_TRUE(sync_data.value().Equals(string_value.get()));
1422 } 1423 }
1423 } 1424 }
1424 1425
1425 } // namespace extensions 1426 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698