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 // 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/message_loop_proxy.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
11 #include "chrome/browser/chrome_plugin_host.h" | 11 #include "chrome/browser/chrome_plugin_host.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/chrome_plugin_lib.h" | 13 #include "chrome/common/chrome_plugin_lib.h" |
14 #include "chrome/common/net/url_request_context_getter.h" | 14 #include "chrome/common/net/url_request_context_getter.h" |
15 #include "chrome/test/chrome_plugin/test_chrome_plugin.h" | 15 #include "chrome/test/chrome_plugin/test_chrome_plugin.h" |
| 16 #include "chrome/test/test_url_request_context_getter.h" |
16 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
17 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
18 #include "net/url_request/url_request_test_job.h" | 19 #include "net/url_request/url_request_test_job.h" |
19 #include "net/url_request/url_request_unittest.h" | 20 #include "net/url_request/url_request_test_util.h" |
20 #include "net/test/test_server.h" | 21 #include "net/test/test_server.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); | 26 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); |
26 const char kPluginFilename[] = "test_chrome_plugin.dll"; | 27 const char kPluginFilename[] = "test_chrome_plugin.dll"; |
27 const int kResponseBufferSize = 4096; | 28 const int kResponseBufferSize = 4096; |
28 | 29 |
29 class TestURLRequestContextGetter : public URLRequestContextGetter { | |
30 public: | |
31 virtual net::URLRequestContext* GetURLRequestContext() { | |
32 if (!context_) | |
33 context_ = new TestURLRequestContext(); | |
34 return context_; | |
35 } | |
36 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { | |
37 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | |
38 } | |
39 | |
40 private: | |
41 ~TestURLRequestContextGetter() {} | |
42 scoped_refptr<net::URLRequestContext> context_; | |
43 }; | |
44 | |
45 class ChromePluginTest : public testing::Test, | 30 class ChromePluginTest : public testing::Test, |
46 public net::URLRequest::Delegate { | 31 public net::URLRequest::Delegate { |
47 public: | 32 public: |
48 ChromePluginTest() | 33 ChromePluginTest() |
49 : io_thread_(BrowserThread::IO, &message_loop_), | 34 : io_thread_(BrowserThread::IO, &message_loop_), |
50 request_(NULL), | 35 request_(NULL), |
51 response_buffer_(new net::IOBuffer(kResponseBufferSize)), | 36 response_buffer_(new net::IOBuffer(kResponseBufferSize)), |
52 plugin_(NULL), | 37 plugin_(NULL), |
53 expected_payload_(NULL), | 38 expected_payload_(NULL), |
54 request_context_getter_(new TestURLRequestContextGetter()) { | 39 request_context_getter_(new TestURLRequestContextGetter()) { |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 TEST_F(ChromePluginTest, DoesNotInterceptOwnRequest) { | 285 TEST_F(ChromePluginTest, DoesNotInterceptOwnRequest) { |
301 const TestResponsePayload& payload = kChromeTestPluginPayloads[0]; | 286 const TestResponsePayload& payload = kChromeTestPluginPayloads[0]; |
302 | 287 |
303 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( | 288 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( |
304 "GET", GURL(payload.url))); | 289 "GET", GURL(payload.url))); |
305 | 290 |
306 MessageLoop::current()->Run(); | 291 MessageLoop::current()->Run(); |
307 } | 292 } |
308 | 293 |
309 } // namespace | 294 } // namespace |
OLD | NEW |