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

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

Issue 12987023: Rip autofill code out of webdataservice (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change method name in AutofillTable Created 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 db_credit_card.reset(tmp_credit_card); 1071 db_credit_card.reset(tmp_credit_card);
1072 EXPECT_EQ(credit_card, *db_credit_card); 1072 EXPECT_EQ(credit_card, *db_credit_card);
1073 sql::Statement s_unchanged(db_->GetSQLConnection()->GetUniqueStatement( 1073 sql::Statement s_unchanged(db_->GetSQLConnection()->GetUniqueStatement(
1074 "SELECT date_modified FROM credit_cards")); 1074 "SELECT date_modified FROM credit_cards"));
1075 ASSERT_TRUE(s_unchanged.is_valid()); 1075 ASSERT_TRUE(s_unchanged.is_valid());
1076 ASSERT_TRUE(s_unchanged.Step()); 1076 ASSERT_TRUE(s_unchanged.Step());
1077 EXPECT_EQ(mock_modification_date, s_unchanged.ColumnInt64(0)); 1077 EXPECT_EQ(mock_modification_date, s_unchanged.ColumnInt64(0));
1078 EXPECT_FALSE(s_unchanged.Step()); 1078 EXPECT_FALSE(s_unchanged.Step());
1079 } 1079 }
1080 1080
1081 TEST_F(AutofillTableTest, RemoveAutofillProfilesAndCreditCardsModifiedBetween) { 1081 TEST_F(AutofillTableTest, RemoveAutofillDataModifiedBetween) {
1082 // Populate the autofill_profiles and credit_cards tables. 1082 // Populate the autofill_profiles and credit_cards tables.
1083 ASSERT_TRUE(db_->GetSQLConnection()->Execute( 1083 ASSERT_TRUE(db_->GetSQLConnection()->Execute(
1084 "INSERT INTO autofill_profiles (guid, date_modified) " 1084 "INSERT INTO autofill_profiles (guid, date_modified) "
1085 "VALUES('00000000-0000-0000-0000-000000000000', 11);" 1085 "VALUES('00000000-0000-0000-0000-000000000000', 11);"
1086 "INSERT INTO autofill_profiles (guid, date_modified) " 1086 "INSERT INTO autofill_profiles (guid, date_modified) "
1087 "VALUES('00000000-0000-0000-0000-000000000001', 21);" 1087 "VALUES('00000000-0000-0000-0000-000000000001', 21);"
1088 "INSERT INTO autofill_profiles (guid, date_modified) " 1088 "INSERT INTO autofill_profiles (guid, date_modified) "
1089 "VALUES('00000000-0000-0000-0000-000000000002', 31);" 1089 "VALUES('00000000-0000-0000-0000-000000000002', 31);"
1090 "INSERT INTO autofill_profiles (guid, date_modified) " 1090 "INSERT INTO autofill_profiles (guid, date_modified) "
1091 "VALUES('00000000-0000-0000-0000-000000000003', 41);" 1091 "VALUES('00000000-0000-0000-0000-000000000003', 41);"
(...skipping 10 matching lines...) Expand all
1102 "INSERT INTO credit_cards (guid, date_modified) " 1102 "INSERT INTO credit_cards (guid, date_modified) "
1103 "VALUES('00000000-0000-0000-0000-000000000009', 47);" 1103 "VALUES('00000000-0000-0000-0000-000000000009', 47);"
1104 "INSERT INTO credit_cards (guid, date_modified) " 1104 "INSERT INTO credit_cards (guid, date_modified) "
1105 "VALUES('00000000-0000-0000-0000-000000000010', 57);" 1105 "VALUES('00000000-0000-0000-0000-000000000010', 57);"
1106 "INSERT INTO credit_cards (guid, date_modified) " 1106 "INSERT INTO credit_cards (guid, date_modified) "
1107 "VALUES('00000000-0000-0000-0000-000000000011', 67);")); 1107 "VALUES('00000000-0000-0000-0000-000000000011', 67);"));
1108 1108
1109 // Remove all entries modified in the bounded time range [17,41). 1109 // Remove all entries modified in the bounded time range [17,41).
1110 std::vector<std::string> profile_guids; 1110 std::vector<std::string> profile_guids;
1111 std::vector<std::string> credit_card_guids; 1111 std::vector<std::string> credit_card_guids;
1112 table_->RemoveAutofillProfilesAndCreditCardsModifiedBetween( 1112 table_->RemoveAutofillDataModifiedBetween(
1113 Time::FromTimeT(17), Time::FromTimeT(41), 1113 Time::FromTimeT(17), Time::FromTimeT(41),
1114 &profile_guids, &credit_card_guids); 1114 &profile_guids, &credit_card_guids);
1115 ASSERT_EQ(2UL, profile_guids.size()); 1115 ASSERT_EQ(2UL, profile_guids.size());
1116 EXPECT_EQ("00000000-0000-0000-0000-000000000001", profile_guids[0]); 1116 EXPECT_EQ("00000000-0000-0000-0000-000000000001", profile_guids[0]);
1117 EXPECT_EQ("00000000-0000-0000-0000-000000000002", profile_guids[1]); 1117 EXPECT_EQ("00000000-0000-0000-0000-000000000002", profile_guids[1]);
1118 sql::Statement s_autofill_profiles_bounded( 1118 sql::Statement s_autofill_profiles_bounded(
1119 db_->GetSQLConnection()->GetUniqueStatement( 1119 db_->GetSQLConnection()->GetUniqueStatement(
1120 "SELECT date_modified FROM autofill_profiles")); 1120 "SELECT date_modified FROM autofill_profiles"));
1121 ASSERT_TRUE(s_autofill_profiles_bounded.is_valid()); 1121 ASSERT_TRUE(s_autofill_profiles_bounded.is_valid());
1122 ASSERT_TRUE(s_autofill_profiles_bounded.Step()); 1122 ASSERT_TRUE(s_autofill_profiles_bounded.Step());
(...skipping 15 matching lines...) Expand all
1138 ASSERT_TRUE(s_credit_cards_bounded.is_valid()); 1138 ASSERT_TRUE(s_credit_cards_bounded.is_valid());
1139 ASSERT_TRUE(s_credit_cards_bounded.Step()); 1139 ASSERT_TRUE(s_credit_cards_bounded.Step());
1140 EXPECT_EQ(47, s_credit_cards_bounded.ColumnInt64(0)); 1140 EXPECT_EQ(47, s_credit_cards_bounded.ColumnInt64(0));
1141 ASSERT_TRUE(s_credit_cards_bounded.Step()); 1141 ASSERT_TRUE(s_credit_cards_bounded.Step());
1142 EXPECT_EQ(57, s_credit_cards_bounded.ColumnInt64(0)); 1142 EXPECT_EQ(57, s_credit_cards_bounded.ColumnInt64(0));
1143 ASSERT_TRUE(s_credit_cards_bounded.Step()); 1143 ASSERT_TRUE(s_credit_cards_bounded.Step());
1144 EXPECT_EQ(67, s_credit_cards_bounded.ColumnInt64(0)); 1144 EXPECT_EQ(67, s_credit_cards_bounded.ColumnInt64(0));
1145 EXPECT_FALSE(s_credit_cards_bounded.Step()); 1145 EXPECT_FALSE(s_credit_cards_bounded.Step());
1146 1146
1147 // Remove all entries modified on or after time 51 (unbounded range). 1147 // Remove all entries modified on or after time 51 (unbounded range).
1148 table_->RemoveAutofillProfilesAndCreditCardsModifiedBetween( 1148 table_->RemoveAutofillDataModifiedBetween(
1149 Time::FromTimeT(51), Time(), 1149 Time::FromTimeT(51), Time(),
1150 &profile_guids, &credit_card_guids); 1150 &profile_guids, &credit_card_guids);
1151 ASSERT_EQ(2UL, profile_guids.size()); 1151 ASSERT_EQ(2UL, profile_guids.size());
1152 EXPECT_EQ("00000000-0000-0000-0000-000000000004", profile_guids[0]); 1152 EXPECT_EQ("00000000-0000-0000-0000-000000000004", profile_guids[0]);
1153 EXPECT_EQ("00000000-0000-0000-0000-000000000005", profile_guids[1]); 1153 EXPECT_EQ("00000000-0000-0000-0000-000000000005", profile_guids[1]);
1154 sql::Statement s_autofill_profiles_unbounded( 1154 sql::Statement s_autofill_profiles_unbounded(
1155 db_->GetSQLConnection()->GetUniqueStatement( 1155 db_->GetSQLConnection()->GetUniqueStatement(
1156 "SELECT date_modified FROM autofill_profiles")); 1156 "SELECT date_modified FROM autofill_profiles"));
1157 ASSERT_TRUE(s_autofill_profiles_unbounded.is_valid()); 1157 ASSERT_TRUE(s_autofill_profiles_unbounded.is_valid());
1158 ASSERT_TRUE(s_autofill_profiles_unbounded.Step()); 1158 ASSERT_TRUE(s_autofill_profiles_unbounded.Step());
1159 EXPECT_EQ(11, s_autofill_profiles_unbounded.ColumnInt64(0)); 1159 EXPECT_EQ(11, s_autofill_profiles_unbounded.ColumnInt64(0));
1160 ASSERT_TRUE(s_autofill_profiles_unbounded.Step()); 1160 ASSERT_TRUE(s_autofill_profiles_unbounded.Step());
1161 EXPECT_EQ(41, s_autofill_profiles_unbounded.ColumnInt64(0)); 1161 EXPECT_EQ(41, s_autofill_profiles_unbounded.ColumnInt64(0));
1162 EXPECT_FALSE(s_autofill_profiles_unbounded.Step()); 1162 EXPECT_FALSE(s_autofill_profiles_unbounded.Step());
1163 ASSERT_EQ(2UL, credit_card_guids.size()); 1163 ASSERT_EQ(2UL, credit_card_guids.size());
1164 EXPECT_EQ("00000000-0000-0000-0000-000000000010", credit_card_guids[0]); 1164 EXPECT_EQ("00000000-0000-0000-0000-000000000010", credit_card_guids[0]);
1165 EXPECT_EQ("00000000-0000-0000-0000-000000000011", credit_card_guids[1]); 1165 EXPECT_EQ("00000000-0000-0000-0000-000000000011", credit_card_guids[1]);
1166 sql::Statement s_credit_cards_unbounded( 1166 sql::Statement s_credit_cards_unbounded(
1167 db_->GetSQLConnection()->GetUniqueStatement( 1167 db_->GetSQLConnection()->GetUniqueStatement(
1168 "SELECT date_modified FROM credit_cards")); 1168 "SELECT date_modified FROM credit_cards"));
1169 ASSERT_TRUE(s_credit_cards_unbounded.is_valid()); 1169 ASSERT_TRUE(s_credit_cards_unbounded.is_valid());
1170 ASSERT_TRUE(s_credit_cards_unbounded.Step()); 1170 ASSERT_TRUE(s_credit_cards_unbounded.Step());
1171 EXPECT_EQ(47, s_credit_cards_unbounded.ColumnInt64(0)); 1171 EXPECT_EQ(47, s_credit_cards_unbounded.ColumnInt64(0));
1172 EXPECT_FALSE(s_credit_cards_unbounded.Step()); 1172 EXPECT_FALSE(s_credit_cards_unbounded.Step());
1173 1173
1174 // Remove all remaining entries. 1174 // Remove all remaining entries.
1175 table_->RemoveAutofillProfilesAndCreditCardsModifiedBetween( 1175 table_->RemoveAutofillDataModifiedBetween(
1176 Time(), Time(), 1176 Time(), Time(),
1177 &profile_guids, &credit_card_guids); 1177 &profile_guids, &credit_card_guids);
1178 ASSERT_EQ(2UL, profile_guids.size()); 1178 ASSERT_EQ(2UL, profile_guids.size());
1179 EXPECT_EQ("00000000-0000-0000-0000-000000000000", profile_guids[0]); 1179 EXPECT_EQ("00000000-0000-0000-0000-000000000000", profile_guids[0]);
1180 EXPECT_EQ("00000000-0000-0000-0000-000000000003", profile_guids[1]); 1180 EXPECT_EQ("00000000-0000-0000-0000-000000000003", profile_guids[1]);
1181 sql::Statement s_autofill_profiles_empty( 1181 sql::Statement s_autofill_profiles_empty(
1182 db_->GetSQLConnection()->GetUniqueStatement( 1182 db_->GetSQLConnection()->GetUniqueStatement(
1183 "SELECT date_modified FROM autofill_profiles")); 1183 "SELECT date_modified FROM autofill_profiles"));
1184 ASSERT_TRUE(s_autofill_profiles_empty.is_valid()); 1184 ASSERT_TRUE(s_autofill_profiles_empty.is_valid());
1185 EXPECT_FALSE(s_autofill_profiles_empty.Step()); 1185 EXPECT_FALSE(s_autofill_profiles_empty.Step());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 1320
1321 // make sure the lists of entries match 1321 // make sure the lists of entries match
1322 ASSERT_EQ(expected_entries.size(), entry_set.size()); 1322 ASSERT_EQ(expected_entries.size(), entry_set.size());
1323 AutofillEntrySetIterator it; 1323 AutofillEntrySetIterator it;
1324 for (it = entry_set.begin(); it != entry_set.end(); it++) { 1324 for (it = entry_set.begin(); it != entry_set.end(); it++) {
1325 expected_entries.erase(*it); 1325 expected_entries.erase(*it);
1326 } 1326 }
1327 1327
1328 EXPECT_EQ(0U, expected_entries.size()); 1328 EXPECT_EQ(0U, expected_entries.size());
1329 } 1329 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/autofill_table.cc ('k') | chrome/browser/webdata/autofill_web_data_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698