Index: chrome/browser/ui/autofill/field_map_wrapper_unittest.cc |
diff --git a/chrome/browser/ui/autofill/field_map_wrapper_unittest.cc b/chrome/browser/ui/autofill/field_map_wrapper_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bba63e095bd8be6de418447b731a2ccebaf63014 |
--- /dev/null |
+++ b/chrome/browser/ui/autofill/field_map_wrapper_unittest.cc |
@@ -0,0 +1,38 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ui/autofill/field_map_wrapper.h" |
+ |
+#include "base/strings/utf_string_conversions.h" |
+#include "components/autofill/core/browser/autofill_type.h" |
+#include "components/autofill/core/browser/field_types.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace autofill { |
+ |
+TEST(FieldMapWrapperTest, CorrectCountryForSection) { |
+ FieldValueMap map; |
+ map[ADDRESS_BILLING_COUNTRY] = base::ASCIIToUTF16("China"); |
+ map[ADDRESS_HOME_COUNTRY] = base::ASCIIToUTF16("France"); |
+ |
+ // Ensure that a wrapper for the billing section only uses the |
+ // billing-specific country field in |map| ("China" or "CN"). |
+ FieldMapWrapper billing_wrapper(map, SECTION_BILLING); |
+ EXPECT_EQ(base::ASCIIToUTF16("China"), |
+ billing_wrapper.GetInfo(AutofillType(ADDRESS_HOME_COUNTRY))); |
+ EXPECT_EQ(base::ASCIIToUTF16("CN"), |
+ billing_wrapper.GetInfo(AutofillType(HTML_TYPE_COUNTRY_CODE, |
+ HTML_MODE_SHIPPING))); |
+ |
+ // And conversely that the shipping wrapper only returns "France" or "FR" (the |
+ // shipping country). |
+ FieldMapWrapper shipping_wrapper(map, SECTION_SHIPPING); |
+ EXPECT_EQ(base::ASCIIToUTF16("France"), |
+ shipping_wrapper.GetInfo(AutofillType(ADDRESS_BILLING_COUNTRY))); |
+ EXPECT_EQ(base::ASCIIToUTF16("FR"), |
+ shipping_wrapper.GetInfo(AutofillType(HTML_TYPE_COUNTRY_CODE, |
+ HTML_MODE_BILLING))); |
+} |
+ |
+} // namespace autofill |