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

Side by Side Diff: components/autofill/core/browser/autofill_download_unittest.cc

Issue 22009003: [Autofill] Distinguish between native field types and potentially HTML field types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 MockAutofillMetrics mock_metric_logger; 197 MockAutofillMetrics mock_metric_logger;
198 EXPECT_CALL(mock_metric_logger, 198 EXPECT_CALL(mock_metric_logger,
199 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); 199 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1);
200 EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(), 200 EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(),
201 mock_metric_logger)); 201 mock_metric_logger));
202 // Set upload to 100% so requests happen. 202 // Set upload to 100% so requests happen.
203 download_manager_.SetPositiveUploadRate(1.0); 203 download_manager_.SetPositiveUploadRate(1.0);
204 download_manager_.SetNegativeUploadRate(1.0); 204 download_manager_.SetNegativeUploadRate(1.0);
205 // Request with id 1. 205 // Request with id 1.
206 EXPECT_TRUE(download_manager_.StartUploadRequest( 206 EXPECT_TRUE(download_manager_.StartUploadRequest(
207 *(form_structures[0]), true, FieldTypeSet())); 207 *(form_structures[0]), true, ServerFieldTypeSet()));
208 // Request with id 2. 208 // Request with id 2.
209 EXPECT_TRUE(download_manager_.StartUploadRequest( 209 EXPECT_TRUE(download_manager_.StartUploadRequest(
210 *(form_structures[1]), false, FieldTypeSet())); 210 *(form_structures[1]), false, ServerFieldTypeSet()));
211 211
212 const char *responses[] = { 212 const char *responses[] = {
213 "<autofillqueryresponse>" 213 "<autofillqueryresponse>"
214 "<field autofilltype=\"0\" />" 214 "<field autofilltype=\"0\" />"
215 "<field autofilltype=\"3\" />" 215 "<field autofilltype=\"3\" />"
216 "<field autofilltype=\"5\" />" 216 "<field autofilltype=\"5\" />"
217 "<field autofilltype=\"9\" />" 217 "<field autofilltype=\"9\" />"
218 "<field autofilltype=\"0\" />" 218 "<field autofilltype=\"0\" />"
219 "<field autofilltype=\"30\" />" 219 "<field autofilltype=\"30\" />"
220 "<field autofilltype=\"31\" />" 220 "<field autofilltype=\"31\" />"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 EXPECT_EQ(0, responses_.front().error); 265 EXPECT_EQ(0, responses_.front().error);
266 EXPECT_EQ(std::string(), responses_.front().signature); 266 EXPECT_EQ(std::string(), responses_.front().signature);
267 EXPECT_EQ(responses[0], responses_.front().response); 267 EXPECT_EQ(responses[0], responses_.front().response);
268 responses_.pop_front(); 268 responses_.pop_front();
269 269
270 // Set upload to 0% so no new requests happen. 270 // Set upload to 0% so no new requests happen.
271 download_manager_.SetPositiveUploadRate(0.0); 271 download_manager_.SetPositiveUploadRate(0.0);
272 download_manager_.SetNegativeUploadRate(0.0); 272 download_manager_.SetNegativeUploadRate(0.0);
273 // No actual requests for the next two calls, as we set upload rate to 0%. 273 // No actual requests for the next two calls, as we set upload rate to 0%.
274 EXPECT_FALSE(download_manager_.StartUploadRequest( 274 EXPECT_FALSE(download_manager_.StartUploadRequest(
275 *(form_structures[0]), true, FieldTypeSet())); 275 *(form_structures[0]), true, ServerFieldTypeSet()));
276 EXPECT_FALSE(download_manager_.StartUploadRequest( 276 EXPECT_FALSE(download_manager_.StartUploadRequest(
277 *(form_structures[1]), false, FieldTypeSet())); 277 *(form_structures[1]), false, ServerFieldTypeSet()));
278 fetcher = factory.GetFetcherByID(3); 278 fetcher = factory.GetFetcherByID(3);
279 EXPECT_EQ(NULL, fetcher); 279 EXPECT_EQ(NULL, fetcher);
280 280
281 // Modify form structures to miss the cache. 281 // Modify form structures to miss the cache.
282 field.label = ASCIIToUTF16("Address line 2"); 282 field.label = ASCIIToUTF16("Address line 2");
283 field.name = ASCIIToUTF16("address2"); 283 field.name = ASCIIToUTF16("address2");
284 field.form_control_type = "text"; 284 field.form_control_type = "text";
285 form.fields.push_back(field); 285 form.fields.push_back(field);
286 form_structure = new FormStructure(form, std::string()); 286 form_structure = new FormStructure(form, std::string());
287 form_structures.push_back(form_structure); 287 form_structures.push_back(form_structure);
(...skipping 20 matching lines...) Expand all
308 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(0); 308 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(0);
309 EXPECT_FALSE(download_manager_.StartQueryRequest(form_structures.get(), 309 EXPECT_FALSE(download_manager_.StartQueryRequest(form_structures.get(),
310 mock_metric_logger)); 310 mock_metric_logger));
311 fetcher = factory.GetFetcherByID(4); 311 fetcher = factory.GetFetcherByID(4);
312 EXPECT_EQ(NULL, fetcher); 312 EXPECT_EQ(NULL, fetcher);
313 313
314 // Set upload required to true so requests happen. 314 // Set upload required to true so requests happen.
315 form_structures[0]->upload_required_ = UPLOAD_REQUIRED; 315 form_structures[0]->upload_required_ = UPLOAD_REQUIRED;
316 // Request with id 4. 316 // Request with id 4.
317 EXPECT_TRUE(download_manager_.StartUploadRequest( 317 EXPECT_TRUE(download_manager_.StartUploadRequest(
318 *(form_structures[0]), true, FieldTypeSet())); 318 *(form_structures[0]), true, ServerFieldTypeSet()));
319 fetcher = factory.GetFetcherByID(4); 319 fetcher = factory.GetFetcherByID(4);
320 ASSERT_TRUE(fetcher); 320 ASSERT_TRUE(fetcher);
321 fetcher->set_backoff_delay(TestTimeouts::action_max_timeout()); 321 fetcher->set_backoff_delay(TestTimeouts::action_max_timeout());
322 FakeOnURLFetchComplete(fetcher, 503, std::string(responses[2])); 322 FakeOnURLFetchComplete(fetcher, 503, std::string(responses[2]));
323 EXPECT_EQ(AutofillDownloadTest::REQUEST_UPLOAD_FAILED, 323 EXPECT_EQ(AutofillDownloadTest::REQUEST_UPLOAD_FAILED,
324 responses_.front().type_of_response); 324 responses_.front().type_of_response);
325 EXPECT_EQ(503, responses_.front().error); 325 EXPECT_EQ(503, responses_.front().error);
326 responses_.pop_front(); 326 responses_.pop_front();
327 327
328 // Upload requests should be ignored for the next 10 seconds. 328 // Upload requests should be ignored for the next 10 seconds.
329 EXPECT_FALSE(download_manager_.StartUploadRequest( 329 EXPECT_FALSE(download_manager_.StartUploadRequest(
330 *(form_structures[0]), true, FieldTypeSet())); 330 *(form_structures[0]), true, ServerFieldTypeSet()));
331 fetcher = factory.GetFetcherByID(5); 331 fetcher = factory.GetFetcherByID(5);
332 EXPECT_EQ(NULL, fetcher); 332 EXPECT_EQ(NULL, fetcher);
333 } 333 }
334 334
335 TEST_F(AutofillDownloadTest, CacheQueryTest) { 335 TEST_F(AutofillDownloadTest, CacheQueryTest) {
336 // Create and register factory. 336 // Create and register factory.
337 net::TestURLFetcherFactory factory; 337 net::TestURLFetcherFactory factory;
338 338
339 FormData form; 339 FormData form;
340 form.method = ASCIIToUTF16("post"); 340 form.method = ASCIIToUTF16("post");
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 EXPECT_EQ(static_cast<size_t>(0), responses_.size()); 482 EXPECT_EQ(static_cast<size_t>(0), responses_.size());
483 483
484 fetcher = factory.GetFetcherByID(3); 484 fetcher = factory.GetFetcherByID(3);
485 ASSERT_TRUE(fetcher); 485 ASSERT_TRUE(fetcher);
486 FakeOnURLFetchComplete(fetcher, 200, std::string(responses[0])); 486 FakeOnURLFetchComplete(fetcher, 200, std::string(responses[0]));
487 ASSERT_EQ(static_cast<size_t>(1), responses_.size()); 487 ASSERT_EQ(static_cast<size_t>(1), responses_.size());
488 EXPECT_EQ(responses[0], responses_.front().response); 488 EXPECT_EQ(responses[0], responses_.front().response);
489 } 489 }
490 490
491 } // namespace autofill 491 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_download.cc ('k') | components/autofill/core/browser/autofill_field.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698