Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / autofill / data_model_wrapper_unittest.cc
index eaf8bf1..2df388e 100644 (file)
@@ -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"
@@ -30,7 +31,6 @@ TEST(AutofillCreditCardWrapperTest, GetInfoCreditCardExpMonth) {
   }
 }
 
-#if !defined(OS_ANDROID)
 TEST(AutofillCreditCardWrapperTest, GetDisplayTextEmptyWhenExpired) {
   CreditCard card;
   card.SetRawInfo(CREDIT_CARD_EXP_MONTH, ASCIIToUTF16("1"));
@@ -92,7 +92,67 @@ TEST(DataModelWrapperTest, GetDisplayTextEmptyWithoutPhone) {
             address_wrapper.GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER)));
   EXPECT_FALSE(address_wrapper.GetDisplayText(&unused, &unused2));
 }
-#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"));
+  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(
@@ -172,25 +232,4 @@ TEST(DataModelWrapperTest, GetDisplayPhoneNumber) {
 
 }
 
-TEST(FieldMapWrapperTest, BothShippingAndBillingCanCoexist) {
-  DetailInputs inputs;
-
-  DetailInput billing_street;
-  billing_street.type = ADDRESS_BILLING_STREET_ADDRESS;
-  inputs.push_back(billing_street);
-
-  DetailInput shipping_street;
-  shipping_street.type = ADDRESS_HOME_STREET_ADDRESS;
-  inputs.push_back(shipping_street);
-
-  FieldValueMap outputs;
-  outputs[inputs[0].type] = ASCIIToUTF16("123 billing street");
-  outputs[inputs[1].type] = ASCIIToUTF16("123 shipping street");
-
-  FieldMapWrapper wrapper(outputs);
-  wrapper.FillInputs(&inputs);
-
-  EXPECT_NE(inputs[0].initial_value, inputs[1].initial_value);
-}
-
 }  // namespace autofill