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

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

Issue 148273010: rAc: fix international address formatting (mostly) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/data_model_wrapper_unittest.cc
diff --git a/chrome/browser/ui/autofill/data_model_wrapper_unittest.cc b/chrome/browser/ui/autofill/data_model_wrapper_unittest.cc
index eaf8bf1f7429f8c3a9b8a7c4b8f81cf532fcaffd..da32f19c6dcf40d7f1daa68598764e01265823d7 100644
--- a/chrome/browser/ui/autofill/data_model_wrapper_unittest.cc
+++ b/chrome/browser/ui/autofill/data_model_wrapper_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/guid.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
@@ -94,6 +95,67 @@ TEST(DataModelWrapperTest, GetDisplayTextEmptyWithoutPhone) {
}
#endif
+TEST(DataModelWrapperTest, GetDisplayText) {
+ AutofillProfile profile = test::GetFullProfile();
+ base::string16 vertical, horizontal;
+ EXPECT_TRUE(
+ AutofillProfileWrapper(&profile).GetDisplayText(&horizontal, &vertical));
+ EXPECT_EQ(
+ ASCIIToUTF16("John H. Doe, 666 Erebus St., Apt 8, Elysium, CA 91111\n"
+ "johndoe@hades.com\n"
+ "+1 650-211-1111"),
+ horizontal);
+ EXPECT_EQ(
+ ASCIIToUTF16("John H. Doe\n"
+ "666 Erebus St.\n"
+ "Apt 8\n"
+ "Elysium, CA 91111\n"
+ "johndoe@hades.com\n"
+ "+1 650-211-1111"),
+ vertical);
+
+ // A Japanese address.
+ AutofillProfile foreign_profile(
+ base::GenerateGUID(), "http://www.example.com/");
+ foreign_profile.SetRawInfo(
+ ADDRESS_HOME_COUNTRY, ASCIIToUTF16("JP"));
+ foreign_profile.SetRawInfo(
+ ADDRESS_HOME_STATE,
+ 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
+ foreign_profile.SetRawInfo(
+ ADDRESS_HOME_CITY,
+ base::WideToUTF16(L"\u6E0B\u8C37\u533A"));
+ foreign_profile.SetRawInfo(
+ ADDRESS_HOME_DEPENDENT_LOCALITY,
+ base::WideToUTF16(L"\uC911\uAD6C"));
+ foreign_profile.SetRawInfo(
+ ADDRESS_HOME_STREET_ADDRESS,
+ base::WideToUTF16(
+ L"\u685C\u4E18\u753A26-1\n"
+ L"\u30BB\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC6\u968E"));
+ foreign_profile.SetRawInfo(
+ NAME_FULL,
+ base::WideToUTF16(L"\u6751\u4E0A \u7F8E\u7D00"));
+ foreign_profile.SetRawInfo(ADDRESS_HOME_ZIP, base::ASCIIToUTF16("150-8512"));
+ foreign_profile.SetRawInfo(
+ PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("+81-3-6384-9000"));
+
+ EXPECT_TRUE(AutofillProfileWrapper(&foreign_profile).GetDisplayText(
+ &horizontal, &vertical));
+ EXPECT_EQ(
+ base::WideToUTF16(
+ L"\u3012150-8512\n"
+ L"\u6771\u4EAC\u90FD\u6E0B\u8C37\u533A\n"
+ L"\u685C\u4E18\u753A26-1\n"
+ L"\u30BB\u30EB\u30EA\u30A2\u30F3\u30BF\u30EF\u30FC6\u968E\n"
+ L"\u6751\u4E0A \u7F8E\u7D00\n"
+ L"+81-3-6384-9000"),
+ vertical);
+ // TODO(estade): we should also verify that |horizontal| is correct, but right
+ // now it uses the incorrect address line separator. See:
+ // http://crbug.com/270261
+}
+
TEST(WalletInstrumentWrapperTest, GetInfoCreditCardExpMonth) {
scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument(
wallet::GetTestMaskedInstrument());

Powered by Google App Engine
This is Rietveld 408576698