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/autofill_dialog_i18n_input.h" 6 7#include "components/autofill/core/browser/field_types.h" 8#include "testing/gtest/include/gtest/gtest.h" 9#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h" 10 11namespace autofill { 12namespace i18ninput { 13 14namespace { 15 16const size_t kNumberOfAddressLinesUS = 6; 17 18} // namespace 19 20TEST(AutofillDialogI18nInput, USShippingAddress) { 21 DetailInputs inputs; 22 std::string language_code; 23 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs, 24 &language_code); 25 26 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); 27 EXPECT_EQ(NAME_FULL, inputs[0].type); 28 EXPECT_EQ(ADDRESS_HOME_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); 29 EXPECT_EQ("en", language_code); 30} 31 32TEST(AutofillDialogI18nInput, USBillingAddress) { 33 DetailInputs inputs; 34 BuildAddressInputs(common::ADDRESS_TYPE_BILLING, "US", &inputs, NULL); 35 36 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); 37 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type); 38 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); 39} 40 41TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) { 42 DetailInputs inputs; 43 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs, NULL); 44 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); 45 46 int input_index = 2; 47 48 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines. 49 EXPECT_NE(inputs[input_index - 1].length, DetailInput::SHORT); 50 51 const DetailInput& city = inputs[input_index++]; 52 EXPECT_EQ(ADDRESS_HOME_CITY, city.type); 53 EXPECT_EQ(city.length, DetailInput::SHORT); 54 55 const DetailInput& state = inputs[input_index++]; 56 EXPECT_EQ(ADDRESS_HOME_STATE, state.type); 57 EXPECT_EQ(state.length, DetailInput::SHORT); 58 59 const DetailInput& zip = inputs[input_index++]; 60 EXPECT_EQ(ADDRESS_HOME_ZIP, zip.type); 61 EXPECT_EQ(zip.length, DetailInput::SHORT); 62 63 EXPECT_NE(inputs[input_index].length, DetailInput::SHORT); 64} 65 66TEST(AutofillDialogI18nInput, IvoryCoastNoStreetLine2) { 67 DetailInputs inputs; 68 std::string language_code; 69 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "CI", &inputs, 70 &language_code); 71 for (size_t i = 0; i < inputs.size(); ++i) { 72 EXPECT_NE(ADDRESS_HOME_LINE2, inputs[i].type); 73 } 74 EXPECT_EQ("fr", language_code); 75} 76 77} // namespace i18ninput 78} // namespace autofill 79