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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_i18n_input_unittest.cc

Issue 63053003: Ask libaddressinput for address components to use in requestAutocomplete(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
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..a893505e1694b9d9719ccb6ad04d578637866629
--- /dev/null
+++ b/chrome/browser/ui/autofill/autofill_dialog_i18n_input_unittest.cc
@@ -0,0 +1,79 @@
+// 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.
+
+#include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
+
+#include "base/command_line.h"
+#include "chrome/common/chrome_switches.h"
+#include "components/autofill/core/browser/field_types.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace autofill {
+namespace i18ninput {
+
+namespace {
+
+const size_t kNumberOfAddressLinesUS = 7;
+
+void AppendSwitch() {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n);
+ ASSERT_TRUE(Enabled());
+}
+
+} // namespace
+
+TEST(AutofillDialogI18nInput, DisabledByDefault) {
+ EXPECT_FALSE(Enabled());
+}
+
+TEST(AutofillDialogI18nInput, USShippingAddress) {
+ AppendSwitch();
+
+ DetailInputs inputs;
+ BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &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) {
+ AppendSwitch();
+
+ DetailInputs inputs;
+ BuildAddressInputs(common::ADDRESS_TYPE_BILLING, "US", &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) {
+ AppendSwitch();
+
+ DetailInputs inputs;
+ BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs);
+ ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
+
+ // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines.
+ EXPECT_NE(inputs[2].length, DetailInput::SHORT);
+
+ const DetailInput& city = inputs[3];
+ ASSERT_EQ(ADDRESS_HOME_CITY, city.type);
+ EXPECT_EQ(city.length, DetailInput::SHORT);
+
+ const DetailInput& state = inputs[4];
+ ASSERT_EQ(ADDRESS_HOME_STATE, state.type);
+ EXPECT_EQ(state.length, DetailInput::SHORT);
+
+ const DetailInput& zip = inputs[5];
+ ASSERT_EQ(ADDRESS_HOME_ZIP, zip.type);
+ EXPECT_EQ(zip.length, DetailInput::SHORT);
+
+ EXPECT_NE(inputs[6].length, DetailInput::SHORT);
+}
+
+} // namespace i18ninput
+} // namespace autofill
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc ('k') | chrome/browser/ui/autofill/autofill_dialog_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698