Index: chrome/browser/ui/autofill/autofill_dialog_i18n_input_unittest.cc |
diff --git a/chrome/browser/ui/autofill/autofill_dialog_i18n_input_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_i18n_input_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..86e662581f5307169fde6519981c62e765ad0fe1 |
--- /dev/null |
+++ b/chrome/browser/ui/autofill/autofill_dialog_i18n_input_unittest.cc |
@@ -0,0 +1,71 @@ |
+// Copyright 2013 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. |
+// |
+// Unit tests for generation of internationalized address input forms. Only US |
+// addresses are tested until libaddressinput is integrated. |
+ |
+#include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" |
+ |
+#include "base/command_line.h" |
+#include "chrome/common/chrome_switches.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace autofill { |
+namespace i18ninput { |
+ |
+namespace { |
+ |
+const size_t kNumberOfAddressLinesUS = 7; |
+ |
+} // namespace |
+ |
+TEST(AutofillDialogI18nInput, I18nAddressInputIsDisabledByDefault) { |
+ EXPECT_FALSE(IsI18nAddressInputEnabled()); |
+ CommandLine::ForCurrentProcess()->AppendSwitch( |
+ ::switches::kEnableAutofillAddressInternationalization); |
+ EXPECT_TRUE(IsI18nAddressInputEnabled()); |
+} |
+ |
+TEST(AutofillDialogI18nInput, USShippingAddress) { |
+ DetailInputs inputs; |
+ BuildI18nInputs(ADDRESS_TYPE_SHIPPING, "US", 0, &inputs); |
+ |
+ ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); |
+ EXPECT_EQ(NAME_FULL, inputs[0].type); |
+ EXPECT_EQ(ADDRESS_HOME_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); |
+} |
+ |
+TEST(AutofillDialogI18nInput, USBillingAddress) { |
+ DetailInputs inputs; |
+ BuildI18nInputs(ADDRESS_TYPE_BILLING, "US", 0, &inputs); |
+ |
+ ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); |
+ EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type); |
+ EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); |
+} |
+ |
+TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) { |
+ DetailInputs inputs; |
+ BuildI18nInputs(ADDRESS_TYPE_SHIPPING, "US", 0, &inputs); |
+ ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); |
+ |
+ const DetailInput& city = inputs[3]; |
+ ASSERT_EQ(ADDRESS_HOME_CITY, city.type); |
+ |
+ const DetailInput& state = inputs[4]; |
+ ASSERT_EQ(ADDRESS_HOME_STATE, state.type); |
+ |
+ const DetailInput& zip = inputs[5]; |
+ ASSERT_EQ(ADDRESS_HOME_ZIP, zip.type); |
+ |
+ EXPECT_EQ(city.row_id, state.row_id); |
+ EXPECT_EQ(state.row_id, zip.row_id); |
+ |
+ // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines. |
+ EXPECT_NE(inputs[2].row_id, city.row_id); |
+ EXPECT_NE(inputs[6].row_id, city.row_id); |
+} |
+ |
+} // namespace i18ninput |
+} // namespace autofill |