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"
14 TEST(AutofillOptionsHandlerTest
, AddressToDictionary
) {
15 autofill::AutofillProfile profile
;
16 autofill::test::SetProfileInfoWithGuid(&profile
,
31 base::DictionaryValue dictionary
;
32 options::AutofillOptionsHandler::AutofillProfileToDictionary(profile
,
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
));
44 EXPECT_TRUE(dictionary
.GetString("guid", &value
));
45 EXPECT_EQ("guid", value
);
46 EXPECT_TRUE(dictionary
.GetString("languageCode", &value
));
48 EXPECT_TRUE(dictionary
.GetString("postalCode", &value
));
49 EXPECT_EQ("77300", value
);
50 EXPECT_TRUE(dictionary
.GetString("sortingCode", &value
));
52 EXPECT_TRUE(dictionary
.GetString("state", &value
));
53 EXPECT_EQ("TX", value
);
55 base::ListValue
* list_value
;
56 EXPECT_TRUE(dictionary
.GetList("email", &list_value
));
57 EXPECT_EQ(1U, list_value
->GetSize());
58 EXPECT_TRUE(list_value
->GetString(0, &value
));
59 EXPECT_EQ("fml@example.com", value
);
61 EXPECT_TRUE(dictionary
.GetList("fullName", &list_value
));
62 EXPECT_EQ(1U, list_value
->GetSize());
63 EXPECT_TRUE(list_value
->GetString(0, &value
));
64 EXPECT_EQ("First Middle Last", value
);
66 EXPECT_TRUE(dictionary
.GetList("phone", &list_value
));
67 EXPECT_EQ(1U, list_value
->GetSize());
68 EXPECT_TRUE(list_value
->GetString(0, &value
));
69 EXPECT_EQ("832-555-1000", value
);
72 } // namespace options