OLD | NEW |
---|---|
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 field.name = ASCIIToUTF16("Submit"); | 80 field.name = ASCIIToUTF16("Submit"); |
81 field.form_control_type = "submit"; | 81 field.form_control_type = "submit"; |
82 form.fields.push_back(field); | 82 form.fields.push_back(field); |
83 | 83 |
84 FormStructure form_structure(form); | 84 FormStructure form_structure(form); |
85 | 85 |
86 // All fields are counted. | 86 // All fields are counted. |
87 EXPECT_EQ(3U, form_structure.field_count()); | 87 EXPECT_EQ(3U, form_structure.field_count()); |
88 } | 88 } |
89 | 89 |
90 TEST(FormStructureTest, AutofillFlowInfo) { | |
91 FormData form; | |
92 form.method = ASCIIToUTF16("post"); | |
93 | |
94 FormFieldData field; | |
95 field.label = ASCIIToUTF16("username"); | |
96 field.name = ASCIIToUTF16("username"); | |
97 field.form_control_type = "text"; | |
98 form.fields.push_back(field); | |
99 | |
100 FormStructure form_structure(form); | |
101 | |
102 EXPECT_FALSE(form_structure.IsStartOfAutofillableFlow()); | |
103 EXPECT_FALSE(form_structure.IsInAutofillableFlow()); | |
Ilya Sherman
2013/01/15 06:31:52
Please add more thorough tests for these methods.
Raman Kakilate
2013/01/15 23:02:33
Added more tests.
| |
104 } | |
105 | |
90 TEST(FormStructureTest, AutofillCount) { | 106 TEST(FormStructureTest, AutofillCount) { |
91 FormData form; | 107 FormData form; |
92 form.method = ASCIIToUTF16("post"); | 108 form.method = ASCIIToUTF16("post"); |
93 | 109 |
94 FormFieldData field; | 110 FormFieldData field; |
95 field.label = ASCIIToUTF16("username"); | 111 field.label = ASCIIToUTF16("username"); |
96 field.name = ASCIIToUTF16("username"); | 112 field.name = ASCIIToUTF16("username"); |
97 field.form_control_type = "text"; | 113 field.form_control_type = "text"; |
98 form.fields.push_back(field); | 114 form.fields.push_back(field); |
99 | 115 |
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2087 field.form_control_type = "submit"; | 2103 field.form_control_type = "submit"; |
2088 form.fields.push_back(field); | 2104 form.fields.push_back(field); |
2089 | 2105 |
2090 EXPECT_EQ(form, FormStructure(form).ToFormData()); | 2106 EXPECT_EQ(form, FormStructure(form).ToFormData()); |
2091 | 2107 |
2092 // Currently |FormStructure(form_data)ToFormData().user_submitted| is always | 2108 // Currently |FormStructure(form_data)ToFormData().user_submitted| is always |
2093 // false. This forces a future author that changes this to update this test. | 2109 // false. This forces a future author that changes this to update this test. |
2094 form.user_submitted = true; | 2110 form.user_submitted = true; |
2095 EXPECT_NE(form, FormStructure(form).ToFormData()); | 2111 EXPECT_NE(form, FormStructure(form).ToFormData()); |
2096 } | 2112 } |
OLD | NEW |