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

Side by Side Diff: components/autofill/core/browser/autofill_field_unittest.cc

Issue 22009003: [Autofill] Distinguish between native field types and potentially HTML field types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 "base/strings/string_util.h" 5 #include "base/strings/string_util.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "components/autofill/core/browser/autofill_field.h" 7 #include "components/autofill/core/browser/autofill_field.h"
8 #include "components/autofill/core/browser/autofill_type.h"
8 #include "components/autofill/core/browser/field_types.h" 9 #include "components/autofill/core/browser/field_types.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace autofill { 12 namespace autofill {
12 namespace { 13 namespace {
13 14
14 TEST(AutofillFieldTest, Type) { 15 TEST(AutofillFieldTest, Type) {
15 AutofillField field; 16 AutofillField field;
16 ASSERT_EQ(NO_SERVER_DATA, field.server_type()); 17 ASSERT_EQ(NO_SERVER_DATA, field.server_type());
17 ASSERT_EQ(UNKNOWN_TYPE, field.heuristic_type()); 18 ASSERT_EQ(UNKNOWN_TYPE, field.heuristic_type());
18 19
19 // |server_type_| is NO_SERVER_DATA, so |heuristic_type_| is returned. 20 // |server_type_| is NO_SERVER_DATA, so |heuristic_type_| is returned.
20 EXPECT_EQ(UNKNOWN_TYPE, field.type()); 21 EXPECT_EQ(UNKNOWN_TYPE, field.Type().server_type());
21 22
22 // Set the heuristic type and check it. 23 // Set the heuristic type and check it.
23 field.set_heuristic_type(NAME_FIRST); 24 field.set_heuristic_type(NAME_FIRST);
24 EXPECT_EQ(NAME_FIRST, field.type()); 25 EXPECT_EQ(NAME_FIRST, field.Type().server_type());
25 26
26 // Set the server type and check it. 27 // Set the server type and check it.
27 field.set_server_type(ADDRESS_BILLING_LINE1); 28 field.set_server_type(ADDRESS_BILLING_LINE1);
28 EXPECT_EQ(ADDRESS_BILLING_LINE1, field.type()); 29 EXPECT_EQ(ADDRESS_BILLING_LINE1, field.Type().server_type());
29 30
30 // Remove the server type to make sure the heuristic type is preserved. 31 // Remove the server type to make sure the heuristic type is preserved.
31 field.set_server_type(NO_SERVER_DATA); 32 field.set_server_type(NO_SERVER_DATA);
32 EXPECT_EQ(NAME_FIRST, field.type()); 33 EXPECT_EQ(NAME_FIRST, field.Type().server_type());
33 } 34 }
34 35
35 TEST(AutofillFieldTest, IsEmpty) { 36 TEST(AutofillFieldTest, IsEmpty) {
36 AutofillField field; 37 AutofillField field;
37 ASSERT_EQ(base::string16(), field.value); 38 ASSERT_EQ(base::string16(), field.value);
38 39
39 // Field value is empty. 40 // Field value is empty.
40 EXPECT_TRUE(field.IsEmpty()); 41 EXPECT_TRUE(field.IsEmpty());
41 42
42 // Field value is non-empty. 43 // Field value is non-empty.
(...skipping 21 matching lines...) Expand all
64 field.set_heuristic_type(NAME_FIRST); 65 field.set_heuristic_type(NAME_FIRST);
65 EXPECT_EQ("502192749", field.FieldSignature()); 66 EXPECT_EQ("502192749", field.FieldSignature());
66 67
67 // Server type does not affect FieldSignature. 68 // Server type does not affect FieldSignature.
68 field.set_server_type(NAME_LAST); 69 field.set_server_type(NAME_LAST);
69 EXPECT_EQ("502192749", field.FieldSignature()); 70 EXPECT_EQ("502192749", field.FieldSignature());
70 } 71 }
71 72
72 TEST(AutofillFieldTest, IsFieldFillable) { 73 TEST(AutofillFieldTest, IsFieldFillable) {
73 AutofillField field; 74 AutofillField field;
74 ASSERT_EQ(UNKNOWN_TYPE, field.type()); 75 ASSERT_EQ(UNKNOWN_TYPE, field.Type().server_type());
75 76
76 // Type is unknown. 77 // Type is unknown.
77 EXPECT_FALSE(field.IsFieldFillable()); 78 EXPECT_FALSE(field.IsFieldFillable());
78 79
79 // Only heuristic type is set. 80 // Only heuristic type is set.
80 field.set_heuristic_type(NAME_FIRST); 81 field.set_heuristic_type(NAME_FIRST);
81 EXPECT_TRUE(field.IsFieldFillable()); 82 EXPECT_TRUE(field.IsFieldFillable());
82 83
83 // Only server type is set. 84 // Only server type is set.
84 field.set_heuristic_type(UNKNOWN_TYPE); 85 field.set_heuristic_type(UNKNOWN_TYPE);
85 field.set_server_type(NAME_LAST); 86 field.set_server_type(NAME_LAST);
86 EXPECT_TRUE(field.IsFieldFillable()); 87 EXPECT_TRUE(field.IsFieldFillable());
87 88
88 // Both types set. 89 // Both types set.
89 field.set_heuristic_type(NAME_FIRST); 90 field.set_heuristic_type(NAME_FIRST);
90 field.set_server_type(NAME_LAST); 91 field.set_server_type(NAME_LAST);
91 EXPECT_TRUE(field.IsFieldFillable()); 92 EXPECT_TRUE(field.IsFieldFillable());
92 } 93 }
93 94
94 } // namespace 95 } // namespace
95 } // namespace autofill 96 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_field.cc ('k') | components/autofill/core/browser/autofill_ie_toolbar_import_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698