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

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

Issue 11539003: Pop up requestAutocomplete UI when autofill server hints chrome client that it is in a multipage au… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Resolve with AutofillDialogController refactoring. Created 7 years, 11 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
« no previous file with comments | « chrome/browser/autofill/form_structure.cc ('k') | chrome/chrome_browser.gypi » ('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/form_structure.h" 5 #include "chrome/browser/autofill/form_structure.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autofill/autofill_metrics.h" 10 #include "chrome/browser/autofill/autofill_metrics.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return os; 52 return os;
53 } 53 }
54 54
55 } // namespace content 55 } // namespace content
56 56
57 class FormStructureTest { 57 class FormStructureTest {
58 public: 58 public:
59 static std::string Hash64Bit(const std::string& str) { 59 static std::string Hash64Bit(const std::string& str) {
60 return FormStructure::Hash64Bit(str); 60 return FormStructure::Hash64Bit(str);
61 } 61 }
62
63 static void SetPageDetails(FormStructure* form,
64 int page_number,
65 int total_pages) {
66 form->current_page_number_ = page_number;
67 form->total_pages_ = total_pages;
68 }
62 }; 69 };
63 70
64 TEST(FormStructureTest, FieldCount) { 71 TEST(FormStructureTest, FieldCount) {
65 FormData form; 72 FormData form;
66 form.method = ASCIIToUTF16("post"); 73 form.method = ASCIIToUTF16("post");
67 74
68 FormFieldData field; 75 FormFieldData field;
69 field.label = ASCIIToUTF16("username"); 76 field.label = ASCIIToUTF16("username");
70 field.name = ASCIIToUTF16("username"); 77 field.name = ASCIIToUTF16("username");
71 field.form_control_type = "text"; 78 field.form_control_type = "text";
72 form.fields.push_back(field); 79 form.fields.push_back(field);
73 80
74 field.label = ASCIIToUTF16("password"); 81 field.label = ASCIIToUTF16("password");
75 field.name = ASCIIToUTF16("password"); 82 field.name = ASCIIToUTF16("password");
76 field.form_control_type = "password"; 83 field.form_control_type = "password";
77 form.fields.push_back(field); 84 form.fields.push_back(field);
78 85
79 field.label = string16(); 86 field.label = string16();
80 field.name = ASCIIToUTF16("Submit"); 87 field.name = ASCIIToUTF16("Submit");
81 field.form_control_type = "submit"; 88 field.form_control_type = "submit";
82 form.fields.push_back(field); 89 form.fields.push_back(field);
83 90
84 FormStructure form_structure(form); 91 FormStructure form_structure(form);
85 92
86 // All fields are counted. 93 // All fields are counted.
87 EXPECT_EQ(3U, form_structure.field_count()); 94 EXPECT_EQ(3U, form_structure.field_count());
88 } 95 }
89 96
97 TEST(FormStructureTest, AutofillFlowInfo) {
98 FormData form;
99 form.method = ASCIIToUTF16("post");
100
101 FormFieldData field;
102 field.label = ASCIIToUTF16("username");
103 field.name = ASCIIToUTF16("username");
104 field.form_control_type = "text";
105 form.fields.push_back(field);
106
107 FormStructure form_structure(form);
108 EXPECT_FALSE(form_structure.IsStartOfAutofillableFlow());
109 EXPECT_FALSE(form_structure.IsInAutofillableFlow());
110
111 FormStructureTest::SetPageDetails(&form_structure, -1, 0);
112 EXPECT_FALSE(form_structure.IsStartOfAutofillableFlow());
113 EXPECT_FALSE(form_structure.IsInAutofillableFlow());
114
115 FormStructureTest::SetPageDetails(&form_structure, 0, 0);
116 EXPECT_FALSE(form_structure.IsStartOfAutofillableFlow());
117 EXPECT_FALSE(form_structure.IsInAutofillableFlow());
118
119 FormStructureTest::SetPageDetails(&form_structure, 0, 1);
120 EXPECT_TRUE(form_structure.IsStartOfAutofillableFlow());
121 EXPECT_TRUE(form_structure.IsInAutofillableFlow());
122
123 FormStructureTest::SetPageDetails(&form_structure, 1, 2);
124 EXPECT_FALSE(form_structure.IsStartOfAutofillableFlow());
125 EXPECT_TRUE(form_structure.IsInAutofillableFlow());
126
127 FormStructureTest::SetPageDetails(&form_structure, 2, 2);
128 EXPECT_FALSE(form_structure.IsStartOfAutofillableFlow());
129 EXPECT_FALSE(form_structure.IsInAutofillableFlow());
130 }
131
90 TEST(FormStructureTest, AutofillCount) { 132 TEST(FormStructureTest, AutofillCount) {
91 FormData form; 133 FormData form;
92 form.method = ASCIIToUTF16("post"); 134 form.method = ASCIIToUTF16("post");
93 135
94 FormFieldData field; 136 FormFieldData field;
95 field.label = ASCIIToUTF16("username"); 137 field.label = ASCIIToUTF16("username");
96 field.name = ASCIIToUTF16("username"); 138 field.name = ASCIIToUTF16("username");
97 field.form_control_type = "text"; 139 field.form_control_type = "text";
98 form.fields.push_back(field); 140 form.fields.push_back(field);
99 141
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 field.form_control_type = "submit"; 2129 field.form_control_type = "submit";
2088 form.fields.push_back(field); 2130 form.fields.push_back(field);
2089 2131
2090 EXPECT_EQ(form, FormStructure(form).ToFormData()); 2132 EXPECT_EQ(form, FormStructure(form).ToFormData());
2091 2133
2092 // Currently |FormStructure(form_data)ToFormData().user_submitted| is always 2134 // Currently |FormStructure(form_data)ToFormData().user_submitted| is always
2093 // false. This forces a future author that changes this to update this test. 2135 // false. This forces a future author that changes this to update this test.
2094 form.user_submitted = true; 2136 form.user_submitted = true;
2095 EXPECT_NE(form, FormStructure(form).ToFormData()); 2137 EXPECT_NE(form, FormStructure(form).ToFormData());
2096 } 2138 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/form_structure.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698