OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 "chrome/browser/ui/webui/options/autofill_options_handler.h" | |
6 | |
7 #include "base/values.h" | |
8 #include "components/autofill/core/browser/autofill_profile.h" | |
9 #include "components/autofill/core/browser/autofill_test_utils.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 | |
12 namespace options { | |
13 | |
14 TEST(AutofillOptionsHandlerTest, AddressToDictionary) { | |
15 autofill::AutofillProfile profile; | |
16 autofill::test::SetProfileInfoWithGuid(&profile, | |
17 "guid", | |
18 "First", | |
19 "Middle", | |
20 "Last", | |
21 "fml@example.com", | |
22 "Acme inc", | |
23 "123 Main", | |
24 "Apt 2", | |
25 "Laredo", | |
26 "TX", | |
27 "77300", | |
28 "US", | |
29 "832-555-1000"); | |
30 | |
31 base::DictionaryValue dictionary; | |
32 options::AutofillOptionsHandler::AutofillProfileToDictionary(profile, | |
33 &dictionary); | |
34 | |
35 std::string value; | |
36 EXPECT_TRUE(dictionary.GetString("addrLines", &value)); | |
37 EXPECT_EQ("123 Main\nApt 2", value); | |
38 EXPECT_TRUE(dictionary.GetString("city", &value)); | |
39 EXPECT_EQ("Laredo", value); | |
40 EXPECT_TRUE(dictionary.GetString("country", &value)); | |
41 EXPECT_EQ("US", value); | |
42 EXPECT_TRUE(dictionary.GetString("dependentLocality", &value)); | |
43 EXPECT_EQ("", value); | |
44 EXPECT_TRUE(dictionary.GetString("guid", &value)); | |
45 EXPECT_EQ("guid", value); | |
46 EXPECT_TRUE(dictionary.GetString("languageCode", &value)); | |
47 EXPECT_EQ("", value); | |
48 EXPECT_TRUE(dictionary.GetString("postalCode", &value)); | |
49 EXPECT_EQ("77300", value); | |
50 EXPECT_TRUE(dictionary.GetString("sortingCode", &value)); | |
51 EXPECT_EQ("", value); | |
52 EXPECT_TRUE(dictionary.GetString("state", &value)); | |
53 EXPECT_EQ("TX", value); | |
54 EXPECT_TRUE(dictionary.GetString("email", &value)); | |
55 EXPECT_EQ("fml@example.com", value); | |
56 EXPECT_TRUE(dictionary.GetString("fullName", &value)); | |
57 EXPECT_EQ("First Middle Last", value); | |
58 EXPECT_TRUE(dictionary.GetString("phone", &value)); | |
59 EXPECT_EQ("832-555-1000", value); | |
60 } | |
61 | |
62 } // namespace options | |
OLD | NEW |