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

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

Issue 13488009: Remove application locale cache in autofill code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 8 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 "components/autofill/browser/autofill_ie_toolbar_import_win.h" 5 #include "components/autofill/browser/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 "components/autofill/browser/autofill_profile.h" 10 #include "components/autofill/browser/autofill_profile.h"
11 #include "components/autofill/browser/credit_card.h" 11 #include "components/autofill/browser/credit_card.h"
12 #include "components/autofill/browser/field_types.h" 12 #include "components/autofill/browser/field_types.h"
13 #include "sync/util/data_encryption_win.h" 13 #include "sync/util/data_encryption_win.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 using base::win::RegKey; 16 using base::win::RegKey;
17 17
18 // Defined in autofill_ie_toolbar_import_win.cc. Not exposed in the header file. 18 // Defined in autofill_ie_toolbar_import_win.cc. Not exposed in the header file.
19 bool ImportCurrentUserProfiles(std::vector<AutofillProfile>* profiles, 19 bool ImportCurrentUserProfiles(const std::string& app_locale,
20 std::vector<AutofillProfile>* profiles,
20 std::vector<CreditCard>* credit_cards); 21 std::vector<CreditCard>* credit_cards);
21 22
22 namespace { 23 namespace {
23 24
24 const wchar_t kUnitTestRegistrySubKey[] = L"SOFTWARE\\Chromium Unit Tests"; 25 const wchar_t kUnitTestRegistrySubKey[] = L"SOFTWARE\\Chromium Unit Tests";
25 const wchar_t kUnitTestUserOverrideSubKey[] = 26 const wchar_t kUnitTestUserOverrideSubKey[] =
26 L"SOFTWARE\\Chromium Unit Tests\\HKCU Override"; 27 L"SOFTWARE\\Chromium Unit Tests\\HKCU Override";
27 28
28 const wchar_t* const kProfileKey = 29 const wchar_t* const kProfileKey =
29 L"Software\\Google\\Google Toolbar\\4.0\\Autofill\\Profiles"; 30 L"Software\\Google\\Google Toolbar\\4.0\\Autofill\\Profiles";
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 EXPECT_TRUE(cc_key.Valid()); 151 EXPECT_TRUE(cc_key.Valid());
151 CreateSubkey(&cc_key, L"0", credit_card, arraysize(credit_card)); 152 CreateSubkey(&cc_key, L"0", credit_card, arraysize(credit_card));
152 EncryptAndWrite(&cc_key, &empty_password); 153 EncryptAndWrite(&cc_key, &empty_password);
153 EncryptAndWrite(&cc_key, &empty_salt); 154 EncryptAndWrite(&cc_key, &empty_salt);
154 155
155 profile_key.Close(); 156 profile_key.Close();
156 cc_key.Close(); 157 cc_key.Close();
157 158
158 std::vector<AutofillProfile> profiles; 159 std::vector<AutofillProfile> profiles;
159 std::vector<CreditCard> credit_cards; 160 std::vector<CreditCard> credit_cards;
160 EXPECT_TRUE(ImportCurrentUserProfiles(&profiles, &credit_cards)); 161 EXPECT_TRUE(ImportCurrentUserProfiles("en-US", &profiles, &credit_cards));
161 ASSERT_EQ(2U, profiles.size()); 162 ASSERT_EQ(2U, profiles.size());
162 // The profiles are read in reverse order. 163 // The profiles are read in reverse order.
163 EXPECT_EQ(profile1[0].value, profiles[1].GetRawInfo(NAME_FIRST)); 164 EXPECT_EQ(profile1[0].value, profiles[1].GetRawInfo(NAME_FIRST));
164 EXPECT_EQ(profile1[1].value, profiles[1].GetRawInfo(NAME_MIDDLE)); 165 EXPECT_EQ(profile1[1].value, profiles[1].GetRawInfo(NAME_MIDDLE));
165 EXPECT_EQ(profile1[2].value, profiles[1].GetRawInfo(NAME_LAST)); 166 EXPECT_EQ(profile1[2].value, profiles[1].GetRawInfo(NAME_LAST));
166 EXPECT_EQ(profile1[3].value, profiles[1].GetRawInfo(EMAIL_ADDRESS)); 167 EXPECT_EQ(profile1[3].value, profiles[1].GetRawInfo(EMAIL_ADDRESS));
167 EXPECT_EQ(profile1[4].value, profiles[1].GetRawInfo(COMPANY_NAME)); 168 EXPECT_EQ(profile1[4].value, profiles[1].GetRawInfo(COMPANY_NAME));
168 EXPECT_EQ(profile1[7].value, 169 EXPECT_EQ(profile1[7].value,
169 profiles[1].GetInfo(PHONE_HOME_COUNTRY_CODE, "US")); 170 profiles[1].GetInfo(PHONE_HOME_COUNTRY_CODE, "US"));
170 EXPECT_EQ(profile1[6].value, profiles[1].GetInfo(PHONE_HOME_CITY_CODE, "US")); 171 EXPECT_EQ(profile1[6].value, profiles[1].GetInfo(PHONE_HOME_CITY_CODE, "US"));
(...skipping 17 matching lines...) Expand all
188 189
189 // Mock password encrypted cc. 190 // Mock password encrypted cc.
190 cc_key.Open(HKEY_CURRENT_USER, kCreditCardKey, KEY_ALL_ACCESS); 191 cc_key.Open(HKEY_CURRENT_USER, kCreditCardKey, KEY_ALL_ACCESS);
191 EXPECT_TRUE(cc_key.Valid()); 192 EXPECT_TRUE(cc_key.Valid());
192 EncryptAndWrite(&cc_key, &protected_password); 193 EncryptAndWrite(&cc_key, &protected_password);
193 EncryptAndWrite(&cc_key, &protected_salt); 194 EncryptAndWrite(&cc_key, &protected_salt);
194 cc_key.Close(); 195 cc_key.Close();
195 196
196 profiles.clear(); 197 profiles.clear();
197 credit_cards.clear(); 198 credit_cards.clear();
198 EXPECT_TRUE(ImportCurrentUserProfiles(&profiles, &credit_cards)); 199 EXPECT_TRUE(ImportCurrentUserProfiles("en-US", &profiles, &credit_cards));
199 // Profiles are not protected. 200 // Profiles are not protected.
200 EXPECT_EQ(2U, profiles.size()); 201 EXPECT_EQ(2U, profiles.size());
201 // Credit cards are. 202 // Credit cards are.
202 EXPECT_EQ(0U, credit_cards.size()); 203 EXPECT_EQ(0U, credit_cards.size());
203 } 204 }
204 205
OLDNEW
« no previous file with comments | « components/autofill/browser/autofill_ie_toolbar_import_win.cc ('k') | components/autofill/browser/autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698