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 <stack> | 5 #include <stack> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "content/browser/appcache/appcache.h" |
| 16 #include "content/browser/appcache/appcache_backend_impl.h" |
| 17 #include "content/browser/appcache/appcache_request_handler.h" |
| 18 #include "content/browser/appcache/appcache_url_request_job.h" |
15 #include "content/browser/appcache/mock_appcache_policy.h" | 19 #include "content/browser/appcache/mock_appcache_policy.h" |
16 #include "content/browser/appcache/mock_appcache_service.h" | 20 #include "content/browser/appcache/mock_appcache_service.h" |
17 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
18 #include "net/base/request_priority.h" | 22 #include "net/base/request_priority.h" |
19 #include "net/http/http_response_headers.h" | 23 #include "net/http/http_response_headers.h" |
20 #include "net/url_request/url_request.h" | 24 #include "net/url_request/url_request.h" |
21 #include "net/url_request/url_request_context.h" | 25 #include "net/url_request/url_request_context.h" |
22 #include "net/url_request/url_request_error_job.h" | 26 #include "net/url_request/url_request_error_job.h" |
23 #include "net/url_request/url_request_job_factory.h" | 27 #include "net/url_request/url_request_job_factory.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "webkit/browser/appcache/appcache.h" | |
26 #include "webkit/browser/appcache/appcache_backend_impl.h" | |
27 #include "webkit/browser/appcache/appcache_request_handler.h" | |
28 #include "webkit/browser/appcache/appcache_url_request_job.h" | |
29 | |
30 using appcache::AppCache; | |
31 using appcache::AppCacheBackendImpl; | |
32 using appcache::AppCacheEntry; | |
33 using appcache::AppCacheFrontend; | |
34 using appcache::AppCacheGroup; | |
35 using appcache::AppCacheHost; | |
36 using appcache::AppCacheInfo; | |
37 using appcache::AppCacheRequestHandler; | |
38 using appcache::AppCacheURLRequestJob; | |
39 using appcache::kAppCacheNoCacheId; | |
40 | 29 |
41 namespace content { | 30 namespace content { |
42 | 31 |
43 static const int kMockProcessId = 1; | 32 static const int kMockProcessId = 1; |
44 | 33 |
45 class AppCacheRequestHandlerTest : public testing::Test { | 34 class AppCacheRequestHandlerTest : public testing::Test { |
46 public: | 35 public: |
47 class MockFrontend : public AppCacheFrontend { | 36 class MockFrontend : public AppCacheFrontend { |
48 public: | 37 public: |
49 virtual void OnCacheSelected( | 38 virtual void OnCacheSelected( |
50 int host_id, const appcache::AppCacheInfo& info) OVERRIDE {} | 39 int host_id, const AppCacheInfo& info) OVERRIDE {} |
51 | 40 |
52 virtual void OnStatusChanged(const std::vector<int>& host_ids, | 41 virtual void OnStatusChanged(const std::vector<int>& host_ids, |
53 appcache::AppCacheStatus status) OVERRIDE {} | 42 AppCacheStatus status) OVERRIDE {} |
54 | 43 |
55 virtual void OnEventRaised(const std::vector<int>& host_ids, | 44 virtual void OnEventRaised(const std::vector<int>& host_ids, |
56 appcache::AppCacheEventID event_id) OVERRIDE {} | 45 AppCacheEventID event_id) OVERRIDE {} |
57 | 46 |
58 virtual void OnErrorEventRaised( | 47 virtual void OnErrorEventRaised( |
59 const std::vector<int>& host_ids, | 48 const std::vector<int>& host_ids, |
60 const appcache::AppCacheErrorDetails& details) OVERRIDE {} | 49 const AppCacheErrorDetails& details) OVERRIDE {} |
61 | 50 |
62 virtual void OnProgressEventRaised(const std::vector<int>& host_ids, | 51 virtual void OnProgressEventRaised(const std::vector<int>& host_ids, |
63 const GURL& url, | 52 const GURL& url, |
64 int num_total, | 53 int num_total, |
65 int num_complete) OVERRIDE { | 54 int num_complete) OVERRIDE { |
66 } | 55 } |
67 | 56 |
68 virtual void OnLogMessage(int host_id, | 57 virtual void OnLogMessage(int host_id, |
69 appcache::AppCacheLogLevel log_level, | 58 AppCacheLogLevel log_level, |
70 const std::string& message) OVERRIDE { | 59 const std::string& message) OVERRIDE { |
71 } | 60 } |
72 | 61 |
73 virtual void OnContentBlocked(int host_id, | 62 virtual void OnContentBlocked(int host_id, |
74 const GURL& manifest_url) OVERRIDE {} | 63 const GURL& manifest_url) OVERRIDE {} |
75 }; | 64 }; |
76 | 65 |
77 // Helper callback to run a test on our io_thread. The io_thread is spun up | 66 // Helper callback to run a test on our io_thread. The io_thread is spun up |
78 // once and reused for all tests. | 67 // once and reused for all tests. |
79 template <class Method> | 68 template <class Method> |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 | 994 |
1006 TEST_F(AppCacheRequestHandlerTest, WorkerRequest) { | 995 TEST_F(AppCacheRequestHandlerTest, WorkerRequest) { |
1007 RunTestOnIOThread(&AppCacheRequestHandlerTest::WorkerRequest); | 996 RunTestOnIOThread(&AppCacheRequestHandlerTest::WorkerRequest); |
1008 } | 997 } |
1009 | 998 |
1010 TEST_F(AppCacheRequestHandlerTest, MainResource_Blocked) { | 999 TEST_F(AppCacheRequestHandlerTest, MainResource_Blocked) { |
1011 RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Blocked); | 1000 RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Blocked); |
1012 } | 1001 } |
1013 | 1002 |
1014 } // namespace content | 1003 } // namespace content |
OLD | NEW |