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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "content/browser/browser_thread_impl.h" |
7 #include "content/browser/mock_resource_context.h" | 8 #include "content/browser/mock_resource_context.h" |
8 #include "content/browser/renderer_host/dummy_resource_handler.h" | 9 #include "content/browser/renderer_host/dummy_resource_handler.h" |
9 #include "content/browser/renderer_host/global_request_id.h" | 10 #include "content/browser/renderer_host/global_request_id.h" |
10 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 11 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
11 #include "content/browser/renderer_host/resource_queue.h" | 12 #include "content/browser/renderer_host/resource_queue.h" |
12 #include "content/test/test_browser_thread.h" | |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
| 17 using content::BrowserThreadImpl; |
17 using content::DummyResourceHandler; | 18 using content::DummyResourceHandler; |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 const char kTestUrl[] = "data:text/plain,Hello World!"; | 22 const char kTestUrl[] = "data:text/plain,Hello World!"; |
22 | 23 |
23 ResourceDispatcherHostRequestInfo* GetRequestInfo(int request_id) { | 24 ResourceDispatcherHostRequestInfo* GetRequestInfo(int request_id) { |
24 return new ResourceDispatcherHostRequestInfo( | 25 return new ResourceDispatcherHostRequestInfo( |
25 new DummyResourceHandler(), ChildProcessInfo::RENDER_PROCESS, 0, 0, 0, | 26 new DummyResourceHandler(), ChildProcessInfo::RENDER_PROCESS, 0, 0, 0, |
26 request_id, false, -1, ResourceType::MAIN_FRAME, | 27 request_id, false, -1, ResourceType::MAIN_FRAME, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } | 117 } |
117 | 118 |
118 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) { | 119 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) { |
119 } | 120 } |
120 | 121 |
121 protected: | 122 protected: |
122 int response_started_count_; | 123 int response_started_count_; |
123 | 124 |
124 private: | 125 private: |
125 MessageLoop message_loop_; | 126 MessageLoop message_loop_; |
126 content::TestBrowserThread ui_thread_; | 127 BrowserThreadImpl ui_thread_; |
127 content::TestBrowserThread io_thread_; | 128 BrowserThreadImpl io_thread_; |
128 }; | 129 }; |
129 | 130 |
130 TEST_F(ResourceQueueTest, Basic) { | 131 TEST_F(ResourceQueueTest, Basic) { |
131 // Test the simplest lifycycle of ResourceQueue. | 132 // Test the simplest lifycycle of ResourceQueue. |
132 ResourceQueue queue; | 133 ResourceQueue queue; |
133 queue.Initialize(ResourceQueue::DelegateSet()); | 134 queue.Initialize(ResourceQueue::DelegateSet()); |
134 queue.Shutdown(); | 135 queue.Shutdown(); |
135 } | 136 } |
136 | 137 |
137 TEST_F(ResourceQueueTest, NeverDelayingDelegate) { | 138 TEST_F(ResourceQueueTest, NeverDelayingDelegate) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 MessageLoop::current()->RunAllPending(); | 255 MessageLoop::current()->RunAllPending(); |
255 EXPECT_EQ(0, response_started_count_); | 256 EXPECT_EQ(0, response_started_count_); |
256 | 257 |
257 queue.Shutdown(); | 258 queue.Shutdown(); |
258 | 259 |
259 MessageLoop::current()->RunAllPending(); | 260 MessageLoop::current()->RunAllPending(); |
260 EXPECT_EQ(0, response_started_count_); | 261 EXPECT_EQ(0, response_started_count_); |
261 } | 262 } |
262 | 263 |
263 } // namespace | 264 } // namespace |
OLD | NEW |