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

Side by Side Diff: chrome/browser/autofill/autofill_type_unittest.cc

Issue 6650014: Autofill extend profiles to include multi-valued fields, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit Created 9 years, 9 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
« no previous file with comments | « chrome/browser/autofill/autofill_type.cc ('k') | chrome/browser/autofill/contact_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/autofill/autofill_type.h" 5 #include "chrome/browser/autofill/autofill_type.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace { 8 namespace {
9 9
10 TEST(AutofillTypeTest, Basic) { 10 TEST(AutofillTypeTest, Basic) {
11 // No server data. 11 // No server data.
12 AutofillType none(NO_SERVER_DATA); 12 AutofillType none(NO_SERVER_DATA);
13 EXPECT_EQ(NO_SERVER_DATA, none.field_type()); 13 EXPECT_EQ(NO_SERVER_DATA, none.field_type());
14 EXPECT_EQ(AutofillType::NO_GROUP, none.group()); 14 EXPECT_EQ(AutofillType::NO_GROUP, none.group());
15 EXPECT_EQ(AutofillType::NO_SUBGROUP, none.subgroup()); 15 EXPECT_EQ(AutofillType::NO_SUBGROUP, none.subgroup());
16 16
17 // Unknown type. 17 // Unknown type.
18 AutofillType unknown(UNKNOWN_TYPE); 18 AutofillType unknown(UNKNOWN_TYPE);
19 EXPECT_EQ(UNKNOWN_TYPE, unknown.field_type()); 19 EXPECT_EQ(UNKNOWN_TYPE, unknown.field_type());
20 EXPECT_EQ(AutofillType::NO_GROUP, unknown.group()); 20 EXPECT_EQ(AutofillType::NO_GROUP, unknown.group());
21 EXPECT_EQ(AutofillType::NO_SUBGROUP, unknown.subgroup()); 21 EXPECT_EQ(AutofillType::NO_SUBGROUP, unknown.subgroup());
22 22
23 // Type with group but no subgroup. 23 // Type with group but no subgroup.
24 AutofillType first(NAME_FIRST); 24 AutofillType first(NAME_FIRST);
25 EXPECT_EQ(NAME_FIRST, first.field_type()); 25 EXPECT_EQ(NAME_FIRST, first.field_type());
26 EXPECT_EQ(AutofillType::CONTACT_INFO, first.group()); 26 EXPECT_EQ(AutofillType::NAME, first.group());
27 EXPECT_EQ(AutofillType::NO_SUBGROUP, first.subgroup()); 27 EXPECT_EQ(AutofillType::NO_SUBGROUP, first.subgroup());
28 28
29 // Type with group and subgroup. 29 // Type with group and subgroup.
30 AutofillType phone(PHONE_HOME_NUMBER); 30 AutofillType phone(PHONE_HOME_NUMBER);
31 EXPECT_EQ(PHONE_HOME_NUMBER, phone.field_type()); 31 EXPECT_EQ(PHONE_HOME_NUMBER, phone.field_type());
32 EXPECT_EQ(AutofillType::PHONE_HOME, phone.group()); 32 EXPECT_EQ(AutofillType::PHONE_HOME, phone.group());
33 EXPECT_EQ(AutofillType::PHONE_NUMBER, phone.subgroup()); 33 EXPECT_EQ(AutofillType::PHONE_NUMBER, phone.subgroup());
34 34
35 // Last value, to check any offset errors. 35 // Last value, to check any offset errors.
36 AutofillType last(COMPANY_NAME); 36 AutofillType last(COMPANY_NAME);
37 EXPECT_EQ(COMPANY_NAME, last.field_type()); 37 EXPECT_EQ(COMPANY_NAME, last.field_type());
38 EXPECT_EQ(AutofillType::CONTACT_INFO, last.group()); 38 EXPECT_EQ(AutofillType::COMPANY, last.group());
39 EXPECT_EQ(AutofillType::NO_SUBGROUP, last.subgroup()); 39 EXPECT_EQ(AutofillType::NO_SUBGROUP, last.subgroup());
40 40
41 // Boundary (error) condition. 41 // Boundary (error) condition.
42 AutofillType boundary(MAX_VALID_FIELD_TYPE); 42 AutofillType boundary(MAX_VALID_FIELD_TYPE);
43 EXPECT_EQ(UNKNOWN_TYPE, boundary.field_type()); 43 EXPECT_EQ(UNKNOWN_TYPE, boundary.field_type());
44 EXPECT_EQ(AutofillType::NO_GROUP, boundary.group()); 44 EXPECT_EQ(AutofillType::NO_GROUP, boundary.group());
45 EXPECT_EQ(AutofillType::NO_SUBGROUP, boundary.subgroup()); 45 EXPECT_EQ(AutofillType::NO_SUBGROUP, boundary.subgroup());
46 46
47 // Beyond the boundary (error) condition. 47 // Beyond the boundary (error) condition.
48 AutofillType beyond(static_cast<AutofillFieldType>(MAX_VALID_FIELD_TYPE+10)); 48 AutofillType beyond(static_cast<AutofillFieldType>(MAX_VALID_FIELD_TYPE+10));
49 EXPECT_EQ(UNKNOWN_TYPE, beyond.field_type()); 49 EXPECT_EQ(UNKNOWN_TYPE, beyond.field_type());
50 EXPECT_EQ(AutofillType::NO_GROUP, beyond.group()); 50 EXPECT_EQ(AutofillType::NO_GROUP, beyond.group());
51 EXPECT_EQ(AutofillType::NO_SUBGROUP, beyond.subgroup()); 51 EXPECT_EQ(AutofillType::NO_SUBGROUP, beyond.subgroup());
52 52
53 // In-between value. Missing from enum but within range. Error condition. 53 // In-between value. Missing from enum but within range. Error condition.
54 AutofillType between(static_cast<AutofillFieldType>(16)); 54 AutofillType between(static_cast<AutofillFieldType>(16));
55 EXPECT_EQ(UNKNOWN_TYPE, between.field_type()); 55 EXPECT_EQ(UNKNOWN_TYPE, between.field_type());
56 EXPECT_EQ(AutofillType::NO_GROUP, between.group()); 56 EXPECT_EQ(AutofillType::NO_GROUP, between.group());
57 EXPECT_EQ(AutofillType::NO_SUBGROUP, between.subgroup()); 57 EXPECT_EQ(AutofillType::NO_SUBGROUP, between.subgroup());
58 } 58 }
59 59
60 } // namespace 60 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_type.cc ('k') | chrome/browser/autofill/contact_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698