Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(819)

Side by Side Diff: chrome/browser/ui/webui/options/autofill_options_handler_unittest.cc

Issue 1868003003: Preserving first/middle/last names when an Autofill profile is submitted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h" 5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h"
6 6
7 #include "base/strings/utf_string_conversions.h"
7 #include "base/values.h" 8 #include "base/values.h"
8 #include "components/autofill/core/browser/autofill_profile.h" 9 #include "components/autofill/core/browser/autofill_profile.h"
9 #include "components/autofill/core/browser/autofill_test_utils.h" 10 #include "components/autofill/core/browser/autofill_test_utils.h"
11 #include "components/autofill/core/common/autofill_constants.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 13
14 using autofill::AutofillType;
15
12 namespace options { 16 namespace options {
13 17
14 TEST(AutofillOptionsHandlerTest, AddressToDictionary) { 18 TEST(AutofillOptionsHandlerTest, AddressToDictionary) {
15 autofill::AutofillProfile profile; 19 autofill::AutofillProfile profile;
16 autofill::test::SetProfileInfoWithGuid(&profile, 20 autofill::test::SetProfileInfoWithGuid(&profile,
17 "guid", 21 "guid",
18 "First", 22 "First",
19 "Middle", 23 "Middle",
20 "Last", 24 "Last",
21 "fml@example.com", 25 "fml@example.com",
(...skipping 30 matching lines...) Expand all
52 EXPECT_TRUE(dictionary.GetString("state", &value)); 56 EXPECT_TRUE(dictionary.GetString("state", &value));
53 EXPECT_EQ("TX", value); 57 EXPECT_EQ("TX", value);
54 EXPECT_TRUE(dictionary.GetString("email", &value)); 58 EXPECT_TRUE(dictionary.GetString("email", &value));
55 EXPECT_EQ("fml@example.com", value); 59 EXPECT_EQ("fml@example.com", value);
56 EXPECT_TRUE(dictionary.GetString("fullName", &value)); 60 EXPECT_TRUE(dictionary.GetString("fullName", &value));
57 EXPECT_EQ("First Middle Last", value); 61 EXPECT_EQ("First Middle Last", value);
58 EXPECT_TRUE(dictionary.GetString("phone", &value)); 62 EXPECT_TRUE(dictionary.GetString("phone", &value));
59 EXPECT_EQ("832-555-1000", value); 63 EXPECT_EQ("832-555-1000", value);
60 } 64 }
61 65
66 TEST(AutofillOptionsHandlerTest, ShouldTransferNameComponents) {
67 autofill::AutofillProfile prior_profile;
68 autofill::test::SetProfileInfo(
69 &prior_profile, "First", "Middle", "Last", "fml@example.com", "Acme inc",
70 "123 Main", "Apt 2", "Laredo", "TX", "77300", "US", "832-555-1000");
71
72 autofill::AutofillProfile new_profile;
73 autofill::test::SetProfileInfo(&new_profile, "", "", "", "fml@example.com",
74 "Acme inc", "123 Main", "Apt 2", "Laredo",
75 "TX", "77300", "US", "832-555-1000");
76
77 new_profile.SetInfo(AutofillType(autofill::NAME_FULL),
78 base::UTF8ToUTF16("First Last"), "en-US");
79 EXPECT_TRUE(AutofillOptionsHandler::ShouldTransferNameComponents(
80 new_profile, prior_profile));
81
82 new_profile.SetInfo(AutofillType(autofill::NAME_FULL),
83 base::UTF8ToUTF16("First Middle Last"), "en-US");
84 EXPECT_TRUE(AutofillOptionsHandler::ShouldTransferNameComponents(
85 new_profile, prior_profile));
86
87 new_profile.SetInfo(AutofillType(autofill::NAME_FULL),
88 base::UTF8ToUTF16("First M Last"), "en-US");
89 EXPECT_TRUE(AutofillOptionsHandler::ShouldTransferNameComponents(
90 new_profile, prior_profile));
91
92 new_profile.SetInfo(AutofillType(autofill::NAME_FULL),
93 base::UTF8ToUTF16("First M. Last"), "en-US");
94 EXPECT_TRUE(AutofillOptionsHandler::ShouldTransferNameComponents(
95 new_profile, prior_profile));
96
97 new_profile.SetInfo(AutofillType(autofill::NAME_FULL),
98 base::UTF8ToUTF16("Kirby Puckett"), "en-US");
99 EXPECT_FALSE(AutofillOptionsHandler::ShouldTransferNameComponents(
100 new_profile, prior_profile));
101 }
102
62 } // namespace options 103 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698