OLD | NEW |
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 Loading... |
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), profile1[0].value); |
167 profile1[0].value); | 167 EXPECT_EQ(profiles[1].GetFieldText(NAME_MIDDLE), profile1[1].value); |
168 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(NAME_MIDDLE)), | 168 EXPECT_EQ(profiles[1].GetFieldText(NAME_LAST), profile1[2].value); |
169 profile1[1].value); | 169 EXPECT_EQ(profiles[1].GetFieldText(EMAIL_ADDRESS), profile1[3].value); |
170 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(NAME_LAST)), | 170 EXPECT_EQ(profiles[1].GetFieldText(COMPANY_NAME), profile1[4].value); |
171 profile1[2].value); | 171 EXPECT_EQ(profiles[1].GetFieldText(PHONE_HOME_COUNTRY_CODE), |
172 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(EMAIL_ADDRESS)), | |
173 profile1[3].value); | |
174 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(COMPANY_NAME)), | |
175 profile1[4].value); | |
176 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(PHONE_HOME_COUNTRY_CODE)), | |
177 profile1[7].value); | 172 profile1[7].value); |
178 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(PHONE_HOME_CITY_CODE)), | 173 EXPECT_EQ(profiles[1].GetFieldText(PHONE_HOME_CITY_CODE), profile1[6].value); |
179 profile1[6].value); | 174 EXPECT_EQ(profiles[1].GetFieldText(PHONE_HOME_NUMBER), L"5555555"); |
180 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(PHONE_HOME_NUMBER)), | 175 EXPECT_EQ(profiles[1].GetFieldText(PHONE_HOME_WHOLE_NUMBER), L"14445555555"); |
181 L"5555555"); | |
182 EXPECT_EQ(profiles[1].GetFieldText(AutofillType(PHONE_HOME_WHOLE_NUMBER)), | |
183 L"14445555555"); | |
184 | 176 |
185 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(NAME_FIRST)), | 177 EXPECT_EQ(profiles[0].GetFieldText(NAME_FIRST), profile2[0].value); |
186 profile2[0].value); | 178 EXPECT_EQ(profiles[0].GetFieldText(NAME_LAST), profile2[1].value); |
187 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(NAME_LAST)), | 179 EXPECT_EQ(profiles[0].GetFieldText(EMAIL_ADDRESS), profile2[2].value); |
188 profile2[1].value); | 180 EXPECT_EQ(profiles[0].GetFieldText(COMPANY_NAME), profile2[3].value); |
189 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(EMAIL_ADDRESS)), | 181 EXPECT_EQ(profiles[0].GetFieldText(PHONE_FAX_COUNTRY_CODE), |
190 profile2[2].value); | |
191 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(COMPANY_NAME)), | |
192 profile2[3].value); | |
193 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(PHONE_FAX_COUNTRY_CODE)), | |
194 profile2[6].value); | 182 profile2[6].value); |
195 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(PHONE_FAX_CITY_CODE)), | 183 EXPECT_EQ(profiles[0].GetFieldText(PHONE_FAX_CITY_CODE), profile2[5].value); |
196 profile2[5].value); | 184 EXPECT_EQ(profiles[0].GetFieldText(PHONE_FAX_NUMBER), L"5556666"); |
197 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(PHONE_FAX_NUMBER)), | 185 EXPECT_EQ(profiles[0].GetFieldText(PHONE_FAX_WHOLE_NUMBER), L"27775556666"); |
198 L"5556666"); | |
199 EXPECT_EQ(profiles[0].GetFieldText(AutofillType(PHONE_FAX_WHOLE_NUMBER)), | |
200 L"27775556666"); | |
201 | 186 |
202 ASSERT_EQ(credit_cards.size(), 1); | 187 ASSERT_EQ(credit_cards.size(), 1); |
203 EXPECT_EQ(credit_cards[0].GetFieldText(AutofillType(CREDIT_CARD_NAME)), | 188 EXPECT_EQ(credit_cards[0].GetFieldText(CREDIT_CARD_NAME), |
204 credit_card[0].value); | 189 credit_card[0].value); |
205 EXPECT_EQ(credit_cards[0].GetFieldText(AutofillType(CREDIT_CARD_NUMBER)), | 190 EXPECT_EQ(credit_cards[0].GetFieldText(CREDIT_CARD_NUMBER), |
206 L"4111111111111111"); | 191 L"4111111111111111"); |
207 EXPECT_EQ(credit_cards[0].GetFieldText(AutofillType(CREDIT_CARD_EXP_MONTH)), | 192 EXPECT_EQ(credit_cards[0].GetFieldText(CREDIT_CARD_EXP_MONTH), |
208 credit_card[2].value); | 193 credit_card[2].value); |
209 EXPECT_EQ(credit_cards[0].GetFieldText( | 194 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); | 195 credit_card[3].value); |
212 | 196 |
213 // Mock password encrypted cc. | 197 // Mock password encrypted cc. |
214 cc_key.Open(HKEY_CURRENT_USER, kCreditCardKey, KEY_ALL_ACCESS); | 198 cc_key.Open(HKEY_CURRENT_USER, kCreditCardKey, KEY_ALL_ACCESS); |
215 EXPECT_TRUE(cc_key.Valid()); | 199 EXPECT_TRUE(cc_key.Valid()); |
216 EncryptAndWrite(&cc_key, &protected_password); | 200 EncryptAndWrite(&cc_key, &protected_password); |
217 EncryptAndWrite(&cc_key, &protected_salt); | 201 EncryptAndWrite(&cc_key, &protected_salt); |
218 cc_key.Close(); | 202 cc_key.Close(); |
219 | 203 |
220 profiles.clear(); | 204 profiles.clear(); |
221 credit_cards.clear(); | 205 credit_cards.clear(); |
222 EXPECT_TRUE(ImportCurrentUserProfiles(&profiles, &credit_cards)); | 206 EXPECT_TRUE(ImportCurrentUserProfiles(&profiles, &credit_cards)); |
223 // Profiles are not protected. | 207 // Profiles are not protected. |
224 EXPECT_EQ(profiles.size(), 2); | 208 EXPECT_EQ(profiles.size(), 2); |
225 // Credit cards are. | 209 // Credit cards are. |
226 EXPECT_EQ(credit_cards.size(), 0); | 210 EXPECT_EQ(credit_cards.size(), 0); |
227 } | 211 } |
228 | 212 |
OLD | NEW |