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