| 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/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/chrome_plugin_host.h" | 9 #include "chrome/browser/chrome_plugin_host.h" |
| 10 #include "chrome/browser/net/url_fetcher.h" | 10 #include "chrome/browser/net/url_fetcher.h" |
| 11 #include "chrome/browser/profile.h" | 11 #include "chrome/browser/profile.h" |
| 12 #include "chrome/common/chrome_plugin_lib.h" | 12 #include "chrome/common/chrome_plugin_lib.h" |
| 13 #include "chrome/test/chrome_plugin/test_chrome_plugin.h" | 13 #include "chrome/test/chrome_plugin/test_chrome_plugin.h" |
| 14 #include "net/url_request/url_request_test_job.h" | 14 #include "net/url_request/url_request_test_job.h" |
| 15 #include "net/url_request/url_request_unittest.h" | 15 #include "net/url_request/url_request_unittest.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 |
| 19 const wchar_t kDocRoot[] = L"chrome/test/data"; | 20 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 20 const FilePath::CharType kPluginFilename[] = | 21 const char kPluginFilename[] = "test_chrome_plugin.dll"; |
| 21 FILE_PATH_LITERAL("test_chrome_plugin.dll"); | |
| 22 | 22 |
| 23 class ChromePluginTest : public testing::Test, public URLRequest::Delegate { | 23 class ChromePluginTest : public testing::Test, public URLRequest::Delegate { |
| 24 public: | 24 public: |
| 25 ChromePluginTest() | 25 ChromePluginTest() |
| 26 : request_(NULL), | 26 : request_(NULL), |
| 27 plugin_(NULL), | 27 plugin_(NULL), |
| 28 expected_payload_(NULL), | 28 expected_payload_(NULL), |
| 29 request_context_(new TestURLRequestContext()) { | 29 request_context_(new TestURLRequestContext()) { |
| 30 } | 30 } |
| 31 | 31 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 static void STDCALL CPT_InvokeLater(TestFuncParams::CallbackFunc callback, | 114 static void STDCALL CPT_InvokeLater(TestFuncParams::CallbackFunc callback, |
| 115 void* callback_data, int delay_ms) { | 115 void* callback_data, int delay_ms) { |
| 116 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 116 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 117 NewRunnableFunction(callback, callback_data), delay_ms); | 117 NewRunnableFunction(callback, callback_data), delay_ms); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void ChromePluginTest::LoadPlugin() { | 120 void ChromePluginTest::LoadPlugin() { |
| 121 FilePath path; | 121 FilePath path; |
| 122 PathService::Get(base::DIR_EXE, &path); | 122 PathService::Get(base::DIR_EXE, &path); |
| 123 path = path.Append(kPluginFilename); | 123 path = path.AppendASCII(kPluginFilename); |
| 124 plugin_ = ChromePluginLib::Create(path, GetCPBrowserFuncsForBrowser()); | 124 plugin_ = ChromePluginLib::Create(path, GetCPBrowserFuncsForBrowser()); |
| 125 | 125 |
| 126 // Exchange test APIs with the plugin. | 126 // Exchange test APIs with the plugin. |
| 127 TestFuncParams params; | 127 TestFuncParams params; |
| 128 params.bfuncs.test_complete = CPT_Complete; | 128 params.bfuncs.test_complete = CPT_Complete; |
| 129 params.bfuncs.invoke_later = CPT_InvokeLater; | 129 params.bfuncs.invoke_later = CPT_InvokeLater; |
| 130 EXPECT_EQ(CPERR_SUCCESS, plugin_->CP_Test(¶ms)); | 130 EXPECT_EQ(CPERR_SUCCESS, plugin_->CP_Test(¶ms)); |
| 131 test_funcs_ = params.pfuncs; | 131 test_funcs_ = params.pfuncs; |
| 132 | 132 |
| 133 EXPECT_TRUE(plugin_); | 133 EXPECT_TRUE(plugin_); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // Tests that the plugin does not intercept its own requests. | 277 // Tests that the plugin does not intercept its own requests. |
| 278 TEST_F(ChromePluginTest, DoesNotInterceptOwnRequest) { | 278 TEST_F(ChromePluginTest, DoesNotInterceptOwnRequest) { |
| 279 const TestResponsePayload& payload = kChromeTestPluginPayloads[0]; | 279 const TestResponsePayload& payload = kChromeTestPluginPayloads[0]; |
| 280 | 280 |
| 281 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( | 281 EXPECT_EQ(CPERR_SUCCESS, test_funcs_.test_make_request( |
| 282 "GET", GURL(payload.url))); | 282 "GET", GURL(payload.url))); |
| 283 | 283 |
| 284 MessageLoop::current()->Run(); | 284 MessageLoop::current()->Run(); |
| 285 } | 285 } |
| 286 | 286 |
| OLD | NEW |