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/location.h" | 5 #include "base/location.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/autofill/autofill_profile.h" | 8 #include "chrome/browser/autofill/autofill_profile.h" |
9 #include "chrome/browser/sync/internal_api/read_node_mock.h" | 9 #include "chrome/browser/sync/internal_api/read_node_mock.h" |
10 #include "chrome/browser/sync/internal_api/syncapi_mock.h" | 10 #include "chrome/browser/sync/internal_api/syncapi_mock.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 MATCHER_P(CheckSyncChanges, n_sync_changes_list, "") { | 50 MATCHER_P(CheckSyncChanges, n_sync_changes_list, "") { |
51 if (arg.size() != n_sync_changes_list.size()) | 51 if (arg.size() != n_sync_changes_list.size()) |
52 return false; | 52 return false; |
53 SyncChangeList::const_iterator passed, expected; | 53 SyncChangeList::const_iterator passed, expected; |
54 for (passed = arg.begin(), expected = n_sync_changes_list.begin(); | 54 for (passed = arg.begin(), expected = n_sync_changes_list.begin(); |
55 passed != arg.end() && expected != n_sync_changes_list.end(); | 55 passed != arg.end() && expected != n_sync_changes_list.end(); |
56 ++passed, ++expected) { | 56 ++passed, ++expected) { |
57 DCHECK(passed->IsValid()); | 57 DCHECK(passed->IsValid()); |
58 if (passed->change_type() != expected->change_type()) | 58 if (passed->change_type() != expected->change_type()) |
59 return false; | 59 return false; |
60 if (passed->sync_data().GetSpecifics().GetExtension( | 60 if (passed->sync_data().GetSpecifics().autofill_profile().guid() != |
61 sync_pb::autofill_profile).guid() != | 61 expected->sync_data().GetSpecifics().autofill_profile().guid()) { |
62 expected->sync_data().GetSpecifics().GetExtension( | |
63 sync_pb::autofill_profile).guid()) { | |
64 return false; | 62 return false; |
65 } | 63 } |
66 } | 64 } |
67 return true; | 65 return true; |
68 } | 66 } |
69 | 67 |
70 MATCHER_P(DataBundleCheck, n_bundle, "") { | 68 MATCHER_P(DataBundleCheck, n_bundle, "") { |
71 if ((arg.profiles_to_delete.size() != n_bundle.profiles_to_delete.size()) || | 69 if ((arg.profiles_to_delete.size() != n_bundle.profiles_to_delete.size()) || |
72 (arg.profiles_to_update.size() != n_bundle.profiles_to_update.size()) || | 70 (arg.profiles_to_update.size() != n_bundle.profiles_to_update.size()) || |
73 (arg.profiles_to_add.size() != n_bundle.profiles_to_add.size())) { | 71 (arg.profiles_to_add.size() != n_bundle.profiles_to_add.size())) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 SyncDataList data_list; | 201 SyncDataList data_list; |
204 // Takes ownership of sync_processor_. | 202 // Takes ownership of sync_processor_. |
205 autofill_syncable_service_.MergeDataAndStartSyncing( | 203 autofill_syncable_service_.MergeDataAndStartSyncing( |
206 syncable::AUTOFILL_PROFILE, data_list, sync_processor_.release()); | 204 syncable::AUTOFILL_PROFILE, data_list, sync_processor_.release()); |
207 | 205 |
208 SyncDataList data = | 206 SyncDataList data = |
209 autofill_syncable_service_.GetAllSyncData(syncable::AUTOFILL_PROFILE); | 207 autofill_syncable_service_.GetAllSyncData(syncable::AUTOFILL_PROFILE); |
210 | 208 |
211 EXPECT_EQ(2U, data.size()); | 209 EXPECT_EQ(2U, data.size()); |
212 EXPECT_EQ(guid_present1, data.front().GetSpecifics() | 210 EXPECT_EQ(guid_present1, data.front().GetSpecifics() |
213 .GetExtension(sync_pb::autofill_profile).guid()); | 211 .autofill_profile().guid()); |
214 EXPECT_EQ(guid_present2, data.back().GetSpecifics() | 212 EXPECT_EQ(guid_present2, data.back().GetSpecifics() |
215 .GetExtension(sync_pb::autofill_profile).guid()); | 213 .autofill_profile().guid()); |
216 } | 214 } |
217 | 215 |
218 TEST_F(AutofillProfileSyncableServiceTest, ProcessSyncChanges) { | 216 TEST_F(AutofillProfileSyncableServiceTest, ProcessSyncChanges) { |
219 std::vector<AutofillProfile *> profiles_from_web_db; | 217 std::vector<AutofillProfile *> profiles_from_web_db; |
220 std::string guid_present = kGuid1; | 218 std::string guid_present = kGuid1; |
221 std::string guid_synced = kGuid2; | 219 std::string guid_synced = kGuid2; |
222 | 220 |
223 SyncChangeList change_list; | 221 SyncChangeList change_list; |
224 AutofillProfile profile(guid_synced); | 222 AutofillProfile profile(guid_synced); |
225 profile.SetInfo(NAME_FIRST, UTF8ToUTF16("Jane")); | 223 profile.SetInfo(NAME_FIRST, UTF8ToUTF16("Jane")); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 profile1.GetMultiInfo(EMAIL_ADDRESS, &values); | 400 profile1.GetMultiInfo(EMAIL_ADDRESS, &values); |
403 ASSERT_EQ(values.size(), 3U); | 401 ASSERT_EQ(values.size(), 3U); |
404 EXPECT_EQ(values[0], UTF8ToUTF16("1@1.com")); | 402 EXPECT_EQ(values[0], UTF8ToUTF16("1@1.com")); |
405 EXPECT_EQ(values[1], UTF8ToUTF16("2@1.com")); | 403 EXPECT_EQ(values[1], UTF8ToUTF16("2@1.com")); |
406 EXPECT_EQ(values[2], UTF8ToUTF16("3@1.com")); | 404 EXPECT_EQ(values[2], UTF8ToUTF16("3@1.com")); |
407 | 405 |
408 profile1.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); | 406 profile1.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); |
409 ASSERT_EQ(values.size(), 1U); | 407 ASSERT_EQ(values.size(), 1U); |
410 EXPECT_EQ(values[0], UTF8ToUTF16("650234567")); | 408 EXPECT_EQ(values[0], UTF8ToUTF16("650234567")); |
411 } | 409 } |
OLD | NEW |