Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / autofill_options_handler_unittest.cc
bloba00cc4cb3d709efce5939148c610c1799f09e1c8
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.
5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h"
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"
12 namespace options {
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");
31 base::DictionaryValue dictionary;
32 options::AutofillOptionsHandler::AutofillProfileToDictionary(profile,
33 &dictionary);
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);
62 } // namespace options