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

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

Issue 6673079: Reduce boxing and unboxing of AutofillFieldType (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile on Windows. Created 9 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) 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 "chrome/browser/autofill/autofill_ie_toolbar_import_win.h" 5 #include "chrome/browser/autofill/autofill_ie_toolbar_import_win.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/win/registry.h" 9 #include "base/win/registry.h"
10 #include "chrome/browser/autofill/autofill_profile.h" 10 #include "chrome/browser/autofill/autofill_profile.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 EncryptAndWrite(&cc_key, &empty_salt); 156 EncryptAndWrite(&cc_key, &empty_salt);
157 157
158 profile_key.Close(); 158 profile_key.Close();
159 cc_key.Close(); 159 cc_key.Close();
160 160
161 std::vector<AutofillProfile> profiles; 161 std::vector<AutofillProfile> profiles;
162 std::vector<CreditCard> credit_cards; 162 std::vector<CreditCard> credit_cards;
163 EXPECT_TRUE(ImportCurrentUserProfiles(&profiles, &credit_cards)); 163 EXPECT_TRUE(ImportCurrentUserProfiles(&profiles, &credit_cards));
164 ASSERT_EQ(profiles.size(), 2); 164 ASSERT_EQ(profiles.size(), 2);
165 // The profiles are read in reverse order. 165 // The profiles are read in reverse order.
166 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(NAME_FIRST)), 166 EXPECT_EQ(profiles[1].GetFieldText(NAME_FIRST),
167 profile1[0].value); 167 profile1[0].value);
dhollowa 2011/03/16 17:07:11 nit: A number of these should fit on single line n
Ilya Sherman 2011/03/17 03:42:29 Done.
168 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(NAME_MIDDLE)), 168 EXPECT_EQ(profiles[1].GetFieldText(NAME_MIDDLE),
169 profile1[1].value); 169 profile1[1].value);
170 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(NAME_LAST)), 170 EXPECT_EQ(profiles[1].GetFieldText(NAME_LAST),
171 profile1[2].value); 171 profile1[2].value);
172 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(EMAIL_ADDRESS)), 172 EXPECT_EQ(profiles[1].GetFieldText(EMAIL_ADDRESS),
173 profile1[3].value); 173 profile1[3].value);
174 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(COMPANY_NAME)), 174 EXPECT_EQ(profiles[1].GetFieldText(COMPANY_NAME),
175 profile1[4].value); 175 profile1[4].value);
176 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(PHONE_HOME_COUNTRY_CODE)), 176 EXPECT_EQ(profiles[1].GetFieldText(PHONE_HOME_COUNTRY_CODE),
177 profile1[7].value); 177 profile1[7].value);
178 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(PHONE_HOME_CITY_CODE)), 178 EXPECT_EQ(profiles[1].GetFieldText(PHONE_HOME_CITY_CODE),
179 profile1[6].value); 179 profile1[6].value);
180 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(PHONE_HOME_NUMBER)), 180 EXPECT_EQ(profiles[1].GetFieldText(PHONE_HOME_NUMBER),
181 L"5555555"); 181 L"5555555");
182 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(PHONE_HOME_WHOLE_NUMBER)), 182 EXPECT_EQ(profiles[1].GetFieldText(PHONE_HOME_WHOLE_NUMBER),
183 L"14445555555"); 183 L"14445555555");
184 184
185 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(NAME_FIRST)), 185 EXPECT_EQ(profiles[0].GetFieldText(NAME_FIRST),
186 profile2[0].value); 186 profile2[0].value);
187 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(NAME_LAST)), 187 EXPECT_EQ(profiles[0].GetFieldText(NAME_LAST),
188 profile2[1].value); 188 profile2[1].value);
189 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(EMAIL_ADDRESS)), 189 EXPECT_EQ(profiles[0].GetFieldText(EMAIL_ADDRESS),
190 profile2[2].value); 190 profile2[2].value);
191 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(COMPANY_NAME)), 191 EXPECT_EQ(profiles[0].GetFieldText(COMPANY_NAME),
192 profile2[3].value); 192 profile2[3].value);
193 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(PHONE_FAX_COUNTRY_CODE)), 193 EXPECT_EQ(profiles[0].GetFieldText(PHONE_FAX_COUNTRY_CODE),
194 profile2[6].value); 194 profile2[6].value);
195 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(PHONE_FAX_CITY_CODE)), 195 EXPECT_EQ(profiles[0].GetFieldText(PHONE_FAX_CITY_CODE),
196 profile2[5].value); 196 profile2[5].value);
197 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(PHONE_FAX_NUMBER)), 197 EXPECT_EQ(profiles[0].GetFieldText(PHONE_FAX_NUMBER),
198 L"5556666"); 198 L"5556666");
199 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(PHONE_FAX_WHOLE_NUMBER)), 199 EXPECT_EQ(profiles[0].GetFieldText(PHONE_FAX_WHOLE_NUMBER),
200 L"27775556666"); 200 L"27775556666");
201 201
202 ASSERT_EQ(credit_cards.size(), 1); 202 ASSERT_EQ(credit_cards.size(), 1);
203 EXPECT_EQ(credit_cards[0].GetFieldText(AutofillType(CREDIT_CARD_NAME)), 203 EXPECT_EQ(credit_cards[0].GetFieldText(CREDIT_CARD_NAME),
204 credit_card[0].value); 204 credit_card[0].value);
205 EXPECT_EQ(credit_cards[0].GetFieldText(AutofillType(CREDIT_CARD_NUMBER)), 205 EXPECT_EQ(credit_cards[0].GetFieldText(CREDIT_CARD_NUMBER),
206 L"4111111111111111"); 206 L"4111111111111111");
207 EXPECT_EQ(credit_cards[0].GetFieldText(AutofillType(CREDIT_CARD_EXP_MONTH)), 207 EXPECT_EQ(credit_cards[0].GetFieldText(CREDIT_CARD_EXP_MONTH),
208 credit_card[2].value); 208 credit_card[2].value);
209 EXPECT_EQ(credit_cards[0].GetFieldText( 209 EXPECT_EQ(credit_cards[0].GetFieldText(CREDIT_CARD_EXP_4_DIGIT_YEAR),
210 AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)),
211 credit_card[3].value); 210 credit_card[3].value);
212 211
213 // Mock password encrypted cc. 212 // Mock password encrypted cc.
214 cc_key.Open(HKEY_CURRENT_USER, kCreditCardKey, KEY_ALL_ACCESS); 213 cc_key.Open(HKEY_CURRENT_USER, kCreditCardKey, KEY_ALL_ACCESS);
215 EXPECT_TRUE(cc_key.Valid()); 214 EXPECT_TRUE(cc_key.Valid());
216 EncryptAndWrite(&cc_key, &protected_password); 215 EncryptAndWrite(&cc_key, &protected_password);
217 EncryptAndWrite(&cc_key, &protected_salt); 216 EncryptAndWrite(&cc_key, &protected_salt);
218 cc_key.Close(); 217 cc_key.Close();
219 218
220 profiles.clear(); 219 profiles.clear();
221 credit_cards.clear(); 220 credit_cards.clear();
222 EXPECT_TRUE(ImportCurrentUserProfiles(&profiles, &credit_cards)); 221 EXPECT_TRUE(ImportCurrentUserProfiles(&profiles, &credit_cards));
223 // Profiles are not protected. 222 // Profiles are not protected.
224 EXPECT_EQ(profiles.size(), 2); 223 EXPECT_EQ(profiles.size(), 2);
225 // Credit cards are. 224 // Credit cards are.
226 EXPECT_EQ(credit_cards.size(), 0); 225 EXPECT_EQ(credit_cards.size(), 0);
227 } 226 }
228 227
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698