| OLD | NEW |
| 1 | 1 |
| 2 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/sync/test/integration/autofill_helper.h" | 8 #include "chrome/browser/sync/test/integration/autofill_helper.h" |
| 9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 using autofill_helper::RemoveProfile; | 39 using autofill_helper::RemoveProfile; |
| 40 using autofill_helper::SetCreditCards; | 40 using autofill_helper::SetCreditCards; |
| 41 using autofill_helper::UpdateProfile; | 41 using autofill_helper::UpdateProfile; |
| 42 using bookmarks_helper::AddFolder; | 42 using bookmarks_helper::AddFolder; |
| 43 using bookmarks_helper::AddURL; | 43 using bookmarks_helper::AddURL; |
| 44 using bookmarks_helper::IndexedURL; | 44 using bookmarks_helper::IndexedURL; |
| 45 using bookmarks_helper::IndexedURLTitle; | 45 using bookmarks_helper::IndexedURLTitle; |
| 46 | 46 |
| 47 class TwoClientAutofillSyncTest : public SyncTest { | 47 class TwoClientAutofillSyncTest : public SyncTest { |
| 48 public: | 48 public: |
| 49 TwoClientAutofillSyncTest() : SyncTest(TWO_CLIENT) { count = 0; } | 49 TwoClientAutofillSyncTest() : SyncTest(TWO_CLIENT) {} |
| 50 ~TwoClientAutofillSyncTest() override {} | 50 ~TwoClientAutofillSyncTest() override {} |
| 51 | 51 |
| 52 bool TestUsesSelfNotifications() override { return false; } | 52 bool TestUsesSelfNotifications() override { return false; } |
| 53 | 53 |
| 54 // We do this so as to make a change that will trigger the autofill to sync. | |
| 55 // By default autofill does not sync unless there is some other change. | |
| 56 void MakeABookmarkChange(int profile) { | |
| 57 ASSERT_TRUE( | |
| 58 AddURL(profile, IndexedURLTitle(count), GURL(IndexedURL(count)))); | |
| 59 ++count; | |
| 60 } | |
| 61 private: | 54 private: |
| 62 int count; | |
| 63 DISALLOW_COPY_AND_ASSIGN(TwoClientAutofillSyncTest); | 55 DISALLOW_COPY_AND_ASSIGN(TwoClientAutofillSyncTest); |
| 64 }; | 56 }; |
| 65 | 57 |
| 66 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, WebDataServiceSanity) { | 58 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, WebDataServiceSanity) { |
| 67 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 59 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 68 | 60 |
| 69 // Client0 adds a key. | 61 // Client0 adds a key. |
| 70 std::set<AutofillKey> keys; | 62 std::set<AutofillKey> keys; |
| 71 keys.insert(AutofillKey("name0", "value0")); | 63 keys.insert(AutofillKey("name0", "value0")); |
| 72 AddKeys(0, keys); | 64 AddKeys(0, keys); |
| 73 MakeABookmarkChange(0); | |
| 74 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); | 65 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); |
| 75 ASSERT_EQ(1U, GetAllKeys(0).size()); | 66 ASSERT_EQ(1U, GetAllKeys(0).size()); |
| 76 | 67 |
| 77 // Client1 adds a key. | 68 // Client1 adds a key. |
| 78 keys.clear(); | 69 keys.clear(); |
| 79 keys.insert(AutofillKey("name1", "value1-0")); | 70 keys.insert(AutofillKey("name1", "value1-0")); |
| 80 AddKeys(1, keys); | 71 AddKeys(1, keys); |
| 81 MakeABookmarkChange(1); | |
| 82 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); | 72 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); |
| 83 ASSERT_EQ(2U, GetAllKeys(0).size()); | 73 ASSERT_EQ(2U, GetAllKeys(0).size()); |
| 84 | 74 |
| 85 // Client0 adds a key with the same name. | 75 // Client0 adds a key with the same name. |
| 86 keys.clear(); | 76 keys.clear(); |
| 87 keys.insert(AutofillKey("name1", "value1-1")); | 77 keys.insert(AutofillKey("name1", "value1-1")); |
| 88 AddKeys(0, keys); | 78 AddKeys(0, keys); |
| 89 MakeABookmarkChange(0); | |
| 90 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); | 79 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); |
| 91 ASSERT_EQ(3U, GetAllKeys(0).size()); | 80 ASSERT_EQ(3U, GetAllKeys(0).size()); |
| 92 | 81 |
| 93 // Client1 removes a key. | 82 // Client1 removes a key. |
| 94 RemoveKey(1, AutofillKey("name1", "value1-0")); | 83 RemoveKey(1, AutofillKey("name1", "value1-0")); |
| 95 MakeABookmarkChange(1); | |
| 96 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); | 84 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); |
| 97 ASSERT_EQ(2U, GetAllKeys(0).size()); | 85 ASSERT_EQ(2U, GetAllKeys(0).size()); |
| 98 | 86 |
| 99 // Client0 removes the rest. | 87 // Client0 removes the rest. |
| 100 RemoveKey(0, AutofillKey("name0", "value0")); | 88 RemoveKey(0, AutofillKey("name0", "value0")); |
| 101 RemoveKey(0, AutofillKey("name1", "value1-1")); | 89 RemoveKey(0, AutofillKey("name1", "value1-1")); |
| 102 MakeABookmarkChange(0); | |
| 103 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); | 90 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); |
| 104 ASSERT_EQ(0U, GetAllKeys(0).size()); | 91 ASSERT_EQ(0U, GetAllKeys(0).size()); |
| 105 } | 92 } |
| 106 | 93 |
| 107 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddUnicodeProfile) { | 94 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddUnicodeProfile) { |
| 108 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 95 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
| 109 | 96 |
| 110 std::set<AutofillKey> keys; | 97 std::set<AutofillKey> keys; |
| 111 keys.insert(AutofillKey(base::WideToUTF16(L"Sigur R\u00F3s"), | 98 keys.insert(AutofillKey(base::WideToUTF16(L"Sigur R\u00F3s"), |
| 112 base::WideToUTF16(L"\u00C1g\u00E6tis byrjun"))); | 99 base::WideToUTF16(L"\u00C1g\u00E6tis byrjun"))); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); | 135 ASSERT_TRUE(AutofillKeysChecker(0, 1).Wait()); |
| 149 ASSERT_EQ(5U, GetAllKeys(0).size()); | 136 ASSERT_EQ(5U, GetAllKeys(0).size()); |
| 150 } | 137 } |
| 151 | 138 |
| 152 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, | 139 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, |
| 153 PersonalDataManagerSanity) { | 140 PersonalDataManagerSanity) { |
| 154 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 141 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 155 | 142 |
| 156 // Client0 adds a profile. | 143 // Client0 adds a profile. |
| 157 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | 144 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 158 MakeABookmarkChange(0); | |
| 159 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 145 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 160 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 146 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 161 | 147 |
| 162 // Client1 adds a profile. | 148 // Client1 adds a profile. |
| 163 AddProfile(1, CreateAutofillProfile(PROFILE_MARION)); | 149 AddProfile(1, CreateAutofillProfile(PROFILE_MARION)); |
| 164 MakeABookmarkChange(1); | |
| 165 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 150 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 166 ASSERT_EQ(2U, GetAllAutoFillProfiles(0).size()); | 151 ASSERT_EQ(2U, GetAllAutoFillProfiles(0).size()); |
| 167 | 152 |
| 168 // Client0 adds the same profile. | 153 // Client0 adds the same profile. |
| 169 AddProfile(0, CreateAutofillProfile(PROFILE_MARION)); | 154 AddProfile(0, CreateAutofillProfile(PROFILE_MARION)); |
| 170 MakeABookmarkChange(0); | |
| 171 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 155 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 172 ASSERT_EQ(2U, GetAllAutoFillProfiles(0).size()); | 156 ASSERT_EQ(2U, GetAllAutoFillProfiles(0).size()); |
| 173 | 157 |
| 174 // Client1 removes a profile. | 158 // Client1 removes a profile. |
| 175 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid()); | 159 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid()); |
| 176 MakeABookmarkChange(1); | |
| 177 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 160 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 178 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 161 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 179 | 162 |
| 180 // Client0 updates a profile. | 163 // Client0 updates a profile. |
| 181 UpdateProfile(0, | 164 UpdateProfile(0, |
| 182 GetAllAutoFillProfiles(0)[0]->guid(), | 165 GetAllAutoFillProfiles(0)[0]->guid(), |
| 183 AutofillType(autofill::NAME_FIRST), | 166 AutofillType(autofill::NAME_FIRST), |
| 184 base::ASCIIToUTF16("Bart")); | 167 base::ASCIIToUTF16("Bart")); |
| 185 MakeABookmarkChange(0); | |
| 186 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 168 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 187 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 169 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 188 | 170 |
| 189 // Client1 removes remaining profile. | 171 // Client1 removes remaining profile. |
| 190 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid()); | 172 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid()); |
| 191 MakeABookmarkChange(1); | |
| 192 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 173 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 193 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size()); | 174 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size()); |
| 194 } | 175 } |
| 195 | 176 |
| 196 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddDuplicateProfiles) { | 177 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddDuplicateProfiles) { |
| 197 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 178 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
| 198 | 179 |
| 199 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | 180 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 200 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | 181 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 201 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 182 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 223 | 204 |
| 224 AddProfile(0, CreateAutofillProfile(PROFILE_NULL)); | 205 AddProfile(0, CreateAutofillProfile(PROFILE_NULL)); |
| 225 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 206 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 226 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size()); | 207 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size()); |
| 227 } | 208 } |
| 228 | 209 |
| 229 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddProfile) { | 210 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddProfile) { |
| 230 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 211 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 231 | 212 |
| 232 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | 213 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 233 MakeABookmarkChange(0); | |
| 234 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 214 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 235 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 215 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 236 } | 216 } |
| 237 | 217 |
| 238 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddMultipleProfiles) { | 218 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, AddMultipleProfiles) { |
| 239 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 219 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 240 | 220 |
| 241 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | 221 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 242 AddProfile(0, CreateAutofillProfile(PROFILE_MARION)); | 222 AddProfile(0, CreateAutofillProfile(PROFILE_MARION)); |
| 243 AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER)); | 223 AddProfile(0, CreateAutofillProfile(PROFILE_FRASIER)); |
| 244 MakeABookmarkChange(0); | |
| 245 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 224 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 246 ASSERT_EQ(3U, GetAllAutoFillProfiles(0).size()); | 225 ASSERT_EQ(3U, GetAllAutoFillProfiles(0).size()); |
| 247 } | 226 } |
| 248 | 227 |
| 249 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DeleteProfile) { | 228 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, DeleteProfile) { |
| 250 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 229 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 251 | 230 |
| 252 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | 231 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 253 MakeABookmarkChange(0); | |
| 254 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 232 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 255 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 233 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 256 | 234 |
| 257 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid()); | 235 RemoveProfile(1, GetAllAutoFillProfiles(1)[0]->guid()); |
| 258 MakeABookmarkChange(1); | |
| 259 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 236 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 260 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size()); | 237 ASSERT_EQ(0U, GetAllAutoFillProfiles(0).size()); |
| 261 } | 238 } |
| 262 | 239 |
| 263 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MergeProfiles) { | 240 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MergeProfiles) { |
| 264 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; | 241 ASSERT_TRUE(SetupClients()) << "SetupClients() failed."; |
| 265 | 242 |
| 266 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | 243 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 267 AddProfile(1, CreateAutofillProfile(PROFILE_MARION)); | 244 AddProfile(1, CreateAutofillProfile(PROFILE_MARION)); |
| 268 AddProfile(1, CreateAutofillProfile(PROFILE_FRASIER)); | 245 AddProfile(1, CreateAutofillProfile(PROFILE_FRASIER)); |
| 269 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 246 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 270 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 247 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 271 ASSERT_EQ(3U, GetAllAutoFillProfiles(0).size()); | 248 ASSERT_EQ(3U, GetAllAutoFillProfiles(0).size()); |
| 272 } | 249 } |
| 273 | 250 |
| 274 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, UpdateFields) { | 251 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, UpdateFields) { |
| 275 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 252 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 276 | 253 |
| 277 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | 254 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 278 MakeABookmarkChange(0); | |
| 279 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 255 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 280 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 256 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 281 | 257 |
| 282 UpdateProfile(0, | 258 UpdateProfile(0, |
| 283 GetAllAutoFillProfiles(0)[0]->guid(), | 259 GetAllAutoFillProfiles(0)[0]->guid(), |
| 284 AutofillType(autofill::NAME_FIRST), | 260 AutofillType(autofill::NAME_FIRST), |
| 285 base::ASCIIToUTF16("Lisa")); | 261 base::ASCIIToUTF16("Lisa")); |
| 286 UpdateProfile(0, | 262 UpdateProfile(0, |
| 287 GetAllAutoFillProfiles(0)[0]->guid(), | 263 GetAllAutoFillProfiles(0)[0]->guid(), |
| 288 AutofillType(autofill::EMAIL_ADDRESS), | 264 AutofillType(autofill::EMAIL_ADDRESS), |
| 289 base::ASCIIToUTF16("grrrl@TV.com")); | 265 base::ASCIIToUTF16("grrrl@TV.com")); |
| 290 MakeABookmarkChange(0); | |
| 291 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 266 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 292 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 267 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 293 } | 268 } |
| 294 | 269 |
| 295 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ConflictingFields) { | 270 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ConflictingFields) { |
| 296 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 271 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 297 | 272 |
| 298 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | 273 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 299 MakeABookmarkChange(0); | |
| 300 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 274 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 301 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 275 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 276 |
| 302 UpdateProfile(0, | 277 UpdateProfile(0, |
| 303 GetAllAutoFillProfiles(0)[0]->guid(), | 278 GetAllAutoFillProfiles(0)[0]->guid(), |
| 304 AutofillType(autofill::NAME_FIRST), | 279 AutofillType(autofill::NAME_FIRST), |
| 305 base::ASCIIToUTF16("Lisa")); | 280 base::ASCIIToUTF16("Lisa")); |
| 306 MakeABookmarkChange(0); | |
| 307 UpdateProfile(1, | 281 UpdateProfile(1, |
| 308 GetAllAutoFillProfiles(1)[0]->guid(), | 282 GetAllAutoFillProfiles(1)[0]->guid(), |
| 309 AutofillType(autofill::NAME_FIRST), | 283 AutofillType(autofill::NAME_FIRST), |
| 310 base::ASCIIToUTF16("Bart")); | 284 base::ASCIIToUTF16("Bart")); |
| 311 MakeABookmarkChange(1); | 285 |
| 286 // Don't care which write wins the conflict, only that the two clients agree. |
| 312 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 287 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 313 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 288 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 314 } | 289 } |
| 315 | 290 |
| 316 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MaxLength) { | 291 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, MaxLength) { |
| 317 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 292 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 318 | 293 |
| 319 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | 294 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 320 MakeABookmarkChange(0); | |
| 321 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 295 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 322 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 296 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 323 | 297 |
| 324 base::string16 max_length_string(AutofillTable::kMaxDataLength, '.'); | 298 base::string16 max_length_string(AutofillTable::kMaxDataLength, '.'); |
| 325 UpdateProfile(0, | 299 UpdateProfile(0, |
| 326 GetAllAutoFillProfiles(0)[0]->guid(), | 300 GetAllAutoFillProfiles(0)[0]->guid(), |
| 327 AutofillType(autofill::NAME_FULL), | 301 AutofillType(autofill::NAME_FULL), |
| 328 max_length_string); | 302 max_length_string); |
| 329 UpdateProfile(0, | 303 UpdateProfile(0, |
| 330 GetAllAutoFillProfiles(0)[0]->guid(), | 304 GetAllAutoFillProfiles(0)[0]->guid(), |
| 331 AutofillType(autofill::EMAIL_ADDRESS), | 305 AutofillType(autofill::EMAIL_ADDRESS), |
| 332 max_length_string); | 306 max_length_string); |
| 333 UpdateProfile(0, | 307 UpdateProfile(0, |
| 334 GetAllAutoFillProfiles(0)[0]->guid(), | 308 GetAllAutoFillProfiles(0)[0]->guid(), |
| 335 AutofillType(autofill::ADDRESS_HOME_LINE1), | 309 AutofillType(autofill::ADDRESS_HOME_LINE1), |
| 336 max_length_string); | 310 max_length_string); |
| 337 | 311 |
| 338 MakeABookmarkChange(0); | |
| 339 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 312 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 340 } | 313 } |
| 341 | 314 |
| 342 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ExceedsMaxLength) { | 315 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, ExceedsMaxLength) { |
| 343 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 316 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 344 | 317 |
| 345 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | 318 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 346 MakeABookmarkChange(0); | |
| 347 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 319 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 348 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 320 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 349 | 321 |
| 350 base::string16 exceeds_max_length_string( | 322 base::string16 exceeds_max_length_string( |
| 351 AutofillTable::kMaxDataLength + 1, '.'); | 323 AutofillTable::kMaxDataLength + 1, '.'); |
| 352 UpdateProfile(0, | 324 UpdateProfile(0, |
| 353 GetAllAutoFillProfiles(0)[0]->guid(), | 325 GetAllAutoFillProfiles(0)[0]->guid(), |
| 354 AutofillType(autofill::NAME_FIRST), | 326 AutofillType(autofill::NAME_FIRST), |
| 355 exceeds_max_length_string); | 327 exceeds_max_length_string); |
| 356 UpdateProfile(0, | 328 UpdateProfile(0, |
| 357 GetAllAutoFillProfiles(0)[0]->guid(), | 329 GetAllAutoFillProfiles(0)[0]->guid(), |
| 358 AutofillType(autofill::NAME_LAST), | 330 AutofillType(autofill::NAME_LAST), |
| 359 exceeds_max_length_string); | 331 exceeds_max_length_string); |
| 360 UpdateProfile(0, | 332 UpdateProfile(0, |
| 361 GetAllAutoFillProfiles(0)[0]->guid(), | 333 GetAllAutoFillProfiles(0)[0]->guid(), |
| 362 AutofillType(autofill::EMAIL_ADDRESS), | 334 AutofillType(autofill::EMAIL_ADDRESS), |
| 363 exceeds_max_length_string); | 335 exceeds_max_length_string); |
| 364 UpdateProfile(0, | 336 UpdateProfile(0, |
| 365 GetAllAutoFillProfiles(0)[0]->guid(), | 337 GetAllAutoFillProfiles(0)[0]->guid(), |
| 366 AutofillType(autofill::ADDRESS_HOME_LINE1), | 338 AutofillType(autofill::ADDRESS_HOME_LINE1), |
| 367 exceeds_max_length_string); | 339 exceeds_max_length_string); |
| 368 | 340 |
| 369 MakeABookmarkChange(0); | |
| 370 ASSERT_TRUE(BookmarksMatchChecker().Wait()); | 341 ASSERT_TRUE(BookmarksMatchChecker().Wait()); |
| 371 EXPECT_FALSE(ProfilesMatch(0, 1)); | 342 EXPECT_FALSE(ProfilesMatch(0, 1)); |
| 372 } | 343 } |
| 373 | 344 |
| 374 // Test credit cards don't sync. | 345 // Test credit cards don't sync. |
| 375 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, NoCreditCardSync) { | 346 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, NoCreditCardSync) { |
| 376 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 347 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 377 | 348 |
| 378 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); | |
| 379 | |
| 380 CreditCard card; | 349 CreditCard card; |
| 381 card.SetRawInfo(autofill::CREDIT_CARD_NUMBER, | 350 card.SetRawInfo(autofill::CREDIT_CARD_NUMBER, |
| 382 base::ASCIIToUTF16("6011111111111117")); | 351 base::ASCIIToUTF16("6011111111111117")); |
| 383 std::vector<CreditCard> credit_cards; | 352 std::vector<CreditCard> credit_cards{card}; |
| 384 credit_cards.push_back(card); | |
| 385 SetCreditCards(0, &credit_cards); | 353 SetCreditCards(0, &credit_cards); |
| 386 | 354 |
| 387 MakeABookmarkChange(0); | 355 AddProfile(0, CreateAutofillProfile(PROFILE_HOMER)); |
| 356 |
| 357 // Because the credit card was created before the profile, if we wait for the |
| 358 // profile to sync between both clients, it should give the credit card enough |
| 359 // time to sync. We cannot directly wait/block for the credit card to sync |
| 360 // because we're expecting it to not sync. |
| 388 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 361 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 389 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); | 362 ASSERT_EQ(1U, GetAllAutoFillProfiles(0).size()); |
| 390 | 363 |
| 391 PersonalDataManager* pdm = GetPersonalDataManager(1); | 364 PersonalDataManager* pdm = GetPersonalDataManager(1); |
| 392 ASSERT_EQ(0U, pdm->GetCreditCards().size()); | 365 ASSERT_EQ(0U, pdm->GetCreditCards().size()); |
| 393 } | 366 } |
| 394 | 367 |
| 395 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, | 368 IN_PROC_BROWSER_TEST_F(TwoClientAutofillSyncTest, |
| 396 E2E_ONLY(TwoClientsAddAutofillProfiles)) { | 369 E2E_ONLY(TwoClientsAddAutofillProfiles)) { |
| 397 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 370 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 409 AddProfile(0, CreateUniqueAutofillProfile()); | 382 AddProfile(0, CreateUniqueAutofillProfile()); |
| 410 | 383 |
| 411 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); | 384 ASSERT_TRUE(AutofillProfileChecker(0, 1).Wait()); |
| 412 | 385 |
| 413 // Check that the total number of autofill profiles is as expected | 386 // Check that the total number of autofill profiles is as expected |
| 414 for (int i = 0; i < num_clients(); ++i) { | 387 for (int i = 0; i < num_clients(); ++i) { |
| 415 ASSERT_EQ(GetProfileCount(i), init_autofill_profiles_count + 1) << | 388 ASSERT_EQ(GetProfileCount(i), init_autofill_profiles_count + 1) << |
| 416 "Total autofill profile count is wrong."; | 389 "Total autofill profile count is wrong."; |
| 417 } | 390 } |
| 418 } | 391 } |
| OLD | NEW |