| 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 <list> | 5 #include <list> |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/autofill/autofill_download.h" | 10 #include "chrome/browser/autofill/autofill_download.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 form_structure = new FormStructure(form); | 305 form_structure = new FormStructure(form); |
| 306 form_structures.push_back(form_structure); | 306 form_structures.push_back(form_structure); |
| 307 | 307 |
| 308 // Request with id 3. | 308 // Request with id 3. |
| 309 EXPECT_CALL(mock_metric_logger, | 309 EXPECT_CALL(mock_metric_logger, |
| 310 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); | 310 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); |
| 311 EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(), | 311 EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(), |
| 312 mock_metric_logger)); | 312 mock_metric_logger)); |
| 313 fetcher = factory.GetFetcherByID(3); | 313 fetcher = factory.GetFetcherByID(3); |
| 314 ASSERT_TRUE(fetcher); | 314 ASSERT_TRUE(fetcher); |
| 315 fetcher->set_backoff_delay_for_testing( | 315 fetcher->SetBackoffDelayForTesting( |
| 316 base::TimeDelta::FromMilliseconds(TestTimeouts::action_max_timeout_ms())); | 316 base::TimeDelta::FromMilliseconds(TestTimeouts::action_max_timeout_ms())); |
| 317 FakeOnURLFetchComplete(fetcher, 500, std::string(responses[0])); | 317 FakeOnURLFetchComplete(fetcher, 500, std::string(responses[0])); |
| 318 | 318 |
| 319 EXPECT_EQ(AutofillDownloadTest::REQUEST_QUERY_FAILED, | 319 EXPECT_EQ(AutofillDownloadTest::REQUEST_QUERY_FAILED, |
| 320 responses_.front().type_of_response); | 320 responses_.front().type_of_response); |
| 321 EXPECT_EQ(500, responses_.front().error); | 321 EXPECT_EQ(500, responses_.front().error); |
| 322 // Expected response on non-query request is an empty string. | 322 // Expected response on non-query request is an empty string. |
| 323 EXPECT_EQ(std::string(), responses_.front().response); | 323 EXPECT_EQ(std::string(), responses_.front().response); |
| 324 responses_.pop_front(); | 324 responses_.pop_front(); |
| 325 | 325 |
| 326 // Query requests should be ignored for the next 10 seconds. | 326 // Query requests should be ignored for the next 10 seconds. |
| 327 EXPECT_CALL(mock_metric_logger, | 327 EXPECT_CALL(mock_metric_logger, |
| 328 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(0); | 328 LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(0); |
| 329 EXPECT_FALSE(download_manager_.StartQueryRequest(form_structures.get(), | 329 EXPECT_FALSE(download_manager_.StartQueryRequest(form_structures.get(), |
| 330 mock_metric_logger)); | 330 mock_metric_logger)); |
| 331 fetcher = factory.GetFetcherByID(4); | 331 fetcher = factory.GetFetcherByID(4); |
| 332 EXPECT_EQ(NULL, fetcher); | 332 EXPECT_EQ(NULL, fetcher); |
| 333 | 333 |
| 334 // Set upload required to true so requests happen. | 334 // Set upload required to true so requests happen. |
| 335 form_structures[0]->upload_required_ = UPLOAD_REQUIRED; | 335 form_structures[0]->upload_required_ = UPLOAD_REQUIRED; |
| 336 // Request with id 4. | 336 // Request with id 4. |
| 337 EXPECT_TRUE(download_manager_.StartUploadRequest( | 337 EXPECT_TRUE(download_manager_.StartUploadRequest( |
| 338 *(form_structures[0]), true, FieldTypeSet())); | 338 *(form_structures[0]), true, FieldTypeSet())); |
| 339 fetcher = factory.GetFetcherByID(4); | 339 fetcher = factory.GetFetcherByID(4); |
| 340 ASSERT_TRUE(fetcher); | 340 ASSERT_TRUE(fetcher); |
| 341 fetcher->set_backoff_delay_for_testing( | 341 fetcher->SetBackoffDelayForTesting( |
| 342 base::TimeDelta::FromMilliseconds(TestTimeouts::action_max_timeout_ms())); | 342 base::TimeDelta::FromMilliseconds(TestTimeouts::action_max_timeout_ms())); |
| 343 FakeOnURLFetchComplete(fetcher, 503, std::string(responses[2])); | 343 FakeOnURLFetchComplete(fetcher, 503, std::string(responses[2])); |
| 344 EXPECT_EQ(AutofillDownloadTest::REQUEST_UPLOAD_FAILED, | 344 EXPECT_EQ(AutofillDownloadTest::REQUEST_UPLOAD_FAILED, |
| 345 responses_.front().type_of_response); | 345 responses_.front().type_of_response); |
| 346 EXPECT_EQ(503, responses_.front().error); | 346 EXPECT_EQ(503, responses_.front().error); |
| 347 responses_.pop_front(); | 347 responses_.pop_front(); |
| 348 | 348 |
| 349 // Upload requests should be ignored for the next 10 seconds. | 349 // Upload requests should be ignored for the next 10 seconds. |
| 350 EXPECT_FALSE(download_manager_.StartUploadRequest( | 350 EXPECT_FALSE(download_manager_.StartUploadRequest( |
| 351 *(form_structures[0]), true, FieldTypeSet())); | 351 *(form_structures[0]), true, FieldTypeSet())); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 mock_metric_logger)); | 502 mock_metric_logger)); |
| 503 // No responses yet | 503 // No responses yet |
| 504 EXPECT_EQ(static_cast<size_t>(0), responses_.size()); | 504 EXPECT_EQ(static_cast<size_t>(0), responses_.size()); |
| 505 | 505 |
| 506 fetcher = factory.GetFetcherByID(3); | 506 fetcher = factory.GetFetcherByID(3); |
| 507 ASSERT_TRUE(fetcher); | 507 ASSERT_TRUE(fetcher); |
| 508 FakeOnURLFetchComplete(fetcher, 200, std::string(responses[0])); | 508 FakeOnURLFetchComplete(fetcher, 200, std::string(responses[0])); |
| 509 ASSERT_EQ(static_cast<size_t>(1), responses_.size()); | 509 ASSERT_EQ(static_cast<size_t>(1), responses_.size()); |
| 510 EXPECT_EQ(responses[0], responses_.front().response); | 510 EXPECT_EQ(responses[0], responses_.front().response); |
| 511 } | 511 } |
| OLD | NEW |