OLD | NEW |
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 "components/precache/core/precache_fetcher.h" | 5 #include "components/precache/core/precache_fetcher.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/thread_task_runner_handle.h" |
17 #include "components/precache/core/precache_switches.h" | 17 #include "components/precache/core/precache_switches.h" |
18 #include "components/precache/core/proto/precache.pb.h" | 18 #include "components/precache/core/proto/precache.pb.h" |
19 #include "net/http/http_response_headers.h" | 19 #include "net/http/http_response_headers.h" |
20 #include "net/http/http_status_code.h" | 20 #include "net/http/http_status_code.h" |
21 #include "net/url_request/test_url_fetcher_factory.h" | 21 #include "net/url_request/test_url_fetcher_factory.h" |
22 #include "net/url_request/url_request_status.h" | 22 #include "net/url_request/url_request_status.h" |
23 #include "net/url_request/url_request_test_util.h" | 23 #include "net/url_request/url_request_test_util.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 | 25 |
26 namespace precache { | 26 namespace precache { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 private: | 69 private: |
70 bool was_on_done_called_; | 70 bool was_on_done_called_; |
71 }; | 71 }; |
72 | 72 |
73 class PrecacheFetcherTest : public testing::Test { | 73 class PrecacheFetcherTest : public testing::Test { |
74 public: | 74 public: |
75 PrecacheFetcherTest() | 75 PrecacheFetcherTest() |
76 : request_context_(new net::TestURLRequestContextGetter( | 76 : request_context_(new net::TestURLRequestContextGetter( |
77 base::MessageLoopProxy::current())), | 77 base::ThreadTaskRunnerHandle::Get())), |
78 factory_(NULL, base::Bind(&TestURLFetcherCallback::CreateURLFetcher, | 78 factory_(NULL, |
79 base::Unretained(&url_callback_))) {} | 79 base::Bind(&TestURLFetcherCallback::CreateURLFetcher, |
| 80 base::Unretained(&url_callback_))) {} |
80 | 81 |
81 protected: | 82 protected: |
82 base::MessageLoopForUI loop_; | 83 base::MessageLoopForUI loop_; |
83 scoped_refptr<net::TestURLRequestContextGetter> request_context_; | 84 scoped_refptr<net::TestURLRequestContextGetter> request_context_; |
84 TestURLFetcherCallback url_callback_; | 85 TestURLFetcherCallback url_callback_; |
85 net::FakeURLFetcherFactory factory_; | 86 net::FakeURLFetcherFactory factory_; |
86 TestPrecacheDelegate precache_delegate_; | 87 TestPrecacheDelegate precache_delegate_; |
87 }; | 88 }; |
88 | 89 |
89 const char kConfigURL[] = "http://config-url.com"; | 90 const char kConfigURL[] = "http://config-url.com"; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 EXPECT_EQ(expected_requested_urls, url_callback_.requested_urls()); | 300 EXPECT_EQ(expected_requested_urls, url_callback_.requested_urls()); |
300 | 301 |
301 EXPECT_TRUE(precache_delegate_.was_on_done_called()); | 302 EXPECT_TRUE(precache_delegate_.was_on_done_called()); |
302 } | 303 } |
303 | 304 |
304 #endif // PRECACHE_MANIFEST_URL_PREFIX | 305 #endif // PRECACHE_MANIFEST_URL_PREFIX |
305 | 306 |
306 } // namespace | 307 } // namespace |
307 | 308 |
308 } // namespace precache | 309 } // namespace precache |
OLD | NEW |