| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 file_ = temp_dir_.path().AppendASCII("TestWebDatabase"); | 129 file_ = temp_dir_.path().AppendASCII("TestWebDatabase"); |
| 130 | 130 |
| 131 table_.reset(new AutofillTable); | 131 table_.reset(new AutofillTable); |
| 132 db_.reset(new WebDatabase); | 132 db_.reset(new WebDatabase); |
| 133 db_->AddTable(table_.get()); | 133 db_->AddTable(table_.get()); |
| 134 ASSERT_EQ(sql::INIT_OK, db_->Init(file_)); | 134 ASSERT_EQ(sql::INIT_OK, db_->Init(file_)); |
| 135 } | 135 } |
| 136 | 136 |
| 137 base::FilePath file_; | 137 base::FilePath file_; |
| 138 base::ScopedTempDir temp_dir_; | 138 base::ScopedTempDir temp_dir_; |
| 139 scoped_ptr<AutofillTable> table_; | 139 std::unique_ptr<AutofillTable> table_; |
| 140 scoped_ptr<WebDatabase> db_; | 140 std::unique_ptr<WebDatabase> db_; |
| 141 | 141 |
| 142 private: | 142 private: |
| 143 DISALLOW_COPY_AND_ASSIGN(AutofillTableTest); | 143 DISALLOW_COPY_AND_ASSIGN(AutofillTableTest); |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 TEST_F(AutofillTableTest, Autofill) { | 146 TEST_F(AutofillTableTest, Autofill) { |
| 147 Time t1 = Time::Now(); | 147 Time t1 = Time::Now(); |
| 148 | 148 |
| 149 // Simulate the submission of a handful of entries in a field called "Name", | 149 // Simulate the submission of a handful of entries in a field called "Name", |
| 150 // some more often than others. | 150 // some more often than others. |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 home_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, ASCIIToUTF16("MAGIC ###")); | 722 home_profile.SetRawInfo(ADDRESS_HOME_SORTING_CODE, ASCIIToUTF16("MAGIC ###")); |
| 723 home_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); | 723 home_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); |
| 724 home_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567")); | 724 home_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567")); |
| 725 home_profile.set_language_code("en"); | 725 home_profile.set_language_code("en"); |
| 726 | 726 |
| 727 Time pre_creation_time = Time::Now(); | 727 Time pre_creation_time = Time::Now(); |
| 728 EXPECT_TRUE(table_->AddAutofillProfile(home_profile)); | 728 EXPECT_TRUE(table_->AddAutofillProfile(home_profile)); |
| 729 Time post_creation_time = Time::Now(); | 729 Time post_creation_time = Time::Now(); |
| 730 | 730 |
| 731 // Get the 'Home' profile. | 731 // Get the 'Home' profile. |
| 732 scoped_ptr<AutofillProfile> db_profile = | 732 std::unique_ptr<AutofillProfile> db_profile = |
| 733 table_->GetAutofillProfile(home_profile.guid()); | 733 table_->GetAutofillProfile(home_profile.guid()); |
| 734 ASSERT_TRUE(db_profile); | 734 ASSERT_TRUE(db_profile); |
| 735 EXPECT_EQ(home_profile, *db_profile); | 735 EXPECT_EQ(home_profile, *db_profile); |
| 736 sql::Statement s_home(db_->GetSQLConnection()->GetUniqueStatement( | 736 sql::Statement s_home(db_->GetSQLConnection()->GetUniqueStatement( |
| 737 "SELECT date_modified " | 737 "SELECT date_modified " |
| 738 "FROM autofill_profiles WHERE guid=?")); | 738 "FROM autofill_profiles WHERE guid=?")); |
| 739 s_home.BindString(0, home_profile.guid()); | 739 s_home.BindString(0, home_profile.guid()); |
| 740 ASSERT_TRUE(s_home.is_valid()); | 740 ASSERT_TRUE(s_home.is_valid()); |
| 741 ASSERT_TRUE(s_home.Step()); | 741 ASSERT_TRUE(s_home.Step()); |
| 742 EXPECT_GE(s_home.ColumnInt64(0), pre_creation_time.ToTimeT()); | 742 EXPECT_GE(s_home.ColumnInt64(0), pre_creation_time.ToTimeT()); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1 Main St")); | 861 profile.SetRawInfo(ADDRESS_HOME_LINE1, ASCIIToUTF16("1 Main St")); |
| 862 profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Los Angeles")); | 862 profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("Los Angeles")); |
| 863 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); | 863 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("CA")); |
| 864 profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025")); | 864 profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025")); |
| 865 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); | 865 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); |
| 866 | 866 |
| 867 // Mark this profile as in the trash. This stops |AddAutofillProfile| from | 867 // Mark this profile as in the trash. This stops |AddAutofillProfile| from |
| 868 // adding it. | 868 // adding it. |
| 869 EXPECT_TRUE(table_->AddAutofillGUIDToTrash(profile.guid())); | 869 EXPECT_TRUE(table_->AddAutofillGUIDToTrash(profile.guid())); |
| 870 EXPECT_TRUE(table_->AddAutofillProfile(profile)); | 870 EXPECT_TRUE(table_->AddAutofillProfile(profile)); |
| 871 scoped_ptr<AutofillProfile> added_profile = | 871 std::unique_ptr<AutofillProfile> added_profile = |
| 872 table_->GetAutofillProfile(profile.guid()); | 872 table_->GetAutofillProfile(profile.guid()); |
| 873 EXPECT_FALSE(added_profile); | 873 EXPECT_FALSE(added_profile); |
| 874 | 874 |
| 875 // Add the profile for real this time. | 875 // Add the profile for real this time. |
| 876 EXPECT_TRUE(table_->EmptyAutofillProfilesTrash()); | 876 EXPECT_TRUE(table_->EmptyAutofillProfilesTrash()); |
| 877 EXPECT_TRUE(table_->GetAutofillProfilesInTrash(&guids)); | 877 EXPECT_TRUE(table_->GetAutofillProfilesInTrash(&guids)); |
| 878 EXPECT_TRUE(guids.empty()); | 878 EXPECT_TRUE(guids.empty()); |
| 879 EXPECT_TRUE(table_->AddAutofillProfile(profile)); | 879 EXPECT_TRUE(table_->AddAutofillProfile(profile)); |
| 880 added_profile = table_->GetAutofillProfile(profile.guid()); | 880 added_profile = table_->GetAutofillProfile(profile.guid()); |
| 881 EXPECT_TRUE(added_profile); | 881 EXPECT_TRUE(added_profile); |
| 882 | 882 |
| 883 // Mark this profile as in the trash. This stops |UpdateAutofillProfileMulti| | 883 // Mark this profile as in the trash. This stops |UpdateAutofillProfileMulti| |
| 884 // from updating it. In normal operation a profile should not be both in the | 884 // from updating it. In normal operation a profile should not be both in the |
| 885 // trash and in the profiles table simultaneously. | 885 // trash and in the profiles table simultaneously. |
| 886 EXPECT_TRUE(table_->AddAutofillGUIDToTrash(profile.guid())); | 886 EXPECT_TRUE(table_->AddAutofillGUIDToTrash(profile.guid())); |
| 887 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Jane")); | 887 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Jane")); |
| 888 EXPECT_TRUE(table_->UpdateAutofillProfile(profile)); | 888 EXPECT_TRUE(table_->UpdateAutofillProfile(profile)); |
| 889 scoped_ptr<AutofillProfile> updated_profile = | 889 std::unique_ptr<AutofillProfile> updated_profile = |
| 890 table_->GetAutofillProfile(profile.guid()); | 890 table_->GetAutofillProfile(profile.guid()); |
| 891 EXPECT_TRUE(updated_profile); | 891 EXPECT_TRUE(updated_profile); |
| 892 EXPECT_EQ(ASCIIToUTF16("John"), updated_profile->GetRawInfo(NAME_FIRST)); | 892 EXPECT_EQ(ASCIIToUTF16("John"), updated_profile->GetRawInfo(NAME_FIRST)); |
| 893 | 893 |
| 894 // Try to delete the trashed profile. This stops |RemoveAutofillProfile| from | 894 // Try to delete the trashed profile. This stops |RemoveAutofillProfile| from |
| 895 // deleting it. In normal operation deletion is done by migration step, and | 895 // deleting it. In normal operation deletion is done by migration step, and |
| 896 // removal from trash is done by |WebDataService|. |RemoveAutofillProfile| | 896 // removal from trash is done by |WebDataService|. |RemoveAutofillProfile| |
| 897 // does remove the item from the trash if it is found however, so that if | 897 // does remove the item from the trash if it is found however, so that if |
| 898 // other clients remove it (via Sync say) then it is gone and doesn't need to | 898 // other clients remove it (via Sync say) then it is gone and doesn't need to |
| 899 // be processed further by |WebDataService|. | 899 // be processed further by |WebDataService|. |
| 900 EXPECT_TRUE(table_->RemoveAutofillProfile(profile.guid())); | 900 EXPECT_TRUE(table_->RemoveAutofillProfile(profile.guid())); |
| 901 scoped_ptr<AutofillProfile> removed_profile = | 901 std::unique_ptr<AutofillProfile> removed_profile = |
| 902 table_->GetAutofillProfile(profile.guid()); | 902 table_->GetAutofillProfile(profile.guid()); |
| 903 EXPECT_TRUE(removed_profile); | 903 EXPECT_TRUE(removed_profile); |
| 904 EXPECT_FALSE(table_->IsAutofillGUIDInTrash(profile.guid())); | 904 EXPECT_FALSE(table_->IsAutofillGUIDInTrash(profile.guid())); |
| 905 | 905 |
| 906 // Check that emptying the trash now allows removal to occur. | 906 // Check that emptying the trash now allows removal to occur. |
| 907 EXPECT_TRUE(table_->EmptyAutofillProfilesTrash()); | 907 EXPECT_TRUE(table_->EmptyAutofillProfilesTrash()); |
| 908 EXPECT_TRUE(table_->RemoveAutofillProfile(profile.guid())); | 908 EXPECT_TRUE(table_->RemoveAutofillProfile(profile.guid())); |
| 909 removed_profile = table_->GetAutofillProfile(profile.guid()); | 909 removed_profile = table_->GetAutofillProfile(profile.guid()); |
| 910 EXPECT_FALSE(removed_profile); | 910 EXPECT_FALSE(removed_profile); |
| 911 } | 911 } |
| 912 | 912 |
| 913 TEST_F(AutofillTableTest, CreditCard) { | 913 TEST_F(AutofillTableTest, CreditCard) { |
| 914 // Add a 'Work' credit card. | 914 // Add a 'Work' credit card. |
| 915 CreditCard work_creditcard; | 915 CreditCard work_creditcard; |
| 916 work_creditcard.set_origin("https://www.example.com/"); | 916 work_creditcard.set_origin("https://www.example.com/"); |
| 917 work_creditcard.SetRawInfo(CREDIT_CARD_NAME_FULL, | 917 work_creditcard.SetRawInfo(CREDIT_CARD_NAME_FULL, |
| 918 ASCIIToUTF16("Jack Torrance")); | 918 ASCIIToUTF16("Jack Torrance")); |
| 919 work_creditcard.SetRawInfo(CREDIT_CARD_NUMBER, | 919 work_creditcard.SetRawInfo(CREDIT_CARD_NUMBER, |
| 920 ASCIIToUTF16("1234567890123456")); | 920 ASCIIToUTF16("1234567890123456")); |
| 921 work_creditcard.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("04")); | 921 work_creditcard.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("04")); |
| 922 work_creditcard.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, | 922 work_creditcard.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, |
| 923 ASCIIToUTF16("2013")); | 923 ASCIIToUTF16("2013")); |
| 924 | 924 |
| 925 Time pre_creation_time = Time::Now(); | 925 Time pre_creation_time = Time::Now(); |
| 926 EXPECT_TRUE(table_->AddCreditCard(work_creditcard)); | 926 EXPECT_TRUE(table_->AddCreditCard(work_creditcard)); |
| 927 Time post_creation_time = Time::Now(); | 927 Time post_creation_time = Time::Now(); |
| 928 | 928 |
| 929 // Get the 'Work' credit card. | 929 // Get the 'Work' credit card. |
| 930 scoped_ptr<CreditCard> db_creditcard = | 930 std::unique_ptr<CreditCard> db_creditcard = |
| 931 table_->GetCreditCard(work_creditcard.guid()); | 931 table_->GetCreditCard(work_creditcard.guid()); |
| 932 ASSERT_TRUE(db_creditcard); | 932 ASSERT_TRUE(db_creditcard); |
| 933 EXPECT_EQ(work_creditcard, *db_creditcard); | 933 EXPECT_EQ(work_creditcard, *db_creditcard); |
| 934 sql::Statement s_work(db_->GetSQLConnection()->GetUniqueStatement( | 934 sql::Statement s_work(db_->GetSQLConnection()->GetUniqueStatement( |
| 935 "SELECT guid, name_on_card, expiration_month, expiration_year, " | 935 "SELECT guid, name_on_card, expiration_month, expiration_year, " |
| 936 "card_number_encrypted, date_modified " | 936 "card_number_encrypted, date_modified " |
| 937 "FROM credit_cards WHERE guid=?")); | 937 "FROM credit_cards WHERE guid=?")); |
| 938 s_work.BindString(0, work_creditcard.guid()); | 938 s_work.BindString(0, work_creditcard.guid()); |
| 939 ASSERT_TRUE(s_work.is_valid()); | 939 ASSERT_TRUE(s_work.is_valid()); |
| 940 ASSERT_TRUE(s_work.Step()); | 940 ASSERT_TRUE(s_work.Step()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 // Set a mocked value for the profile's creation time. | 1018 // Set a mocked value for the profile's creation time. |
| 1019 const time_t kMockCreationDate = Time::Now().ToTimeT() - 13; | 1019 const time_t kMockCreationDate = Time::Now().ToTimeT() - 13; |
| 1020 sql::Statement s_mock_creation_date( | 1020 sql::Statement s_mock_creation_date( |
| 1021 db_->GetSQLConnection()->GetUniqueStatement( | 1021 db_->GetSQLConnection()->GetUniqueStatement( |
| 1022 "UPDATE autofill_profiles SET date_modified = ?")); | 1022 "UPDATE autofill_profiles SET date_modified = ?")); |
| 1023 ASSERT_TRUE(s_mock_creation_date.is_valid()); | 1023 ASSERT_TRUE(s_mock_creation_date.is_valid()); |
| 1024 s_mock_creation_date.BindInt64(0, kMockCreationDate); | 1024 s_mock_creation_date.BindInt64(0, kMockCreationDate); |
| 1025 ASSERT_TRUE(s_mock_creation_date.Run()); | 1025 ASSERT_TRUE(s_mock_creation_date.Run()); |
| 1026 | 1026 |
| 1027 // Get the profile. | 1027 // Get the profile. |
| 1028 scoped_ptr<AutofillProfile> db_profile = | 1028 std::unique_ptr<AutofillProfile> db_profile = |
| 1029 table_->GetAutofillProfile(profile.guid()); | 1029 table_->GetAutofillProfile(profile.guid()); |
| 1030 ASSERT_TRUE(db_profile); | 1030 ASSERT_TRUE(db_profile); |
| 1031 EXPECT_EQ(profile, *db_profile); | 1031 EXPECT_EQ(profile, *db_profile); |
| 1032 sql::Statement s_original(db_->GetSQLConnection()->GetUniqueStatement( | 1032 sql::Statement s_original(db_->GetSQLConnection()->GetUniqueStatement( |
| 1033 "SELECT date_modified FROM autofill_profiles")); | 1033 "SELECT date_modified FROM autofill_profiles")); |
| 1034 ASSERT_TRUE(s_original.is_valid()); | 1034 ASSERT_TRUE(s_original.is_valid()); |
| 1035 ASSERT_TRUE(s_original.Step()); | 1035 ASSERT_TRUE(s_original.Step()); |
| 1036 EXPECT_EQ(kMockCreationDate, s_original.ColumnInt64(0)); | 1036 EXPECT_EQ(kMockCreationDate, s_original.ColumnInt64(0)); |
| 1037 EXPECT_FALSE(s_original.Step()); | 1037 EXPECT_FALSE(s_original.Step()); |
| 1038 | 1038 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 // Set a mocked value for the credit card's creation time. | 1089 // Set a mocked value for the credit card's creation time. |
| 1090 const time_t kMockCreationDate = Time::Now().ToTimeT() - 13; | 1090 const time_t kMockCreationDate = Time::Now().ToTimeT() - 13; |
| 1091 sql::Statement s_mock_creation_date( | 1091 sql::Statement s_mock_creation_date( |
| 1092 db_->GetSQLConnection()->GetUniqueStatement( | 1092 db_->GetSQLConnection()->GetUniqueStatement( |
| 1093 "UPDATE credit_cards SET date_modified = ?")); | 1093 "UPDATE credit_cards SET date_modified = ?")); |
| 1094 ASSERT_TRUE(s_mock_creation_date.is_valid()); | 1094 ASSERT_TRUE(s_mock_creation_date.is_valid()); |
| 1095 s_mock_creation_date.BindInt64(0, kMockCreationDate); | 1095 s_mock_creation_date.BindInt64(0, kMockCreationDate); |
| 1096 ASSERT_TRUE(s_mock_creation_date.Run()); | 1096 ASSERT_TRUE(s_mock_creation_date.Run()); |
| 1097 | 1097 |
| 1098 // Get the credit card. | 1098 // Get the credit card. |
| 1099 scoped_ptr<CreditCard> db_credit_card = | 1099 std::unique_ptr<CreditCard> db_credit_card = |
| 1100 table_->GetCreditCard(credit_card.guid()); | 1100 table_->GetCreditCard(credit_card.guid()); |
| 1101 ASSERT_TRUE(db_credit_card); | 1101 ASSERT_TRUE(db_credit_card); |
| 1102 EXPECT_EQ(credit_card, *db_credit_card); | 1102 EXPECT_EQ(credit_card, *db_credit_card); |
| 1103 sql::Statement s_original(db_->GetSQLConnection()->GetUniqueStatement( | 1103 sql::Statement s_original(db_->GetSQLConnection()->GetUniqueStatement( |
| 1104 "SELECT date_modified FROM credit_cards")); | 1104 "SELECT date_modified FROM credit_cards")); |
| 1105 ASSERT_TRUE(s_original.is_valid()); | 1105 ASSERT_TRUE(s_original.is_valid()); |
| 1106 ASSERT_TRUE(s_original.Step()); | 1106 ASSERT_TRUE(s_original.Step()); |
| 1107 EXPECT_EQ(kMockCreationDate, s_original.ColumnInt64(0)); | 1107 EXPECT_EQ(kMockCreationDate, s_original.ColumnInt64(0)); |
| 1108 EXPECT_FALSE(s_original.Step()); | 1108 EXPECT_FALSE(s_original.Step()); |
| 1109 | 1109 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 // Set a mocked value for the profile's creation time. | 1168 // Set a mocked value for the profile's creation time. |
| 1169 const time_t kMockCreationDate = Time::Now().ToTimeT() - 13; | 1169 const time_t kMockCreationDate = Time::Now().ToTimeT() - 13; |
| 1170 sql::Statement s_mock_creation_date( | 1170 sql::Statement s_mock_creation_date( |
| 1171 db_->GetSQLConnection()->GetUniqueStatement( | 1171 db_->GetSQLConnection()->GetUniqueStatement( |
| 1172 "UPDATE autofill_profiles SET date_modified = ?")); | 1172 "UPDATE autofill_profiles SET date_modified = ?")); |
| 1173 ASSERT_TRUE(s_mock_creation_date.is_valid()); | 1173 ASSERT_TRUE(s_mock_creation_date.is_valid()); |
| 1174 s_mock_creation_date.BindInt64(0, kMockCreationDate); | 1174 s_mock_creation_date.BindInt64(0, kMockCreationDate); |
| 1175 ASSERT_TRUE(s_mock_creation_date.Run()); | 1175 ASSERT_TRUE(s_mock_creation_date.Run()); |
| 1176 | 1176 |
| 1177 // Get the profile. | 1177 // Get the profile. |
| 1178 scoped_ptr<AutofillProfile> db_profile = | 1178 std::unique_ptr<AutofillProfile> db_profile = |
| 1179 table_->GetAutofillProfile(profile.guid()); | 1179 table_->GetAutofillProfile(profile.guid()); |
| 1180 ASSERT_TRUE(db_profile); | 1180 ASSERT_TRUE(db_profile); |
| 1181 EXPECT_EQ(profile, *db_profile); | 1181 EXPECT_EQ(profile, *db_profile); |
| 1182 sql::Statement s_original(db_->GetSQLConnection()->GetUniqueStatement( | 1182 sql::Statement s_original(db_->GetSQLConnection()->GetUniqueStatement( |
| 1183 "SELECT date_modified FROM autofill_profiles")); | 1183 "SELECT date_modified FROM autofill_profiles")); |
| 1184 ASSERT_TRUE(s_original.is_valid()); | 1184 ASSERT_TRUE(s_original.is_valid()); |
| 1185 ASSERT_TRUE(s_original.Step()); | 1185 ASSERT_TRUE(s_original.Step()); |
| 1186 EXPECT_EQ(kMockCreationDate, s_original.ColumnInt64(0)); | 1186 EXPECT_EQ(kMockCreationDate, s_original.ColumnInt64(0)); |
| 1187 EXPECT_FALSE(s_original.Step()); | 1187 EXPECT_FALSE(s_original.Step()); |
| 1188 | 1188 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1215 // Set a mocked value for the credit card's creation time. | 1215 // Set a mocked value for the credit card's creation time. |
| 1216 const time_t kMockCreationDate = Time::Now().ToTimeT() - 13; | 1216 const time_t kMockCreationDate = Time::Now().ToTimeT() - 13; |
| 1217 sql::Statement s_mock_creation_date( | 1217 sql::Statement s_mock_creation_date( |
| 1218 db_->GetSQLConnection()->GetUniqueStatement( | 1218 db_->GetSQLConnection()->GetUniqueStatement( |
| 1219 "UPDATE credit_cards SET date_modified = ?")); | 1219 "UPDATE credit_cards SET date_modified = ?")); |
| 1220 ASSERT_TRUE(s_mock_creation_date.is_valid()); | 1220 ASSERT_TRUE(s_mock_creation_date.is_valid()); |
| 1221 s_mock_creation_date.BindInt64(0, kMockCreationDate); | 1221 s_mock_creation_date.BindInt64(0, kMockCreationDate); |
| 1222 ASSERT_TRUE(s_mock_creation_date.Run()); | 1222 ASSERT_TRUE(s_mock_creation_date.Run()); |
| 1223 | 1223 |
| 1224 // Get the credit card. | 1224 // Get the credit card. |
| 1225 scoped_ptr<CreditCard> db_credit_card = | 1225 std::unique_ptr<CreditCard> db_credit_card = |
| 1226 table_->GetCreditCard(credit_card.guid()); | 1226 table_->GetCreditCard(credit_card.guid()); |
| 1227 ASSERT_TRUE(db_credit_card); | 1227 ASSERT_TRUE(db_credit_card); |
| 1228 EXPECT_EQ(credit_card, *db_credit_card); | 1228 EXPECT_EQ(credit_card, *db_credit_card); |
| 1229 sql::Statement s_original(db_->GetSQLConnection()->GetUniqueStatement( | 1229 sql::Statement s_original(db_->GetSQLConnection()->GetUniqueStatement( |
| 1230 "SELECT date_modified FROM credit_cards")); | 1230 "SELECT date_modified FROM credit_cards")); |
| 1231 ASSERT_TRUE(s_original.is_valid()); | 1231 ASSERT_TRUE(s_original.is_valid()); |
| 1232 ASSERT_TRUE(s_original.Step()); | 1232 ASSERT_TRUE(s_original.Step()); |
| 1233 EXPECT_EQ(kMockCreationDate, s_original.ColumnInt64(0)); | 1233 EXPECT_EQ(kMockCreationDate, s_original.ColumnInt64(0)); |
| 1234 EXPECT_FALSE(s_original.Step()); | 1234 EXPECT_FALSE(s_original.Step()); |
| 1235 | 1235 |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 for (size_t j = 0; j < kTestCases[i].expected_suggestion_count; ++j) { | 1978 for (size_t j = 0; j < kTestCases[i].expected_suggestion_count; ++j) { |
| 1979 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_suggestion[j]), v[j]); | 1979 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_suggestion[j]), v[j]); |
| 1980 } | 1980 } |
| 1981 | 1981 |
| 1982 changes.clear(); | 1982 changes.clear(); |
| 1983 table_->RemoveFormElementsAddedBetween(t1, Time(), &changes); | 1983 table_->RemoveFormElementsAddedBetween(t1, Time(), &changes); |
| 1984 } | 1984 } |
| 1985 } | 1985 } |
| 1986 | 1986 |
| 1987 } // namespace autofill | 1987 } // namespace autofill |
| OLD | NEW |