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

Side by Side Diff: components/autofill/core/browser/contact_info_unittest.cc

Issue 1080883002: Remove some more bad ASCII-centric autofill code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 5 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
OLDNEW
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 "components/autofill/core/browser/contact_info.h" 5 #include "components/autofill/core/browser/contact_info.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "components/autofill/core/browser/autofill_type.h" 12 #include "components/autofill/core/browser/autofill_type.h"
13 #include "components/autofill/core/browser/field_types.h" 13 #include "components/autofill/core/browser/field_types.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 using base::ASCIIToUTF16; 16 using base::ASCIIToUTF16;
17 using base::UTF8ToUTF16;
17 18
18 namespace autofill { 19 namespace autofill {
19 20
20 struct FullNameTestCase { 21 struct FullNameTestCase {
21 std::string full_name_input; 22 std::string full_name_input;
22 std::string given_name_output; 23 std::string given_name_output;
23 std::string middle_name_output; 24 std::string middle_name_output;
24 std::string family_name_output; 25 std::string family_name_output;
25 } full_name_test_cases[] = { 26 } full_name_test_cases[] = {
26 { "", "", "", "" }, 27 { "", "", "", "" },
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 {{"Marion", "Mitchell", "Morrison"}, 210 {{"Marion", "Mitchell", "Morrison"},
210 {"Marion Mitchell", "", "MORRISON"}, 211 {"Marion Mitchell", "", "MORRISON"},
211 false}, 212 false},
212 213
213 // Different names. 214 // Different names.
214 {{"Marion", "Mitchell", "Morrison"}, {"Marion", "M.", "Morrison"}, false}, 215 {{"Marion", "Mitchell", "Morrison"}, {"Marion", "M.", "Morrison"}, false},
215 {{"Marion", "Mitchell", "Morrison"}, {"MARION", "M.", "MORRISON"}, false}, 216 {{"Marion", "Mitchell", "Morrison"}, {"MARION", "M.", "MORRISON"}, false},
216 {{"Marion", "Mitchell", "Morrison"}, 217 {{"Marion", "Mitchell", "Morrison"},
217 {"David", "Mitchell", "Morrison"}, 218 {"David", "Mitchell", "Morrison"},
218 false}, 219 false},
220
221 // Non-ASCII characters.
222 {{"M\xc3\xa1rion Mitchell", "", "Morrison"},
223 {"M\xc3\x81RION MITCHELL", "", "MORRISON"},
224 true},
219 }; 225 };
220 226
221 for (size_t i = 0; i < arraysize(test_cases); ++i) { 227 for (size_t i = 0; i < arraysize(test_cases); ++i) {
222 SCOPED_TRACE(base::StringPrintf("i: %" PRIuS, i)); 228 SCOPED_TRACE(base::StringPrintf("i: %" PRIuS, i));
223 229
224 // Construct the starting_profile. 230 // Construct the starting_profile.
225 NameInfo starting_profile; 231 NameInfo starting_profile;
226 starting_profile.SetRawInfo(NAME_FIRST, 232 starting_profile.SetRawInfo(NAME_FIRST,
227 ASCIIToUTF16(test_cases[i].starting_names[0])); 233 UTF8ToUTF16(test_cases[i].starting_names[0]));
228 starting_profile.SetRawInfo(NAME_MIDDLE, 234 starting_profile.SetRawInfo(NAME_MIDDLE,
229 ASCIIToUTF16(test_cases[i].starting_names[1])); 235 UTF8ToUTF16(test_cases[i].starting_names[1]));
230 starting_profile.SetRawInfo(NAME_LAST, 236 starting_profile.SetRawInfo(NAME_LAST,
231 ASCIIToUTF16(test_cases[i].starting_names[2])); 237 UTF8ToUTF16(test_cases[i].starting_names[2]));
232 238
233 // Construct the additional_profile. 239 // Construct the additional_profile.
234 NameInfo additional_profile; 240 NameInfo additional_profile;
235 additional_profile.SetRawInfo( 241 additional_profile.SetRawInfo(
236 NAME_FIRST, ASCIIToUTF16(test_cases[i].additional_names[0])); 242 NAME_FIRST, UTF8ToUTF16(test_cases[i].additional_names[0]));
237 additional_profile.SetRawInfo( 243 additional_profile.SetRawInfo(
238 NAME_MIDDLE, ASCIIToUTF16(test_cases[i].additional_names[1])); 244 NAME_MIDDLE, UTF8ToUTF16(test_cases[i].additional_names[1]));
239 additional_profile.SetRawInfo( 245 additional_profile.SetRawInfo(
240 NAME_LAST, ASCIIToUTF16(test_cases[i].additional_names[2])); 246 NAME_LAST, UTF8ToUTF16(test_cases[i].additional_names[2]));
241 247
242 // Verify the test expectations. 248 // Verify the test expectations.
243 EXPECT_EQ(test_cases[i].expected_result, 249 EXPECT_EQ(test_cases[i].expected_result,
244 starting_profile.ParsedNamesAreEqual(additional_profile)); 250 starting_profile.ParsedNamesAreEqual(additional_profile));
245 } 251 }
246 } 252 }
247 253
248 } // namespace autofill 254 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/contact_info.cc ('k') | components/autofill/core/browser/credit_card.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698