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

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

Issue 11198048: [Autofill] Update the autocomplete types implementation to match the current HTML spec. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes to default section handling Created 8 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 5 #include <vector>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autofill/autocomplete_history_manager.h" 10 #include "chrome/browser/autofill/autocomplete_history_manager.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 form.method = ASCIIToUTF16("POST"); 67 form.method = ASCIIToUTF16("POST");
68 form.origin = GURL("http://myform.com/form.html"); 68 form.origin = GURL("http://myform.com/form.html");
69 form.action = GURL("http://myform.com/submit.html"); 69 form.action = GURL("http://myform.com/submit.html");
70 form.user_submitted = true; 70 form.user_submitted = true;
71 71
72 // Valid Visa credit card number pulled from the paypal help site. 72 // Valid Visa credit card number pulled from the paypal help site.
73 FormFieldData valid_cc; 73 FormFieldData valid_cc;
74 valid_cc.label = ASCIIToUTF16("Credit Card"); 74 valid_cc.label = ASCIIToUTF16("Credit Card");
75 valid_cc.name = ASCIIToUTF16("ccnum"); 75 valid_cc.name = ASCIIToUTF16("ccnum");
76 valid_cc.value = ASCIIToUTF16("4012888888881881"); 76 valid_cc.value = ASCIIToUTF16("4012888888881881");
77 valid_cc.form_control_type = ASCIIToUTF16("text"); 77 valid_cc.form_control_type = "text";
78 form.fields.push_back(valid_cc); 78 form.fields.push_back(valid_cc);
79 79
80 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0); 80 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0);
81 autocomplete_manager_->OnFormSubmitted(form); 81 autocomplete_manager_->OnFormSubmitted(form);
82 } 82 }
83 83
84 // Contrary test to AutocompleteHistoryManagerTest.CreditCardNumberValue. The 84 // Contrary test to AutocompleteHistoryManagerTest.CreditCardNumberValue. The
85 // value being submitted is not a valid credit card number, so it will be sent 85 // value being submitted is not a valid credit card number, so it will be sent
86 // to the WebDatabase to be saved. 86 // to the WebDatabase to be saved.
87 TEST_F(AutocompleteHistoryManagerTest, NonCreditCardNumberValue) { 87 TEST_F(AutocompleteHistoryManagerTest, NonCreditCardNumberValue) {
88 FormData form; 88 FormData form;
89 form.name = ASCIIToUTF16("MyForm"); 89 form.name = ASCIIToUTF16("MyForm");
90 form.method = ASCIIToUTF16("POST"); 90 form.method = ASCIIToUTF16("POST");
91 form.origin = GURL("http://myform.com/form.html"); 91 form.origin = GURL("http://myform.com/form.html");
92 form.action = GURL("http://myform.com/submit.html"); 92 form.action = GURL("http://myform.com/submit.html");
93 form.user_submitted = true; 93 form.user_submitted = true;
94 94
95 // Invalid credit card number. 95 // Invalid credit card number.
96 FormFieldData invalid_cc; 96 FormFieldData invalid_cc;
97 invalid_cc.label = ASCIIToUTF16("Credit Card"); 97 invalid_cc.label = ASCIIToUTF16("Credit Card");
98 invalid_cc.name = ASCIIToUTF16("ccnum"); 98 invalid_cc.name = ASCIIToUTF16("ccnum");
99 invalid_cc.value = ASCIIToUTF16("4580123456789012"); 99 invalid_cc.value = ASCIIToUTF16("4580123456789012");
100 invalid_cc.form_control_type = ASCIIToUTF16("text"); 100 invalid_cc.form_control_type = "text";
101 form.fields.push_back(invalid_cc); 101 form.fields.push_back(invalid_cc);
102 102
103 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1); 103 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1);
104 autocomplete_manager_->OnFormSubmitted(form); 104 autocomplete_manager_->OnFormSubmitted(form);
105 } 105 }
106 106
107 // Tests that SSNs are not sent to the WebDatabase to be saved. 107 // Tests that SSNs are not sent to the WebDatabase to be saved.
108 TEST_F(AutocompleteHistoryManagerTest, SSNValue) { 108 TEST_F(AutocompleteHistoryManagerTest, SSNValue) {
109 FormData form; 109 FormData form;
110 form.name = ASCIIToUTF16("MyForm"); 110 form.name = ASCIIToUTF16("MyForm");
111 form.method = ASCIIToUTF16("POST"); 111 form.method = ASCIIToUTF16("POST");
112 form.origin = GURL("http://myform.com/form.html"); 112 form.origin = GURL("http://myform.com/form.html");
113 form.action = GURL("http://myform.com/submit.html"); 113 form.action = GURL("http://myform.com/submit.html");
114 form.user_submitted = true; 114 form.user_submitted = true;
115 115
116 FormFieldData ssn; 116 FormFieldData ssn;
117 ssn.label = ASCIIToUTF16("Social Security Number"); 117 ssn.label = ASCIIToUTF16("Social Security Number");
118 ssn.name = ASCIIToUTF16("ssn"); 118 ssn.name = ASCIIToUTF16("ssn");
119 ssn.value = ASCIIToUTF16("078-05-1120"); 119 ssn.value = ASCIIToUTF16("078-05-1120");
120 ssn.form_control_type = ASCIIToUTF16("text"); 120 ssn.form_control_type = "text";
121 form.fields.push_back(ssn); 121 form.fields.push_back(ssn);
122 122
123 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0); 123 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0);
124 autocomplete_manager_->OnFormSubmitted(form); 124 autocomplete_manager_->OnFormSubmitted(form);
125 } 125 }
126 126
127 // Verify that autocomplete text is saved for search fields. 127 // Verify that autocomplete text is saved for search fields.
128 TEST_F(AutocompleteHistoryManagerTest, SearchField) { 128 TEST_F(AutocompleteHistoryManagerTest, SearchField) {
129 FormData form; 129 FormData form;
130 form.name = ASCIIToUTF16("MyForm"); 130 form.name = ASCIIToUTF16("MyForm");
131 form.method = ASCIIToUTF16("POST"); 131 form.method = ASCIIToUTF16("POST");
132 form.origin = GURL("http://myform.com/form.html"); 132 form.origin = GURL("http://myform.com/form.html");
133 form.action = GURL("http://myform.com/submit.html"); 133 form.action = GURL("http://myform.com/submit.html");
134 form.user_submitted = true; 134 form.user_submitted = true;
135 135
136 // Search field. 136 // Search field.
137 FormFieldData search_field; 137 FormFieldData search_field;
138 search_field.label = ASCIIToUTF16("Search"); 138 search_field.label = ASCIIToUTF16("Search");
139 search_field.name = ASCIIToUTF16("search"); 139 search_field.name = ASCIIToUTF16("search");
140 search_field.value = ASCIIToUTF16("my favorite query"); 140 search_field.value = ASCIIToUTF16("my favorite query");
141 search_field.form_control_type = ASCIIToUTF16("search"); 141 search_field.form_control_type = "search";
142 form.fields.push_back(search_field); 142 form.fields.push_back(search_field);
143 143
144 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1); 144 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1);
145 autocomplete_manager_->OnFormSubmitted(form); 145 autocomplete_manager_->OnFormSubmitted(form);
146 } 146 }
147 147
148 namespace { 148 namespace {
149 149
150 class MockAutofillExternalDelegate : public TestAutofillExternalDelegate { 150 class MockAutofillExternalDelegate : public TestAutofillExternalDelegate {
151 public: 151 public:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 scoped_ptr<AutofillWebDataService>( 193 scoped_ptr<AutofillWebDataService>(
194 new AutofillWebDataServiceImpl(web_data_service_))); 194 new AutofillWebDataServiceImpl(web_data_service_)));
195 195
196 MockAutofillExternalDelegate external_delegate(web_contents()); 196 MockAutofillExternalDelegate external_delegate(web_contents());
197 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); 197 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _));
198 autocomplete_history_manager.SetExternalDelegate(&external_delegate); 198 autocomplete_history_manager.SetExternalDelegate(&external_delegate);
199 199
200 // Should trigger a call to OnSuggestionsReturned, verified by the mock. 200 // Should trigger a call to OnSuggestionsReturned, verified by the mock.
201 autocomplete_history_manager.SendSuggestions(NULL); 201 autocomplete_history_manager.SendSuggestions(NULL);
202 } 202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698