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

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

Issue 440283002: Android: Get AutofillProfile summary labels from PersonalDataManagerAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: after early return Created 6 years, 4 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
« no previous file with comments | « components/autofill/core/browser/autofill_profile.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/format_macros.h" 6 #include "base/format_macros.h"
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 // One field at least, from suggested fields - filter same as the first non- 439 // One field at least, from suggested fields - filter same as the first non-
440 // unknown suggested field. 440 // unknown suggested field.
441 suggested_fields.clear(); 441 suggested_fields.clear();
442 suggested_fields.push_back(UNKNOWN_TYPE); 442 suggested_fields.push_back(UNKNOWN_TYPE);
443 suggested_fields.push_back(NAME_FULL); 443 suggested_fields.push_back(NAME_FULL);
444 suggested_fields.push_back(ADDRESS_HOME_LINE1); 444 suggested_fields.push_back(ADDRESS_HOME_LINE1);
445 AutofillProfile::CreateInferredLabels(profiles.get(), &suggested_fields, 445 AutofillProfile::CreateInferredLabels(profiles.get(), &suggested_fields,
446 NAME_FULL, 1, "en-US", &labels); 446 NAME_FULL, 1, "en-US", &labels);
447 EXPECT_EQ(base::string16(ASCIIToUTF16("666 Erebus St.")), labels[0]); 447 EXPECT_EQ(base::string16(ASCIIToUTF16("666 Erebus St.")), labels[0]);
448 EXPECT_EQ(base::string16(ASCIIToUTF16("123 Letha Shore.")), labels[1]); 448 EXPECT_EQ(base::string16(ASCIIToUTF16("123 Letha Shore.")), labels[1]);
449
450 // No suggested fields, but non-unknown excluded field.
451 AutofillProfile::CreateInferredLabels(profiles.get(), NULL,
452 NAME_FULL, 1, "en-US", &labels);
453 EXPECT_EQ(base::string16(ASCIIToUTF16("666 Erebus St.")), labels[0]);
454 EXPECT_EQ(base::string16(ASCIIToUTF16("123 Letha Shore.")), labels[1]);
449 } 455 }
450 456
451 // Test that we fall back to using the full name if there are no other 457 // Test that we fall back to using the full name if there are no other
452 // distinguishing fields, but only if it makes sense given the suggested fields. 458 // distinguishing fields, but only if it makes sense given the suggested fields.
453 TEST(AutofillProfileTest, CreateInferredLabelsFallsBackToFullName) { 459 TEST(AutofillProfileTest, CreateInferredLabelsFallsBackToFullName) {
454 ScopedVector<AutofillProfile> profiles; 460 ScopedVector<AutofillProfile> profiles;
455 profiles.push_back( 461 profiles.push_back(
456 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/")); 462 new AutofillProfile(base::GenerateGUID(), "https://www.example.com/"));
457 test::SetProfileInfo(profiles[0], 463 test::SetProfileInfo(profiles[0],
458 "John", "", "Doe", "doe@example.com", "", 464 "John", "", "Doe", "doe@example.com", "",
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 1142
1137 for (size_t i = 0; i < current_case.expected_result.size(); ++i) { 1143 for (size_t i = 0; i < current_case.expected_result.size(); ++i) {
1138 EXPECT_EQ(first_names[i], merged_first_names[i]); 1144 EXPECT_EQ(first_names[i], merged_first_names[i]);
1139 EXPECT_EQ(middle_names[i], merged_middle_names[i]); 1145 EXPECT_EQ(middle_names[i], merged_middle_names[i]);
1140 EXPECT_EQ(last_names[i], merged_last_names[i]); 1146 EXPECT_EQ(last_names[i], merged_last_names[i]);
1141 } 1147 }
1142 } 1148 }
1143 } 1149 }
1144 1150
1145 } // namespace autofill 1151 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_profile.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698