OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/autofill/field_map_wrapper.h" |
| 6 |
| 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "components/autofill/core/browser/autofill_type.h" |
| 9 #include "components/autofill/core/browser/field_types.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace autofill { |
| 13 |
| 14 TEST(FieldMapWrapperTest, CorrectCountryForSection) { |
| 15 FieldValueMap map; |
| 16 map[ADDRESS_BILLING_COUNTRY] = base::ASCIIToUTF16("China"); |
| 17 map[ADDRESS_HOME_COUNTRY] = base::ASCIIToUTF16("France"); |
| 18 |
| 19 // Ensure that a wrapper for the billing section only uses the |
| 20 // billing-specific country field in |map| ("China" or "CN"). |
| 21 FieldMapWrapper billing_wrapper(map, SECTION_BILLING); |
| 22 EXPECT_EQ(base::ASCIIToUTF16("China"), |
| 23 billing_wrapper.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY))); |
| 24 EXPECT_EQ(base::ASCIIToUTF16("CN"), |
| 25 billing_wrapper.GetInfo(AutofillType(HTML_TYPE_COUNTRY_CODE, |
| 26 HTML_MODE_SHIPPING))); |
| 27 |
| 28 // And conversely that the shipping wrapper only returns "France" or "FR" (the |
| 29 // shipping country). |
| 30 FieldMapWrapper shipping_wrapper(map, SECTION_SHIPPING); |
| 31 EXPECT_EQ(base::ASCIIToUTF16("France"), |
| 32 shipping_wrapper.GetInfo(AutofillType(ADDRESS_BILLING_COUNTRY))); |
| 33 EXPECT_EQ(base::ASCIIToUTF16("FR"), |
| 34 shipping_wrapper.GetInfo(AutofillType(HTML_TYPE_COUNTRY_CODE, |
| 35 HTML_MODE_BILLING))); |
| 36 } |
| 37 |
| 38 } // namespace autofill |
OLD | NEW |