Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / autofill / content / browser / wallet / wallet_items_unittest.cc
index 6cf23dc..0f3493d 100644 (file)
@@ -3,13 +3,13 @@
 // found in the LICENSE file.
 
 #include "base/json/json_reader.h"
-#include "base/logging.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/values.h"
 #include "components/autofill/content/browser/wallet/gaia_account.h"
 #include "components/autofill/content/browser/wallet/required_action.h"
 #include "components/autofill/content/browser/wallet/wallet_items.h"
+#include "components/autofill/content/browser/wallet/wallet_test_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
 
@@ -21,10 +21,6 @@ const char kMaskedInstrument[] =
     "{"
     "  \"descriptive_name\":\"descriptive_name\","
     "  \"type\":\"VISA\","
-    "  \"supported_currency\":"
-    "  ["
-    "    \"currency\""
-    "  ],"
     "  \"last_four_digits\":\"last_four_digits\","
     "  \"expiration_month\":12,"
     "  \"expiration_year\":2012,"
@@ -34,11 +30,14 @@ const char kMaskedInstrument[] =
     "    \"address1\":\"address1\","
     "    \"address2\":\"address2\","
     "    \"city\":\"city\","
+    "    \"dependent_locality_name\":\"burough\","
     "    \"state\":\"state\","
     "    \"postal_code\":\"postal_code\","
+    "    \"sorting_code\":\"sorting_code\","
     "    \"phone_number\":\"phone_number\","
     "    \"country_code\":\"US\","
-    "    \"type\":\"FULL\""
+    "    \"type\":\"FULL\","
+    "    \"language_code\":\"language_code\""
     "  },"
     "  \"status\":\"VALID\","
     "  \"object_id\":\"object_id\""
@@ -48,10 +47,6 @@ const char kMaskedInstrumentMissingStatus[] =
     "{"
     "  \"descriptive_name\":\"descriptive_name\","
     "  \"type\":\"VISA\","
-    "  \"supported_currency\":"
-    "  ["
-    "    \"currency\""
-    "  ],"
     "  \"last_four_digits\":\"last_four_digits\","
     "  \"expiration_month\":12,"
     "  \"expiration_year\":2012,"
@@ -61,10 +56,13 @@ const char kMaskedInstrumentMissingStatus[] =
     "    \"address1\":\"address1\","
     "    \"address2\":\"address2\","
     "    \"city\":\"city\","
+    "    \"dependent_locality_name\":\"burough\","
     "    \"state\":\"state\","
     "    \"postal_code\":\"postal_code\","
+    "    \"sorting_code\":\"sorting_code\","
     "    \"phone_number\":\"phone_number\","
-    "    \"country_code\":\"US\""
+    "    \"country_code\":\"US\","
+    "    \"language_code\":\"language_code\""
     "  },"
     "  \"object_id\":\"object_id\","
     "  \"amex_disallowed\":true"
@@ -73,10 +71,6 @@ const char kMaskedInstrumentMissingStatus[] =
 const char kMaskedInstrumentMissingType[] =
     "{"
     "  \"descriptive_name\":\"descriptive_name\","
-    "  \"supported_currency\":"
-    "  ["
-    "    \"currency\""
-    "  ],"
     "  \"last_four_digits\":\"last_four_digits\","
     "  \"expiration_month\":12,"
     "  \"expiration_year\":2012,"
@@ -86,10 +80,13 @@ const char kMaskedInstrumentMissingType[] =
     "    \"address1\":\"address1\","
     "    \"address2\":\"address2\","
     "    \"city\":\"city\","
+    "    \"dependent_locality_name\":\"burough\","
     "    \"state\":\"state\","
     "    \"postal_code\":\"postal_code\","
+    "    \"sorting_code\":\"sorting_code\","
     "    \"phone_number\":\"phone_number\","
-    "    \"country_code\":\"US\""
+    "    \"country_code\":\"US\","
+    "    \"language_code\":\"language_code\""
     "  },"
     "  \"status\":\"VALID\","
     "  \"object_id\":\"object_id\""
@@ -99,10 +96,6 @@ const char kMaskedInstrumentMissingLastFourDigits[] =
     "{"
     "  \"descriptive_name\":\"descriptive_name\","
     "  \"type\":\"VISA\","
-    "  \"supported_currency\":"
-    "  ["
-    "    \"currency\""
-    "  ],"
     "  \"expiration_month\":12,"
     "  \"expiration_year\":2012,"
     "  \"billing_address\":"
@@ -111,10 +104,13 @@ const char kMaskedInstrumentMissingLastFourDigits[] =
     "    \"address1\":\"address1\","
     "    \"address2\":\"address2\","
     "    \"city\":\"city\","
+    "    \"dependent_locality_name\":\"burough\","
     "    \"state\":\"state\","
     "    \"postal_code\":\"postal_code\","
+    "    \"sorting_code\":\"sorting_code\","
     "    \"phone_number\":\"phone_number\","
-    "    \"country_code\":\"US\""
+    "    \"country_code\":\"US\","
+    "    \"language_code\":\"language_code\""
     "  },"
     "  \"status\":\"VALID\","
     "  \"object_id\":\"object_id\""
@@ -124,10 +120,6 @@ const char kMaskedInstrumentMissingAddress[] =
     "{"
     "  \"descriptive_name\":\"descriptive_name\","
     "  \"type\":\"VISA\","
-    "  \"supported_currency\":"
-    "  ["
-    "    \"currency\""
-    "  ],"
     "  \"last_four_digits\":\"last_four_digits\","
     "  \"expiration_month\":12,"
     "  \"expiration_year\":2012,"
@@ -139,10 +131,6 @@ const char kMaskedInstrumentMalformedAddress[] =
     "{"
     "  \"descriptive_name\":\"descriptive_name\","
     "  \"type\":\"VISA\","
-    "  \"supported_currency\":"
-    "  ["
-    "    \"currency\""
-    "  ],"
     "  \"last_four_digits\":\"last_four_digits\","
     "  \"expiration_month\":12,"
     "  \"expiration_year\":2012,"
@@ -151,6 +139,7 @@ const char kMaskedInstrumentMalformedAddress[] =
     "    \"address1\":\"address1\","
     "    \"address2\":\"address2\","
     "    \"city\":\"city\","
+    "    \"dependent_locality_name\":\"burough\","
     "    \"state\":\"state\","
     "    \"phone_number\":\"phone_number\","
     "    \"country_code\":\"US\""
@@ -163,10 +152,6 @@ const char kMaskedInstrumentMissingObjectId[] =
     "{"
     "  \"descriptive_name\":\"descriptive_name\","
     "  \"type\":\"VISA\","
-    "  \"supported_currency\":"
-    "  ["
-    "    \"currency\""
-    "  ],"
     "  \"last_four_digits\":\"last_four_digits\","
     "  \"expiration_month\":12,"
     "  \"expiration_year\":2012,"
@@ -176,10 +161,12 @@ const char kMaskedInstrumentMissingObjectId[] =
     "    \"address1\":\"address1\","
     "    \"address2\":\"address2\","
     "    \"city\":\"city\","
+    "    \"dependent_locality_name\":\"burough\","
     "    \"state\":\"state\","
     "    \"postal_code\":\"postal_code\","
     "    \"phone_number\":\"phone_number\","
-    "    \"country_code\":\"US\""
+    "    \"country_code\":\"US\","
+    "    \"language_code\":\"language_code\""
     "  },"
     "  \"status\":\"VALID\""
     "}";
@@ -235,10 +222,6 @@ const char kWalletItemsMissingGoogleTransactionId[] =
     "    {"
     "      \"descriptive_name\":\"descriptive_name\","
     "      \"type\":\"VISA\","
-    "      \"supported_currency\":"
-    "      ["
-    "        \"currency\""
-    "      ],"
     "      \"last_four_digits\":\"last_four_digits\","
     "      \"expiration_month\":12,"
     "      \"expiration_year\":2012,"
@@ -251,7 +234,8 @@ const char kWalletItemsMissingGoogleTransactionId[] =
     "        \"state\":\"state\","
     "        \"postal_code\":\"postal_code\","
     "        \"phone_number\":\"phone_number\","
-    "        \"country_code\":\"US\""
+    "        \"country_code\":\"US\","
+    "        \"language_code\":\"language_code\""
     "      },"
     "      \"status\":\"VALID\","
     "      \"object_id\":\"object_id\""
@@ -274,7 +258,8 @@ const char kWalletItemsMissingGoogleTransactionId[] =
     "        \"locality_name\":\"locality_name\","
     "        \"administrative_area_name\":\"administrative_area_name\","
     "        \"postal_code_number\":\"postal_code_number\","
-    "        \"country_name_code\":\"US\""
+    "        \"country_name_code\":\"US\","
+    "        \"language_code\":\"language_code\""
     "      }"
     "    }"
     "  ],"
@@ -300,10 +285,6 @@ const char kWalletItems[] =
     "    {"
     "      \"descriptive_name\":\"descriptive_name\","
     "      \"type\":\"VISA\","
-    "      \"supported_currency\":"
-    "      ["
-    "        \"currency\""
-    "      ],"
     "      \"last_four_digits\":\"last_four_digits\","
     "      \"expiration_month\":12,"
     "      \"expiration_year\":2012,"
@@ -313,11 +294,14 @@ const char kWalletItems[] =
     "        \"address1\":\"address1\","
     "        \"address2\":\"address2\","
     "        \"city\":\"city\","
+    "        \"dependent_locality_name\":\"burough\","
     "        \"state\":\"state\","
     "        \"postal_code\":\"postal_code\","
+    "        \"sorting_code\":\"sorting_code\","
     "        \"phone_number\":\"phone_number\","
     "        \"country_code\":\"US\","
-    "        \"type\":\"FULL\""
+    "        \"type\":\"FULL\","
+    "        \"language_code\":\"language_code\""
     "      },"
     "      \"status\":\"VALID\","
     "      \"object_id\":\"object_id\""
@@ -338,9 +322,12 @@ const char kWalletItems[] =
     "          \"address_line_2\""
     "        ],"
     "        \"locality_name\":\"locality_name\","
+    "        \"dependent_locality_name\":\"dependent_locality_name\","
     "        \"administrative_area_name\":\"administrative_area_name\","
     "        \"postal_code_number\":\"postal_code_number\","
-    "        \"country_name_code\":\"US\""
+    "        \"sorting_code\":\"sorting_code\","
+    "        \"country_name_code\":\"US\","
+    "        \"language_code\":\"language_code\""
     "      }"
     "    }"
     "  ],"
@@ -371,6 +358,12 @@ const char kWalletItems[] =
     "      \"avatar_url_48x48\":\"https://lh3.googleusercontent.com/48.jpg\","
     "      \"avatar_url_96x96\":\"https://lh3.googleusercontent.com/96.jpg\""
     "    }"
+    "  ],"
+    "  \"allowed_shipping_spec_by_country\":"
+    "  ["
+    "    {\"country_code\":\"AC\"},"
+    "    {\"country_code\":\"AD\"},"
+    "    {\"country_code\":\"US\"}"
     "  ]";
 
 const char kRequiredLegalDocument[] =
@@ -441,21 +434,21 @@ TEST_F(WalletItemsTest, CreateMaskedInstrumentMissingObjectId) {
 
 TEST_F(WalletItemsTest, CreateMaskedInstrument) {
   SetUpDictionary(kMaskedInstrument);
-  scoped_ptr<Address> address(new Address("US",
-                                          ASCIIToUTF16("name"),
-                                          ASCIIToUTF16("address1"),
-                                          ASCIIToUTF16("address2"),
-                                          ASCIIToUTF16("city"),
-                                          ASCIIToUTF16("state"),
-                                          ASCIIToUTF16("postal_code"),
-                                          ASCIIToUTF16("phone_number"),
-                                          std::string()));
-  std::vector<base::string16> supported_currencies;
-  supported_currencies.push_back(ASCIIToUTF16("currency"));
+  scoped_ptr<Address> address(
+      new Address("US",
+                  ASCIIToUTF16("name"),
+                  StreetAddress("address1", "address2"),
+                  ASCIIToUTF16("city"),
+                  ASCIIToUTF16("burough"),
+                  ASCIIToUTF16("state"),
+                  ASCIIToUTF16("postal_code"),
+                  ASCIIToUTF16("sorting_code"),
+                  ASCIIToUTF16("phone_number"),
+                  std::string(),
+                  "language_code"));
   WalletItems::MaskedInstrument masked_instrument(
       ASCIIToUTF16("descriptive_name"),
       WalletItems::MaskedInstrument::VISA,
-      supported_currencies,
       ASCIIToUTF16("last_four_digits"),
       12,
       2012,
@@ -568,21 +561,21 @@ TEST_F(WalletItemsTest, CreateWalletItems) {
   expected.AddAccount(user2.Pass());
   EXPECT_EQ("123456789", expected.ObfuscatedGaiaId());
 
-  scoped_ptr<Address> billing_address(new Address("US",
-                                                  ASCIIToUTF16("name"),
-                                                  ASCIIToUTF16("address1"),
-                                                  ASCIIToUTF16("address2"),
-                                                  ASCIIToUTF16("city"),
-                                                  ASCIIToUTF16("state"),
-                                                  ASCIIToUTF16("postal_code"),
-                                                  ASCIIToUTF16("phone_number"),
-                                                  std::string()));
-  std::vector<base::string16> supported_currencies;
-  supported_currencies.push_back(ASCIIToUTF16("currency"));
+  scoped_ptr<Address> billing_address(
+      new Address("US",
+                  ASCIIToUTF16("name"),
+                  StreetAddress("address1", "address2"),
+                  ASCIIToUTF16("city"),
+                  ASCIIToUTF16("burough"),
+                  ASCIIToUTF16("state"),
+                  ASCIIToUTF16("postal_code"),
+                  ASCIIToUTF16("sorting_code"),
+                  ASCIIToUTF16("phone_number"),
+                  std::string(),
+                  "language_code"));
   scoped_ptr<WalletItems::MaskedInstrument> masked_instrument(
       new WalletItems::MaskedInstrument(ASCIIToUTF16("descriptive_name"),
                                         WalletItems::MaskedInstrument::VISA,
-                                        supported_currencies,
                                         ASCIIToUTF16("last_four_digits"),
                                         12,
                                         2012,
@@ -594,14 +587,21 @@ TEST_F(WalletItemsTest, CreateWalletItems) {
   scoped_ptr<Address> shipping_address(
       new Address("US",
                   ASCIIToUTF16("recipient_name"),
-                  ASCIIToUTF16("address_line_1"),
-                  ASCIIToUTF16("address_line_2"),
+                  StreetAddress("address_line_1", "address_line_2"),
                   ASCIIToUTF16("locality_name"),
+                  ASCIIToUTF16("dependent_locality_name"),
                   ASCIIToUTF16("administrative_area_name"),
                   ASCIIToUTF16("postal_code_number"),
+                  ASCIIToUTF16("sorting_code"),
                   ASCIIToUTF16("phone_number"),
-                  "id"));
+                  "id",
+                  "language_code"));
   expected.AddAddress(shipping_address.Pass());
+
+  expected.AddAllowedShippingCountry("AC");
+  expected.AddAllowedShippingCountry("AD");
+  expected.AddAllowedShippingCountry("US");
+
   EXPECT_EQ(expected, *WalletItems::CreateWalletItems(*dict));
 
   // Now try with a legal document as well.