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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1173 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
1174 &unique_ids)); | 1174 &unique_ids)); |
1175 | 1175 |
1176 base::string16 expected_values[] = { | 1176 base::string16 expected_values[] = { |
1177 ASCIIToUTF16("************3456"), | 1177 ASCIIToUTF16("************3456"), |
1178 ASCIIToUTF16("************8765") | 1178 ASCIIToUTF16("************8765") |
1179 }; | 1179 }; |
1180 base::string16 expected_labels[] = { ASCIIToUTF16("*3456"), | 1180 base::string16 expected_labels[] = { ASCIIToUTF16("*3456"), |
1181 ASCIIToUTF16("*8765")}; | 1181 ASCIIToUTF16("*8765")}; |
1182 base::string16 expected_icons[] = { | 1182 base::string16 expected_icons[] = { |
1183 ASCIIToUTF16("visaCC"), | 1183 ASCIIToUTF16(kVisaCard), |
1184 ASCIIToUTF16("genericCC") | 1184 ASCIIToUTF16(kMasterCard) |
1185 }; | 1185 }; |
1186 int expected_unique_ids[] = { | 1186 int expected_unique_ids[] = { |
1187 autofill_manager_->GetPackedCreditCardID(4), | 1187 autofill_manager_->GetPackedCreditCardID(4), |
1188 autofill_manager_->GetPackedCreditCardID(5) | 1188 autofill_manager_->GetPackedCreditCardID(5) |
1189 }; | 1189 }; |
1190 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1190 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
1191 kDefaultPageID, arraysize(expected_values), expected_values, | 1191 kDefaultPageID, arraysize(expected_values), expected_values, |
1192 expected_labels, expected_icons, expected_unique_ids); | 1192 expected_labels, expected_icons, expected_unique_ids); |
1193 } | 1193 } |
1194 | 1194 |
(...skipping 18 matching lines...) Expand all Loading... |
1213 int page_id = 0; | 1213 int page_id = 0; |
1214 std::vector<base::string16> values; | 1214 std::vector<base::string16> values; |
1215 std::vector<base::string16> labels; | 1215 std::vector<base::string16> labels; |
1216 std::vector<base::string16> icons; | 1216 std::vector<base::string16> icons; |
1217 std::vector<int> unique_ids; | 1217 std::vector<int> unique_ids; |
1218 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1218 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
1219 &unique_ids)); | 1219 &unique_ids)); |
1220 | 1220 |
1221 base::string16 expected_values[] = {ASCIIToUTF16("************3456")}; | 1221 base::string16 expected_values[] = {ASCIIToUTF16("************3456")}; |
1222 base::string16 expected_labels[] = {ASCIIToUTF16("*3456")}; | 1222 base::string16 expected_labels[] = {ASCIIToUTF16("*3456")}; |
1223 base::string16 expected_icons[] = {ASCIIToUTF16("visaCC")}; | 1223 base::string16 expected_icons[] = {ASCIIToUTF16(kVisaCard)}; |
1224 int expected_unique_ids[] = {autofill_manager_->GetPackedCreditCardID(4)}; | 1224 int expected_unique_ids[] = {autofill_manager_->GetPackedCreditCardID(4)}; |
1225 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1225 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
1226 kDefaultPageID, arraysize(expected_values), expected_values, | 1226 kDefaultPageID, arraysize(expected_values), expected_values, |
1227 expected_labels, expected_icons, expected_unique_ids); | 1227 expected_labels, expected_icons, expected_unique_ids); |
1228 } | 1228 } |
1229 | 1229 |
1230 // Test that we return credit card profile suggestions when the selected form | 1230 // Test that we return credit card profile suggestions when the selected form |
1231 // field is not the credit card number field. | 1231 // field is not the credit card number field. |
1232 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsNonCCNumber) { | 1232 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsNonCCNumber) { |
1233 // Set up our form data. | 1233 // Set up our form data. |
(...skipping 18 matching lines...) Expand all Loading... |
1252 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1252 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
1253 &unique_ids)); | 1253 &unique_ids)); |
1254 | 1254 |
1255 base::string16 expected_values[] = { | 1255 base::string16 expected_values[] = { |
1256 ASCIIToUTF16("Elvis Presley"), | 1256 ASCIIToUTF16("Elvis Presley"), |
1257 ASCIIToUTF16("Buddy Holly") | 1257 ASCIIToUTF16("Buddy Holly") |
1258 }; | 1258 }; |
1259 base::string16 expected_labels[] = { ASCIIToUTF16("*3456"), | 1259 base::string16 expected_labels[] = { ASCIIToUTF16("*3456"), |
1260 ASCIIToUTF16("*8765") }; | 1260 ASCIIToUTF16("*8765") }; |
1261 base::string16 expected_icons[] = { | 1261 base::string16 expected_icons[] = { |
1262 ASCIIToUTF16("visaCC"), | 1262 ASCIIToUTF16(kVisaCard), |
1263 ASCIIToUTF16("genericCC") | 1263 ASCIIToUTF16(kMasterCard) |
1264 }; | 1264 }; |
1265 int expected_unique_ids[] = { | 1265 int expected_unique_ids[] = { |
1266 autofill_manager_->GetPackedCreditCardID(4), | 1266 autofill_manager_->GetPackedCreditCardID(4), |
1267 autofill_manager_->GetPackedCreditCardID(5) | 1267 autofill_manager_->GetPackedCreditCardID(5) |
1268 }; | 1268 }; |
1269 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1269 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
1270 kDefaultPageID, arraysize(expected_values), expected_values, | 1270 kDefaultPageID, arraysize(expected_values), expected_values, |
1271 expected_labels, expected_icons, expected_unique_ids); | 1271 expected_labels, expected_icons, expected_unique_ids); |
1272 } | 1272 } |
1273 | 1273 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 ASCIIToUTF16("************3456"), | 1376 ASCIIToUTF16("************3456"), |
1377 ASCIIToUTF16("************8765"), | 1377 ASCIIToUTF16("************8765"), |
1378 ASCIIToUTF16("************3456") | 1378 ASCIIToUTF16("************3456") |
1379 }; | 1379 }; |
1380 base::string16 expected_labels[] = { | 1380 base::string16 expected_labels[] = { |
1381 ASCIIToUTF16("*3456"), | 1381 ASCIIToUTF16("*3456"), |
1382 ASCIIToUTF16("*8765"), | 1382 ASCIIToUTF16("*8765"), |
1383 ASCIIToUTF16("*3456"), | 1383 ASCIIToUTF16("*3456"), |
1384 }; | 1384 }; |
1385 base::string16 expected_icons[] = { | 1385 base::string16 expected_icons[] = { |
1386 ASCIIToUTF16("visaCC"), | 1386 ASCIIToUTF16(kVisaCard), |
1387 ASCIIToUTF16("genericCC"), | 1387 ASCIIToUTF16(kMasterCard), |
1388 ASCIIToUTF16("masterCardCC") | 1388 ASCIIToUTF16(kMasterCard) |
1389 }; | 1389 }; |
1390 int expected_unique_ids[] = { | 1390 int expected_unique_ids[] = { |
1391 autofill_manager_->GetPackedCreditCardID(4), | 1391 autofill_manager_->GetPackedCreditCardID(4), |
1392 autofill_manager_->GetPackedCreditCardID(5), | 1392 autofill_manager_->GetPackedCreditCardID(5), |
1393 autofill_manager_->GetPackedCreditCardID(7) | 1393 autofill_manager_->GetPackedCreditCardID(7) |
1394 }; | 1394 }; |
1395 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1395 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
1396 kDefaultPageID, arraysize(expected_values), expected_values, | 1396 kDefaultPageID, arraysize(expected_values), expected_values, |
1397 expected_labels, expected_icons, expected_unique_ids); | 1397 expected_labels, expected_icons, expected_unique_ids); |
1398 } | 1398 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1449 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
1450 &unique_ids)); | 1450 &unique_ids)); |
1451 | 1451 |
1452 base::string16 expected_values2[] = { | 1452 base::string16 expected_values2[] = { |
1453 ASCIIToUTF16("************3456"), | 1453 ASCIIToUTF16("************3456"), |
1454 ASCIIToUTF16("************8765") | 1454 ASCIIToUTF16("************8765") |
1455 }; | 1455 }; |
1456 base::string16 expected_labels2[] = { ASCIIToUTF16("*3456"), | 1456 base::string16 expected_labels2[] = { ASCIIToUTF16("*3456"), |
1457 ASCIIToUTF16("*8765")}; | 1457 ASCIIToUTF16("*8765")}; |
1458 base::string16 expected_icons2[] = { | 1458 base::string16 expected_icons2[] = { |
1459 ASCIIToUTF16("visaCC"), | 1459 ASCIIToUTF16(kVisaCard), |
1460 ASCIIToUTF16("genericCC") | 1460 ASCIIToUTF16(kMasterCard) |
1461 }; | 1461 }; |
1462 int expected_unique_ids2[] = { | 1462 int expected_unique_ids2[] = { |
1463 autofill_manager_->GetPackedCreditCardID(4), | 1463 autofill_manager_->GetPackedCreditCardID(4), |
1464 autofill_manager_->GetPackedCreditCardID(5) | 1464 autofill_manager_->GetPackedCreditCardID(5) |
1465 }; | 1465 }; |
1466 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1466 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
1467 kPageID2, arraysize(expected_values2), expected_values2, | 1467 kPageID2, arraysize(expected_values2), expected_values2, |
1468 expected_labels2, expected_icons2, expected_unique_ids2); | 1468 expected_labels2, expected_icons2, expected_unique_ids2); |
1469 } | 1469 } |
1470 | 1470 |
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3284 CreateTestAddressFormData(&form); | 3284 CreateTestAddressFormData(&form); |
3285 std::vector<FormData> forms(1, form); | 3285 std::vector<FormData> forms(1, form); |
3286 FormsSeen(forms); | 3286 FormsSeen(forms); |
3287 const FormFieldData& field = form.fields[0]; | 3287 const FormFieldData& field = form.fields[0]; |
3288 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 3288 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
3289 | 3289 |
3290 autofill_manager_->SetExternalDelegate(NULL); | 3290 autofill_manager_->SetExternalDelegate(NULL); |
3291 } | 3291 } |
3292 | 3292 |
3293 } // namespace autofill | 3293 } // namespace autofill |
OLD | NEW |