| 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/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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 autofill_test::CreateTestFormField( | 584 autofill_test::CreateTestFormField( |
| 585 "State:", "state", "California", "text", &field); | 585 "State:", "state", "California", "text", &field); |
| 586 form.fields.push_back(field); | 586 form.fields.push_back(field); |
| 587 autofill_test::CreateTestFormField( | 587 autofill_test::CreateTestFormField( |
| 588 "Zip:", "zip", "94102", "text", &field); | 588 "Zip:", "zip", "94102", "text", &field); |
| 589 form.fields.push_back(field); | 589 form.fields.push_back(field); |
| 590 FormStructure form_structure(form); | 590 FormStructure form_structure(form); |
| 591 std::vector<const FormStructure*> forms; | 591 std::vector<const FormStructure*> forms; |
| 592 forms.push_back(&form_structure); | 592 forms.push_back(&form_structure); |
| 593 const CreditCard* imported_credit_card; | 593 const CreditCard* imported_credit_card; |
| 594 EXPECT_TRUE(personal_data_->ImportFormData(forms, &imported_credit_card)); | 594 EXPECT_FALSE(personal_data_->ImportFormData(forms, &imported_credit_card)); |
| 595 ASSERT_FALSE(imported_credit_card); | 595 ASSERT_EQ(static_cast<CreditCard*>(NULL), imported_credit_card); |
| 596 | 596 |
| 597 // Wait for the refresh. | 597 // Wait for the refresh. |
| 598 EXPECT_CALL(personal_data_observer_, | 598 EXPECT_CALL(personal_data_observer_, |
| 599 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); | 599 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); |
| 600 | 600 |
| 601 MessageLoop::current()->Run(); | 601 MessageLoop::current()->Run(); |
| 602 | 602 |
| 603 AutofillProfile expected; | |
| 604 autofill_test::SetProfileInfo(&expected, "George", NULL, | |
| 605 "Washington", NULL, NULL, "21 Laussat St", NULL, | |
| 606 "San Francisco", "California", "94102", NULL, NULL, NULL); | |
| 607 const std::vector<AutofillProfile*>& results = personal_data_->profiles(); | 603 const std::vector<AutofillProfile*>& results = personal_data_->profiles(); |
| 608 ASSERT_EQ(1U, results.size()); | 604 ASSERT_EQ(0U, results.size()); |
| 609 EXPECT_EQ(0, expected.Compare(*results[0])); | |
| 610 } | 605 } |
| 611 | 606 |
| 612 TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) { | 607 TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) { |
| 613 FormData form; | 608 FormData form; |
| 614 webkit_glue::FormField field; | 609 webkit_glue::FormField field; |
| 615 autofill_test::CreateTestFormField( | 610 autofill_test::CreateTestFormField( |
| 616 "First name:", "first_name", "George", "text", &field); | 611 "First name:", "first_name", "George", "text", &field); |
| 617 form.fields.push_back(field); | 612 form.fields.push_back(field); |
| 618 autofill_test::CreateTestFormField( | 613 autofill_test::CreateTestFormField( |
| 619 "Last name:", "last_name", "Washington", "text", &field); | 614 "Last name:", "last_name", "Washington", "text", &field); |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1615 | 1610 |
| 1616 // Expect that the newer information is saved. In this case the year is | 1611 // Expect that the newer information is saved. In this case the year is |
| 1617 // added to the existing credit card. | 1612 // added to the existing credit card. |
| 1618 CreditCard expected2; | 1613 CreditCard expected2; |
| 1619 autofill_test::SetCreditCardInfo(&expected2, | 1614 autofill_test::SetCreditCardInfo(&expected2, |
| 1620 "Biggie Smalls", "4111111111111111", "01", "2011"); | 1615 "Biggie Smalls", "4111111111111111", "01", "2011"); |
| 1621 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); | 1616 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); |
| 1622 ASSERT_EQ(1U, results2.size()); | 1617 ASSERT_EQ(1U, results2.size()); |
| 1623 EXPECT_EQ(0, expected2.Compare(*results2[0])); | 1618 EXPECT_EQ(0, expected2.Compare(*results2[0])); |
| 1624 } | 1619 } |
| OLD | NEW |