Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/guid.h" | |
| 5 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 9 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
| 9 #include "chrome/browser/ui/autofill/data_model_wrapper.h" | 10 #include "chrome/browser/ui/autofill/data_model_wrapper.h" |
| 10 #include "components/autofill/content/browser/wallet/wallet_items.h" | 11 #include "components/autofill/content/browser/wallet/wallet_items.h" |
| 11 #include "components/autofill/content/browser/wallet/wallet_test_util.h" | 12 #include "components/autofill/content/browser/wallet/wallet_test_util.h" |
| 12 #include "components/autofill/core/browser/autofill_profile.h" | 13 #include "components/autofill/core/browser/autofill_profile.h" |
| 13 #include "components/autofill/core/browser/autofill_test_utils.h" | 14 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 14 #include "components/autofill/core/browser/credit_card.h" | 15 #include "components/autofill/core/browser/credit_card.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 EXPECT_EQ(base::string16(), | 88 EXPECT_EQ(base::string16(), |
| 88 instrument_wrapper.GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER))); | 89 instrument_wrapper.GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER))); |
| 89 EXPECT_FALSE(instrument_wrapper.GetDisplayText(&unused, &unused2)); | 90 EXPECT_FALSE(instrument_wrapper.GetDisplayText(&unused, &unused2)); |
| 90 | 91 |
| 91 EXPECT_EQ(base::string16(), | 92 EXPECT_EQ(base::string16(), |
| 92 address_wrapper.GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER))); | 93 address_wrapper.GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER))); |
| 93 EXPECT_FALSE(address_wrapper.GetDisplayText(&unused, &unused2)); | 94 EXPECT_FALSE(address_wrapper.GetDisplayText(&unused, &unused2)); |
| 94 } | 95 } |
| 95 #endif | 96 #endif |
| 96 | 97 |
| 98 TEST(DataModelWrapperTest, GetDisplayText) { | |
| 99 AutofillProfile profile = test::GetFullProfile(); | |
| 100 base::string16 vertical, horizontal; | |
| 101 EXPECT_TRUE( | |
| 102 AutofillProfileWrapper(&profile).GetDisplayText(&horizontal, &vertical)); | |
| 103 EXPECT_EQ( | |
| 104 ASCIIToUTF16("John H. Doe, 666 Erebus St., Apt 8, Elysium, CA 91111\n" | |
| 105 "johndoe@hades.com\n" | |
| 106 "+1 650-211-1111"), | |
| 107 horizontal); | |
| 108 EXPECT_EQ( | |
| 109 ASCIIToUTF16("John H. Doe\n" | |
| 110 "666 Erebus St.\n" | |
| 111 "Apt 8\n" | |
| 112 "Elysium, CA 91111\n" | |
| 113 "johndoe@hades.com\n" | |
| 114 "+1 650-211-1111"), | |
| 115 vertical); | |
| 116 | |
| 117 // A Japanese address. | |
| 118 AutofillProfile foreign_profile( | |
| 119 base::GenerateGUID(), "http://www.example.com/"); | |
| 120 foreign_profile.SetRawInfo( | |
| 121 ADDRESS_HOME_COUNTRY, ASCIIToUTF16("JP")); | |
| 122 foreign_profile.SetRawInfo( | |
| 123 ADDRESS_HOME_STATE, | |
| 124 base::WideToUTF16(L"\u6771\u4EAC\u90FD")); | |
|
Dan Beam
2014/01/29 03:26:59
can we use literals (東京都) instead?
Evan Stade
2014/01/29 04:11:00
no --- see many other tests that do this, esp in b
| |
| 125 foreign_profile.SetRawInfo( | |
| 126 ADDRESS_HOME_CITY, | |
| 127 base::WideToUTF16(L"\u6E0B\u8C37\u533A")); | |
| 128 foreign_profile.SetRawInfo( | |
| 129 ADDRESS_HOME_DEPENDENT_LOCALITY, | |
| 130 base::WideToUTF16(L"\uC911\uAD6C")); | |
| 131 foreign_profile.SetRawInfo( | |
| 132 ADDRESS_HOME_STREET_ADDRESS, | |
| 133 base::WideToUTF16( | |
| 134 L"\u685C\u4E18\u753A26-1\n" | |
| 135 L"\u30BB\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC6\u968E")); | |
| 136 foreign_profile.SetRawInfo( | |
| 137 NAME_FULL, | |
| 138 base::WideToUTF16(L"\u6751\u4E0A \u7F8E\u7D00")); | |
| 139 foreign_profile.SetRawInfo(ADDRESS_HOME_ZIP, base::ASCIIToUTF16("150-8512")); | |
| 140 foreign_profile.SetRawInfo( | |
| 141 PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("+81-3-6384-9000")); | |
| 142 | |
| 143 EXPECT_TRUE(AutofillProfileWrapper(&foreign_profile).GetDisplayText( | |
| 144 &horizontal, &vertical)); | |
| 145 EXPECT_EQ( | |
| 146 base::WideToUTF16( | |
| 147 L"\u3012150-8512\n" | |
| 148 L"\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\n" | |
| 149 L"\u685C\u4E18\u753A26-1\n" | |
| 150 L"\u30BB\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC6\u968E\n" | |
| 151 L"\u6751\u4E0A \u7F8E\u7D00\n" | |
| 152 L"+81-3-6384-9000"), | |
| 153 vertical); | |
| 154 // TODO(estade): we should also verify that |horizontal| is correct, but right | |
| 155 // now it uses the incorrect address line separator. See: | |
| 156 // http://crbug.com/270261 | |
| 157 } | |
| 158 | |
| 97 TEST(WalletInstrumentWrapperTest, GetInfoCreditCardExpMonth) { | 159 TEST(WalletInstrumentWrapperTest, GetInfoCreditCardExpMonth) { |
| 98 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument( | 160 scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument( |
| 99 wallet::GetTestMaskedInstrument()); | 161 wallet::GetTestMaskedInstrument()); |
| 100 MonthComboboxModel model; | 162 MonthComboboxModel model; |
| 101 for (int month = 1; month <= 12; ++month) { | 163 for (int month = 1; month <= 12; ++month) { |
| 102 instrument->expiration_month_ = month; | 164 instrument->expiration_month_ = month; |
| 103 WalletInstrumentWrapper wrapper(instrument.get()); | 165 WalletInstrumentWrapper wrapper(instrument.get()); |
| 104 EXPECT_EQ(model.GetItemAt(month), | 166 EXPECT_EQ(model.GetItemAt(month), |
| 105 wrapper.GetInfo(AutofillType(CREDIT_CARD_EXP_MONTH))); | 167 wrapper.GetInfo(AutofillType(CREDIT_CARD_EXP_MONTH))); |
| 106 } | 168 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 outputs[inputs[0].type] = ASCIIToUTF16("123 billing street"); | 249 outputs[inputs[0].type] = ASCIIToUTF16("123 billing street"); |
| 188 outputs[inputs[1].type] = ASCIIToUTF16("123 shipping street"); | 250 outputs[inputs[1].type] = ASCIIToUTF16("123 shipping street"); |
| 189 | 251 |
| 190 FieldMapWrapper wrapper(outputs); | 252 FieldMapWrapper wrapper(outputs); |
| 191 wrapper.FillInputs(&inputs); | 253 wrapper.FillInputs(&inputs); |
| 192 | 254 |
| 193 EXPECT_NE(inputs[0].initial_value, inputs[1].initial_value); | 255 EXPECT_NE(inputs[0].initial_value, inputs[1].initial_value); |
| 194 } | 256 } |
| 195 | 257 |
| 196 } // namespace autofill | 258 } // namespace autofill |
| OLD | NEW |