OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/autofill/core/browser/autofill_download_manager.h" | 5 #include "components/autofill/core/browser/autofill_download_manager.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | |
10 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
11 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
13 #include "base/test/histogram_tester.h" | 12 #include "base/test/histogram_tester.h" |
14 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
| 14 #include "base/thread_task_runner_handle.h" |
15 #include "components/autofill/core/browser/autofill_field.h" | 15 #include "components/autofill/core/browser/autofill_field.h" |
16 #include "components/autofill/core/browser/autofill_metrics.h" | 16 #include "components/autofill/core/browser/autofill_metrics.h" |
17 #include "components/autofill/core/browser/autofill_test_utils.h" | 17 #include "components/autofill/core/browser/autofill_test_utils.h" |
18 #include "components/autofill/core/browser/autofill_type.h" | 18 #include "components/autofill/core/browser/autofill_type.h" |
19 #include "components/autofill/core/browser/form_structure.h" | 19 #include "components/autofill/core/browser/form_structure.h" |
20 #include "components/autofill/core/browser/test_autofill_driver.h" | 20 #include "components/autofill/core/browser/test_autofill_driver.h" |
21 #include "components/autofill/core/common/form_data.h" | 21 #include "components/autofill/core/common/form_data.h" |
22 #include "net/url_request/test_url_fetcher_factory.h" | 22 #include "net/url_request/test_url_fetcher_factory.h" |
23 #include "net/url_request/url_request_status.h" | 23 #include "net/url_request/url_request_status.h" |
24 #include "net/url_request/url_request_test_util.h" | 24 #include "net/url_request/url_request_test_util.h" |
(...skipping 28 matching lines...) Expand all Loading... |
53 // TestURLFetcherFactory is used, which creates URLFetchers that do not | 53 // TestURLFetcherFactory is used, which creates URLFetchers that do not |
54 // go over the wire, but allow calling back HTTP responses directly. | 54 // go over the wire, but allow calling back HTTP responses directly. |
55 // The responses in test are out of order and verify: successful query request, | 55 // The responses in test are out of order and verify: successful query request, |
56 // successful upload request, failed upload request. | 56 // successful upload request, failed upload request. |
57 class AutofillDownloadTest : public AutofillDownloadManager::Observer, | 57 class AutofillDownloadTest : public AutofillDownloadManager::Observer, |
58 public testing::Test { | 58 public testing::Test { |
59 public: | 59 public: |
60 AutofillDownloadTest() | 60 AutofillDownloadTest() |
61 : prefs_(test::PrefServiceForTesting()), | 61 : prefs_(test::PrefServiceForTesting()), |
62 request_context_(new net::TestURLRequestContextGetter( | 62 request_context_(new net::TestURLRequestContextGetter( |
63 base::MessageLoopProxy::current())), | 63 base::ThreadTaskRunnerHandle::Get())), |
64 download_manager_(&driver_, prefs_.get(), this) { | 64 download_manager_(&driver_, prefs_.get(), this) { |
65 driver_.SetURLRequestContext(request_context_.get()); | 65 driver_.SetURLRequestContext(request_context_.get()); |
66 } | 66 } |
67 | 67 |
68 void LimitCache(size_t cache_size) { | 68 void LimitCache(size_t cache_size) { |
69 download_manager_.set_max_form_cache_size(cache_size); | 69 download_manager_.set_max_form_cache_size(cache_size); |
70 } | 70 } |
71 | 71 |
72 // AutofillDownloadManager::Observer implementation. | 72 // AutofillDownloadManager::Observer implementation. |
73 void OnLoadedServerPredictions(const std::string& response_xml) override { | 73 void OnLoadedServerPredictions(const std::string& response_xml) override { |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 EXPECT_EQ(static_cast<size_t>(0), responses_.size()); | 470 EXPECT_EQ(static_cast<size_t>(0), responses_.size()); |
471 | 471 |
472 fetcher = factory.GetFetcherByID(3); | 472 fetcher = factory.GetFetcherByID(3); |
473 ASSERT_TRUE(fetcher); | 473 ASSERT_TRUE(fetcher); |
474 FakeOnURLFetchComplete(fetcher, 200, std::string(responses[0])); | 474 FakeOnURLFetchComplete(fetcher, 200, std::string(responses[0])); |
475 ASSERT_EQ(static_cast<size_t>(1), responses_.size()); | 475 ASSERT_EQ(static_cast<size_t>(1), responses_.size()); |
476 EXPECT_EQ(responses[0], responses_.front().response); | 476 EXPECT_EQ(responses[0], responses_.front().response); |
477 } | 477 } |
478 | 478 |
479 } // namespace autofill | 479 } // namespace autofill |
OLD | NEW |