Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Side by Side Diff: chrome/browser/autofill/personal_data_manager_unittest.cc

Issue 6676031: Autofill database migration to clean up bogus profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to Lingesh's observer mechanism. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 "State:", "state", "California", "text", &field); 586 "State:", "state", "California", "text", &field);
587 form.fields.push_back(field); 587 form.fields.push_back(field);
588 autofill_test::CreateTestFormField( 588 autofill_test::CreateTestFormField(
589 "Zip:", "zip", "94102", "text", &field); 589 "Zip:", "zip", "94102", "text", &field);
590 form.fields.push_back(field); 590 form.fields.push_back(field);
591 FormStructure form_structure(form); 591 FormStructure form_structure(form);
592 form_structure.DetermineHeuristicTypes(); 592 form_structure.DetermineHeuristicTypes();
593 std::vector<const FormStructure*> forms; 593 std::vector<const FormStructure*> forms;
594 forms.push_back(&form_structure); 594 forms.push_back(&form_structure);
595 const CreditCard* imported_credit_card; 595 const CreditCard* imported_credit_card;
596 EXPECT_TRUE(personal_data_->ImportFormData(forms, &imported_credit_card)); 596 EXPECT_FALSE(personal_data_->ImportFormData(forms, &imported_credit_card));
597 ASSERT_FALSE(imported_credit_card); 597 ASSERT_EQ(static_cast<CreditCard*>(NULL), imported_credit_card);
598 598
599 // Wait for the refresh. 599 // Wait for the refresh.
600 EXPECT_CALL(personal_data_observer_, 600 EXPECT_CALL(personal_data_observer_,
601 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); 601 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop());
602 602
603 MessageLoop::current()->Run(); 603 MessageLoop::current()->Run();
604 604
605 AutofillProfile expected;
606 autofill_test::SetProfileInfo(&expected, "George", NULL,
607 "Washington", NULL, NULL, "21 Laussat St", NULL,
608 "San Francisco", "California", "94102", NULL, NULL, NULL);
609 const std::vector<AutofillProfile*>& results = personal_data_->profiles(); 605 const std::vector<AutofillProfile*>& results = personal_data_->profiles();
610 ASSERT_EQ(1U, results.size()); 606 ASSERT_EQ(0U, results.size());
611 EXPECT_EQ(0, expected.Compare(*results[0]));
612 } 607 }
613 608
614 TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) { 609 TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) {
615 FormData form; 610 FormData form;
616 webkit_glue::FormField field; 611 webkit_glue::FormField field;
617 autofill_test::CreateTestFormField( 612 autofill_test::CreateTestFormField(
618 "First name:", "first_name", "George", "text", &field); 613 "First name:", "first_name", "George", "text", &field);
619 form.fields.push_back(field); 614 form.fields.push_back(field);
620 autofill_test::CreateTestFormField( 615 autofill_test::CreateTestFormField(
621 "Last name:", "last_name", "Washington", "text", &field); 616 "Last name:", "last_name", "Washington", "text", &field);
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 1635
1641 // Expect that the newer information is saved. In this case the year is 1636 // Expect that the newer information is saved. In this case the year is
1642 // added to the existing credit card. 1637 // added to the existing credit card.
1643 CreditCard expected2; 1638 CreditCard expected2;
1644 autofill_test::SetCreditCardInfo(&expected2, 1639 autofill_test::SetCreditCardInfo(&expected2,
1645 "Biggie Smalls", "4111111111111111", "01", "2011"); 1640 "Biggie Smalls", "4111111111111111", "01", "2011");
1646 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); 1641 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards();
1647 ASSERT_EQ(1U, results2.size()); 1642 ASSERT_EQ(1U, results2.size());
1648 EXPECT_EQ(0, expected2.Compare(*results2[0])); 1643 EXPECT_EQ(0, expected2.Compare(*results2[0]));
1649 } 1644 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698