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

Side by Side Diff: chrome/browser/webdata/autofill_table_unittest.cc

Issue 8966003: Update webdata files to take advantage of DLOG(FATAL) in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 9 years 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 <vector> 5 #include <vector>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 566
567 // Get the 'Home' profile. 567 // Get the 'Home' profile.
568 AutofillProfile* db_profile; 568 AutofillProfile* db_profile;
569 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile( 569 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(
570 home_profile.guid(), &db_profile)); 570 home_profile.guid(), &db_profile));
571 EXPECT_EQ(home_profile, *db_profile); 571 EXPECT_EQ(home_profile, *db_profile);
572 sql::Statement s_home(db.GetSQLConnection()->GetUniqueStatement( 572 sql::Statement s_home(db.GetSQLConnection()->GetUniqueStatement(
573 "SELECT date_modified " 573 "SELECT date_modified "
574 "FROM autofill_profiles WHERE guid=?")); 574 "FROM autofill_profiles WHERE guid=?"));
575 s_home.BindString(0, home_profile.guid()); 575 s_home.BindString(0, home_profile.guid());
576 ASSERT_TRUE(s_home); 576 ASSERT_TRUE(s_home.is_valid());
577 ASSERT_TRUE(s_home.Step()); 577 ASSERT_TRUE(s_home.Step());
578 EXPECT_GE(s_home.ColumnInt64(0), pre_creation_time.ToTimeT()); 578 EXPECT_GE(s_home.ColumnInt64(0), pre_creation_time.ToTimeT());
579 EXPECT_LE(s_home.ColumnInt64(0), post_creation_time.ToTimeT()); 579 EXPECT_LE(s_home.ColumnInt64(0), post_creation_time.ToTimeT());
580 EXPECT_FALSE(s_home.Step()); 580 EXPECT_FALSE(s_home.Step());
581 delete db_profile; 581 delete db_profile;
582 582
583 // Add a 'Billing' profile. 583 // Add a 'Billing' profile.
584 AutofillProfile billing_profile = home_profile; 584 AutofillProfile billing_profile = home_profile;
585 billing_profile.set_guid(guid::GenerateGUID()); 585 billing_profile.set_guid(guid::GenerateGUID());
586 billing_profile.SetInfo(ADDRESS_HOME_LINE1, 586 billing_profile.SetInfo(ADDRESS_HOME_LINE1,
587 ASCIIToUTF16("5678 Bottom Street")); 587 ASCIIToUTF16("5678 Bottom Street"));
588 billing_profile.SetInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("suite 3")); 588 billing_profile.SetInfo(ADDRESS_HOME_LINE2, ASCIIToUTF16("suite 3"));
589 589
590 pre_creation_time = Time::Now(); 590 pre_creation_time = Time::Now();
591 EXPECT_TRUE(db.GetAutofillTable()->AddAutofillProfile(billing_profile)); 591 EXPECT_TRUE(db.GetAutofillTable()->AddAutofillProfile(billing_profile));
592 post_creation_time = Time::Now(); 592 post_creation_time = Time::Now();
593 593
594 // Get the 'Billing' profile. 594 // Get the 'Billing' profile.
595 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile( 595 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(
596 billing_profile.guid(), &db_profile)); 596 billing_profile.guid(), &db_profile));
597 EXPECT_EQ(billing_profile, *db_profile); 597 EXPECT_EQ(billing_profile, *db_profile);
598 sql::Statement s_billing(db.GetSQLConnection()->GetUniqueStatement( 598 sql::Statement s_billing(db.GetSQLConnection()->GetUniqueStatement(
599 "SELECT date_modified FROM autofill_profiles WHERE guid=?")); 599 "SELECT date_modified FROM autofill_profiles WHERE guid=?"));
600 s_billing.BindString(0, billing_profile.guid()); 600 s_billing.BindString(0, billing_profile.guid());
601 ASSERT_TRUE(s_billing); 601 ASSERT_TRUE(s_billing.is_valid());
602 ASSERT_TRUE(s_billing.Step()); 602 ASSERT_TRUE(s_billing.Step());
603 EXPECT_GE(s_billing.ColumnInt64(0), pre_creation_time.ToTimeT()); 603 EXPECT_GE(s_billing.ColumnInt64(0), pre_creation_time.ToTimeT());
604 EXPECT_LE(s_billing.ColumnInt64(0), post_creation_time.ToTimeT()); 604 EXPECT_LE(s_billing.ColumnInt64(0), post_creation_time.ToTimeT());
605 EXPECT_FALSE(s_billing.Step()); 605 EXPECT_FALSE(s_billing.Step());
606 delete db_profile; 606 delete db_profile;
607 607
608 // Update the 'Billing' profile, name only. 608 // Update the 'Billing' profile, name only.
609 billing_profile.SetInfo(NAME_FIRST, ASCIIToUTF16("Jane")); 609 billing_profile.SetInfo(NAME_FIRST, ASCIIToUTF16("Jane"));
610 Time pre_modification_time = Time::Now(); 610 Time pre_modification_time = Time::Now();
611 EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfileMulti( 611 EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfileMulti(
612 billing_profile)); 612 billing_profile));
613 Time post_modification_time = Time::Now(); 613 Time post_modification_time = Time::Now();
614 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile( 614 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(
615 billing_profile.guid(), &db_profile)); 615 billing_profile.guid(), &db_profile));
616 EXPECT_EQ(billing_profile, *db_profile); 616 EXPECT_EQ(billing_profile, *db_profile);
617 sql::Statement s_billing_updated(db.GetSQLConnection()->GetUniqueStatement( 617 sql::Statement s_billing_updated(db.GetSQLConnection()->GetUniqueStatement(
618 "SELECT date_modified FROM autofill_profiles WHERE guid=?")); 618 "SELECT date_modified FROM autofill_profiles WHERE guid=?"));
619 s_billing_updated.BindString(0, billing_profile.guid()); 619 s_billing_updated.BindString(0, billing_profile.guid());
620 ASSERT_TRUE(s_billing_updated); 620 ASSERT_TRUE(s_billing_updated.is_valid());
621 ASSERT_TRUE(s_billing_updated.Step()); 621 ASSERT_TRUE(s_billing_updated.Step());
622 EXPECT_GE(s_billing_updated.ColumnInt64(0), 622 EXPECT_GE(s_billing_updated.ColumnInt64(0),
623 pre_modification_time.ToTimeT()); 623 pre_modification_time.ToTimeT());
624 EXPECT_LE(s_billing_updated.ColumnInt64(0), 624 EXPECT_LE(s_billing_updated.ColumnInt64(0),
625 post_modification_time.ToTimeT()); 625 post_modification_time.ToTimeT());
626 EXPECT_FALSE(s_billing_updated.Step()); 626 EXPECT_FALSE(s_billing_updated.Step());
627 delete db_profile; 627 delete db_profile;
628 628
629 // Update the 'Billing' profile. 629 // Update the 'Billing' profile.
630 billing_profile.SetInfo(NAME_FIRST, ASCIIToUTF16("Janice")); 630 billing_profile.SetInfo(NAME_FIRST, ASCIIToUTF16("Janice"));
(...skipping 11 matching lines...) Expand all
642 Time pre_modification_time_2 = Time::Now(); 642 Time pre_modification_time_2 = Time::Now();
643 EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfileMulti( 643 EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfileMulti(
644 billing_profile)); 644 billing_profile));
645 Time post_modification_time_2 = Time::Now(); 645 Time post_modification_time_2 = Time::Now();
646 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile( 646 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(
647 billing_profile.guid(), &db_profile)); 647 billing_profile.guid(), &db_profile));
648 EXPECT_EQ(billing_profile, *db_profile); 648 EXPECT_EQ(billing_profile, *db_profile);
649 sql::Statement s_billing_updated_2(db.GetSQLConnection()->GetUniqueStatement( 649 sql::Statement s_billing_updated_2(db.GetSQLConnection()->GetUniqueStatement(
650 "SELECT date_modified FROM autofill_profiles WHERE guid=?")); 650 "SELECT date_modified FROM autofill_profiles WHERE guid=?"));
651 s_billing_updated_2.BindString(0, billing_profile.guid()); 651 s_billing_updated_2.BindString(0, billing_profile.guid());
652 ASSERT_TRUE(s_billing_updated_2); 652 ASSERT_TRUE(s_billing_updated_2.is_valid());
653 ASSERT_TRUE(s_billing_updated_2.Step()); 653 ASSERT_TRUE(s_billing_updated_2.Step());
654 EXPECT_GE(s_billing_updated_2.ColumnInt64(0), 654 EXPECT_GE(s_billing_updated_2.ColumnInt64(0),
655 pre_modification_time_2.ToTimeT()); 655 pre_modification_time_2.ToTimeT());
656 EXPECT_LE(s_billing_updated_2.ColumnInt64(0), 656 EXPECT_LE(s_billing_updated_2.ColumnInt64(0),
657 post_modification_time_2.ToTimeT()); 657 post_modification_time_2.ToTimeT());
658 EXPECT_FALSE(s_billing_updated_2.Step()); 658 EXPECT_FALSE(s_billing_updated_2.Step());
659 delete db_profile; 659 delete db_profile;
660 660
661 // Remove the 'Billing' profile. 661 // Remove the 'Billing' profile.
662 EXPECT_TRUE(db.GetAutofillTable()->RemoveAutofillProfile( 662 EXPECT_TRUE(db.GetAutofillTable()->RemoveAutofillProfile(
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 // Get the 'Work' credit card. 943 // Get the 'Work' credit card.
944 CreditCard* db_creditcard; 944 CreditCard* db_creditcard;
945 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(work_creditcard.guid(), 945 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(work_creditcard.guid(),
946 &db_creditcard)); 946 &db_creditcard));
947 EXPECT_EQ(work_creditcard, *db_creditcard); 947 EXPECT_EQ(work_creditcard, *db_creditcard);
948 sql::Statement s_work(db.GetSQLConnection()->GetUniqueStatement( 948 sql::Statement s_work(db.GetSQLConnection()->GetUniqueStatement(
949 "SELECT guid, name_on_card, expiration_month, expiration_year, " 949 "SELECT guid, name_on_card, expiration_month, expiration_year, "
950 "card_number_encrypted, date_modified " 950 "card_number_encrypted, date_modified "
951 "FROM credit_cards WHERE guid=?")); 951 "FROM credit_cards WHERE guid=?"));
952 s_work.BindString(0, work_creditcard.guid()); 952 s_work.BindString(0, work_creditcard.guid());
953 ASSERT_TRUE(s_work); 953 ASSERT_TRUE(s_work.is_valid());
954 ASSERT_TRUE(s_work.Step()); 954 ASSERT_TRUE(s_work.Step());
955 EXPECT_GE(s_work.ColumnInt64(5), pre_creation_time.ToTimeT()); 955 EXPECT_GE(s_work.ColumnInt64(5), pre_creation_time.ToTimeT());
956 EXPECT_LE(s_work.ColumnInt64(5), post_creation_time.ToTimeT()); 956 EXPECT_LE(s_work.ColumnInt64(5), post_creation_time.ToTimeT());
957 EXPECT_FALSE(s_work.Step()); 957 EXPECT_FALSE(s_work.Step());
958 delete db_creditcard; 958 delete db_creditcard;
959 959
960 // Add a 'Target' credit card. 960 // Add a 'Target' credit card.
961 CreditCard target_creditcard; 961 CreditCard target_creditcard;
962 target_creditcard.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Jack Torrance")); 962 target_creditcard.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Jack Torrance"));
963 target_creditcard.SetInfo(CREDIT_CARD_NUMBER, 963 target_creditcard.SetInfo(CREDIT_CARD_NUMBER,
964 ASCIIToUTF16("1111222233334444")); 964 ASCIIToUTF16("1111222233334444"));
965 target_creditcard.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("06")); 965 target_creditcard.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("06"));
966 target_creditcard.SetInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2012")); 966 target_creditcard.SetInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2012"));
967 967
968 pre_creation_time = Time::Now(); 968 pre_creation_time = Time::Now();
969 EXPECT_TRUE(db.GetAutofillTable()->AddCreditCard(target_creditcard)); 969 EXPECT_TRUE(db.GetAutofillTable()->AddCreditCard(target_creditcard));
970 post_creation_time = Time::Now(); 970 post_creation_time = Time::Now();
971 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(target_creditcard.guid(), 971 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(target_creditcard.guid(),
972 &db_creditcard)); 972 &db_creditcard));
973 EXPECT_EQ(target_creditcard, *db_creditcard); 973 EXPECT_EQ(target_creditcard, *db_creditcard);
974 sql::Statement s_target(db.GetSQLConnection()->GetUniqueStatement( 974 sql::Statement s_target(db.GetSQLConnection()->GetUniqueStatement(
975 "SELECT guid, name_on_card, expiration_month, expiration_year, " 975 "SELECT guid, name_on_card, expiration_month, expiration_year, "
976 "card_number_encrypted, date_modified " 976 "card_number_encrypted, date_modified "
977 "FROM credit_cards WHERE guid=?")); 977 "FROM credit_cards WHERE guid=?"));
978 s_target.BindString(0, target_creditcard.guid()); 978 s_target.BindString(0, target_creditcard.guid());
979 ASSERT_TRUE(s_target); 979 ASSERT_TRUE(s_target.is_valid());
980 ASSERT_TRUE(s_target.Step()); 980 ASSERT_TRUE(s_target.Step());
981 EXPECT_GE(s_target.ColumnInt64(5), pre_creation_time.ToTimeT()); 981 EXPECT_GE(s_target.ColumnInt64(5), pre_creation_time.ToTimeT());
982 EXPECT_LE(s_target.ColumnInt64(5), post_creation_time.ToTimeT()); 982 EXPECT_LE(s_target.ColumnInt64(5), post_creation_time.ToTimeT());
983 EXPECT_FALSE(s_target.Step()); 983 EXPECT_FALSE(s_target.Step());
984 delete db_creditcard; 984 delete db_creditcard;
985 985
986 // Update the 'Target' credit card. 986 // Update the 'Target' credit card.
987 target_creditcard.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Charles Grady")); 987 target_creditcard.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Charles Grady"));
988 Time pre_modification_time = Time::Now(); 988 Time pre_modification_time = Time::Now();
989 EXPECT_TRUE(db.GetAutofillTable()->UpdateCreditCard(target_creditcard)); 989 EXPECT_TRUE(db.GetAutofillTable()->UpdateCreditCard(target_creditcard));
990 Time post_modification_time = Time::Now(); 990 Time post_modification_time = Time::Now();
991 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(target_creditcard.guid(), 991 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(target_creditcard.guid(),
992 &db_creditcard)); 992 &db_creditcard));
993 EXPECT_EQ(target_creditcard, *db_creditcard); 993 EXPECT_EQ(target_creditcard, *db_creditcard);
994 sql::Statement s_target_updated(db.GetSQLConnection()->GetUniqueStatement( 994 sql::Statement s_target_updated(db.GetSQLConnection()->GetUniqueStatement(
995 "SELECT guid, name_on_card, expiration_month, expiration_year, " 995 "SELECT guid, name_on_card, expiration_month, expiration_year, "
996 "card_number_encrypted, date_modified " 996 "card_number_encrypted, date_modified "
997 "FROM credit_cards WHERE guid=?")); 997 "FROM credit_cards WHERE guid=?"));
998 s_target_updated.BindString(0, target_creditcard.guid()); 998 s_target_updated.BindString(0, target_creditcard.guid());
999 ASSERT_TRUE(s_target_updated); 999 ASSERT_TRUE(s_target_updated.is_valid());
1000 ASSERT_TRUE(s_target_updated.Step()); 1000 ASSERT_TRUE(s_target_updated.Step());
1001 EXPECT_GE(s_target_updated.ColumnInt64(5), pre_modification_time.ToTimeT()); 1001 EXPECT_GE(s_target_updated.ColumnInt64(5), pre_modification_time.ToTimeT());
1002 EXPECT_LE(s_target_updated.ColumnInt64(5), post_modification_time.ToTimeT()); 1002 EXPECT_LE(s_target_updated.ColumnInt64(5), post_modification_time.ToTimeT());
1003 EXPECT_FALSE(s_target_updated.Step()); 1003 EXPECT_FALSE(s_target_updated.Step());
1004 delete db_creditcard; 1004 delete db_creditcard;
1005 1005
1006 // Remove the 'Target' credit card. 1006 // Remove the 'Target' credit card.
1007 EXPECT_TRUE(db.GetAutofillTable()->RemoveCreditCard( 1007 EXPECT_TRUE(db.GetAutofillTable()->RemoveCreditCard(
1008 target_creditcard.guid())); 1008 target_creditcard.guid()));
1009 EXPECT_FALSE(db.GetAutofillTable()->GetCreditCard(target_creditcard.guid(), 1009 EXPECT_FALSE(db.GetAutofillTable()->GetCreditCard(target_creditcard.guid(),
(...skipping 17 matching lines...) Expand all
1027 profile.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); 1027 profile.SetInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA"));
1028 profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025")); 1028 profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025"));
1029 profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); 1029 profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
1030 profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567")); 1030 profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567"));
1031 db.GetAutofillTable()->AddAutofillProfile(profile); 1031 db.GetAutofillTable()->AddAutofillProfile(profile);
1032 1032
1033 // Set a mocked value for the profile's creation time. 1033 // Set a mocked value for the profile's creation time.
1034 const time_t mock_creation_date = Time::Now().ToTimeT() - 13; 1034 const time_t mock_creation_date = Time::Now().ToTimeT() - 13;
1035 sql::Statement s_mock_creation_date(db.GetSQLConnection()->GetUniqueStatement( 1035 sql::Statement s_mock_creation_date(db.GetSQLConnection()->GetUniqueStatement(
1036 "UPDATE autofill_profiles SET date_modified = ?")); 1036 "UPDATE autofill_profiles SET date_modified = ?"));
1037 ASSERT_TRUE(s_mock_creation_date); 1037 ASSERT_TRUE(s_mock_creation_date.is_valid());
1038 s_mock_creation_date.BindInt64(0, mock_creation_date); 1038 s_mock_creation_date.BindInt64(0, mock_creation_date);
1039 ASSERT_TRUE(s_mock_creation_date.Run()); 1039 ASSERT_TRUE(s_mock_creation_date.Run());
1040 1040
1041 // Get the profile. 1041 // Get the profile.
1042 AutofillProfile* tmp_profile; 1042 AutofillProfile* tmp_profile;
1043 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(profile.guid(), 1043 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(profile.guid(),
1044 &tmp_profile)); 1044 &tmp_profile));
1045 scoped_ptr<AutofillProfile> db_profile(tmp_profile); 1045 scoped_ptr<AutofillProfile> db_profile(tmp_profile);
1046 EXPECT_EQ(profile, *db_profile); 1046 EXPECT_EQ(profile, *db_profile);
1047 sql::Statement s_original(db.GetSQLConnection()->GetUniqueStatement( 1047 sql::Statement s_original(db.GetSQLConnection()->GetUniqueStatement(
1048 "SELECT date_modified FROM autofill_profiles")); 1048 "SELECT date_modified FROM autofill_profiles"));
1049 ASSERT_TRUE(s_original); 1049 ASSERT_TRUE(s_original.is_valid());
1050 ASSERT_TRUE(s_original.Step()); 1050 ASSERT_TRUE(s_original.Step());
1051 EXPECT_EQ(mock_creation_date, s_original.ColumnInt64(0)); 1051 EXPECT_EQ(mock_creation_date, s_original.ColumnInt64(0));
1052 EXPECT_FALSE(s_original.Step()); 1052 EXPECT_FALSE(s_original.Step());
1053 1053
1054 // Now, update the profile and save the update to the database. 1054 // Now, update the profile and save the update to the database.
1055 // The modification date should change to reflect the update. 1055 // The modification date should change to reflect the update.
1056 profile.SetInfo(EMAIL_ADDRESS, ASCIIToUTF16("js@smith.xyz")); 1056 profile.SetInfo(EMAIL_ADDRESS, ASCIIToUTF16("js@smith.xyz"));
1057 db.GetAutofillTable()->UpdateAutofillProfileMulti(profile); 1057 db.GetAutofillTable()->UpdateAutofillProfileMulti(profile);
1058 1058
1059 // Get the profile. 1059 // Get the profile.
1060 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(profile.guid(), 1060 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(profile.guid(),
1061 &tmp_profile)); 1061 &tmp_profile));
1062 db_profile.reset(tmp_profile); 1062 db_profile.reset(tmp_profile);
1063 EXPECT_EQ(profile, *db_profile); 1063 EXPECT_EQ(profile, *db_profile);
1064 sql::Statement s_updated(db.GetSQLConnection()->GetUniqueStatement( 1064 sql::Statement s_updated(db.GetSQLConnection()->GetUniqueStatement(
1065 "SELECT date_modified FROM autofill_profiles")); 1065 "SELECT date_modified FROM autofill_profiles"));
1066 ASSERT_TRUE(s_updated); 1066 ASSERT_TRUE(s_updated.is_valid());
1067 ASSERT_TRUE(s_updated.Step()); 1067 ASSERT_TRUE(s_updated.Step());
1068 EXPECT_LT(mock_creation_date, s_updated.ColumnInt64(0)); 1068 EXPECT_LT(mock_creation_date, s_updated.ColumnInt64(0));
1069 EXPECT_FALSE(s_updated.Step()); 1069 EXPECT_FALSE(s_updated.Step());
1070 1070
1071 // Set a mocked value for the profile's modification time. 1071 // Set a mocked value for the profile's modification time.
1072 const time_t mock_modification_date = Time::Now().ToTimeT() - 7; 1072 const time_t mock_modification_date = Time::Now().ToTimeT() - 7;
1073 sql::Statement s_mock_modification_date( 1073 sql::Statement s_mock_modification_date(
1074 db.GetSQLConnection()->GetUniqueStatement( 1074 db.GetSQLConnection()->GetUniqueStatement(
1075 "UPDATE autofill_profiles SET date_modified = ?")); 1075 "UPDATE autofill_profiles SET date_modified = ?"));
1076 ASSERT_TRUE(s_mock_modification_date); 1076 ASSERT_TRUE(s_mock_modification_date.is_valid());
1077 s_mock_modification_date.BindInt64(0, mock_modification_date); 1077 s_mock_modification_date.BindInt64(0, mock_modification_date);
1078 ASSERT_TRUE(s_mock_modification_date.Run()); 1078 ASSERT_TRUE(s_mock_modification_date.Run());
1079 1079
1080 // Finally, call into |UpdateAutofillProfileMulti()| without changing the 1080 // Finally, call into |UpdateAutofillProfileMulti()| without changing the
1081 // profile. The modification date should not change. 1081 // profile. The modification date should not change.
1082 db.GetAutofillTable()->UpdateAutofillProfileMulti(profile); 1082 db.GetAutofillTable()->UpdateAutofillProfileMulti(profile);
1083 1083
1084 // Get the profile. 1084 // Get the profile.
1085 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(profile.guid(), 1085 ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(profile.guid(),
1086 &tmp_profile)); 1086 &tmp_profile));
1087 db_profile.reset(tmp_profile); 1087 db_profile.reset(tmp_profile);
1088 EXPECT_EQ(profile, *db_profile); 1088 EXPECT_EQ(profile, *db_profile);
1089 sql::Statement s_unchanged(db.GetSQLConnection()->GetUniqueStatement( 1089 sql::Statement s_unchanged(db.GetSQLConnection()->GetUniqueStatement(
1090 "SELECT date_modified FROM autofill_profiles")); 1090 "SELECT date_modified FROM autofill_profiles"));
1091 ASSERT_TRUE(s_unchanged); 1091 ASSERT_TRUE(s_unchanged.is_valid());
1092 ASSERT_TRUE(s_unchanged.Step()); 1092 ASSERT_TRUE(s_unchanged.Step());
1093 EXPECT_EQ(mock_modification_date, s_unchanged.ColumnInt64(0)); 1093 EXPECT_EQ(mock_modification_date, s_unchanged.ColumnInt64(0));
1094 EXPECT_FALSE(s_unchanged.Step()); 1094 EXPECT_FALSE(s_unchanged.Step());
1095 } 1095 }
1096 1096
1097 TEST_F(AutofillTableTest, UpdateCreditCard) { 1097 TEST_F(AutofillTableTest, UpdateCreditCard) {
1098 WebDatabase db; 1098 WebDatabase db;
1099 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); 1099 ASSERT_EQ(sql::INIT_OK, db.Init(file_));
1100 1100
1101 // Add a credit card to the db. 1101 // Add a credit card to the db.
1102 CreditCard credit_card; 1102 CreditCard credit_card;
1103 credit_card.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Jack Torrance")); 1103 credit_card.SetInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Jack Torrance"));
1104 credit_card.SetInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1234567890123456")); 1104 credit_card.SetInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("1234567890123456"));
1105 credit_card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("04")); 1105 credit_card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("04"));
1106 credit_card.SetInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2013")); 1106 credit_card.SetInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, ASCIIToUTF16("2013"));
1107 db.GetAutofillTable()->AddCreditCard(credit_card); 1107 db.GetAutofillTable()->AddCreditCard(credit_card);
1108 1108
1109 // Set a mocked value for the credit card's creation time. 1109 // Set a mocked value for the credit card's creation time.
1110 const time_t mock_creation_date = Time::Now().ToTimeT() - 13; 1110 const time_t mock_creation_date = Time::Now().ToTimeT() - 13;
1111 sql::Statement s_mock_creation_date(db.GetSQLConnection()->GetUniqueStatement( 1111 sql::Statement s_mock_creation_date(db.GetSQLConnection()->GetUniqueStatement(
1112 "UPDATE credit_cards SET date_modified = ?")); 1112 "UPDATE credit_cards SET date_modified = ?"));
1113 ASSERT_TRUE(s_mock_creation_date); 1113 ASSERT_TRUE(s_mock_creation_date.is_valid());
1114 s_mock_creation_date.BindInt64(0, mock_creation_date); 1114 s_mock_creation_date.BindInt64(0, mock_creation_date);
1115 ASSERT_TRUE(s_mock_creation_date.Run()); 1115 ASSERT_TRUE(s_mock_creation_date.Run());
1116 1116
1117 // Get the credit card. 1117 // Get the credit card.
1118 CreditCard* tmp_credit_card; 1118 CreditCard* tmp_credit_card;
1119 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(credit_card.guid(), 1119 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(credit_card.guid(),
1120 &tmp_credit_card)); 1120 &tmp_credit_card));
1121 scoped_ptr<CreditCard> db_credit_card(tmp_credit_card); 1121 scoped_ptr<CreditCard> db_credit_card(tmp_credit_card);
1122 EXPECT_EQ(credit_card, *db_credit_card); 1122 EXPECT_EQ(credit_card, *db_credit_card);
1123 sql::Statement s_original(db.GetSQLConnection()->GetUniqueStatement( 1123 sql::Statement s_original(db.GetSQLConnection()->GetUniqueStatement(
1124 "SELECT date_modified FROM credit_cards")); 1124 "SELECT date_modified FROM credit_cards"));
1125 ASSERT_TRUE(s_original); 1125 ASSERT_TRUE(s_original.is_valid());
1126 ASSERT_TRUE(s_original.Step()); 1126 ASSERT_TRUE(s_original.Step());
1127 EXPECT_EQ(mock_creation_date, s_original.ColumnInt64(0)); 1127 EXPECT_EQ(mock_creation_date, s_original.ColumnInt64(0));
1128 EXPECT_FALSE(s_original.Step()); 1128 EXPECT_FALSE(s_original.Step());
1129 1129
1130 // Now, update the credit card and save the update to the database. 1130 // Now, update the credit card and save the update to the database.
1131 // The modification date should change to reflect the update. 1131 // The modification date should change to reflect the update.
1132 credit_card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01")); 1132 credit_card.SetInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("01"));
1133 db.GetAutofillTable()->UpdateCreditCard(credit_card); 1133 db.GetAutofillTable()->UpdateCreditCard(credit_card);
1134 1134
1135 // Get the credit card. 1135 // Get the credit card.
1136 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(credit_card.guid(), 1136 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(credit_card.guid(),
1137 &tmp_credit_card)); 1137 &tmp_credit_card));
1138 db_credit_card.reset(tmp_credit_card); 1138 db_credit_card.reset(tmp_credit_card);
1139 EXPECT_EQ(credit_card, *db_credit_card); 1139 EXPECT_EQ(credit_card, *db_credit_card);
1140 sql::Statement s_updated(db.GetSQLConnection()->GetUniqueStatement( 1140 sql::Statement s_updated(db.GetSQLConnection()->GetUniqueStatement(
1141 "SELECT date_modified FROM credit_cards")); 1141 "SELECT date_modified FROM credit_cards"));
1142 ASSERT_TRUE(s_updated); 1142 ASSERT_TRUE(s_updated.is_valid());
1143 ASSERT_TRUE(s_updated.Step()); 1143 ASSERT_TRUE(s_updated.Step());
1144 EXPECT_LT(mock_creation_date, s_updated.ColumnInt64(0)); 1144 EXPECT_LT(mock_creation_date, s_updated.ColumnInt64(0));
1145 EXPECT_FALSE(s_updated.Step()); 1145 EXPECT_FALSE(s_updated.Step());
1146 1146
1147 // Set a mocked value for the credit card's modification time. 1147 // Set a mocked value for the credit card's modification time.
1148 const time_t mock_modification_date = Time::Now().ToTimeT() - 7; 1148 const time_t mock_modification_date = Time::Now().ToTimeT() - 7;
1149 sql::Statement s_mock_modification_date( 1149 sql::Statement s_mock_modification_date(
1150 db.GetSQLConnection()->GetUniqueStatement( 1150 db.GetSQLConnection()->GetUniqueStatement(
1151 "UPDATE credit_cards SET date_modified = ?")); 1151 "UPDATE credit_cards SET date_modified = ?"));
1152 ASSERT_TRUE(s_mock_modification_date); 1152 ASSERT_TRUE(s_mock_modification_date.is_valid());
1153 s_mock_modification_date.BindInt64(0, mock_modification_date); 1153 s_mock_modification_date.BindInt64(0, mock_modification_date);
1154 ASSERT_TRUE(s_mock_modification_date.Run()); 1154 ASSERT_TRUE(s_mock_modification_date.Run());
1155 1155
1156 // Finally, call into |UpdateCreditCard()| without changing the credit card. 1156 // Finally, call into |UpdateCreditCard()| without changing the credit card.
1157 // The modification date should not change. 1157 // The modification date should not change.
1158 db.GetAutofillTable()->UpdateCreditCard(credit_card); 1158 db.GetAutofillTable()->UpdateCreditCard(credit_card);
1159 1159
1160 // Get the profile. 1160 // Get the profile.
1161 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(credit_card.guid(), 1161 ASSERT_TRUE(db.GetAutofillTable()->GetCreditCard(credit_card.guid(),
1162 &tmp_credit_card)); 1162 &tmp_credit_card));
1163 db_credit_card.reset(tmp_credit_card); 1163 db_credit_card.reset(tmp_credit_card);
1164 EXPECT_EQ(credit_card, *db_credit_card); 1164 EXPECT_EQ(credit_card, *db_credit_card);
1165 sql::Statement s_unchanged(db.GetSQLConnection()->GetUniqueStatement( 1165 sql::Statement s_unchanged(db.GetSQLConnection()->GetUniqueStatement(
1166 "SELECT date_modified FROM credit_cards")); 1166 "SELECT date_modified FROM credit_cards"));
1167 ASSERT_TRUE(s_unchanged); 1167 ASSERT_TRUE(s_unchanged.is_valid());
1168 ASSERT_TRUE(s_unchanged.Step()); 1168 ASSERT_TRUE(s_unchanged.Step());
1169 EXPECT_EQ(mock_modification_date, s_unchanged.ColumnInt64(0)); 1169 EXPECT_EQ(mock_modification_date, s_unchanged.ColumnInt64(0));
1170 EXPECT_FALSE(s_unchanged.Step()); 1170 EXPECT_FALSE(s_unchanged.Step());
1171 } 1171 }
1172 1172
1173 TEST_F(AutofillTableTest, RemoveAutofillProfilesAndCreditCardsModifiedBetween) { 1173 TEST_F(AutofillTableTest, RemoveAutofillProfilesAndCreditCardsModifiedBetween) {
1174 WebDatabase db; 1174 WebDatabase db;
1175 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); 1175 ASSERT_EQ(sql::INIT_OK, db.Init(file_));
1176 1176
1177 // Populate the autofill_profiles and credit_cards tables. 1177 // Populate the autofill_profiles and credit_cards tables.
(...skipping 28 matching lines...) Expand all
1206 std::vector<std::string> credit_card_guids; 1206 std::vector<std::string> credit_card_guids;
1207 db.GetAutofillTable()->RemoveAutofillProfilesAndCreditCardsModifiedBetween( 1207 db.GetAutofillTable()->RemoveAutofillProfilesAndCreditCardsModifiedBetween(
1208 Time::FromTimeT(17), Time::FromTimeT(41), 1208 Time::FromTimeT(17), Time::FromTimeT(41),
1209 &profile_guids, &credit_card_guids); 1209 &profile_guids, &credit_card_guids);
1210 ASSERT_EQ(2UL, profile_guids.size()); 1210 ASSERT_EQ(2UL, profile_guids.size());
1211 EXPECT_EQ("00000000-0000-0000-0000-000000000001", profile_guids[0]); 1211 EXPECT_EQ("00000000-0000-0000-0000-000000000001", profile_guids[0]);
1212 EXPECT_EQ("00000000-0000-0000-0000-000000000002", profile_guids[1]); 1212 EXPECT_EQ("00000000-0000-0000-0000-000000000002", profile_guids[1]);
1213 sql::Statement s_autofill_profiles_bounded( 1213 sql::Statement s_autofill_profiles_bounded(
1214 db.GetSQLConnection()->GetUniqueStatement( 1214 db.GetSQLConnection()->GetUniqueStatement(
1215 "SELECT date_modified FROM autofill_profiles")); 1215 "SELECT date_modified FROM autofill_profiles"));
1216 ASSERT_TRUE(s_autofill_profiles_bounded); 1216 ASSERT_TRUE(s_autofill_profiles_bounded.is_valid());
1217 ASSERT_TRUE(s_autofill_profiles_bounded.Step()); 1217 ASSERT_TRUE(s_autofill_profiles_bounded.Step());
1218 EXPECT_EQ(11, s_autofill_profiles_bounded.ColumnInt64(0)); 1218 EXPECT_EQ(11, s_autofill_profiles_bounded.ColumnInt64(0));
1219 ASSERT_TRUE(s_autofill_profiles_bounded.Step()); 1219 ASSERT_TRUE(s_autofill_profiles_bounded.Step());
1220 EXPECT_EQ(41, s_autofill_profiles_bounded.ColumnInt64(0)); 1220 EXPECT_EQ(41, s_autofill_profiles_bounded.ColumnInt64(0));
1221 ASSERT_TRUE(s_autofill_profiles_bounded.Step()); 1221 ASSERT_TRUE(s_autofill_profiles_bounded.Step());
1222 EXPECT_EQ(51, s_autofill_profiles_bounded.ColumnInt64(0)); 1222 EXPECT_EQ(51, s_autofill_profiles_bounded.ColumnInt64(0));
1223 ASSERT_TRUE(s_autofill_profiles_bounded.Step()); 1223 ASSERT_TRUE(s_autofill_profiles_bounded.Step());
1224 EXPECT_EQ(61, s_autofill_profiles_bounded.ColumnInt64(0)); 1224 EXPECT_EQ(61, s_autofill_profiles_bounded.ColumnInt64(0));
1225 EXPECT_FALSE(s_autofill_profiles_bounded.Step()); 1225 EXPECT_FALSE(s_autofill_profiles_bounded.Step());
1226 ASSERT_EQ(3UL, credit_card_guids.size()); 1226 ASSERT_EQ(3UL, credit_card_guids.size());
1227 EXPECT_EQ("00000000-0000-0000-0000-000000000006", credit_card_guids[0]); 1227 EXPECT_EQ("00000000-0000-0000-0000-000000000006", credit_card_guids[0]);
1228 EXPECT_EQ("00000000-0000-0000-0000-000000000007", credit_card_guids[1]); 1228 EXPECT_EQ("00000000-0000-0000-0000-000000000007", credit_card_guids[1]);
1229 EXPECT_EQ("00000000-0000-0000-0000-000000000008", credit_card_guids[2]); 1229 EXPECT_EQ("00000000-0000-0000-0000-000000000008", credit_card_guids[2]);
1230 sql::Statement s_credit_cards_bounded( 1230 sql::Statement s_credit_cards_bounded(
1231 db.GetSQLConnection()->GetUniqueStatement( 1231 db.GetSQLConnection()->GetUniqueStatement(
1232 "SELECT date_modified FROM credit_cards")); 1232 "SELECT date_modified FROM credit_cards"));
1233 ASSERT_TRUE(s_credit_cards_bounded); 1233 ASSERT_TRUE(s_credit_cards_bounded.is_valid());
1234 ASSERT_TRUE(s_credit_cards_bounded.Step()); 1234 ASSERT_TRUE(s_credit_cards_bounded.Step());
1235 EXPECT_EQ(47, s_credit_cards_bounded.ColumnInt64(0)); 1235 EXPECT_EQ(47, s_credit_cards_bounded.ColumnInt64(0));
1236 ASSERT_TRUE(s_credit_cards_bounded.Step()); 1236 ASSERT_TRUE(s_credit_cards_bounded.Step());
1237 EXPECT_EQ(57, s_credit_cards_bounded.ColumnInt64(0)); 1237 EXPECT_EQ(57, s_credit_cards_bounded.ColumnInt64(0));
1238 ASSERT_TRUE(s_credit_cards_bounded.Step()); 1238 ASSERT_TRUE(s_credit_cards_bounded.Step());
1239 EXPECT_EQ(67, s_credit_cards_bounded.ColumnInt64(0)); 1239 EXPECT_EQ(67, s_credit_cards_bounded.ColumnInt64(0));
1240 EXPECT_FALSE(s_credit_cards_bounded.Step()); 1240 EXPECT_FALSE(s_credit_cards_bounded.Step());
1241 1241
1242 // Remove all entries modified on or after time 51 (unbounded range). 1242 // Remove all entries modified on or after time 51 (unbounded range).
1243 db.GetAutofillTable()->RemoveAutofillProfilesAndCreditCardsModifiedBetween( 1243 db.GetAutofillTable()->RemoveAutofillProfilesAndCreditCardsModifiedBetween(
1244 Time::FromTimeT(51), Time(), 1244 Time::FromTimeT(51), Time(),
1245 &profile_guids, &credit_card_guids); 1245 &profile_guids, &credit_card_guids);
1246 ASSERT_EQ(2UL, profile_guids.size()); 1246 ASSERT_EQ(2UL, profile_guids.size());
1247 EXPECT_EQ("00000000-0000-0000-0000-000000000004", profile_guids[0]); 1247 EXPECT_EQ("00000000-0000-0000-0000-000000000004", profile_guids[0]);
1248 EXPECT_EQ("00000000-0000-0000-0000-000000000005", profile_guids[1]); 1248 EXPECT_EQ("00000000-0000-0000-0000-000000000005", profile_guids[1]);
1249 sql::Statement s_autofill_profiles_unbounded( 1249 sql::Statement s_autofill_profiles_unbounded(
1250 db.GetSQLConnection()->GetUniqueStatement( 1250 db.GetSQLConnection()->GetUniqueStatement(
1251 "SELECT date_modified FROM autofill_profiles")); 1251 "SELECT date_modified FROM autofill_profiles"));
1252 ASSERT_TRUE(s_autofill_profiles_unbounded); 1252 ASSERT_TRUE(s_autofill_profiles_unbounded.is_valid());
1253 ASSERT_TRUE(s_autofill_profiles_unbounded.Step()); 1253 ASSERT_TRUE(s_autofill_profiles_unbounded.Step());
1254 EXPECT_EQ(11, s_autofill_profiles_unbounded.ColumnInt64(0)); 1254 EXPECT_EQ(11, s_autofill_profiles_unbounded.ColumnInt64(0));
1255 ASSERT_TRUE(s_autofill_profiles_unbounded.Step()); 1255 ASSERT_TRUE(s_autofill_profiles_unbounded.Step());
1256 EXPECT_EQ(41, s_autofill_profiles_unbounded.ColumnInt64(0)); 1256 EXPECT_EQ(41, s_autofill_profiles_unbounded.ColumnInt64(0));
1257 EXPECT_FALSE(s_autofill_profiles_unbounded.Step()); 1257 EXPECT_FALSE(s_autofill_profiles_unbounded.Step());
1258 ASSERT_EQ(2UL, credit_card_guids.size()); 1258 ASSERT_EQ(2UL, credit_card_guids.size());
1259 EXPECT_EQ("00000000-0000-0000-0000-000000000010", credit_card_guids[0]); 1259 EXPECT_EQ("00000000-0000-0000-0000-000000000010", credit_card_guids[0]);
1260 EXPECT_EQ("00000000-0000-0000-0000-000000000011", credit_card_guids[1]); 1260 EXPECT_EQ("00000000-0000-0000-0000-000000000011", credit_card_guids[1]);
1261 sql::Statement s_credit_cards_unbounded( 1261 sql::Statement s_credit_cards_unbounded(
1262 db.GetSQLConnection()->GetUniqueStatement( 1262 db.GetSQLConnection()->GetUniqueStatement(
1263 "SELECT date_modified FROM credit_cards")); 1263 "SELECT date_modified FROM credit_cards"));
1264 ASSERT_TRUE(s_credit_cards_unbounded); 1264 ASSERT_TRUE(s_credit_cards_unbounded.is_valid());
1265 ASSERT_TRUE(s_credit_cards_unbounded.Step()); 1265 ASSERT_TRUE(s_credit_cards_unbounded.Step());
1266 EXPECT_EQ(47, s_credit_cards_unbounded.ColumnInt64(0)); 1266 EXPECT_EQ(47, s_credit_cards_unbounded.ColumnInt64(0));
1267 EXPECT_FALSE(s_credit_cards_unbounded.Step()); 1267 EXPECT_FALSE(s_credit_cards_unbounded.Step());
1268 1268
1269 // Remove all remaining entries. 1269 // Remove all remaining entries.
1270 db.GetAutofillTable()->RemoveAutofillProfilesAndCreditCardsModifiedBetween( 1270 db.GetAutofillTable()->RemoveAutofillProfilesAndCreditCardsModifiedBetween(
1271 Time(), Time(), 1271 Time(), Time(),
1272 &profile_guids, &credit_card_guids); 1272 &profile_guids, &credit_card_guids);
1273 ASSERT_EQ(2UL, profile_guids.size()); 1273 ASSERT_EQ(2UL, profile_guids.size());
1274 EXPECT_EQ("00000000-0000-0000-0000-000000000000", profile_guids[0]); 1274 EXPECT_EQ("00000000-0000-0000-0000-000000000000", profile_guids[0]);
1275 EXPECT_EQ("00000000-0000-0000-0000-000000000003", profile_guids[1]); 1275 EXPECT_EQ("00000000-0000-0000-0000-000000000003", profile_guids[1]);
1276 sql::Statement s_autofill_profiles_empty( 1276 sql::Statement s_autofill_profiles_empty(
1277 db.GetSQLConnection()->GetUniqueStatement( 1277 db.GetSQLConnection()->GetUniqueStatement(
1278 "SELECT date_modified FROM autofill_profiles")); 1278 "SELECT date_modified FROM autofill_profiles"));
1279 ASSERT_TRUE(s_autofill_profiles_empty); 1279 ASSERT_TRUE(s_autofill_profiles_empty.is_valid());
1280 EXPECT_FALSE(s_autofill_profiles_empty.Step()); 1280 EXPECT_FALSE(s_autofill_profiles_empty.Step());
1281 ASSERT_EQ(1UL, credit_card_guids.size()); 1281 ASSERT_EQ(1UL, credit_card_guids.size());
1282 EXPECT_EQ("00000000-0000-0000-0000-000000000009", credit_card_guids[0]); 1282 EXPECT_EQ("00000000-0000-0000-0000-000000000009", credit_card_guids[0]);
1283 sql::Statement s_credit_cards_empty( 1283 sql::Statement s_credit_cards_empty(
1284 db.GetSQLConnection()->GetUniqueStatement( 1284 db.GetSQLConnection()->GetUniqueStatement(
1285 "SELECT date_modified FROM credit_cards")); 1285 "SELECT date_modified FROM credit_cards"));
1286 ASSERT_TRUE(s_credit_cards_empty); 1286 ASSERT_TRUE(s_credit_cards_empty.is_valid());
1287 EXPECT_FALSE(s_credit_cards_empty.Step()); 1287 EXPECT_FALSE(s_credit_cards_empty.Step());
1288 } 1288 }
1289 1289
1290 TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_NoResults) { 1290 TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_NoResults) {
1291 WebDatabase db; 1291 WebDatabase db;
1292 1292
1293 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); 1293 ASSERT_EQ(sql::INIT_OK, db.Init(file_));
1294 1294
1295 std::vector<AutofillEntry> entries; 1295 std::vector<AutofillEntry> entries;
1296 ASSERT_TRUE(db.GetAutofillTable()->GetAllAutofillEntries(&entries)); 1296 ASSERT_TRUE(db.GetAutofillTable()->GetAllAutofillEntries(&entries));
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 1435
1436 // make sure the lists of entries match 1436 // make sure the lists of entries match
1437 ASSERT_EQ(expected_entries.size(), entry_set.size()); 1437 ASSERT_EQ(expected_entries.size(), entry_set.size());
1438 AutofillEntrySetIterator it; 1438 AutofillEntrySetIterator it;
1439 for (it = entry_set.begin(); it != entry_set.end(); it++) { 1439 for (it = entry_set.begin(); it != entry_set.end(); it++) {
1440 expected_entries.erase(*it); 1440 expected_entries.erase(*it);
1441 } 1441 }
1442 1442
1443 EXPECT_EQ(0U, expected_entries.size()); 1443 EXPECT_EQ(0U, expected_entries.size());
1444 } 1444 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698