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

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

Issue 490373002: Add back organization field for autofill settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Git migration. Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/address_i18n.h" 5 #include "components/autofill/core/browser/address_i18n.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/guid.h" 10 #include "base/guid.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "components/autofill/core/browser/autofill_profile.h" 12 #include "components/autofill/core/browser/autofill_profile.h"
13 #include "components/autofill/core/browser/autofill_test_utils.h" 13 #include "components/autofill/core/browser/autofill_test_utils.h"
14 #include "components/autofill/core/browser/field_types.h" 14 #include "components/autofill/core/browser/field_types.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da ta.h" 16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da ta.h"
17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi eld.h" 17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi eld.h"
18 18
19 namespace autofill { 19 namespace autofill {
20 namespace i18n { 20 namespace i18n {
21 21
22 using ::i18n::addressinput::AddressData; 22 using ::i18n::addressinput::AddressData;
23 using ::i18n::addressinput::AddressField; 23 using ::i18n::addressinput::AddressField;
24 24
25 using ::i18n::addressinput::ADMIN_AREA; 25 using ::i18n::addressinput::ADMIN_AREA;
26 using ::i18n::addressinput::COUNTRY; 26 using ::i18n::addressinput::COUNTRY;
27 using ::i18n::addressinput::DEPENDENT_LOCALITY; 27 using ::i18n::addressinput::DEPENDENT_LOCALITY;
28 using ::i18n::addressinput::LOCALITY; 28 using ::i18n::addressinput::LOCALITY;
29 using ::i18n::addressinput::ORGANIZATION;
29 using ::i18n::addressinput::POSTAL_CODE; 30 using ::i18n::addressinput::POSTAL_CODE;
30 using ::i18n::addressinput::RECIPIENT; 31 using ::i18n::addressinput::RECIPIENT;
31 using ::i18n::addressinput::SORTING_CODE; 32 using ::i18n::addressinput::SORTING_CODE;
32 using ::i18n::addressinput::STREET_ADDRESS; 33 using ::i18n::addressinput::STREET_ADDRESS;
33 34
34 TEST(AddressI18nTest, FieldTypeMirrorConversions) { 35 TEST(AddressI18nTest, FieldTypeMirrorConversions) {
35 static const struct { 36 static const struct {
36 bool billing; 37 bool billing;
37 ServerFieldType server_field; 38 ServerFieldType server_field;
38 AddressField address_field; 39 AddressField address_field;
39 } kTestData[] = { 40 } kTestData[] = {
40 {true, ADDRESS_BILLING_COUNTRY, COUNTRY}, 41 {true, ADDRESS_BILLING_COUNTRY, COUNTRY},
41 {true, ADDRESS_BILLING_STATE, ADMIN_AREA}, 42 {true, ADDRESS_BILLING_STATE, ADMIN_AREA},
42 {true, ADDRESS_BILLING_CITY, LOCALITY}, 43 {true, ADDRESS_BILLING_CITY, LOCALITY},
43 {true, ADDRESS_BILLING_DEPENDENT_LOCALITY, DEPENDENT_LOCALITY}, 44 {true, ADDRESS_BILLING_DEPENDENT_LOCALITY, DEPENDENT_LOCALITY},
44 {true, ADDRESS_BILLING_SORTING_CODE, SORTING_CODE}, 45 {true, ADDRESS_BILLING_SORTING_CODE, SORTING_CODE},
45 {true, ADDRESS_BILLING_ZIP, POSTAL_CODE}, 46 {true, ADDRESS_BILLING_ZIP, POSTAL_CODE},
46 {true, ADDRESS_BILLING_STREET_ADDRESS, STREET_ADDRESS}, 47 {true, ADDRESS_BILLING_STREET_ADDRESS, STREET_ADDRESS},
48 {true, COMPANY_NAME, ORGANIZATION},
47 {true, NAME_BILLING_FULL, RECIPIENT}, 49 {true, NAME_BILLING_FULL, RECIPIENT},
48 {false, ADDRESS_HOME_COUNTRY, COUNTRY}, 50 {false, ADDRESS_HOME_COUNTRY, COUNTRY},
49 {false, ADDRESS_HOME_STATE, ADMIN_AREA}, 51 {false, ADDRESS_HOME_STATE, ADMIN_AREA},
50 {false, ADDRESS_HOME_CITY, LOCALITY}, 52 {false, ADDRESS_HOME_CITY, LOCALITY},
51 {false, ADDRESS_HOME_DEPENDENT_LOCALITY, DEPENDENT_LOCALITY}, 53 {false, ADDRESS_HOME_DEPENDENT_LOCALITY, DEPENDENT_LOCALITY},
52 {false, ADDRESS_HOME_SORTING_CODE, SORTING_CODE}, 54 {false, ADDRESS_HOME_SORTING_CODE, SORTING_CODE},
53 {false, ADDRESS_HOME_ZIP, POSTAL_CODE}, 55 {false, ADDRESS_HOME_ZIP, POSTAL_CODE},
54 {false, ADDRESS_HOME_STREET_ADDRESS, STREET_ADDRESS}, 56 {false, ADDRESS_HOME_STREET_ADDRESS, STREET_ADDRESS},
57 {false, COMPANY_NAME, ORGANIZATION},
55 {false, NAME_FULL, RECIPIENT}, 58 {false, NAME_FULL, RECIPIENT},
56 }; 59 };
57 60
58 for (size_t i = 0; i < arraysize(kTestData); ++i) { 61 for (size_t i = 0; i < arraysize(kTestData); ++i) {
59 AddressField address_field; 62 AddressField address_field;
60 EXPECT_TRUE(FieldForType(kTestData[i].server_field, &address_field)); 63 EXPECT_TRUE(FieldForType(kTestData[i].server_field, &address_field));
61 EXPECT_EQ(kTestData[i].address_field, address_field); 64 EXPECT_EQ(kTestData[i].address_field, address_field);
62 65
63 ServerFieldType server_field = 66 ServerFieldType server_field =
64 TypeForField(kTestData[i].address_field, kTestData[i].billing); 67 TypeForField(kTestData[i].address_field, kTestData[i].billing);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 CreateAddressDataFromAutofillProfile(profile, "en_US"); 111 CreateAddressDataFromAutofillProfile(profile, "en_US");
109 112
110 AddressData expected; 113 AddressData expected;
111 expected.region_code = "US"; 114 expected.region_code = "US";
112 expected.address_line.push_back("666 Erebus St."); 115 expected.address_line.push_back("666 Erebus St.");
113 expected.address_line.push_back("Apt 8"); 116 expected.address_line.push_back("Apt 8");
114 expected.administrative_area = "CA"; 117 expected.administrative_area = "CA";
115 expected.locality = "Elysium"; 118 expected.locality = "Elysium";
116 expected.postal_code = "91111"; 119 expected.postal_code = "91111";
117 expected.language_code = "en"; 120 expected.language_code = "en";
121 expected.organization = "Underworld";
118 expected.recipient = "John H. Doe"; 122 expected.recipient = "John H. Doe";
119 123
120 EXPECT_EQ(expected, *actual); 124 EXPECT_EQ(expected, *actual);
121 } 125 }
122 126
123 } // namespace i18n 127 } // namespace i18n
124 } // namespace autofill 128 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/address_i18n.cc ('k') | components/autofill/core/browser/autofill_profile_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698