OLD | NEW |
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 <list> | 5 #include <list> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 MessageLoopForUI message_loop; | 139 MessageLoopForUI message_loop; |
140 // Create and register factory. | 140 // Create and register factory. |
141 net::TestURLFetcherFactory factory; | 141 net::TestURLFetcherFactory factory; |
142 | 142 |
143 FormData form; | 143 FormData form; |
144 form.method = ASCIIToUTF16("post"); | 144 form.method = ASCIIToUTF16("post"); |
145 | 145 |
146 FormFieldData field; | 146 FormFieldData field; |
147 field.label = ASCIIToUTF16("username"); | 147 field.label = ASCIIToUTF16("username"); |
148 field.name = ASCIIToUTF16("username"); | 148 field.name = ASCIIToUTF16("username"); |
149 field.form_control_type = ASCIIToUTF16("text"); | 149 field.form_control_type = "text"; |
150 form.fields.push_back(field); | 150 form.fields.push_back(field); |
151 | 151 |
152 field.label = ASCIIToUTF16("First Name"); | 152 field.label = ASCIIToUTF16("First Name"); |
153 field.name = ASCIIToUTF16("firstname"); | 153 field.name = ASCIIToUTF16("firstname"); |
154 field.form_control_type = ASCIIToUTF16("text"); | 154 field.form_control_type = "text"; |
155 form.fields.push_back(field); | 155 form.fields.push_back(field); |
156 | 156 |
157 field.label = ASCIIToUTF16("Last Name"); | 157 field.label = ASCIIToUTF16("Last Name"); |
158 field.name = ASCIIToUTF16("lastname"); | 158 field.name = ASCIIToUTF16("lastname"); |
159 field.form_control_type = ASCIIToUTF16("text"); | 159 field.form_control_type = "text"; |
160 form.fields.push_back(field); | 160 form.fields.push_back(field); |
161 | 161 |
162 field.label = ASCIIToUTF16("email"); | 162 field.label = ASCIIToUTF16("email"); |
163 field.name = ASCIIToUTF16("email"); | 163 field.name = ASCIIToUTF16("email"); |
164 field.form_control_type = ASCIIToUTF16("text"); | 164 field.form_control_type = "text"; |
165 form.fields.push_back(field); | 165 form.fields.push_back(field); |
166 | 166 |
167 field.label = ASCIIToUTF16("email2"); | 167 field.label = ASCIIToUTF16("email2"); |
168 field.name = ASCIIToUTF16("email2"); | 168 field.name = ASCIIToUTF16("email2"); |
169 field.form_control_type = ASCIIToUTF16("text"); | 169 field.form_control_type = "text"; |
170 form.fields.push_back(field); | 170 form.fields.push_back(field); |
171 | 171 |
172 field.label = ASCIIToUTF16("password"); | 172 field.label = ASCIIToUTF16("password"); |
173 field.name = ASCIIToUTF16("password"); | 173 field.name = ASCIIToUTF16("password"); |
174 field.form_control_type = ASCIIToUTF16("password"); | 174 field.form_control_type = "password"; |
175 form.fields.push_back(field); | 175 form.fields.push_back(field); |
176 | 176 |
177 field.label = string16(); | 177 field.label = string16(); |
178 field.name = ASCIIToUTF16("Submit"); | 178 field.name = ASCIIToUTF16("Submit"); |
179 field.form_control_type = ASCIIToUTF16("submit"); | 179 field.form_control_type = "submit"; |
180 form.fields.push_back(field); | 180 form.fields.push_back(field); |
181 | 181 |
182 FormStructure *form_structure = new FormStructure(form); | 182 FormStructure *form_structure = new FormStructure(form); |
183 ScopedVector<FormStructure> form_structures; | 183 ScopedVector<FormStructure> form_structures; |
184 form_structures.push_back(form_structure); | 184 form_structures.push_back(form_structure); |
185 | 185 |
186 form.fields.clear(); | 186 form.fields.clear(); |
187 | 187 |
188 field.label = ASCIIToUTF16("address"); | 188 field.label = ASCIIToUTF16("address"); |
189 field.name = ASCIIToUTF16("address"); | 189 field.name = ASCIIToUTF16("address"); |
190 field.form_control_type = ASCIIToUTF16("text"); | 190 field.form_control_type = "text"; |
191 form.fields.push_back(field); | 191 form.fields.push_back(field); |
192 | 192 |
193 field.label = ASCIIToUTF16("address2"); | 193 field.label = ASCIIToUTF16("address2"); |
194 field.name = ASCIIToUTF16("address2"); | 194 field.name = ASCIIToUTF16("address2"); |
195 field.form_control_type = ASCIIToUTF16("text"); | 195 field.form_control_type = "text"; |
196 form.fields.push_back(field); | 196 form.fields.push_back(field); |
197 | 197 |
198 field.label = ASCIIToUTF16("city"); | 198 field.label = ASCIIToUTF16("city"); |
199 field.name = ASCIIToUTF16("city"); | 199 field.name = ASCIIToUTF16("city"); |
200 field.form_control_type = ASCIIToUTF16("text"); | 200 field.form_control_type = "text"; |
201 form.fields.push_back(field); | 201 form.fields.push_back(field); |
202 | 202 |
203 field.label = string16(); | 203 field.label = string16(); |
204 field.name = ASCIIToUTF16("Submit"); | 204 field.name = ASCIIToUTF16("Submit"); |
205 field.form_control_type = ASCIIToUTF16("submit"); | 205 field.form_control_type = "submit"; |
206 form.fields.push_back(field); | 206 form.fields.push_back(field); |
207 | 207 |
208 form_structure = new FormStructure(form); | 208 form_structure = new FormStructure(form); |
209 form_structures.push_back(form_structure); | 209 form_structures.push_back(form_structure); |
210 | 210 |
211 // Request with id 0. | 211 // Request with id 0. |
212 MockAutofillMetrics mock_metric_logger; | 212 MockAutofillMetrics mock_metric_logger; |
213 EXPECT_CALL(mock_metric_logger, | 213 EXPECT_CALL(mock_metric_logger, |
214 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); | 214 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); |
215 EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(), | 215 EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 EXPECT_FALSE(download_manager_.StartUploadRequest( | 289 EXPECT_FALSE(download_manager_.StartUploadRequest( |
290 *(form_structures[0]), true, FieldTypeSet())); | 290 *(form_structures[0]), true, FieldTypeSet())); |
291 EXPECT_FALSE(download_manager_.StartUploadRequest( | 291 EXPECT_FALSE(download_manager_.StartUploadRequest( |
292 *(form_structures[1]), false, FieldTypeSet())); | 292 *(form_structures[1]), false, FieldTypeSet())); |
293 fetcher = factory.GetFetcherByID(3); | 293 fetcher = factory.GetFetcherByID(3); |
294 EXPECT_EQ(NULL, fetcher); | 294 EXPECT_EQ(NULL, fetcher); |
295 | 295 |
296 // Modify form structures to miss the cache. | 296 // Modify form structures to miss the cache. |
297 field.label = ASCIIToUTF16("Address line 2"); | 297 field.label = ASCIIToUTF16("Address line 2"); |
298 field.name = ASCIIToUTF16("address2"); | 298 field.name = ASCIIToUTF16("address2"); |
299 field.form_control_type = ASCIIToUTF16("text"); | 299 field.form_control_type = "text"; |
300 form.fields.push_back(field); | 300 form.fields.push_back(field); |
301 form_structure = new FormStructure(form); | 301 form_structure = new FormStructure(form); |
302 form_structures.push_back(form_structure); | 302 form_structures.push_back(form_structure); |
303 | 303 |
304 // Request with id 3. | 304 // Request with id 3. |
305 EXPECT_CALL(mock_metric_logger, | 305 EXPECT_CALL(mock_metric_logger, |
306 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); | 306 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); |
307 EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(), | 307 EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(), |
308 mock_metric_logger)); | 308 mock_metric_logger)); |
309 fetcher = factory.GetFetcherByID(3); | 309 fetcher = factory.GetFetcherByID(3); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 349 |
350 TEST_F(AutofillDownloadTest, CacheQueryTest) { | 350 TEST_F(AutofillDownloadTest, CacheQueryTest) { |
351 MessageLoopForUI message_loop; | 351 MessageLoopForUI message_loop; |
352 // Create and register factory. | 352 // Create and register factory. |
353 net::TestURLFetcherFactory factory; | 353 net::TestURLFetcherFactory factory; |
354 | 354 |
355 FormData form; | 355 FormData form; |
356 form.method = ASCIIToUTF16("post"); | 356 form.method = ASCIIToUTF16("post"); |
357 | 357 |
358 FormFieldData field; | 358 FormFieldData field; |
359 field.form_control_type = ASCIIToUTF16("text"); | 359 field.form_control_type = "text"; |
360 | 360 |
361 field.label = ASCIIToUTF16("username"); | 361 field.label = ASCIIToUTF16("username"); |
362 field.name = ASCIIToUTF16("username"); | 362 field.name = ASCIIToUTF16("username"); |
363 form.fields.push_back(field); | 363 form.fields.push_back(field); |
364 | 364 |
365 field.label = ASCIIToUTF16("First Name"); | 365 field.label = ASCIIToUTF16("First Name"); |
366 field.name = ASCIIToUTF16("firstname"); | 366 field.name = ASCIIToUTF16("firstname"); |
367 form.fields.push_back(field); | 367 form.fields.push_back(field); |
368 | 368 |
369 field.label = ASCIIToUTF16("Last Name"); | 369 field.label = ASCIIToUTF16("Last Name"); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 mock_metric_logger)); | 496 mock_metric_logger)); |
497 // No responses yet | 497 // No responses yet |
498 EXPECT_EQ(static_cast<size_t>(0), responses_.size()); | 498 EXPECT_EQ(static_cast<size_t>(0), responses_.size()); |
499 | 499 |
500 fetcher = factory.GetFetcherByID(3); | 500 fetcher = factory.GetFetcherByID(3); |
501 ASSERT_TRUE(fetcher); | 501 ASSERT_TRUE(fetcher); |
502 FakeOnURLFetchComplete(fetcher, 200, std::string(responses[0])); | 502 FakeOnURLFetchComplete(fetcher, 200, std::string(responses[0])); |
503 ASSERT_EQ(static_cast<size_t>(1), responses_.size()); | 503 ASSERT_EQ(static_cast<size_t>(1), responses_.size()); |
504 EXPECT_EQ(responses[0], responses_.front().response); | 504 EXPECT_EQ(responses[0], responses_.front().response); |
505 } | 505 } |
OLD | NEW |