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/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/chrome_plugin_host.h" | 10 #include "chrome/browser/chrome_plugin_host.h" |
11 #include "chrome/browser/chrome_thread.h" | 11 #include "chrome/browser/chrome_thread.h" |
12 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/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 "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
17 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
18 #include "net/url_request/url_request_test_job.h" | 18 #include "net/url_request/url_request_test_job.h" |
19 #include "net/url_request/url_request_unittest.h" | 19 #include "net/url_request/url_request_unittest.h" |
| 20 #include "net/test/test_server.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 const wchar_t kDocRoot[] = L"chrome/test/data"; | 25 const wchar_t kDocRoot[] = L"chrome/test/data"; |
25 const char kPluginFilename[] = "test_chrome_plugin.dll"; | 26 const char kPluginFilename[] = "test_chrome_plugin.dll"; |
26 const int kResponseBufferSize = 4096; | 27 const int kResponseBufferSize = 4096; |
27 | 28 |
28 class TestURLRequestContextGetter : public URLRequestContextGetter { | 29 class TestURLRequestContextGetter : public URLRequestContextGetter { |
29 public: | 30 public: |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 272 |
272 // Note: we must add this task after we make the request, so that | 273 // Note: we must add this task after we make the request, so that |
273 // URLRequestTestJob's StartAsync task is added and run first. | 274 // URLRequestTestJob's StartAsync task is added and run first. |
274 MessageLoop::current()->PostTask(FROM_HERE, | 275 MessageLoop::current()->PostTask(FROM_HERE, |
275 NewRunnableFunction(&ProcessAllPendingMessages)); | 276 NewRunnableFunction(&ProcessAllPendingMessages)); |
276 MessageLoop::current()->Run(); | 277 MessageLoop::current()->Run(); |
277 } | 278 } |
278 | 279 |
279 // Tests that the plugin can issue a POST request. | 280 // Tests that the plugin can issue a POST request. |
280 TEST_F(ChromePluginTest, CanMakePOSTRequest) { | 281 TEST_F(ChromePluginTest, CanMakePOSTRequest) { |
281 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); | 282 scoped_refptr<net::HTTPTestServer> server( |
| 283 net::HTTPTestServer::CreateServer(kDocRoot)); |
282 ASSERT_TRUE(NULL != server.get()); | 284 ASSERT_TRUE(NULL != server.get()); |
283 | 285 |
284 GURL url = server->TestServerPage("echo"); | 286 GURL url = server->TestServerPage("echo"); |
285 | 287 |
286 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request("POST", url)); | 288 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request("POST", url)); |
287 | 289 |
288 // Note: we must add this task after we make the request, so that | 290 // Note: we must add this task after we make the request, so that |
289 // URLRequestTestJob's StartAsync task is added and run first. | 291 // URLRequestTestJob's StartAsync task is added and run first. |
290 MessageLoop::current()->PostTask(FROM_HERE, | 292 MessageLoop::current()->PostTask(FROM_HERE, |
291 NewRunnableFunction(&ProcessAllPendingMessages)); | 293 NewRunnableFunction(&ProcessAllPendingMessages)); |
292 MessageLoop::current()->Run(); | 294 MessageLoop::current()->Run(); |
293 } | 295 } |
294 | 296 |
295 // Tests that the plugin does not intercept its own requests. | 297 // Tests that the plugin does not intercept its own requests. |
296 TEST_F(ChromePluginTest, DoesNotInterceptOwnRequest) { | 298 TEST_F(ChromePluginTest, DoesNotInterceptOwnRequest) { |
297 const TestResponsePayload& payload = kChromeTestPluginPayloads[0]; | 299 const TestResponsePayload& payload = kChromeTestPluginPayloads[0]; |
298 | 300 |
299 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( | 301 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( |
300 "GET", GURL(payload.url))); | 302 "GET", GURL(payload.url))); |
301 | 303 |
302 MessageLoop::current()->Run(); | 304 MessageLoop::current()->Run(); |
303 } | 305 } |
304 | 306 |
305 } // namespace | 307 } // namespace |
OLD | NEW |