OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // Tests exercising the Chrome Plugin API. | 4 // Tests exercising the Chrome Plugin API. |
5 | 5 |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/message_loop_proxy.h" |
7 #include "base/path_service.h" | 8 #include "base/path_service.h" |
8 #include "base/string_util.h" | 9 #include "base/string_util.h" |
9 #include "chrome/browser/chrome_plugin_host.h" | 10 #include "chrome/browser/chrome_plugin_host.h" |
10 #include "chrome/browser/chrome_thread.h" | 11 #include "chrome/browser/chrome_thread.h" |
11 #include "chrome/browser/net/url_request_context_getter.h" | 12 #include "chrome/browser/net/url_request_context_getter.h" |
12 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
13 #include "chrome/common/chrome_plugin_lib.h" | 14 #include "chrome/common/chrome_plugin_lib.h" |
14 #include "chrome/test/chrome_plugin/test_chrome_plugin.h" | 15 #include "chrome/test/chrome_plugin/test_chrome_plugin.h" |
15 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
16 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
17 #include "net/url_request/url_request_test_job.h" | 18 #include "net/url_request/url_request_test_job.h" |
18 #include "net/url_request/url_request_unittest.h" | 19 #include "net/url_request/url_request_unittest.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 const wchar_t kDocRoot[] = L"chrome/test/data"; | 24 const wchar_t kDocRoot[] = L"chrome/test/data"; |
24 const char kPluginFilename[] = "test_chrome_plugin.dll"; | 25 const char kPluginFilename[] = "test_chrome_plugin.dll"; |
25 const int kResponseBufferSize = 4096; | 26 const int kResponseBufferSize = 4096; |
26 | 27 |
27 class TestURLRequestContextGetter : public URLRequestContextGetter { | 28 class TestURLRequestContextGetter : public URLRequestContextGetter { |
28 public: | 29 public: |
29 virtual URLRequestContext* GetURLRequestContext() { | 30 virtual URLRequestContext* GetURLRequestContext() { |
30 if (!context_) | 31 if (!context_) |
31 context_ = new TestURLRequestContext(); | 32 context_ = new TestURLRequestContext(); |
32 return context_; | 33 return context_; |
33 } | 34 } |
| 35 virtual scoped_refptr<MessageLoopProxy> GetIOMessageLoopProxy() { |
| 36 return ChromeThread::GetMessageLoopProxyForThread(ChromeThread::IO); |
| 37 } |
| 38 |
34 private: | 39 private: |
35 ~TestURLRequestContextGetter() {} | 40 ~TestURLRequestContextGetter() {} |
36 scoped_refptr<URLRequestContext> context_; | 41 scoped_refptr<URLRequestContext> context_; |
37 }; | 42 }; |
38 | 43 |
39 class ChromePluginTest : public testing::Test, public URLRequest::Delegate { | 44 class ChromePluginTest : public testing::Test, public URLRequest::Delegate { |
40 public: | 45 public: |
41 ChromePluginTest() | 46 ChromePluginTest() |
42 : io_thread_(ChromeThread::IO, &message_loop_), | 47 : io_thread_(ChromeThread::IO, &message_loop_), |
43 request_(NULL), | 48 request_(NULL), |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 TEST_F(ChromePluginTest, DoesNotInterceptOwnRequest) { | 297 TEST_F(ChromePluginTest, DoesNotInterceptOwnRequest) { |
293 const TestResponsePayload& payload = kChromeTestPluginPayloads[0]; | 298 const TestResponsePayload& payload = kChromeTestPluginPayloads[0]; |
294 | 299 |
295 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( | 300 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( |
296 "GET", GURL(payload.url))); | 301 "GET", GURL(payload.url))); |
297 | 302 |
298 MessageLoop::current()->Run(); | 303 MessageLoop::current()->Run(); |
299 } | 304 } |
300 | 305 |
301 } // namespace | 306 } // namespace |
302 | |
OLD | NEW |