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 <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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 | 548 |
549 AutoFillProfile expected; | 549 AutoFillProfile expected; |
550 autofill_test::SetProfileInfo(&expected, NULL, "George", NULL, | 550 autofill_test::SetProfileInfo(&expected, NULL, "George", NULL, |
551 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, | 551 "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, |
552 "San Francisco", "California", "94102", NULL, NULL, NULL); | 552 "San Francisco", "California", "94102", NULL, NULL, NULL); |
553 const std::vector<AutoFillProfile*>& results = personal_data_->profiles(); | 553 const std::vector<AutoFillProfile*>& results = personal_data_->profiles(); |
554 ASSERT_EQ(1U, results.size()); | 554 ASSERT_EQ(1U, results.size()); |
555 EXPECT_EQ(0, expected.Compare(*results[0])); | 555 EXPECT_EQ(0, expected.Compare(*results[0])); |
556 } | 556 } |
557 | 557 |
| 558 TEST_F(PersonalDataManagerTest, ImportFormDataBadEmail) { |
| 559 FormData form; |
| 560 webkit_glue::FormField field; |
| 561 autofill_test::CreateTestFormField( |
| 562 "First name:", "first_name", "George", "text", &field); |
| 563 form.fields.push_back(field); |
| 564 autofill_test::CreateTestFormField( |
| 565 "Last name:", "last_name", "Washington", "text", &field); |
| 566 form.fields.push_back(field); |
| 567 autofill_test::CreateTestFormField( |
| 568 "Email:", "email", "bogus", "text", &field); |
| 569 form.fields.push_back(field); |
| 570 autofill_test::CreateTestFormField( |
| 571 "Address:", "address1", "21 Laussat St", "text", &field); |
| 572 form.fields.push_back(field); |
| 573 autofill_test::CreateTestFormField( |
| 574 "City:", "city", "San Francisco", "text", &field); |
| 575 form.fields.push_back(field); |
| 576 autofill_test::CreateTestFormField( |
| 577 "State:", "state", "California", "text", &field); |
| 578 form.fields.push_back(field); |
| 579 autofill_test::CreateTestFormField( |
| 580 "Zip:", "zip", "94102", "text", &field); |
| 581 form.fields.push_back(field); |
| 582 FormStructure form_structure(form); |
| 583 std::vector<const FormStructure*> forms; |
| 584 forms.push_back(&form_structure); |
| 585 EXPECT_TRUE(personal_data_->ImportFormData(forms)); |
| 586 |
| 587 // Wait for the refresh. |
| 588 EXPECT_CALL(personal_data_observer_, |
| 589 OnPersonalDataLoaded()).WillOnce(QuitUIMessageLoop()); |
| 590 |
| 591 MessageLoop::current()->Run(); |
| 592 |
| 593 AutoFillProfile expected; |
| 594 autofill_test::SetProfileInfo(&expected, NULL, "George", NULL, |
| 595 "Washington", NULL, NULL, "21 Laussat St", NULL, |
| 596 "San Francisco", "California", "94102", NULL, NULL, NULL); |
| 597 const std::vector<AutoFillProfile*>& results = personal_data_->profiles(); |
| 598 ASSERT_EQ(1U, results.size()); |
| 599 EXPECT_EQ(0, expected.Compare(*results[0])); |
| 600 } |
| 601 |
558 TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) { | 602 TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) { |
559 FormData form; | 603 FormData form; |
560 webkit_glue::FormField field; | 604 webkit_glue::FormField field; |
561 autofill_test::CreateTestFormField( | 605 autofill_test::CreateTestFormField( |
562 "First name:", "first_name", "George", "text", &field); | 606 "First name:", "first_name", "George", "text", &field); |
563 form.fields.push_back(field); | 607 form.fields.push_back(field); |
564 autofill_test::CreateTestFormField( | 608 autofill_test::CreateTestFormField( |
565 "Last name:", "last_name", "Washington", "text", &field); | 609 "Last name:", "last_name", "Washington", "text", &field); |
566 form.fields.push_back(field); | 610 form.fields.push_back(field); |
567 autofill_test::CreateTestFormField( | 611 autofill_test::CreateTestFormField( |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 | 1558 |
1515 // Expect that the newer information is saved. In this case the year is | 1559 // Expect that the newer information is saved. In this case the year is |
1516 // added to the existing credit card. | 1560 // added to the existing credit card. |
1517 CreditCard expected2; | 1561 CreditCard expected2; |
1518 autofill_test::SetCreditCardInfo(&expected2, | 1562 autofill_test::SetCreditCardInfo(&expected2, |
1519 "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); | 1563 "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); |
1520 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); | 1564 const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); |
1521 ASSERT_EQ(1U, results2.size()); | 1565 ASSERT_EQ(1U, results2.size()); |
1522 EXPECT_EQ(0, expected2.Compare(*results2[0])); | 1566 EXPECT_EQ(0, expected2.Compare(*results2[0])); |
1523 } | 1567 } |
OLD | NEW |