Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / autofill / content / browser / wallet / wallet_items_unittest.cc
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
3 // found in the LICENSE file.
4
5 #include "base/json/json_reader.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "base/values.h"
9 #include "components/autofill/content/browser/wallet/gaia_account.h"
10 #include "components/autofill/content/browser/wallet/required_action.h"
11 #include "components/autofill/content/browser/wallet/wallet_items.h"
12 #include "components/autofill/content/browser/wallet/wallet_test_util.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "url/gurl.h"
15
16 using base::ASCIIToUTF16;
17
18 namespace {
19
20 const char kMaskedInstrument[] =
21     "{"
22     "  \"descriptive_name\":\"descriptive_name\","
23     "  \"type\":\"VISA\","
24     "  \"last_four_digits\":\"last_four_digits\","
25     "  \"expiration_month\":12,"
26     "  \"expiration_year\":2012,"
27     "  \"billing_address\":"
28     "  {"
29     "    \"name\":\"name\","
30     "    \"address1\":\"address1\","
31     "    \"address2\":\"address2\","
32     "    \"city\":\"city\","
33     "    \"dependent_locality_name\":\"burough\","
34     "    \"state\":\"state\","
35     "    \"postal_code\":\"postal_code\","
36     "    \"sorting_code\":\"sorting_code\","
37     "    \"phone_number\":\"phone_number\","
38     "    \"country_code\":\"US\","
39     "    \"type\":\"FULL\","
40     "    \"language_code\":\"language_code\""
41     "  },"
42     "  \"status\":\"VALID\","
43     "  \"object_id\":\"object_id\""
44     "}";
45
46 const char kMaskedInstrumentMissingStatus[] =
47     "{"
48     "  \"descriptive_name\":\"descriptive_name\","
49     "  \"type\":\"VISA\","
50     "  \"last_four_digits\":\"last_four_digits\","
51     "  \"expiration_month\":12,"
52     "  \"expiration_year\":2012,"
53     "  \"billing_address\":"
54     "  {"
55     "    \"name\":\"name\","
56     "    \"address1\":\"address1\","
57     "    \"address2\":\"address2\","
58     "    \"city\":\"city\","
59     "    \"dependent_locality_name\":\"burough\","
60     "    \"state\":\"state\","
61     "    \"postal_code\":\"postal_code\","
62     "    \"sorting_code\":\"sorting_code\","
63     "    \"phone_number\":\"phone_number\","
64     "    \"country_code\":\"US\","
65     "    \"language_code\":\"language_code\""
66     "  },"
67     "  \"object_id\":\"object_id\","
68     "  \"amex_disallowed\":true"
69     "}";
70
71 const char kMaskedInstrumentMissingType[] =
72     "{"
73     "  \"descriptive_name\":\"descriptive_name\","
74     "  \"last_four_digits\":\"last_four_digits\","
75     "  \"expiration_month\":12,"
76     "  \"expiration_year\":2012,"
77     "  \"billing_address\":"
78     "  {"
79     "    \"name\":\"name\","
80     "    \"address1\":\"address1\","
81     "    \"address2\":\"address2\","
82     "    \"city\":\"city\","
83     "    \"dependent_locality_name\":\"burough\","
84     "    \"state\":\"state\","
85     "    \"postal_code\":\"postal_code\","
86     "    \"sorting_code\":\"sorting_code\","
87     "    \"phone_number\":\"phone_number\","
88     "    \"country_code\":\"US\","
89     "    \"language_code\":\"language_code\""
90     "  },"
91     "  \"status\":\"VALID\","
92     "  \"object_id\":\"object_id\""
93     "}";
94
95 const char kMaskedInstrumentMissingLastFourDigits[] =
96     "{"
97     "  \"descriptive_name\":\"descriptive_name\","
98     "  \"type\":\"VISA\","
99     "  \"expiration_month\":12,"
100     "  \"expiration_year\":2012,"
101     "  \"billing_address\":"
102     "  {"
103     "    \"name\":\"name\","
104     "    \"address1\":\"address1\","
105     "    \"address2\":\"address2\","
106     "    \"city\":\"city\","
107     "    \"dependent_locality_name\":\"burough\","
108     "    \"state\":\"state\","
109     "    \"postal_code\":\"postal_code\","
110     "    \"sorting_code\":\"sorting_code\","
111     "    \"phone_number\":\"phone_number\","
112     "    \"country_code\":\"US\","
113     "    \"language_code\":\"language_code\""
114     "  },"
115     "  \"status\":\"VALID\","
116     "  \"object_id\":\"object_id\""
117     "}";
118
119 const char kMaskedInstrumentMissingAddress[] =
120     "{"
121     "  \"descriptive_name\":\"descriptive_name\","
122     "  \"type\":\"VISA\","
123     "  \"last_four_digits\":\"last_four_digits\","
124     "  \"expiration_month\":12,"
125     "  \"expiration_year\":2012,"
126     "  \"status\":\"VALID\","
127     "  \"object_id\":\"object_id\""
128     "}";
129
130 const char kMaskedInstrumentMalformedAddress[] =
131     "{"
132     "  \"descriptive_name\":\"descriptive_name\","
133     "  \"type\":\"VISA\","
134     "  \"last_four_digits\":\"last_four_digits\","
135     "  \"expiration_month\":12,"
136     "  \"expiration_year\":2012,"
137     "  \"billing_address\":"
138     "  {"
139     "    \"address1\":\"address1\","
140     "    \"address2\":\"address2\","
141     "    \"city\":\"city\","
142     "    \"dependent_locality_name\":\"burough\","
143     "    \"state\":\"state\","
144     "    \"phone_number\":\"phone_number\","
145     "    \"country_code\":\"US\""
146     "  },"
147     "  \"status\":\"VALID\","
148     "  \"object_id\":\"object_id\""
149     "}";
150
151 const char kMaskedInstrumentMissingObjectId[] =
152     "{"
153     "  \"descriptive_name\":\"descriptive_name\","
154     "  \"type\":\"VISA\","
155     "  \"last_four_digits\":\"last_four_digits\","
156     "  \"expiration_month\":12,"
157     "  \"expiration_year\":2012,"
158     "  \"billing_address\":"
159     "  {"
160     "    \"name\":\"name\","
161     "    \"address1\":\"address1\","
162     "    \"address2\":\"address2\","
163     "    \"city\":\"city\","
164     "    \"dependent_locality_name\":\"burough\","
165     "    \"state\":\"state\","
166     "    \"postal_code\":\"postal_code\","
167     "    \"phone_number\":\"phone_number\","
168     "    \"country_code\":\"US\","
169     "    \"language_code\":\"language_code\""
170     "  },"
171     "  \"status\":\"VALID\""
172     "}";
173
174 const char kLegalDocument[] =
175     "{"
176     "  \"legal_document_id\":\"doc_id\","
177     "  \"display_name\":\"display_name\""
178     "}";
179
180 const char kLegalDocumentMissingDocumentId[] =
181     "{"
182     "  \"display_name\":\"display_name\""
183     "}";
184
185 const char kLegalDocumentMissingDisplayName[] =
186     "{"
187     "  \"legal_document_id\":\"doc_id\""
188     "}";
189
190 const char kWalletItemsWithRequiredActions[] =
191     "{"
192     "  \"required_action\":"
193     "  ["
194     "    \"  setup_wallet\","
195     "    \" CHOOse_ANother_INSTRUMENT_OR_ADDRESS\","
196     "    \"AcCePt_ToS  \","
197     "    \"  \\tGAIA_auth   \\n\\r\","
198     "    \"UPDATE_expiration_date\","
199     "    \"UPGRADE_min_ADDRESS   \","
200     "    \" pAsSiVe_GAIA_auth \","
201     "    \" REQUIRE_PHONE_NUMBER\\t \""
202     "  ]"
203     "}";
204
205 const char kWalletItemsWithInvalidRequiredActions[] =
206     "{"
207     "  \"required_action\":"
208     "  ["
209     "    \"verify_CVV\","
210     "    \"invalid_FORM_FIELD\","
211     "    \" 忍者の正体 \""
212     "  ]"
213     "}";
214
215 const char kWalletItemsMissingGoogleTransactionId[] =
216     "{"
217     "  \"required_action\":"
218     "  ["
219     "  ],"
220     "  \"instrument\":"
221     "  ["
222     "    {"
223     "      \"descriptive_name\":\"descriptive_name\","
224     "      \"type\":\"VISA\","
225     "      \"last_four_digits\":\"last_four_digits\","
226     "      \"expiration_month\":12,"
227     "      \"expiration_year\":2012,"
228     "      \"billing_address\":"
229     "      {"
230     "        \"name\":\"name\","
231     "        \"address1\":\"address1\","
232     "        \"address2\":\"address2\","
233     "        \"city\":\"city\","
234     "        \"state\":\"state\","
235     "        \"postal_code\":\"postal_code\","
236     "        \"phone_number\":\"phone_number\","
237     "        \"country_code\":\"US\","
238     "        \"language_code\":\"language_code\""
239     "      },"
240     "      \"status\":\"VALID\","
241     "      \"object_id\":\"object_id\""
242     "    }"
243     "  ],"
244     "  \"default_instrument_id\":\"default_instrument_id\","
245     "  \"address\":"
246     "  ["
247     "    {"
248     "      \"id\":\"id\","
249     "      \"phone_number\":\"phone_number\","
250     "      \"postal_address\":"
251     "      {"
252     "        \"recipient_name\":\"recipient_name\","
253     "        \"address_line\":"
254     "        ["
255     "          \"address_line_1\","
256     "          \"address_line_2\""
257     "        ],"
258     "        \"locality_name\":\"locality_name\","
259     "        \"administrative_area_name\":\"administrative_area_name\","
260     "        \"postal_code_number\":\"postal_code_number\","
261     "        \"country_name_code\":\"US\","
262     "        \"language_code\":\"language_code\""
263     "      }"
264     "    }"
265     "  ],"
266     "  \"default_address_id\":\"default_address_id\","
267     "  \"amex_disallowed\":true,"
268     "  \"required_legal_document\":"
269     "  ["
270     "    {"
271     "      \"legal_document_id\":\"doc_id\","
272     "      \"display_name\":\"display_name\""
273     "    }"
274     "  ]"
275     "}";
276
277 const char kWalletItems[] =
278     "{"
279     "  \"required_action\":"
280     "  ["
281     "  ],"
282     "  \"google_transaction_id\":\"google_transaction_id\","
283     "  \"instrument\":"
284     "  ["
285     "    {"
286     "      \"descriptive_name\":\"descriptive_name\","
287     "      \"type\":\"VISA\","
288     "      \"last_four_digits\":\"last_four_digits\","
289     "      \"expiration_month\":12,"
290     "      \"expiration_year\":2012,"
291     "      \"billing_address\":"
292     "      {"
293     "        \"name\":\"name\","
294     "        \"address1\":\"address1\","
295     "        \"address2\":\"address2\","
296     "        \"city\":\"city\","
297     "        \"dependent_locality_name\":\"burough\","
298     "        \"state\":\"state\","
299     "        \"postal_code\":\"postal_code\","
300     "        \"sorting_code\":\"sorting_code\","
301     "        \"phone_number\":\"phone_number\","
302     "        \"country_code\":\"US\","
303     "        \"type\":\"FULL\","
304     "        \"language_code\":\"language_code\""
305     "      },"
306     "      \"status\":\"VALID\","
307     "      \"object_id\":\"object_id\""
308     "    }"
309     "  ],"
310     "  \"default_instrument_id\":\"default_instrument_id\","
311     "  \"address\":"
312     "  ["
313     "    {"
314     "      \"id\":\"id\","
315     "      \"phone_number\":\"phone_number\","
316     "      \"postal_address\":"
317     "      {"
318     "        \"recipient_name\":\"recipient_name\","
319     "        \"address_line\":"
320     "        ["
321     "          \"address_line_1\","
322     "          \"address_line_2\""
323     "        ],"
324     "        \"locality_name\":\"locality_name\","
325     "        \"dependent_locality_name\":\"dependent_locality_name\","
326     "        \"administrative_area_name\":\"administrative_area_name\","
327     "        \"postal_code_number\":\"postal_code_number\","
328     "        \"sorting_code\":\"sorting_code\","
329     "        \"country_name_code\":\"US\","
330     "        \"language_code\":\"language_code\""
331     "      }"
332     "    }"
333     "  ],"
334     "  \"default_address_id\":\"default_address_id\","
335     "  \"obfuscated_gaia_id\":\"ignore_this_value\","
336     "  \"amex_disallowed\":true,"
337     "  \"gaia_profile\":"
338     "  ["
339     "    {"
340     "      \"buyer_email\":\"user@chromium.org\","
341     "      \"gaia_index\":0,"
342     "      \"gaia_id\":\"123456789\","
343     "      \"buyer_name\":\"Joe Usecase\","
344     "      \"is_active\":true,"
345     "      \"avatar_url_27x27\":\"https://lh3.googleusercontent.com/27.jpg\","
346     "      \"avatar_url_54x54\":\"https://lh3.googleusercontent.com/54.jpg\","
347     "      \"avatar_url_48x48\":\"https://lh3.googleusercontent.com/48.jpg\","
348     "      \"avatar_url_96x96\":\"https://lh3.googleusercontent.com/96.jpg\""
349     "    },"
350     "    {"
351     "      \"buyer_email\":\"user2@chromium.org\","
352     "      \"gaia_index\":1,"
353     "      \"gaia_id\":\"obfuscated_gaia_id\","
354     "      \"buyer_name\":\"Jill Usecase\","
355     "      \"is_active\":false,"
356     "      \"avatar_url_27x27\":\"https://lh3.googleusercontent.com/27.jpg\","
357     "      \"avatar_url_54x54\":\"https://lh3.googleusercontent.com/54.jpg\","
358     "      \"avatar_url_48x48\":\"https://lh3.googleusercontent.com/48.jpg\","
359     "      \"avatar_url_96x96\":\"https://lh3.googleusercontent.com/96.jpg\""
360     "    }"
361     "  ],"
362     "  \"allowed_shipping_spec_by_country\":"
363     "  ["
364     "    {\"country_code\":\"AC\"},"
365     "    {\"country_code\":\"AD\"},"
366     "    {\"country_code\":\"US\"}"
367     "  ]";
368
369 const char kRequiredLegalDocument[] =
370     "  ,"
371     "  \"required_legal_document\":"
372     "  ["
373     "    {"
374     "      \"legal_document_id\":\"doc_id\","
375     "      \"display_name\":\"display_name\""
376     "    }"
377     "  ]";
378
379 const char kCloseJson[] = "}";
380
381 }  // anonymous namespace
382
383 namespace autofill {
384 namespace wallet {
385
386 class WalletItemsTest : public testing::Test {
387  public:
388   WalletItemsTest() {}
389  protected:
390   void SetUpDictionary(const std::string& json) {
391     scoped_ptr<base::Value> value(base::JSONReader::Read(json));
392     ASSERT_TRUE(value.get());
393     ASSERT_TRUE(value->IsType(base::Value::TYPE_DICTIONARY));
394     dict.reset(static_cast<base::DictionaryValue*>(value.release()));
395   }
396   scoped_ptr<base::DictionaryValue> dict;
397 };
398
399 TEST_F(WalletItemsTest, CreateMaskedInstrumentMissingStatus) {
400   SetUpDictionary(kMaskedInstrumentMissingStatus);
401   EXPECT_EQ(NULL,
402             WalletItems::MaskedInstrument::CreateMaskedInstrument(*dict).get());
403 }
404
405 TEST_F(WalletItemsTest, CreateMaskedInstrumentMissingType) {
406   SetUpDictionary(kMaskedInstrumentMissingType);
407   EXPECT_EQ(NULL,
408             WalletItems::MaskedInstrument::CreateMaskedInstrument(*dict).get());
409 }
410
411 TEST_F(WalletItemsTest, CreateMaskedInstrumentMissingLastFourDigits) {
412   SetUpDictionary(kMaskedInstrumentMissingLastFourDigits);
413   EXPECT_EQ(NULL,
414             WalletItems::MaskedInstrument::CreateMaskedInstrument(*dict).get());
415 }
416
417 TEST_F(WalletItemsTest, CreateMaskedInstrumentMissingAddress) {
418   SetUpDictionary(kMaskedInstrumentMissingAddress);
419   EXPECT_EQ(NULL,
420             WalletItems::MaskedInstrument::CreateMaskedInstrument(*dict).get());
421 }
422
423 TEST_F(WalletItemsTest, CreateMaskedInstrumentMalformedAddress) {
424   SetUpDictionary(kMaskedInstrumentMalformedAddress);
425   EXPECT_EQ(NULL,
426             WalletItems::MaskedInstrument::CreateMaskedInstrument(*dict).get());
427 }
428
429 TEST_F(WalletItemsTest, CreateMaskedInstrumentMissingObjectId) {
430   SetUpDictionary(kMaskedInstrumentMissingObjectId);
431   EXPECT_EQ(NULL,
432             WalletItems::MaskedInstrument::CreateMaskedInstrument(*dict).get());
433 }
434
435 TEST_F(WalletItemsTest, CreateMaskedInstrument) {
436   SetUpDictionary(kMaskedInstrument);
437   scoped_ptr<Address> address(
438       new Address("US",
439                   ASCIIToUTF16("name"),
440                   StreetAddress("address1", "address2"),
441                   ASCIIToUTF16("city"),
442                   ASCIIToUTF16("burough"),
443                   ASCIIToUTF16("state"),
444                   ASCIIToUTF16("postal_code"),
445                   ASCIIToUTF16("sorting_code"),
446                   ASCIIToUTF16("phone_number"),
447                   std::string(),
448                   "language_code"));
449   WalletItems::MaskedInstrument masked_instrument(
450       ASCIIToUTF16("descriptive_name"),
451       WalletItems::MaskedInstrument::VISA,
452       ASCIIToUTF16("last_four_digits"),
453       12,
454       2012,
455       address.Pass(),
456       WalletItems::MaskedInstrument::VALID,
457       "object_id");
458   EXPECT_EQ(masked_instrument,
459             *WalletItems::MaskedInstrument::CreateMaskedInstrument(*dict));
460 }
461
462 TEST_F(WalletItemsTest, CreateLegalDocumentMissingDocId) {
463   SetUpDictionary(kLegalDocumentMissingDocumentId);
464   EXPECT_EQ(NULL, WalletItems::LegalDocument::CreateLegalDocument(*dict).get());
465 }
466
467 TEST_F(WalletItemsTest, CreateLegalDocumentMissingDisplayName) {
468   SetUpDictionary(kLegalDocumentMissingDisplayName);
469   EXPECT_EQ(NULL, WalletItems::LegalDocument::CreateLegalDocument(*dict).get());
470 }
471
472 TEST_F(WalletItemsTest, CreateLegalDocument) {
473   SetUpDictionary(kLegalDocument);
474   WalletItems::LegalDocument expected("doc_id", ASCIIToUTF16("display_name"));
475   EXPECT_EQ(expected,
476             *WalletItems::LegalDocument::CreateLegalDocument(*dict));
477 }
478
479 TEST_F(WalletItemsTest, LegalDocumentUrl) {
480   WalletItems::LegalDocument legal_doc("doc_id", ASCIIToUTF16("display_name"));
481   EXPECT_EQ("https://wallet.google.com/legaldocument?docId=doc_id",
482             legal_doc.url().spec());
483 }
484
485 TEST_F(WalletItemsTest, LegalDocumentEmptyId) {
486   WalletItems::LegalDocument legal_doc(GURL("http://example.com"),
487                                        ASCIIToUTF16("display_name"));
488   EXPECT_TRUE(legal_doc.id().empty());
489 }
490
491 TEST_F(WalletItemsTest, CreateWalletItemsWithRequiredActions) {
492   SetUpDictionary(kWalletItemsWithRequiredActions);
493
494   std::vector<RequiredAction> required_actions;
495   required_actions.push_back(SETUP_WALLET);
496   required_actions.push_back(CHOOSE_ANOTHER_INSTRUMENT_OR_ADDRESS);
497   required_actions.push_back(ACCEPT_TOS);
498   required_actions.push_back(GAIA_AUTH);
499   required_actions.push_back(UPDATE_EXPIRATION_DATE);
500   required_actions.push_back(UPGRADE_MIN_ADDRESS);
501   required_actions.push_back(PASSIVE_GAIA_AUTH);
502   required_actions.push_back(REQUIRE_PHONE_NUMBER);
503
504   WalletItems expected(required_actions,
505                        std::string(),
506                        std::string(),
507                        std::string(),
508                        AMEX_DISALLOWED);
509   EXPECT_EQ(expected, *WalletItems::CreateWalletItems(*dict));
510
511   ASSERT_FALSE(required_actions.empty());
512   required_actions.pop_back();
513   WalletItems different_required_actions(required_actions,
514                                          std::string(),
515                                          std::string(),
516                                          std::string(),
517                                          AMEX_DISALLOWED);
518   EXPECT_NE(expected, different_required_actions);
519 }
520
521 TEST_F(WalletItemsTest, CreateWalletItemsWithInvalidRequiredActions) {
522   SetUpDictionary(kWalletItemsWithInvalidRequiredActions);
523   EXPECT_EQ(NULL, WalletItems::CreateWalletItems(*dict).get());
524 }
525
526 TEST_F(WalletItemsTest, CreateWalletItemsMissingGoogleTransactionId) {
527   SetUpDictionary(kWalletItemsMissingGoogleTransactionId);
528   EXPECT_EQ(NULL, WalletItems::CreateWalletItems(*dict).get());
529 }
530
531 TEST_F(WalletItemsTest, CreateWalletItemsMissingAmexDisallowed) {
532   SetUpDictionary(std::string(kWalletItems) + std::string(kCloseJson));
533   EXPECT_TRUE(dict->Remove("amex_disallowed", NULL));
534   base::string16 amex_number = ASCIIToUTF16("378282246310005");
535   base::string16 message;
536   EXPECT_FALSE(WalletItems::CreateWalletItems(*dict)->SupportsCard(amex_number,
537                                                                    &message));
538   EXPECT_FALSE(message.empty());
539 }
540
541 TEST_F(WalletItemsTest, CreateWalletItems) {
542   SetUpDictionary(std::string(kWalletItems) + std::string(kCloseJson));
543   std::vector<RequiredAction> required_actions;
544   WalletItems expected(required_actions,
545                        "google_transaction_id",
546                        "default_instrument_id",
547                        "default_address_id",
548                        AMEX_DISALLOWED);
549
550   scoped_ptr<GaiaAccount> user1(GaiaAccount::CreateForTesting(
551       "user@chromium.org",
552       "123456789",
553       0,
554       true));
555   expected.AddAccount(user1.Pass());
556   scoped_ptr<GaiaAccount> user2(GaiaAccount::CreateForTesting(
557       "user2@chromium.org",
558       "obfuscated_gaia_id",
559       1,
560       false));
561   expected.AddAccount(user2.Pass());
562   EXPECT_EQ("123456789", expected.ObfuscatedGaiaId());
563
564   scoped_ptr<Address> billing_address(
565       new Address("US",
566                   ASCIIToUTF16("name"),
567                   StreetAddress("address1", "address2"),
568                   ASCIIToUTF16("city"),
569                   ASCIIToUTF16("burough"),
570                   ASCIIToUTF16("state"),
571                   ASCIIToUTF16("postal_code"),
572                   ASCIIToUTF16("sorting_code"),
573                   ASCIIToUTF16("phone_number"),
574                   std::string(),
575                   "language_code"));
576   scoped_ptr<WalletItems::MaskedInstrument> masked_instrument(
577       new WalletItems::MaskedInstrument(ASCIIToUTF16("descriptive_name"),
578                                         WalletItems::MaskedInstrument::VISA,
579                                         ASCIIToUTF16("last_four_digits"),
580                                         12,
581                                         2012,
582                                         billing_address.Pass(),
583                                         WalletItems::MaskedInstrument::VALID,
584                                         "object_id"));
585   expected.AddInstrument(masked_instrument.Pass());
586
587   scoped_ptr<Address> shipping_address(
588       new Address("US",
589                   ASCIIToUTF16("recipient_name"),
590                   StreetAddress("address_line_1", "address_line_2"),
591                   ASCIIToUTF16("locality_name"),
592                   ASCIIToUTF16("dependent_locality_name"),
593                   ASCIIToUTF16("administrative_area_name"),
594                   ASCIIToUTF16("postal_code_number"),
595                   ASCIIToUTF16("sorting_code"),
596                   ASCIIToUTF16("phone_number"),
597                   "id",
598                   "language_code"));
599   expected.AddAddress(shipping_address.Pass());
600
601   expected.AddAllowedShippingCountry("AC");
602   expected.AddAllowedShippingCountry("AD");
603   expected.AddAllowedShippingCountry("US");
604
605   EXPECT_EQ(expected, *WalletItems::CreateWalletItems(*dict));
606
607   // Now try with a legal document as well.
608   SetUpDictionary(std::string(kWalletItems) +
609                   std::string(kRequiredLegalDocument) +
610                   std::string(kCloseJson));
611   scoped_ptr<WalletItems::LegalDocument> legal_document(
612       new WalletItems::LegalDocument("doc_id",
613                                      ASCIIToUTF16("display_name")));
614   expected.AddLegalDocument(legal_document.Pass());
615   expected.AddLegalDocument(
616       WalletItems::LegalDocument::CreatePrivacyPolicyDocument());
617
618   EXPECT_EQ(expected, *WalletItems::CreateWalletItems(*dict));
619 }
620
621 }  // namespace wallet
622 }  // namespace autofill