+
+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"));
+ 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
+}