OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/autofill/autofill_common_test.h" | 10 #include "chrome/browser/autofill/autofill_common_test.h" |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 MessageLoop::current()->Run(); | 494 MessageLoop::current()->Run(); |
495 | 495 |
496 // Add the test profiles to the database. | 496 // Add the test profiles to the database. |
497 std::vector<AutoFillProfile> update; | 497 std::vector<AutoFillProfile> update; |
498 update.push_back(profile0); | 498 update.push_back(profile0); |
499 update.push_back(profile1); | 499 update.push_back(profile1); |
500 personal_data_->SetProfiles(&update); | 500 personal_data_->SetProfiles(&update); |
501 | 501 |
502 profile0.set_unique_id(update[0].unique_id()); | 502 profile0.set_unique_id(update[0].unique_id()); |
503 profile1.set_unique_id(update[1].unique_id()); | 503 profile1.set_unique_id(update[1].unique_id()); |
504 profile0.set_label(update[0].Label()); | 504 // Labels depend on other profiles in the list - update labels manually/ |
505 profile1.set_label(update[1].Label()); | 505 std::vector<AutoFillProfile *> profile_pointers; |
| 506 profile_pointers.push_back(&profile0); |
| 507 profile_pointers.push_back(&profile1); |
| 508 AutoFillProfile::AdjustInferredLabels(&profile_pointers); |
506 | 509 |
507 // Wait for the refresh. | 510 // Wait for the refresh. |
508 EXPECT_CALL(personal_data_observer_, | 511 EXPECT_CALL(personal_data_observer_, |
509 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); | 512 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); |
510 | 513 |
511 MessageLoop::current()->Run(); | 514 MessageLoop::current()->Run(); |
512 | 515 |
513 const std::vector<AutoFillProfile*>& results1 = personal_data_->profiles(); | 516 const std::vector<AutoFillProfile*>& results1 = personal_data_->profiles(); |
514 ASSERT_EQ(2U, results1.size()); | 517 ASSERT_EQ(2U, results1.size()); |
515 EXPECT_EQ(profile0, *results1.at(0)); | 518 EXPECT_EQ(profile0, *results1.at(0)); |
516 EXPECT_EQ(profile1, *results1.at(1)); | 519 EXPECT_EQ(profile1, *results1.at(1)); |
517 | 520 |
518 scoped_ptr<AutoFillProfile> profile2(MakeProfile()); | 521 scoped_ptr<AutoFillProfile> profile2(MakeProfile()); |
519 autofill_test::SetProfileInfo(profile2.get(), | 522 autofill_test::SetProfileInfo(profile2.get(), |
520 "Work", "Josephine", "Alicia", "Saenz", | 523 "Work", "Josephine", "Alicia", "Saenz", |
521 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", | 524 "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", |
522 "32801", "US", "19482937549", "13502849239"); | 525 "32801", "US", "19482937549", "13502849239"); |
523 | 526 |
| 527 // Adjust all labels. |
| 528 profile_pointers.push_back(profile2.get()); |
| 529 AutoFillProfile::AdjustInferredLabels(&profile_pointers); |
| 530 |
524 WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); | 531 WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); |
525 ASSERT_TRUE(wds); | 532 ASSERT_TRUE(wds); |
526 wds->AddAutoFillProfile(*profile2.get()); | 533 wds->AddAutoFillProfile(*profile2.get()); |
527 | 534 |
528 personal_data_->Refresh(); | 535 personal_data_->Refresh(); |
529 | 536 |
530 // Wait for the refresh. | 537 // Wait for the refresh. |
531 EXPECT_CALL(personal_data_observer_, | 538 EXPECT_CALL(personal_data_observer_, |
532 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); | 539 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); |
533 | 540 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 expected->set_label(results3[0]->Label()); | 778 expected->set_label(results3[0]->Label()); |
772 EXPECT_EQ(*expected, *results3[0]); | 779 EXPECT_EQ(*expected, *results3[0]); |
773 | 780 |
774 expected.reset(new AutoFillProfile(string16(), 2)); | 781 expected.reset(new AutoFillProfile(string16(), 2)); |
775 autofill_test::SetProfileInfo(expected.get(), NULL, "John", NULL, | 782 autofill_test::SetProfileInfo(expected.get(), NULL, "John", NULL, |
776 "Adams", "second@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, | 783 "Adams", "second@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
777 NULL, NULL); | 784 NULL, NULL); |
778 expected->set_label(results3[1]->Label()); | 785 expected->set_label(results3[1]->Label()); |
779 EXPECT_EQ(*expected, *results3[1]); | 786 EXPECT_EQ(*expected, *results3[1]); |
780 } | 787 } |
OLD | NEW |