| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.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" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 NotificationRegistrar registrar_; | 89 NotificationRegistrar registrar_; |
| 90 NotificationObserverMock observer_; | 90 NotificationObserverMock observer_; |
| 91 PersonalDataLoadedObserverMock personal_data_observer_; | 91 PersonalDataLoadedObserverMock personal_data_observer_; |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 TEST_F(PersonalDataManagerTest, AddProfile) { | 94 TEST_F(PersonalDataManagerTest, AddProfile) { |
| 95 AutofillProfile profile0; | 95 AutofillProfile profile0; |
| 96 autofill_test::SetProfileInfo(&profile0, | 96 autofill_test::SetProfileInfo(&profile0, |
| 97 "John", "Mitchell", "Smith", | 97 "John", "Mitchell", "Smith", |
| 98 "j@s.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", "CA", | 98 "j@s.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", "CA", |
| 99 "94102", "USA", "4158889999", "4152223333"); | 99 "94102", "USA", "4158889999"); |
| 100 | 100 |
| 101 // Add profile0 to the database. | 101 // Add profile0 to the database. |
| 102 personal_data_->AddProfile(profile0); | 102 personal_data_->AddProfile(profile0); |
| 103 | 103 |
| 104 // Reload the database. | 104 // Reload the database. |
| 105 ResetPersonalDataManager(); | 105 ResetPersonalDataManager(); |
| 106 | 106 |
| 107 // Verify the addition. | 107 // Verify the addition. |
| 108 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); | 108 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); |
| 109 ASSERT_EQ(1U, results1.size()); | 109 ASSERT_EQ(1U, results1.size()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 140 ASSERT_EQ(2U, results3.size()); | 140 ASSERT_EQ(2U, results3.size()); |
| 141 EXPECT_EQ(0, profile0.CompareMulti(*results3[0])); | 141 EXPECT_EQ(0, profile0.CompareMulti(*results3[0])); |
| 142 EXPECT_EQ(0, profile1.CompareMulti(*results3[1])); | 142 EXPECT_EQ(0, profile1.CompareMulti(*results3[1])); |
| 143 } | 143 } |
| 144 | 144 |
| 145 TEST_F(PersonalDataManagerTest, AddUpdateRemoveProfiles) { | 145 TEST_F(PersonalDataManagerTest, AddUpdateRemoveProfiles) { |
| 146 AutofillProfile profile0; | 146 AutofillProfile profile0; |
| 147 autofill_test::SetProfileInfo(&profile0, | 147 autofill_test::SetProfileInfo(&profile0, |
| 148 "Marion", "Mitchell", "Morrison", | 148 "Marion", "Mitchell", "Morrison", |
| 149 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 149 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 150 "91601", "US", "12345678910", "01987654321"); | 150 "91601", "US", "12345678910"); |
| 151 | 151 |
| 152 AutofillProfile profile1; | 152 AutofillProfile profile1; |
| 153 autofill_test::SetProfileInfo(&profile1, | 153 autofill_test::SetProfileInfo(&profile1, |
| 154 "Josephine", "Alicia", "Saenz", | 154 "Josephine", "Alicia", "Saenz", |
| 155 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", | 155 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", |
| 156 "US", "19482937549", "13502849239"); | 156 "US", "19482937549"); |
| 157 | 157 |
| 158 AutofillProfile profile2; | 158 AutofillProfile profile2; |
| 159 autofill_test::SetProfileInfo(&profile2, | 159 autofill_test::SetProfileInfo(&profile2, |
| 160 "Josephine", "Alicia", "Saenz", | 160 "Josephine", "Alicia", "Saenz", |
| 161 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 161 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
| 162 "32801", "US", "19482937549", "13502849239"); | 162 "32801", "US", "19482937549"); |
| 163 | 163 |
| 164 // Add two test profiles to the database. | 164 // Add two test profiles to the database. |
| 165 personal_data_->AddProfile(profile0); | 165 personal_data_->AddProfile(profile0); |
| 166 personal_data_->AddProfile(profile1); | 166 personal_data_->AddProfile(profile1); |
| 167 | 167 |
| 168 // Verify that the web database has been updated and the notification sent. | 168 // Verify that the web database has been updated and the notification sent. |
| 169 EXPECT_CALL(personal_data_observer_, | 169 EXPECT_CALL(personal_data_observer_, |
| 170 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 170 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 171 MessageLoop::current()->Run(); | 171 MessageLoop::current()->Run(); |
| 172 | 172 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 ASSERT_EQ(2U, results3.size()); | 256 ASSERT_EQ(2U, results3.size()); |
| 257 EXPECT_EQ(credit_card0, *results3[0]); | 257 EXPECT_EQ(credit_card0, *results3[0]); |
| 258 EXPECT_EQ(credit_card2, *results3[1]); | 258 EXPECT_EQ(credit_card2, *results3[1]); |
| 259 } | 259 } |
| 260 | 260 |
| 261 TEST_F(PersonalDataManagerTest, AddProfilesAndCreditCards) { | 261 TEST_F(PersonalDataManagerTest, AddProfilesAndCreditCards) { |
| 262 AutofillProfile profile0; | 262 AutofillProfile profile0; |
| 263 autofill_test::SetProfileInfo(&profile0, | 263 autofill_test::SetProfileInfo(&profile0, |
| 264 "Marion", "Mitchell", "Morrison", | 264 "Marion", "Mitchell", "Morrison", |
| 265 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 265 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 266 "91601", "US", "12345678910", "01987654321"); | 266 "91601", "US", "12345678910"); |
| 267 | 267 |
| 268 AutofillProfile profile1; | 268 AutofillProfile profile1; |
| 269 autofill_test::SetProfileInfo(&profile1, | 269 autofill_test::SetProfileInfo(&profile1, |
| 270 "Josephine", "Alicia", "Saenz", | 270 "Josephine", "Alicia", "Saenz", |
| 271 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", | 271 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", |
| 272 "US", "19482937549", "13502849239"); | 272 "US", "19482937549"); |
| 273 | 273 |
| 274 CreditCard credit_card0; | 274 CreditCard credit_card0; |
| 275 autofill_test::SetCreditCardInfo(&credit_card0, | 275 autofill_test::SetCreditCardInfo(&credit_card0, |
| 276 "John Dillinger", "423456789012" /* Visa */, "01", "2010"); | 276 "John Dillinger", "423456789012" /* Visa */, "01", "2010"); |
| 277 | 277 |
| 278 CreditCard credit_card1; | 278 CreditCard credit_card1; |
| 279 autofill_test::SetCreditCardInfo(&credit_card1, | 279 autofill_test::SetCreditCardInfo(&credit_card1, |
| 280 "Bonnie Parker", "518765432109" /* Mastercard */, "12", "2012"); | 280 "Bonnie Parker", "518765432109" /* Mastercard */, "12", "2012"); |
| 281 | 281 |
| 282 // Add two test profiles to the database. | 282 // Add two test profiles to the database. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 guids.insert(credit_card0.guid()); | 315 guids.insert(credit_card0.guid()); |
| 316 guids.insert(credit_card1.guid()); | 316 guids.insert(credit_card1.guid()); |
| 317 EXPECT_EQ(4U, guids.size()); | 317 EXPECT_EQ(4U, guids.size()); |
| 318 } | 318 } |
| 319 | 319 |
| 320 // Test for http://crbug.com/50047. Makes sure that guids are populated | 320 // Test for http://crbug.com/50047. Makes sure that guids are populated |
| 321 // correctly on load. | 321 // correctly on load. |
| 322 TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { | 322 TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { |
| 323 AutofillProfile profile0; | 323 AutofillProfile profile0; |
| 324 autofill_test::SetProfileInfo(&profile0, | 324 autofill_test::SetProfileInfo(&profile0, |
| 325 "y", "", "", "", "", "", "", "", "", "", "", "", ""); | 325 "y", "", "", "", "", "", "", "", "", "", "", ""); |
| 326 | 326 |
| 327 // Add the profile0 to the db. | 327 // Add the profile0 to the db. |
| 328 personal_data_->AddProfile(profile0); | 328 personal_data_->AddProfile(profile0); |
| 329 | 329 |
| 330 // Verify that the web database has been updated and the notification sent. | 330 // Verify that the web database has been updated and the notification sent. |
| 331 EXPECT_CALL(personal_data_observer_, | 331 EXPECT_CALL(personal_data_observer_, |
| 332 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 332 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 333 MessageLoop::current()->Run(); | 333 MessageLoop::current()->Run(); |
| 334 | 334 |
| 335 // Verify that we've loaded the profiles from the web database. | 335 // Verify that we've loaded the profiles from the web database. |
| 336 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); | 336 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); |
| 337 ASSERT_EQ(1U, results2.size()); | 337 ASSERT_EQ(1U, results2.size()); |
| 338 EXPECT_EQ(0, profile0.Compare(*results2[0])); | 338 EXPECT_EQ(0, profile0.Compare(*results2[0])); |
| 339 | 339 |
| 340 // Add a new profile. | 340 // Add a new profile. |
| 341 AutofillProfile profile1; | 341 AutofillProfile profile1; |
| 342 autofill_test::SetProfileInfo(&profile1, | 342 autofill_test::SetProfileInfo(&profile1, |
| 343 "z", "", "", "", "", "", "", "", "", "", "", "", ""); | 343 "z", "", "", "", "", "", "", "", "", "", "", ""); |
| 344 personal_data_->AddProfile(profile1); | 344 personal_data_->AddProfile(profile1); |
| 345 | 345 |
| 346 // Verify that the web database has been updated and the notification sent. | 346 // Verify that the web database has been updated and the notification sent. |
| 347 EXPECT_CALL(personal_data_observer_, | 347 EXPECT_CALL(personal_data_observer_, |
| 348 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 348 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 349 MessageLoop::current()->Run(); | 349 MessageLoop::current()->Run(); |
| 350 | 350 |
| 351 // Make sure the two profiles have different GUIDs, both valid. | 351 // Make sure the two profiles have different GUIDs, both valid. |
| 352 const std::vector<AutofillProfile*>& results3 = personal_data_->profiles(); | 352 const std::vector<AutofillProfile*>& results3 = personal_data_->profiles(); |
| 353 ASSERT_EQ(2U, results3.size()); | 353 ASSERT_EQ(2U, results3.size()); |
| 354 EXPECT_NE(results3[0]->guid(), results3[1]->guid()); | 354 EXPECT_NE(results3[0]->guid(), results3[1]->guid()); |
| 355 EXPECT_TRUE(guid::IsValidGUID(results3[0]->guid())); | 355 EXPECT_TRUE(guid::IsValidGUID(results3[0]->guid())); |
| 356 EXPECT_TRUE(guid::IsValidGUID(results3[1]->guid())); | 356 EXPECT_TRUE(guid::IsValidGUID(results3[1]->guid())); |
| 357 } | 357 } |
| 358 | 358 |
| 359 TEST_F(PersonalDataManagerTest, SetEmptyProfile) { | 359 TEST_F(PersonalDataManagerTest, SetEmptyProfile) { |
| 360 AutofillProfile profile0; | 360 AutofillProfile profile0; |
| 361 autofill_test::SetProfileInfo(&profile0, | 361 autofill_test::SetProfileInfo(&profile0, |
| 362 "", "", "", "", "", "", "", "", "", "", "", "", ""); | 362 "", "", "", "", "", "", "", "", "", "", "", ""); |
| 363 | 363 |
| 364 // Add the empty profile to the database. | 364 // Add the empty profile to the database. |
| 365 personal_data_->AddProfile(profile0); | 365 personal_data_->AddProfile(profile0); |
| 366 | 366 |
| 367 // Note: no refresh here. | 367 // Note: no refresh here. |
| 368 | 368 |
| 369 // Reset the PersonalDataManager. This tests that the personal data was saved | 369 // Reset the PersonalDataManager. This tests that the personal data was saved |
| 370 // to the web database, and that we can load the profiles from the web | 370 // to the web database, and that we can load the profiles from the web |
| 371 // database. | 371 // database. |
| 372 ResetPersonalDataManager(); | 372 ResetPersonalDataManager(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 393 // Verify that we've loaded the credit cards from the web database. | 393 // Verify that we've loaded the credit cards from the web database. |
| 394 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); | 394 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); |
| 395 ASSERT_EQ(0U, results2.size()); | 395 ASSERT_EQ(0U, results2.size()); |
| 396 } | 396 } |
| 397 | 397 |
| 398 TEST_F(PersonalDataManagerTest, Refresh) { | 398 TEST_F(PersonalDataManagerTest, Refresh) { |
| 399 AutofillProfile profile0; | 399 AutofillProfile profile0; |
| 400 autofill_test::SetProfileInfo(&profile0, | 400 autofill_test::SetProfileInfo(&profile0, |
| 401 "Marion", "Mitchell", "Morrison", | 401 "Marion", "Mitchell", "Morrison", |
| 402 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", | 402 "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", |
| 403 "91601", "US", "12345678910", "01987654321"); | 403 "91601", "US", "12345678910"); |
| 404 | 404 |
| 405 AutofillProfile profile1; | 405 AutofillProfile profile1; |
| 406 autofill_test::SetProfileInfo(&profile1, | 406 autofill_test::SetProfileInfo(&profile1, |
| 407 "Josephine", "Alicia", "Saenz", | 407 "Josephine", "Alicia", "Saenz", |
| 408 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", | 408 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", |
| 409 "US", "19482937549", "13502849239"); | 409 "US", "19482937549"); |
| 410 | 410 |
| 411 // Add the test profiles to the database. | 411 // Add the test profiles to the database. |
| 412 personal_data_->AddProfile(profile0); | 412 personal_data_->AddProfile(profile0); |
| 413 personal_data_->AddProfile(profile1); | 413 personal_data_->AddProfile(profile1); |
| 414 | 414 |
| 415 // Labels depend on other profiles in the list - update labels manually. | 415 // Labels depend on other profiles in the list - update labels manually. |
| 416 std::vector<AutofillProfile *> profile_pointers; | 416 std::vector<AutofillProfile *> profile_pointers; |
| 417 profile_pointers.push_back(&profile0); | 417 profile_pointers.push_back(&profile0); |
| 418 profile_pointers.push_back(&profile1); | 418 profile_pointers.push_back(&profile1); |
| 419 AutofillProfile::AdjustInferredLabels(&profile_pointers); | 419 AutofillProfile::AdjustInferredLabels(&profile_pointers); |
| 420 | 420 |
| 421 // Verify that the web database has been updated and the notification sent. | 421 // Verify that the web database has been updated and the notification sent. |
| 422 EXPECT_CALL(personal_data_observer_, | 422 EXPECT_CALL(personal_data_observer_, |
| 423 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 423 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 424 MessageLoop::current()->Run(); | 424 MessageLoop::current()->Run(); |
| 425 | 425 |
| 426 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); | 426 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); |
| 427 ASSERT_EQ(2U, results1.size()); | 427 ASSERT_EQ(2U, results1.size()); |
| 428 EXPECT_EQ(profile0, *results1[0]); | 428 EXPECT_EQ(profile0, *results1[0]); |
| 429 EXPECT_EQ(profile1, *results1[1]); | 429 EXPECT_EQ(profile1, *results1[1]); |
| 430 | 430 |
| 431 AutofillProfile profile2; | 431 AutofillProfile profile2; |
| 432 autofill_test::SetProfileInfo(&profile2, | 432 autofill_test::SetProfileInfo(&profile2, |
| 433 "Josephine", "Alicia", "Saenz", | 433 "Josephine", "Alicia", "Saenz", |
| 434 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 434 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
| 435 "32801", "US", "19482937549", "13502849239"); | 435 "32801", "US", "19482937549"); |
| 436 | 436 |
| 437 // Adjust all labels. | 437 // Adjust all labels. |
| 438 profile_pointers.push_back(&profile2); | 438 profile_pointers.push_back(&profile2); |
| 439 AutofillProfile::AdjustInferredLabels(&profile_pointers); | 439 AutofillProfile::AdjustInferredLabels(&profile_pointers); |
| 440 | 440 |
| 441 WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); | 441 WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); |
| 442 ASSERT_TRUE(wds); | 442 ASSERT_TRUE(wds); |
| 443 wds->AddAutofillProfile(profile2); | 443 wds->AddAutofillProfile(profile2); |
| 444 | 444 |
| 445 personal_data_->Refresh(); | 445 personal_data_->Refresh(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 ASSERT_FALSE(imported_credit_card); | 510 ASSERT_FALSE(imported_credit_card); |
| 511 | 511 |
| 512 // Verify that the web database has been updated and the notification sent. | 512 // Verify that the web database has been updated and the notification sent. |
| 513 EXPECT_CALL(personal_data_observer_, | 513 EXPECT_CALL(personal_data_observer_, |
| 514 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 514 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 515 MessageLoop::current()->Run(); | 515 MessageLoop::current()->Run(); |
| 516 | 516 |
| 517 AutofillProfile expected; | 517 AutofillProfile expected; |
| 518 autofill_test::SetProfileInfo(&expected, "George", NULL, | 518 autofill_test::SetProfileInfo(&expected, "George", NULL, |
| 519 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, | 519 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, |
| 520 "San Francisco", "California", "94102", NULL, NULL, NULL); | 520 "San Francisco", "California", "94102", NULL, NULL); |
| 521 const std::vector<AutofillProfile*>& results = personal_data_->profiles(); | 521 const std::vector<AutofillProfile*>& results = personal_data_->profiles(); |
| 522 ASSERT_EQ(1U, results.size()); | 522 ASSERT_EQ(1U, results.size()); |
| 523 EXPECT_EQ(0, expected.Compare(*results[0])); | 523 EXPECT_EQ(0, expected.Compare(*results[0])); |
| 524 } | 524 } |
| 525 | 525 |
| 526 TEST_F(PersonalDataManagerTest, ImportFormDataBadEmail) { | 526 TEST_F(PersonalDataManagerTest, ImportFormDataBadEmail) { |
| 527 FormData form; | 527 FormData form; |
| 528 webkit_glue::FormField field; | 528 webkit_glue::FormField field; |
| 529 autofill_test::CreateTestFormField( | 529 autofill_test::CreateTestFormField( |
| 530 "First name:", "first_name", "George", "text", &field); | 530 "First name:", "first_name", "George", "text", &field); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 ASSERT_FALSE(imported_credit_card); | 624 ASSERT_FALSE(imported_credit_card); |
| 625 | 625 |
| 626 // Verify that the web database has been updated and the notification sent. | 626 // Verify that the web database has been updated and the notification sent. |
| 627 EXPECT_CALL(personal_data_observer_, | 627 EXPECT_CALL(personal_data_observer_, |
| 628 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 628 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 629 MessageLoop::current()->Run(); | 629 MessageLoop::current()->Run(); |
| 630 | 630 |
| 631 AutofillProfile expected; | 631 AutofillProfile expected; |
| 632 autofill_test::SetProfileInfo(&expected, "George", NULL, | 632 autofill_test::SetProfileInfo(&expected, "George", NULL, |
| 633 "Washington", NULL, NULL, "21 Laussat St", NULL, | 633 "Washington", NULL, NULL, "21 Laussat St", NULL, |
| 634 "San Francisco", "California", "94102", NULL, "6505550000", NULL); | 634 "San Francisco", "California", "94102", NULL, "6505550000"); |
| 635 const std::vector<AutofillProfile*>& results = personal_data_->profiles(); | 635 const std::vector<AutofillProfile*>& results = personal_data_->profiles(); |
| 636 ASSERT_EQ(1U, results.size()); | 636 ASSERT_EQ(1U, results.size()); |
| 637 EXPECT_EQ(0, expected.Compare(*results[0])); | 637 EXPECT_EQ(0, expected.Compare(*results[0])); |
| 638 } | 638 } |
| 639 | 639 |
| 640 TEST_F(PersonalDataManagerTest, SetUniqueCreditCardLabels) { | 640 TEST_F(PersonalDataManagerTest, SetUniqueCreditCardLabels) { |
| 641 CreditCard credit_card0; | 641 CreditCard credit_card0; |
| 642 credit_card0.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("John")); | 642 credit_card0.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("John")); |
| 643 CreditCard credit_card1; | 643 CreditCard credit_card1; |
| 644 credit_card1.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Paul")); | 644 credit_card1.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Paul")); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 ASSERT_FALSE(imported_credit_card); | 707 ASSERT_FALSE(imported_credit_card); |
| 708 | 708 |
| 709 // Verify that the web database has been updated and the notification sent. | 709 // Verify that the web database has been updated and the notification sent. |
| 710 EXPECT_CALL(personal_data_observer_, | 710 EXPECT_CALL(personal_data_observer_, |
| 711 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 711 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 712 MessageLoop::current()->Run(); | 712 MessageLoop::current()->Run(); |
| 713 | 713 |
| 714 AutofillProfile expected; | 714 AutofillProfile expected; |
| 715 autofill_test::SetProfileInfo(&expected, "George", NULL, | 715 autofill_test::SetProfileInfo(&expected, "George", NULL, |
| 716 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, | 716 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, |
| 717 "San Francisco", "California", "94102", NULL, NULL, NULL); | 717 "San Francisco", "California", "94102", NULL, NULL); |
| 718 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); | 718 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); |
| 719 ASSERT_EQ(1U, results1.size()); | 719 ASSERT_EQ(1U, results1.size()); |
| 720 EXPECT_EQ(0, expected.Compare(*results1[0])); | 720 EXPECT_EQ(0, expected.Compare(*results1[0])); |
| 721 | 721 |
| 722 // Now create a completely different profile. | 722 // Now create a completely different profile. |
| 723 FormData form2; | 723 FormData form2; |
| 724 autofill_test::CreateTestFormField( | 724 autofill_test::CreateTestFormField( |
| 725 "First name:", "first_name", "John", "text", &field); | 725 "First name:", "first_name", "John", "text", &field); |
| 726 form2.fields.push_back(field); | 726 form2.fields.push_back(field); |
| 727 autofill_test::CreateTestFormField( | 727 autofill_test::CreateTestFormField( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 752 // Verify that the web database has been updated and the notification sent. | 752 // Verify that the web database has been updated and the notification sent. |
| 753 EXPECT_CALL(personal_data_observer_, | 753 EXPECT_CALL(personal_data_observer_, |
| 754 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 754 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 755 MessageLoop::current()->Run(); | 755 MessageLoop::current()->Run(); |
| 756 | 756 |
| 757 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); | 757 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); |
| 758 | 758 |
| 759 AutofillProfile expected2; | 759 AutofillProfile expected2; |
| 760 autofill_test::SetProfileInfo(&expected2, "John", NULL, | 760 autofill_test::SetProfileInfo(&expected2, "John", NULL, |
| 761 "Adams", "second@gmail.com", NULL, "22 Laussat St", NULL, | 761 "Adams", "second@gmail.com", NULL, "22 Laussat St", NULL, |
| 762 "San Francisco", "California", "94102", NULL, NULL, NULL); | 762 "San Francisco", "California", "94102", NULL, NULL); |
| 763 ASSERT_EQ(2U, results2.size()); | 763 ASSERT_EQ(2U, results2.size()); |
| 764 EXPECT_EQ(0, expected.Compare(*results2[0])); | 764 EXPECT_EQ(0, expected.Compare(*results2[0])); |
| 765 EXPECT_EQ(0, expected2.Compare(*results2[1])); | 765 EXPECT_EQ(0, expected2.Compare(*results2[1])); |
| 766 } | 766 } |
| 767 | 767 |
| 768 TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) { | 768 TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) { |
| 769 FormData form1; | 769 FormData form1; |
| 770 webkit_glue::FormField field; | 770 webkit_glue::FormField field; |
| 771 autofill_test::CreateTestFormField( | 771 autofill_test::CreateTestFormField( |
| 772 "First name:", "first_name", "George", "text", &field); | 772 "First name:", "first_name", "George", "text", &field); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 798 ASSERT_FALSE(imported_credit_card); | 798 ASSERT_FALSE(imported_credit_card); |
| 799 | 799 |
| 800 // Verify that the web database has been updated and the notification sent. | 800 // Verify that the web database has been updated and the notification sent. |
| 801 EXPECT_CALL(personal_data_observer_, | 801 EXPECT_CALL(personal_data_observer_, |
| 802 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 802 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 803 MessageLoop::current()->Run(); | 803 MessageLoop::current()->Run(); |
| 804 | 804 |
| 805 AutofillProfile expected; | 805 AutofillProfile expected; |
| 806 autofill_test::SetProfileInfo(&expected, "George", NULL, | 806 autofill_test::SetProfileInfo(&expected, "George", NULL, |
| 807 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, | 807 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, |
| 808 "San Francisco", "California", "94102", NULL, NULL, NULL); | 808 "San Francisco", "California", "94102", NULL, NULL); |
| 809 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); | 809 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); |
| 810 ASSERT_EQ(1U, results1.size()); | 810 ASSERT_EQ(1U, results1.size()); |
| 811 EXPECT_EQ(0, expected.Compare(*results1[0])); | 811 EXPECT_EQ(0, expected.Compare(*results1[0])); |
| 812 | 812 |
| 813 // Now create a completely different profile. | 813 // Now create a completely different profile. |
| 814 FormData form2; | 814 FormData form2; |
| 815 autofill_test::CreateTestFormField( | 815 autofill_test::CreateTestFormField( |
| 816 "First name:", "first_name", "John", "text", &field); | 816 "First name:", "first_name", "John", "text", &field); |
| 817 form2.fields.push_back(field); | 817 form2.fields.push_back(field); |
| 818 autofill_test::CreateTestFormField( | 818 autofill_test::CreateTestFormField( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 ASSERT_FALSE(imported_credit_card); | 900 ASSERT_FALSE(imported_credit_card); |
| 901 | 901 |
| 902 // Verify that the web database has been updated and the notification sent. | 902 // Verify that the web database has been updated and the notification sent. |
| 903 EXPECT_CALL(personal_data_observer_, | 903 EXPECT_CALL(personal_data_observer_, |
| 904 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 904 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 905 MessageLoop::current()->Run(); | 905 MessageLoop::current()->Run(); |
| 906 | 906 |
| 907 AutofillProfile expected; | 907 AutofillProfile expected; |
| 908 autofill_test::SetProfileInfo(&expected, "George", NULL, | 908 autofill_test::SetProfileInfo(&expected, "George", NULL, |
| 909 "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue", | 909 "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue", |
| 910 "Suite A", "San Francisco", "California", "94102", NULL, "4085556666", | 910 "Suite A", "San Francisco", "California", "94102", NULL, "4085556666"); |
| 911 NULL); | |
| 912 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); | 911 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); |
| 913 ASSERT_EQ(1U, results1.size()); | 912 ASSERT_EQ(1U, results1.size()); |
| 914 EXPECT_EQ(0, expected.Compare(*results1[0])); | 913 EXPECT_EQ(0, expected.Compare(*results1[0])); |
| 915 | 914 |
| 916 // Now create an updated profile. | 915 // Now create an updated profile. |
| 917 FormData form2; | 916 FormData form2; |
| 918 autofill_test::CreateTestFormField( | 917 autofill_test::CreateTestFormField( |
| 919 "First name:", "first_name", "George", "text", &field); | 918 "First name:", "first_name", "George", "text", &field); |
| 920 form2.fields.push_back(field); | 919 form2.fields.push_back(field); |
| 921 autofill_test::CreateTestFormField( | 920 autofill_test::CreateTestFormField( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 ASSERT_FALSE(imported_credit_card); | 1000 ASSERT_FALSE(imported_credit_card); |
| 1002 | 1001 |
| 1003 // Verify that the web database has been updated and the notification sent. | 1002 // Verify that the web database has been updated and the notification sent. |
| 1004 EXPECT_CALL(personal_data_observer_, | 1003 EXPECT_CALL(personal_data_observer_, |
| 1005 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1004 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 1006 MessageLoop::current()->Run(); | 1005 MessageLoop::current()->Run(); |
| 1007 | 1006 |
| 1008 AutofillProfile expected; | 1007 AutofillProfile expected; |
| 1009 autofill_test::SetProfileInfo(&expected, "George", NULL, | 1008 autofill_test::SetProfileInfo(&expected, "George", NULL, |
| 1010 "Washington", NULL, NULL, "190 High Street", NULL, | 1009 "Washington", NULL, NULL, "190 High Street", NULL, |
| 1011 "Philadelphia", "Pennsylvania", "19106", NULL, NULL, NULL); | 1010 "Philadelphia", "Pennsylvania", "19106", NULL, NULL); |
| 1012 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); | 1011 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); |
| 1013 ASSERT_EQ(1U, results1.size()); | 1012 ASSERT_EQ(1U, results1.size()); |
| 1014 EXPECT_EQ(0, expected.Compare(*results1[0])); | 1013 EXPECT_EQ(0, expected.Compare(*results1[0])); |
| 1015 | 1014 |
| 1016 // Submit a form with new data for the first profile. | 1015 // Submit a form with new data for the first profile. |
| 1017 FormData form2; | 1016 FormData form2; |
| 1018 autofill_test::CreateTestFormField( | 1017 autofill_test::CreateTestFormField( |
| 1019 "First name:", "first_name", "George", "text", &field); | 1018 "First name:", "first_name", "George", "text", &field); |
| 1020 form2.fields.push_back(field); | 1019 form2.fields.push_back(field); |
| 1021 autofill_test::CreateTestFormField( | 1020 autofill_test::CreateTestFormField( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1046 // Verify that the web database has been updated and the notification sent. | 1045 // Verify that the web database has been updated and the notification sent. |
| 1047 EXPECT_CALL(personal_data_observer_, | 1046 EXPECT_CALL(personal_data_observer_, |
| 1048 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1047 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 1049 MessageLoop::current()->Run(); | 1048 MessageLoop::current()->Run(); |
| 1050 | 1049 |
| 1051 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); | 1050 const std::vector<AutofillProfile*>& results2 = personal_data_->profiles(); |
| 1052 | 1051 |
| 1053 AutofillProfile expected2; | 1052 AutofillProfile expected2; |
| 1054 autofill_test::SetProfileInfo(&expected2, "George", NULL, | 1053 autofill_test::SetProfileInfo(&expected2, "George", NULL, |
| 1055 "Washington", "theprez@gmail.com", NULL, "190 High Street", NULL, | 1054 "Washington", "theprez@gmail.com", NULL, "190 High Street", NULL, |
| 1056 "Philadelphia", "Pennsylvania", "19106", NULL, NULL, NULL); | 1055 "Philadelphia", "Pennsylvania", "19106", NULL, NULL); |
| 1057 ASSERT_EQ(1U, results2.size()); | 1056 ASSERT_EQ(1U, results2.size()); |
| 1058 EXPECT_EQ(0, expected2.Compare(*results2[0])); | 1057 EXPECT_EQ(0, expected2.Compare(*results2[0])); |
| 1059 } | 1058 } |
| 1060 | 1059 |
| 1061 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInNew) { | 1060 TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInNew) { |
| 1062 FormData form1; | 1061 FormData form1; |
| 1063 webkit_glue::FormField field; | 1062 webkit_glue::FormField field; |
| 1064 autofill_test::CreateTestFormField( | 1063 autofill_test::CreateTestFormField( |
| 1065 "First name:", "first_name", "George", "text", &field); | 1064 "First name:", "first_name", "George", "text", &field); |
| 1066 form1.fields.push_back(field); | 1065 form1.fields.push_back(field); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1094 ASSERT_FALSE(imported_credit_card); | 1093 ASSERT_FALSE(imported_credit_card); |
| 1095 | 1094 |
| 1096 // Verify that the web database has been updated and the notification sent. | 1095 // Verify that the web database has been updated and the notification sent. |
| 1097 EXPECT_CALL(personal_data_observer_, | 1096 EXPECT_CALL(personal_data_observer_, |
| 1098 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1097 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 1099 MessageLoop::current()->Run(); | 1098 MessageLoop::current()->Run(); |
| 1100 | 1099 |
| 1101 AutofillProfile expected; | 1100 AutofillProfile expected; |
| 1102 autofill_test::SetProfileInfo(&expected, "George", NULL, | 1101 autofill_test::SetProfileInfo(&expected, "George", NULL, |
| 1103 "Washington", "theprez@gmail.com", "Government", "190 High Street", NULL, | 1102 "Washington", "theprez@gmail.com", "Government", "190 High Street", NULL, |
| 1104 "Philadelphia", "Pennsylvania", "19106", NULL, NULL, NULL); | 1103 "Philadelphia", "Pennsylvania", "19106", NULL, NULL); |
| 1105 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); | 1104 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); |
| 1106 ASSERT_EQ(1U, results1.size()); | 1105 ASSERT_EQ(1U, results1.size()); |
| 1107 EXPECT_EQ(0, expected.Compare(*results1[0])); | 1106 EXPECT_EQ(0, expected.Compare(*results1[0])); |
| 1108 | 1107 |
| 1109 // Submit a form with new data for the first profile. | 1108 // Submit a form with new data for the first profile. |
| 1110 FormData form2; | 1109 FormData form2; |
| 1111 autofill_test::CreateTestFormField( | 1110 autofill_test::CreateTestFormField( |
| 1112 "First name:", "first_name", "George", "text", &field); | 1111 "First name:", "first_name", "George", "text", &field); |
| 1113 form2.fields.push_back(field); | 1112 form2.fields.push_back(field); |
| 1114 autofill_test::CreateTestFormField( | 1113 autofill_test::CreateTestFormField( |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 // Check that there are no available types with no profiles stored. | 1633 // Check that there are no available types with no profiles stored. |
| 1635 FieldTypeSet non_empty_types; | 1634 FieldTypeSet non_empty_types; |
| 1636 personal_data_->GetNonEmptyTypes(&non_empty_types); | 1635 personal_data_->GetNonEmptyTypes(&non_empty_types); |
| 1637 EXPECT_EQ(0U, non_empty_types.size()); | 1636 EXPECT_EQ(0U, non_empty_types.size()); |
| 1638 | 1637 |
| 1639 // Test with one profile stored. | 1638 // Test with one profile stored. |
| 1640 AutofillProfile profile0; | 1639 AutofillProfile profile0; |
| 1641 autofill_test::SetProfileInfo(&profile0, | 1640 autofill_test::SetProfileInfo(&profile0, |
| 1642 "Marion", NULL, "Morrison", | 1641 "Marion", NULL, "Morrison", |
| 1643 "johnwayne@me.xyz", NULL, "123 Zoo St.", NULL, "Hollywood", "CA", | 1642 "johnwayne@me.xyz", NULL, "123 Zoo St.", NULL, "Hollywood", "CA", |
| 1644 "91601", "US", "14155678910", NULL); | 1643 "91601", "US", "14155678910"); |
| 1645 | 1644 |
| 1646 personal_data_->AddProfile(profile0); | 1645 personal_data_->AddProfile(profile0); |
| 1647 | 1646 |
| 1648 // Verify that the web database has been updated and the notification sent. | 1647 // Verify that the web database has been updated and the notification sent. |
| 1649 EXPECT_CALL(personal_data_observer_, | 1648 EXPECT_CALL(personal_data_observer_, |
| 1650 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1649 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 1651 MessageLoop::current()->Run(); | 1650 MessageLoop::current()->Run(); |
| 1652 | 1651 |
| 1653 personal_data_->GetNonEmptyTypes(&non_empty_types); | 1652 personal_data_->GetNonEmptyTypes(&non_empty_types); |
| 1654 EXPECT_EQ(14U, non_empty_types.size()); | 1653 EXPECT_EQ(14U, non_empty_types.size()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1665 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_COUNTRY_CODE)); | 1664 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_COUNTRY_CODE)); |
| 1666 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE)); | 1665 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE)); |
| 1667 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); | 1666 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); |
| 1668 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); | 1667 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); |
| 1669 | 1668 |
| 1670 // Test with multiple profiles stored. | 1669 // Test with multiple profiles stored. |
| 1671 AutofillProfile profile1; | 1670 AutofillProfile profile1; |
| 1672 autofill_test::SetProfileInfo(&profile1, | 1671 autofill_test::SetProfileInfo(&profile1, |
| 1673 "Josephine", "Alicia", "Saenz", | 1672 "Josephine", "Alicia", "Saenz", |
| 1674 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", | 1673 "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", |
| 1675 "US", "16502937549", "14082849239"); | 1674 "US", "16502937549"); |
| 1676 | 1675 |
| 1677 AutofillProfile profile2; | 1676 AutofillProfile profile2; |
| 1678 autofill_test::SetProfileInfo(&profile2, | 1677 autofill_test::SetProfileInfo(&profile2, |
| 1679 "Josephine", "Alicia", "Saenz", | 1678 "Josephine", "Alicia", "Saenz", |
| 1680 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 1679 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
| 1681 "32801", "US", "16502937549", "14152849239"); | 1680 "32801", "US", "16502937549"); |
| 1682 | 1681 |
| 1683 personal_data_->AddProfile(profile1); | 1682 personal_data_->AddProfile(profile1); |
| 1684 personal_data_->AddProfile(profile2); | 1683 personal_data_->AddProfile(profile2); |
| 1685 | 1684 |
| 1686 // Verify that the web database has been updated and the notification sent. | 1685 // Verify that the web database has been updated and the notification sent. |
| 1687 EXPECT_CALL(personal_data_observer_, | 1686 EXPECT_CALL(personal_data_observer_, |
| 1688 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1687 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 1689 MessageLoop::current()->Run(); | 1688 MessageLoop::current()->Run(); |
| 1690 | 1689 |
| 1691 personal_data_->GetNonEmptyTypes(&non_empty_types); | 1690 personal_data_->GetNonEmptyTypes(&non_empty_types); |
| 1692 EXPECT_EQ(23U, non_empty_types.size()); | 1691 EXPECT_EQ(18U, non_empty_types.size()); |
| 1693 EXPECT_TRUE(non_empty_types.count(NAME_FIRST)); | 1692 EXPECT_TRUE(non_empty_types.count(NAME_FIRST)); |
| 1694 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE)); | 1693 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE)); |
| 1695 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE_INITIAL)); | 1694 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE_INITIAL)); |
| 1696 EXPECT_TRUE(non_empty_types.count(NAME_LAST)); | 1695 EXPECT_TRUE(non_empty_types.count(NAME_LAST)); |
| 1697 EXPECT_TRUE(non_empty_types.count(NAME_FULL)); | 1696 EXPECT_TRUE(non_empty_types.count(NAME_FULL)); |
| 1698 EXPECT_TRUE(non_empty_types.count(EMAIL_ADDRESS)); | 1697 EXPECT_TRUE(non_empty_types.count(EMAIL_ADDRESS)); |
| 1699 EXPECT_TRUE(non_empty_types.count(COMPANY_NAME)); | 1698 EXPECT_TRUE(non_empty_types.count(COMPANY_NAME)); |
| 1700 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE1)); | 1699 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE1)); |
| 1701 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE2)); | 1700 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE2)); |
| 1702 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_CITY)); | 1701 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_CITY)); |
| 1703 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STATE)); | 1702 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STATE)); |
| 1704 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_ZIP)); | 1703 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_ZIP)); |
| 1705 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_COUNTRY)); | 1704 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_COUNTRY)); |
| 1706 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_NUMBER)); | 1705 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_NUMBER)); |
| 1707 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE)); | 1706 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE)); |
| 1708 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_COUNTRY_CODE)); | 1707 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_COUNTRY_CODE)); |
| 1709 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); | 1708 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); |
| 1710 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); | 1709 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); |
| 1711 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_NUMBER)); | |
| 1712 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_CITY_CODE)); | |
| 1713 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_COUNTRY_CODE)); | |
| 1714 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_CITY_AND_NUMBER)); | |
| 1715 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_WHOLE_NUMBER)); | |
| 1716 | 1710 |
| 1717 // Test with credit card information also stored. | 1711 // Test with credit card information also stored. |
| 1718 CreditCard credit_card; | 1712 CreditCard credit_card; |
| 1719 autofill_test::SetCreditCardInfo(&credit_card, | 1713 autofill_test::SetCreditCardInfo(&credit_card, |
| 1720 "John Dillinger", "423456789012" /* Visa */, | 1714 "John Dillinger", "423456789012" /* Visa */, |
| 1721 "01", "2010"); | 1715 "01", "2010"); |
| 1722 personal_data_->AddCreditCard(credit_card); | 1716 personal_data_->AddCreditCard(credit_card); |
| 1723 | 1717 |
| 1724 // Verify that the web database has been updated and the notification sent. | 1718 // Verify that the web database has been updated and the notification sent. |
| 1725 EXPECT_CALL(personal_data_observer_, | 1719 EXPECT_CALL(personal_data_observer_, |
| 1726 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1720 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 1727 MessageLoop::current()->Run(); | 1721 MessageLoop::current()->Run(); |
| 1728 | 1722 |
| 1729 personal_data_->GetNonEmptyTypes(&non_empty_types); | 1723 personal_data_->GetNonEmptyTypes(&non_empty_types); |
| 1730 EXPECT_EQ(30U, non_empty_types.size()); | 1724 EXPECT_EQ(25U, non_empty_types.size()); |
| 1731 EXPECT_TRUE(non_empty_types.count(NAME_FIRST)); | 1725 EXPECT_TRUE(non_empty_types.count(NAME_FIRST)); |
| 1732 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE)); | 1726 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE)); |
| 1733 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE_INITIAL)); | 1727 EXPECT_TRUE(non_empty_types.count(NAME_MIDDLE_INITIAL)); |
| 1734 EXPECT_TRUE(non_empty_types.count(NAME_LAST)); | 1728 EXPECT_TRUE(non_empty_types.count(NAME_LAST)); |
| 1735 EXPECT_TRUE(non_empty_types.count(NAME_FULL)); | 1729 EXPECT_TRUE(non_empty_types.count(NAME_FULL)); |
| 1736 EXPECT_TRUE(non_empty_types.count(EMAIL_ADDRESS)); | 1730 EXPECT_TRUE(non_empty_types.count(EMAIL_ADDRESS)); |
| 1737 EXPECT_TRUE(non_empty_types.count(COMPANY_NAME)); | 1731 EXPECT_TRUE(non_empty_types.count(COMPANY_NAME)); |
| 1738 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE1)); | 1732 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE1)); |
| 1739 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE2)); | 1733 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_LINE2)); |
| 1740 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_CITY)); | 1734 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_CITY)); |
| 1741 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STATE)); | 1735 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STATE)); |
| 1742 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_ZIP)); | 1736 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_ZIP)); |
| 1743 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_COUNTRY)); | 1737 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_COUNTRY)); |
| 1744 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_NUMBER)); | 1738 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_NUMBER)); |
| 1745 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE)); | 1739 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE)); |
| 1746 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_COUNTRY_CODE)); | 1740 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_COUNTRY_CODE)); |
| 1747 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); | 1741 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); |
| 1748 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); | 1742 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); |
| 1749 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_NUMBER)); | |
| 1750 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_CITY_CODE)); | |
| 1751 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_COUNTRY_CODE)); | |
| 1752 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_CITY_AND_NUMBER)); | |
| 1753 EXPECT_TRUE(non_empty_types.count(PHONE_FAX_WHOLE_NUMBER)); | |
| 1754 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME)); | 1743 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME)); |
| 1755 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER)); | 1744 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER)); |
| 1756 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH)); | 1745 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH)); |
| 1757 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR)); | 1746 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR)); |
| 1758 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 1747 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 1759 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)); | 1748 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)); |
| 1760 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); | 1749 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); |
| 1761 } | 1750 } |
| 1762 | 1751 |
| 1763 TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) { | 1752 TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1796 ASSERT_FALSE(imported_credit_card); | 1785 ASSERT_FALSE(imported_credit_card); |
| 1797 | 1786 |
| 1798 // Verify that the web database has been updated and the notification sent. | 1787 // Verify that the web database has been updated and the notification sent. |
| 1799 EXPECT_CALL(personal_data_observer_, | 1788 EXPECT_CALL(personal_data_observer_, |
| 1800 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); | 1789 OnPersonalDataChanged()).WillOnce(QuitUIMessageLoop()); |
| 1801 MessageLoop::current()->Run(); | 1790 MessageLoop::current()->Run(); |
| 1802 | 1791 |
| 1803 AutofillProfile expected; | 1792 AutofillProfile expected; |
| 1804 autofill_test::SetProfileInfo(&expected, "George", NULL, | 1793 autofill_test::SetProfileInfo(&expected, "George", NULL, |
| 1805 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, | 1794 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, |
| 1806 "San Francisco", "California", "94102", NULL, "817-555-6789", NULL); | 1795 "San Francisco", "California", "94102", NULL, "817-555-6789"); |
| 1807 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); | 1796 const std::vector<AutofillProfile*>& results1 = personal_data_->profiles(); |
| 1808 ASSERT_EQ(1U, results1.size()); | 1797 ASSERT_EQ(1U, results1.size()); |
| 1809 EXPECT_EQ(0, expected.Compare(*results1[0])); | 1798 EXPECT_EQ(0, expected.Compare(*results1[0])); |
| 1810 | 1799 |
| 1811 // Upper-case the first name and change the phone number. | 1800 // Upper-case the first name and change the phone number. |
| 1812 FormData form2; | 1801 FormData form2; |
| 1813 autofill_test::CreateTestFormField( | 1802 autofill_test::CreateTestFormField( |
| 1814 "First name:", "first_name", "GEORGE", "text", &field); | 1803 "First name:", "first_name", "GEORGE", "text", &field); |
| 1815 form2.fields.push_back(field); | 1804 form2.fields.push_back(field); |
| 1816 autofill_test::CreateTestFormField( | 1805 autofill_test::CreateTestFormField( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1850 | 1839 |
| 1851 // Modify expected to include multi-valued fields. | 1840 // Modify expected to include multi-valued fields. |
| 1852 std::vector<string16> values; | 1841 std::vector<string16> values; |
| 1853 expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values); | 1842 expected.GetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, &values); |
| 1854 values.push_back(ASCIIToUTF16("214-555-1234")); | 1843 values.push_back(ASCIIToUTF16("214-555-1234")); |
| 1855 expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values); | 1844 expected.SetMultiInfo(PHONE_HOME_CITY_AND_NUMBER, values); |
| 1856 | 1845 |
| 1857 ASSERT_EQ(1U, results2.size()); | 1846 ASSERT_EQ(1U, results2.size()); |
| 1858 EXPECT_EQ(0, expected.CompareMulti(*results2[0])); | 1847 EXPECT_EQ(0, expected.CompareMulti(*results2[0])); |
| 1859 } | 1848 } |
| OLD | NEW |