| 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.h" | |
| 8 #include "content/browser/mock_resource_context.h" | 7 #include "content/browser/mock_resource_context.h" |
| 9 #include "content/browser/renderer_host/dummy_resource_handler.h" | 8 #include "content/browser/renderer_host/dummy_resource_handler.h" |
| 10 #include "content/browser/renderer_host/global_request_id.h" | 9 #include "content/browser/renderer_host/global_request_id.h" |
| 11 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 10 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 12 #include "content/browser/renderer_host/resource_queue.h" | 11 #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::DummyResourceHandler; | 17 using content::DummyResourceHandler; |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const char kTestUrl[] = "data:text/plain,Hello World!"; | 21 const char kTestUrl[] = "data:text/plain,Hello World!"; |
| 22 | 22 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) { | 118 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) { |
| 119 } | 119 } |
| 120 | 120 |
| 121 protected: | 121 protected: |
| 122 int response_started_count_; | 122 int response_started_count_; |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 MessageLoop message_loop_; | 125 MessageLoop message_loop_; |
| 126 BrowserThread ui_thread_; | 126 content::TestBrowserThread ui_thread_; |
| 127 BrowserThread io_thread_; | 127 content::TestBrowserThread io_thread_; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 TEST_F(ResourceQueueTest, Basic) { | 130 TEST_F(ResourceQueueTest, Basic) { |
| 131 // Test the simplest lifycycle of ResourceQueue. | 131 // Test the simplest lifycycle of ResourceQueue. |
| 132 ResourceQueue queue; | 132 ResourceQueue queue; |
| 133 queue.Initialize(ResourceQueue::DelegateSet()); | 133 queue.Initialize(ResourceQueue::DelegateSet()); |
| 134 queue.Shutdown(); | 134 queue.Shutdown(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 TEST_F(ResourceQueueTest, NeverDelayingDelegate) { | 137 TEST_F(ResourceQueueTest, NeverDelayingDelegate) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 MessageLoop::current()->RunAllPending(); | 254 MessageLoop::current()->RunAllPending(); |
| 255 EXPECT_EQ(0, response_started_count_); | 255 EXPECT_EQ(0, response_started_count_); |
| 256 | 256 |
| 257 queue.Shutdown(); | 257 queue.Shutdown(); |
| 258 | 258 |
| 259 MessageLoop::current()->RunAllPending(); | 259 MessageLoop::current()->RunAllPending(); |
| 260 EXPECT_EQ(0, response_started_count_); | 260 EXPECT_EQ(0, response_started_count_); |
| 261 } | 261 } |
| 262 | 262 |
| 263 } // namespace | 263 } // namespace |
| OLD | NEW |