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 "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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 | 72 |
73 // Returns whether the result of a storage operation is an expected value. | 73 // Returns whether the result of a storage operation is an expected value. |
74 // Logs when different. | 74 // Logs when different. |
75 testing::AssertionResult SettingsEq( | 75 testing::AssertionResult SettingsEq( |
76 const char* _1, const char* _2, | 76 const char* _1, const char* _2, |
77 const DictionaryValue& expected, | 77 const DictionaryValue& expected, |
78 ValueStore::ReadResult actual) { | 78 ValueStore::ReadResult actual) { |
79 if (actual->HasError()) { | 79 if (actual->HasError()) { |
80 return testing::AssertionFailure() << | 80 return testing::AssertionFailure() << |
81 "Expected: " << GetJson(expected) << | 81 "Expected: " << expected << |
82 ", actual has error: " << actual->error(); | 82 ", actual has error: " << actual->error().message; |
83 } | 83 } |
84 return ValuesEq(_1, _2, &expected, actual->settings().get()); | 84 return ValuesEq(_1, _2, &expected, &actual->settings()); |
85 } | 85 } |
86 | 86 |
87 // SyncChangeProcessor which just records the changes made, accessed after | 87 // SyncChangeProcessor which just records the changes made, accessed after |
88 // being converted to the more useful SettingSyncData via changes(). | 88 // being converted to the more useful SettingSyncData via changes(). |
89 class MockSyncChangeProcessor : public syncer::SyncChangeProcessor { | 89 class MockSyncChangeProcessor : public syncer::SyncChangeProcessor { |
90 public: | 90 public: |
91 MockSyncChangeProcessor() : fail_all_requests_(false) {} | 91 MockSyncChangeProcessor() : fail_all_requests_(false) {} |
92 | 92 |
93 // syncer::SyncChangeProcessor implementation. | 93 // syncer::SyncChangeProcessor implementation. |
94 virtual syncer::SyncError ProcessSyncChanges( | 94 virtual syncer::SyncError ProcessSyncChanges( |
(...skipping 19 matching lines...) Expand all Loading... |
114 } | 114 } |
115 | 115 |
116 // Mock methods. | 116 // Mock methods. |
117 | 117 |
118 const SettingSyncDataList& changes() { return changes_; } | 118 const SettingSyncDataList& changes() { return changes_; } |
119 | 119 |
120 void ClearChanges() { | 120 void ClearChanges() { |
121 changes_.clear(); | 121 changes_.clear(); |
122 } | 122 } |
123 | 123 |
124 void SetFailAllRequests(bool fail_all_requests) { | 124 void set_fail_all_requests(bool fail_all_requests) { |
125 fail_all_requests_ = fail_all_requests; | 125 fail_all_requests_ = fail_all_requests; |
126 } | 126 } |
127 | 127 |
128 // Returns the only change for a given extension setting. If there is not | 128 // Returns the only change for a given extension setting. If there is not |
129 // exactly 1 change for that key, a test assertion will fail. | 129 // exactly 1 change for that key, a test assertion will fail. |
130 SettingSyncData GetOnlyChange( | 130 SettingSyncData GetOnlyChange( |
131 const std::string& extension_id, const std::string& key) { | 131 const std::string& extension_id, const std::string& key) { |
132 SettingSyncDataList matching_changes; | 132 SettingSyncDataList matching_changes; |
133 for (SettingSyncDataList::iterator it = changes_.begin(); | 133 for (SettingSyncDataList::iterator it = changes_.begin(); |
134 it != changes_.end(); ++it) { | 134 it != changes_.end(); ++it) { |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 // There is a bit of a convoluted method to get storage areas that can fail; | 714 // There is a bit of a convoluted method to get storage areas that can fail; |
715 // hand out TestingValueStore object then toggle them failing/succeeding | 715 // hand out TestingValueStore object then toggle them failing/succeeding |
716 // as necessary. | 716 // as necessary. |
717 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); | 717 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); |
718 storage_factory_->Reset(testing_factory); | 718 storage_factory_->Reset(testing_factory); |
719 | 719 |
720 ValueStore* good = AddExtensionAndGetStorage("good", type); | 720 ValueStore* good = AddExtensionAndGetStorage("good", type); |
721 ValueStore* bad = AddExtensionAndGetStorage("bad", type); | 721 ValueStore* bad = AddExtensionAndGetStorage("bad", type); |
722 | 722 |
723 // Make bad fail for incoming sync changes. | 723 // Make bad fail for incoming sync changes. |
724 testing_factory->GetExisting("bad")->SetFailAllRequests(true); | 724 testing_factory->GetExisting("bad")->set_error_code(ValueStore::CORRUPTION); |
725 { | 725 { |
726 syncer::SyncDataList sync_data; | 726 syncer::SyncDataList sync_data; |
727 sync_data.push_back(settings_sync_util::CreateData( | 727 sync_data.push_back(settings_sync_util::CreateData( |
728 "good", "foo", fooValue, model_type)); | 728 "good", "foo", fooValue, model_type)); |
729 sync_data.push_back(settings_sync_util::CreateData( | 729 sync_data.push_back(settings_sync_util::CreateData( |
730 "bad", "foo", fooValue, model_type)); | 730 "bad", "foo", fooValue, model_type)); |
731 GetSyncableService(model_type)->MergeDataAndStartSyncing( | 731 GetSyncableService(model_type)->MergeDataAndStartSyncing( |
732 model_type, | 732 model_type, |
733 sync_data, | 733 sync_data, |
734 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(), | 734 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(), |
735 scoped_ptr<syncer::SyncErrorFactory>( | 735 scoped_ptr<syncer::SyncErrorFactory>( |
736 new syncer::SyncErrorFactoryMock())); | 736 new syncer::SyncErrorFactoryMock())); |
737 } | 737 } |
738 testing_factory->GetExisting("bad")->SetFailAllRequests(false); | 738 testing_factory->GetExisting("bad")->set_error_code(ValueStore::OK); |
739 | 739 |
740 { | 740 { |
741 DictionaryValue dict; | 741 DictionaryValue dict; |
742 dict.Set("foo", fooValue.DeepCopy()); | 742 dict.Set("foo", fooValue.DeepCopy()); |
743 EXPECT_PRED_FORMAT2(SettingsEq, dict, good->Get()); | 743 EXPECT_PRED_FORMAT2(SettingsEq, dict, good->Get()); |
744 } | 744 } |
745 { | 745 { |
746 DictionaryValue dict; | 746 DictionaryValue dict; |
747 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); | 747 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); |
748 } | 748 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 dict.Set("bar", fooValue.DeepCopy()); | 811 dict.Set("bar", fooValue.DeepCopy()); |
812 EXPECT_PRED_FORMAT2(SettingsEq, dict, good->Get()); | 812 EXPECT_PRED_FORMAT2(SettingsEq, dict, good->Get()); |
813 } | 813 } |
814 { | 814 { |
815 DictionaryValue dict; | 815 DictionaryValue dict; |
816 dict.Set("bar", fooValue.DeepCopy()); | 816 dict.Set("bar", fooValue.DeepCopy()); |
817 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); | 817 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); |
818 } | 818 } |
819 | 819 |
820 // Failing ProcessSyncChanges shouldn't go to the storage. | 820 // Failing ProcessSyncChanges shouldn't go to the storage. |
821 testing_factory->GetExisting("bad")->SetFailAllRequests(true); | 821 testing_factory->GetExisting("bad")->set_error_code(ValueStore::CORRUPTION); |
822 { | 822 { |
823 syncer::SyncChangeList change_list; | 823 syncer::SyncChangeList change_list; |
824 change_list.push_back(settings_sync_util::CreateUpdate( | 824 change_list.push_back(settings_sync_util::CreateUpdate( |
825 "good", "foo", fooValue, model_type)); | 825 "good", "foo", fooValue, model_type)); |
826 // (Ditto.) | 826 // (Ditto.) |
827 change_list.push_back(settings_sync_util::CreateUpdate( | 827 change_list.push_back(settings_sync_util::CreateUpdate( |
828 "bad", "foo", fooValue, model_type)); | 828 "bad", "foo", fooValue, model_type)); |
829 GetSyncableService(model_type)->ProcessSyncChanges(FROM_HERE, change_list); | 829 GetSyncableService(model_type)->ProcessSyncChanges(FROM_HERE, change_list); |
830 } | 830 } |
831 testing_factory->GetExisting("bad")->SetFailAllRequests(false); | 831 testing_factory->GetExisting("bad")->set_error_code(ValueStore::OK); |
832 | 832 |
833 { | 833 { |
834 DictionaryValue dict; | 834 DictionaryValue dict; |
835 dict.Set("foo", fooValue.DeepCopy()); | 835 dict.Set("foo", fooValue.DeepCopy()); |
836 dict.Set("bar", fooValue.DeepCopy()); | 836 dict.Set("bar", fooValue.DeepCopy()); |
837 EXPECT_PRED_FORMAT2(SettingsEq, dict, good->Get()); | 837 EXPECT_PRED_FORMAT2(SettingsEq, dict, good->Get()); |
838 } | 838 } |
839 { | 839 { |
840 DictionaryValue dict; | 840 DictionaryValue dict; |
841 dict.Set("bar", fooValue.DeepCopy()); | 841 dict.Set("bar", fooValue.DeepCopy()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 dict.Set("foo", fooValue.DeepCopy()); | 939 dict.Set("foo", fooValue.DeepCopy()); |
940 EXPECT_PRED_FORMAT2(SettingsEq, dict, good->Get()); | 940 EXPECT_PRED_FORMAT2(SettingsEq, dict, good->Get()); |
941 } | 941 } |
942 { | 942 { |
943 DictionaryValue dict; | 943 DictionaryValue dict; |
944 dict.Set("foo", fooValue.DeepCopy()); | 944 dict.Set("foo", fooValue.DeepCopy()); |
945 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); | 945 EXPECT_PRED_FORMAT2(SettingsEq, dict, bad->Get()); |
946 } | 946 } |
947 | 947 |
948 // Now fail ProcessSyncChanges for bad. | 948 // Now fail ProcessSyncChanges for bad. |
949 testing_factory->GetExisting("bad")->SetFailAllRequests(true); | 949 testing_factory->GetExisting("bad")->set_error_code(ValueStore::CORRUPTION); |
950 { | 950 { |
951 syncer::SyncChangeList change_list; | 951 syncer::SyncChangeList change_list; |
952 change_list.push_back(settings_sync_util::CreateAdd( | 952 change_list.push_back(settings_sync_util::CreateAdd( |
953 "good", "bar", barValue, model_type)); | 953 "good", "bar", barValue, model_type)); |
954 change_list.push_back(settings_sync_util::CreateAdd( | 954 change_list.push_back(settings_sync_util::CreateAdd( |
955 "bad", "bar", barValue, model_type)); | 955 "bad", "bar", barValue, model_type)); |
956 GetSyncableService(model_type)->ProcessSyncChanges(FROM_HERE, change_list); | 956 GetSyncableService(model_type)->ProcessSyncChanges(FROM_HERE, change_list); |
957 } | 957 } |
958 testing_factory->GetExisting("bad")->SetFailAllRequests(false); | 958 testing_factory->GetExisting("bad")->set_error_code(ValueStore::OK); |
959 | 959 |
960 { | 960 { |
961 DictionaryValue dict; | 961 DictionaryValue dict; |
962 dict.Set("foo", fooValue.DeepCopy()); | 962 dict.Set("foo", fooValue.DeepCopy()); |
963 dict.Set("bar", barValue.DeepCopy()); | 963 dict.Set("bar", barValue.DeepCopy()); |
964 EXPECT_PRED_FORMAT2(SettingsEq, dict, good->Get()); | 964 EXPECT_PRED_FORMAT2(SettingsEq, dict, good->Get()); |
965 } | 965 } |
966 { | 966 { |
967 DictionaryValue dict; | 967 DictionaryValue dict; |
968 dict.Set("foo", fooValue.DeepCopy()); | 968 dict.Set("foo", fooValue.DeepCopy()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 storage_factory_->Reset(testing_factory); | 1013 storage_factory_->Reset(testing_factory); |
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 // Even though bad will fail to get all sync data, sync data should still | 1021 // Even though bad will fail to get all sync data, sync data should still |
1022 // include that from good. | 1022 // include that from good. |
1023 testing_factory->GetExisting("bad")->SetFailAllRequests(true); | 1023 testing_factory->GetExisting("bad")->set_error_code(ValueStore::CORRUPTION); |
1024 { | 1024 { |
1025 syncer::SyncDataList all_sync_data = | 1025 syncer::SyncDataList all_sync_data = |
1026 GetSyncableService(model_type)->GetAllSyncData(model_type); | 1026 GetSyncableService(model_type)->GetAllSyncData(model_type); |
1027 EXPECT_EQ(1u, all_sync_data.size()); | 1027 EXPECT_EQ(1u, all_sync_data.size()); |
1028 EXPECT_EQ("good/foo", all_sync_data[0].GetTag()); | 1028 EXPECT_EQ("good/foo", all_sync_data[0].GetTag()); |
1029 } | 1029 } |
1030 testing_factory->GetExisting("bad")->SetFailAllRequests(false); | 1030 testing_factory->GetExisting("bad")->set_error_code(ValueStore::OK); |
1031 | 1031 |
1032 // Sync shouldn't be disabled for good (nor bad -- but this is unimportant). | 1032 // Sync shouldn't be disabled for good (nor bad -- but this is unimportant). |
1033 GetSyncableService(model_type)->MergeDataAndStartSyncing( | 1033 GetSyncableService(model_type)->MergeDataAndStartSyncing( |
1034 model_type, | 1034 model_type, |
1035 syncer::SyncDataList(), | 1035 syncer::SyncDataList(), |
1036 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(), | 1036 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(), |
1037 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); | 1037 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); |
1038 | 1038 |
1039 EXPECT_EQ( | 1039 EXPECT_EQ( |
1040 syncer::SyncChange::ACTION_ADD, | 1040 syncer::SyncChange::ACTION_ADD, |
(...skipping 27 matching lines...) Expand all Loading... |
1068 storage_factory_->Reset(testing_factory); | 1068 storage_factory_->Reset(testing_factory); |
1069 | 1069 |
1070 ValueStore* good = AddExtensionAndGetStorage("good", type); | 1070 ValueStore* good = AddExtensionAndGetStorage("good", type); |
1071 ValueStore* bad = AddExtensionAndGetStorage("bad", type); | 1071 ValueStore* bad = AddExtensionAndGetStorage("bad", type); |
1072 | 1072 |
1073 good->Set(DEFAULTS, "foo", fooValue); | 1073 good->Set(DEFAULTS, "foo", fooValue); |
1074 bad->Set(DEFAULTS, "foo", fooValue); | 1074 bad->Set(DEFAULTS, "foo", fooValue); |
1075 | 1075 |
1076 // good will successfully push foo:fooValue to sync, but bad will fail to | 1076 // good will successfully push foo:fooValue to sync, but bad will fail to |
1077 // get them so won't. | 1077 // get them so won't. |
1078 testing_factory->GetExisting("bad")->SetFailAllRequests(true); | 1078 testing_factory->GetExisting("bad")->set_error_code(ValueStore::CORRUPTION); |
1079 GetSyncableService(model_type)->MergeDataAndStartSyncing( | 1079 GetSyncableService(model_type)->MergeDataAndStartSyncing( |
1080 model_type, | 1080 model_type, |
1081 syncer::SyncDataList(), | 1081 syncer::SyncDataList(), |
1082 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(), | 1082 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(), |
1083 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); | 1083 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); |
1084 testing_factory->GetExisting("bad")->SetFailAllRequests(false); | 1084 testing_factory->GetExisting("bad")->set_error_code(ValueStore::OK); |
1085 | 1085 |
1086 EXPECT_EQ( | 1086 EXPECT_EQ( |
1087 syncer::SyncChange::ACTION_ADD, | 1087 syncer::SyncChange::ACTION_ADD, |
1088 sync_processor_->GetOnlyChange("good", "foo").change_type()); | 1088 sync_processor_->GetOnlyChange("good", "foo").change_type()); |
1089 EXPECT_EQ(1u, sync_processor_->changes().size()); | 1089 EXPECT_EQ(1u, sync_processor_->changes().size()); |
1090 | 1090 |
1091 // bad should now be disabled for sync. | 1091 // bad should now be disabled for sync. |
1092 sync_processor_->ClearChanges(); | 1092 sync_processor_->ClearChanges(); |
1093 good->Set(DEFAULTS, "bar", barValue); | 1093 good->Set(DEFAULTS, "bar", barValue); |
1094 bad->Set(DEFAULTS, "bar", barValue); | 1094 bad->Set(DEFAULTS, "bar", barValue); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 | 1170 |
1171 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); | 1171 TestingValueStoreFactory* testing_factory = new TestingValueStoreFactory(); |
1172 storage_factory_->Reset(testing_factory); | 1172 storage_factory_->Reset(testing_factory); |
1173 | 1173 |
1174 ValueStore* good = AddExtensionAndGetStorage("good", type); | 1174 ValueStore* good = AddExtensionAndGetStorage("good", type); |
1175 ValueStore* bad = AddExtensionAndGetStorage("bad", type); | 1175 ValueStore* bad = AddExtensionAndGetStorage("bad", type); |
1176 | 1176 |
1177 // Only set bad; setting good will cause it to fail below. | 1177 // Only set bad; setting good will cause it to fail below. |
1178 bad->Set(DEFAULTS, "foo", fooValue); | 1178 bad->Set(DEFAULTS, "foo", fooValue); |
1179 | 1179 |
1180 sync_processor_->SetFailAllRequests(true); | 1180 sync_processor_->set_fail_all_requests(true); |
1181 GetSyncableService(model_type)->MergeDataAndStartSyncing( | 1181 GetSyncableService(model_type)->MergeDataAndStartSyncing( |
1182 model_type, | 1182 model_type, |
1183 syncer::SyncDataList(), | 1183 syncer::SyncDataList(), |
1184 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(), | 1184 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(), |
1185 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); | 1185 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); |
1186 sync_processor_->SetFailAllRequests(false); | 1186 sync_processor_->set_fail_all_requests(false); |
1187 | 1187 |
1188 // Changes from good will be send to sync, changes from bad won't. | 1188 // Changes from good will be send to sync, changes from bad won't. |
1189 sync_processor_->ClearChanges(); | 1189 sync_processor_->ClearChanges(); |
1190 good->Set(DEFAULTS, "foo", barValue); | 1190 good->Set(DEFAULTS, "foo", barValue); |
1191 bad->Set(DEFAULTS, "foo", barValue); | 1191 bad->Set(DEFAULTS, "foo", barValue); |
1192 | 1192 |
1193 EXPECT_EQ( | 1193 EXPECT_EQ( |
1194 syncer::SyncChange::ACTION_ADD, | 1194 syncer::SyncChange::ACTION_ADD, |
1195 sync_processor_->GetOnlyChange("good", "foo").change_type()); | 1195 sync_processor_->GetOnlyChange("good", "foo").change_type()); |
1196 EXPECT_EQ(1u, sync_processor_->changes().size()); | 1196 EXPECT_EQ(1u, sync_processor_->changes().size()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 ValueStore* bad = AddExtensionAndGetStorage("bad", type); | 1266 ValueStore* bad = AddExtensionAndGetStorage("bad", type); |
1267 | 1267 |
1268 GetSyncableService(model_type)->MergeDataAndStartSyncing( | 1268 GetSyncableService(model_type)->MergeDataAndStartSyncing( |
1269 model_type, | 1269 model_type, |
1270 syncer::SyncDataList(), | 1270 syncer::SyncDataList(), |
1271 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(), | 1271 sync_processor_delegate_.PassAs<syncer::SyncChangeProcessor>(), |
1272 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); | 1272 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); |
1273 | 1273 |
1274 // bad will fail to send changes. | 1274 // bad will fail to send changes. |
1275 good->Set(DEFAULTS, "foo", fooValue); | 1275 good->Set(DEFAULTS, "foo", fooValue); |
1276 sync_processor_->SetFailAllRequests(true); | 1276 sync_processor_->set_fail_all_requests(true); |
1277 bad->Set(DEFAULTS, "foo", fooValue); | 1277 bad->Set(DEFAULTS, "foo", fooValue); |
1278 sync_processor_->SetFailAllRequests(false); | 1278 sync_processor_->set_fail_all_requests(false); |
1279 | 1279 |
1280 EXPECT_EQ( | 1280 EXPECT_EQ( |
1281 syncer::SyncChange::ACTION_ADD, | 1281 syncer::SyncChange::ACTION_ADD, |
1282 sync_processor_->GetOnlyChange("good", "foo").change_type()); | 1282 sync_processor_->GetOnlyChange("good", "foo").change_type()); |
1283 EXPECT_EQ(1u, sync_processor_->changes().size()); | 1283 EXPECT_EQ(1u, sync_processor_->changes().size()); |
1284 | 1284 |
1285 // No further changes should be sent from bad. | 1285 // No further changes should be sent from bad. |
1286 sync_processor_->ClearChanges(); | 1286 sync_processor_->ClearChanges(); |
1287 good->Set(DEFAULTS, "foo", barValue); | 1287 good->Set(DEFAULTS, "foo", barValue); |
1288 bad->Set(DEFAULTS, "foo", barValue); | 1288 bad->Set(DEFAULTS, "foo", barValue); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 | 1414 |
1415 // Test dots in keys that come from sync. | 1415 // Test dots in keys that come from sync. |
1416 { | 1416 { |
1417 ValueStore::ReadResult data = storage->Get(); | 1417 ValueStore::ReadResult data = storage->Get(); |
1418 ASSERT_FALSE(data->HasError()); | 1418 ASSERT_FALSE(data->HasError()); |
1419 | 1419 |
1420 DictionaryValue expected_data; | 1420 DictionaryValue expected_data; |
1421 expected_data.SetWithoutPathExpansion( | 1421 expected_data.SetWithoutPathExpansion( |
1422 "key.with.dot", | 1422 "key.with.dot", |
1423 new base::StringValue("value")); | 1423 new base::StringValue("value")); |
1424 EXPECT_TRUE(Value::Equals(&expected_data, data->settings().get())); | 1424 EXPECT_TRUE(Value::Equals(&expected_data, &data->settings())); |
1425 } | 1425 } |
1426 | 1426 |
1427 // Test dots in keys going to sync. | 1427 // Test dots in keys going to sync. |
1428 { | 1428 { |
1429 scoped_ptr<Value> string_value(new base::StringValue("spot")); | 1429 scoped_ptr<Value> string_value(new base::StringValue("spot")); |
1430 storage->Set(DEFAULTS, "key.with.spot", *string_value); | 1430 storage->Set(DEFAULTS, "key.with.spot", *string_value); |
1431 | 1431 |
1432 ASSERT_EQ(1u, sync_processor_->changes().size()); | 1432 ASSERT_EQ(1u, sync_processor_->changes().size()); |
1433 SettingSyncData sync_data = sync_processor_->changes()[0]; | 1433 SettingSyncData sync_data = sync_processor_->changes()[0]; |
1434 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type()); | 1434 EXPECT_EQ(syncer::SyncChange::ACTION_ADD, sync_data.change_type()); |
1435 EXPECT_EQ("ext", sync_data.extension_id()); | 1435 EXPECT_EQ("ext", sync_data.extension_id()); |
1436 EXPECT_EQ("key.with.spot", sync_data.key()); | 1436 EXPECT_EQ("key.with.spot", sync_data.key()); |
1437 EXPECT_TRUE(sync_data.value().Equals(string_value.get())); | 1437 EXPECT_TRUE(sync_data.value().Equals(string_value.get())); |
1438 } | 1438 } |
1439 } | 1439 } |
1440 | 1440 |
1441 } // namespace extensions | 1441 } // namespace extensions |
OLD | NEW |