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

Side by Side Diff: chrome/browser/autofill/autofill_browsertest.cc

Issue 14564003: Make PersonalDataManager use GetCreditCards() (rather than using credit_cards_ directly) so Autofill (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_util.h" 8 #include "base/file_util.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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 L"\u03cd\u03c3\u03b5\u03b9\u03c2 " 1129 L"\u03cd\u03c3\u03b5\u03b9\u03c2 "
1130 L"\u03ba\u03b1\u03b9 " 1130 L"\u03ba\u03b1\u03b9 "
1131 L"\u03ba\u03b1\u03c4\u03b1\u03c1\u03b3\u03ae" 1131 L"\u03ba\u03b1\u03c4\u03b1\u03c1\u03b3\u03ae"
1132 L"\u03c3\u03b5\u03b9\u03c2")); 1132 L"\u03c3\u03b5\u03b9\u03c2"));
1133 card4.SetRawInfo(CREDIT_CARD_NUMBER, WideToUTF16(L"00000000000000000000000")); 1133 card4.SetRawInfo(CREDIT_CARD_NUMBER, WideToUTF16(L"00000000000000000000000"));
1134 card4.SetRawInfo(CREDIT_CARD_EXP_MONTH, WideToUTF16(L"01")); 1134 card4.SetRawInfo(CREDIT_CARD_EXP_MONTH, WideToUTF16(L"01"));
1135 card4.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, WideToUTF16(L"2016")); 1135 card4.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, WideToUTF16(L"2016"));
1136 cards.push_back(card4); 1136 cards.push_back(card4);
1137 1137
1138 SetCards(&cards); 1138 SetCards(&cards);
1139 ASSERT_EQ(cards.size(), personal_data_manager()->credit_cards().size()); 1139 ASSERT_EQ(cards.size(), personal_data_manager()->GetCreditCards().size());
1140 for (size_t i = 0; i < cards.size(); ++i) 1140 for (size_t i = 0; i < cards.size(); ++i)
1141 ASSERT_EQ(cards[i], *personal_data_manager()->credit_cards()[i]); 1141 ASSERT_EQ(cards[i], *personal_data_manager()->GetCreditCards()[i]);
Lei Zhang 2013/05/01 04:08:52 nits you may want to fix later - maybe just call G
Lei Zhang 2013/05/01 04:08:52 you may also want to just EXPECT_EQ here. Ditto wi
Dan Beam 2013/05/01 04:19:36 while I agree it should be EXPECT_EQ() here I real
Dan Beam 2013/05/01 04:19:36 yeah, I'm not sure of the point of that... though
1142 } 1142 }
1143 1143
1144 // Test filling in invalid values for profiles are saved as-is. Phone 1144 // Test filling in invalid values for profiles are saved as-is. Phone
1145 // information entered into the prefs UI is not validated or rejected except for 1145 // information entered into the prefs UI is not validated or rejected except for
1146 // duplicates. 1146 // duplicates.
1147 // TODO(isherman): rewrite as WebUI test? 1147 // TODO(isherman): rewrite as WebUI test?
1148 IN_PROC_BROWSER_TEST_F(AutofillTest, Invalid) { 1148 IN_PROC_BROWSER_TEST_F(AutofillTest, Invalid) {
1149 // First try profiles with invalid ZIP input. 1149 // First try profiles with invalid ZIP input.
1150 AutofillProfile without_invalid; 1150 AutofillProfile without_invalid;
1151 without_invalid.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Will")); 1151 without_invalid.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Will"));
(...skipping 14 matching lines...) Expand all
1166 profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 1166 profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
1167 } 1167 }
1168 1168
1169 // Test invalid credit card numbers typed in prefs should be saved as-is. 1169 // Test invalid credit card numbers typed in prefs should be saved as-is.
1170 // TODO(isherman): rewrite as WebUI test? 1170 // TODO(isherman): rewrite as WebUI test?
1171 IN_PROC_BROWSER_TEST_F(AutofillTest, PrefsStringSavedAsIs) { 1171 IN_PROC_BROWSER_TEST_F(AutofillTest, PrefsStringSavedAsIs) {
1172 CreditCard card; 1172 CreditCard card;
1173 card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("Not_0123-5Checked")); 1173 card.SetRawInfo(CREDIT_CARD_NUMBER, ASCIIToUTF16("Not_0123-5Checked"));
1174 SetCard(card); 1174 SetCard(card);
1175 1175
1176 ASSERT_EQ(1u, personal_data_manager()->credit_cards().size()); 1176 ASSERT_EQ(1u, personal_data_manager()->GetCreditCards().size());
1177 ASSERT_EQ(card, *personal_data_manager()->credit_cards()[0]); 1177 ASSERT_EQ(card, *personal_data_manager()->GetCreditCards()[0]);
1178 } 1178 }
1179 1179
1180 // Test credit card info with an invalid number is not aggregated. 1180 // Test credit card info with an invalid number is not aggregated.
1181 // When filling out a form with an invalid credit card number (one that does not 1181 // When filling out a form with an invalid credit card number (one that does not
1182 // pass the Luhn test) the credit card info should not be saved into Autofill 1182 // pass the Luhn test) the credit card info should not be saved into Autofill
1183 // preferences. 1183 // preferences.
1184 IN_PROC_BROWSER_TEST_F(AutofillTest, InvalidCreditCardNumberIsNotAggregated) { 1184 IN_PROC_BROWSER_TEST_F(AutofillTest, InvalidCreditCardNumberIsNotAggregated) {
1185 ASSERT_TRUE(test_server()->Start()); 1185 ASSERT_TRUE(test_server()->Start());
1186 std::string card("4408 0412 3456 7890"); 1186 std::string card("4408 0412 3456 7890");
1187 ASSERT_FALSE(autofill::IsValidCreditCardNumber(ASCIIToUTF16(card))); 1187 ASSERT_FALSE(autofill::IsValidCreditCardNumber(ASCIIToUTF16(card)));
1188 SubmitCreditCard("Bob Smith", card.c_str(), "12", "2014"); 1188 SubmitCreditCard("Bob Smith", card.c_str(), "12", "2014");
1189 ASSERT_EQ(0u, 1189 ASSERT_EQ(0u,
1190 InfoBarService::FromWebContents( 1190 InfoBarService::FromWebContents(
1191 browser()->tab_strip_model()->GetActiveWebContents())-> 1191 browser()->tab_strip_model()->GetActiveWebContents())->
1192 infobar_count()); 1192 infobar_count());
1193 } 1193 }
1194 1194
1195 // Test whitespaces and separator chars are stripped for valid CC numbers. 1195 // Test whitespaces and separator chars are stripped for valid CC numbers.
1196 // The credit card numbers used in this test pass the Luhn test. For reference: 1196 // The credit card numbers used in this test pass the Luhn test. For reference:
1197 // http://www.merriampark.com/anatomycc.htm 1197 // http://www.merriampark.com/anatomycc.htm
1198 IN_PROC_BROWSER_TEST_F(AutofillTest, 1198 IN_PROC_BROWSER_TEST_F(AutofillTest,
1199 WhitespacesAndSeparatorCharsStrippedForValidCCNums) { 1199 WhitespacesAndSeparatorCharsStrippedForValidCCNums) {
1200 ASSERT_TRUE(test_server()->Start()); 1200 ASSERT_TRUE(test_server()->Start());
1201 SubmitCreditCard("Bob Smith", "4408 0412 3456 7893", "12", "2014"); 1201 SubmitCreditCard("Bob Smith", "4408 0412 3456 7893", "12", "2014");
1202 SubmitCreditCard("Jane Doe", "4417-1234-5678-9113", "10", "2013"); 1202 SubmitCreditCard("Jane Doe", "4417-1234-5678-9113", "10", "2013");
1203 1203
1204 ASSERT_EQ(2u, personal_data_manager()->credit_cards().size()); 1204 ASSERT_EQ(2u, personal_data_manager()->GetCreditCards().size());
1205 string16 cc1 = personal_data_manager()->credit_cards()[0]->GetRawInfo( 1205 string16 cc1 = personal_data_manager()->GetCreditCards()[0]->GetRawInfo(
1206 CREDIT_CARD_NUMBER); 1206 CREDIT_CARD_NUMBER);
1207 ASSERT_TRUE(autofill::IsValidCreditCardNumber(cc1)); 1207 ASSERT_TRUE(autofill::IsValidCreditCardNumber(cc1));
1208 string16 cc2 = personal_data_manager()->credit_cards()[1]->GetRawInfo( 1208 string16 cc2 = personal_data_manager()->GetCreditCards()[1]->GetRawInfo(
1209 CREDIT_CARD_NUMBER); 1209 CREDIT_CARD_NUMBER);
1210 ASSERT_TRUE(autofill::IsValidCreditCardNumber(cc2)); 1210 ASSERT_TRUE(autofill::IsValidCreditCardNumber(cc2));
1211 } 1211 }
1212 1212
1213 // Test that Autofill aggregates a minimum valid profile. 1213 // Test that Autofill aggregates a minimum valid profile.
1214 // The minimum required address fields must be specified: First Name, Last Name, 1214 // The minimum required address fields must be specified: First Name, Last Name,
1215 // Address Line 1, City, Zip Code, and State. 1215 // Address Line 1, City, Zip Code, and State.
1216 IN_PROC_BROWSER_TEST_F(AutofillTest, AggregatesMinValidProfile) { 1216 IN_PROC_BROWSER_TEST_F(AutofillTest, AggregatesMinValidProfile) {
1217 ASSERT_TRUE(test_server()->Start()); 1217 ASSERT_TRUE(test_server()->Start());
1218 FormMap data; 1218 FormMap data;
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 IN_PROC_BROWSER_TEST_F(AutofillTest, 1710 IN_PROC_BROWSER_TEST_F(AutofillTest,
1711 DISABLED_MergeAggregatedDuplicatedProfiles) { 1711 DISABLED_MergeAggregatedDuplicatedProfiles) {
1712 int num_of_profiles = 1712 int num_of_profiles =
1713 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); 1713 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt");
1714 1714
1715 ASSERT_GT(num_of_profiles, 1715 ASSERT_GT(num_of_profiles,
1716 static_cast<int>(personal_data_manager()->GetProfiles().size())); 1716 static_cast<int>(personal_data_manager()->GetProfiles().size()));
1717 } 1717 }
1718 1718
1719 } // namespace autofill 1719 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698