Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: webkit/glue/plugins/test/plugin_client.cc

Issue 1073003: Added a test for pepper3d. It ensures that we can successfully load a pepper ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #if defined(OS_WIN) 5 #include "webkit/glue/plugins/test/plugin_client.h"
6 #include <windows.h>
7 #endif
8 6
9 #include "base/string_util.h" 7 #include "base/string_util.h"
10 #include "webkit/glue/plugins/test/plugin_client.h" 8 #include "webkit/glue/plugins/test/plugin_test.h"
11 #include "webkit/glue/plugins/test/plugin_arguments_test.h" 9 #include "webkit/glue/plugins/test/plugin_test_factory.h"
12 #include "webkit/glue/plugins/test/plugin_delete_plugin_in_stream_test.h"
13 #include "webkit/glue/plugins/test/plugin_get_javascript_url_test.h"
14 #include "webkit/glue/plugins/test/plugin_get_javascript_url2_test.h"
15 #include "webkit/glue/plugins/test/plugin_geturl_test.h"
16 #include "webkit/glue/plugins/test/plugin_javascript_open_popup.h"
17 #include "webkit/glue/plugins/test/plugin_new_fails_test.h"
18 #include "webkit/glue/plugins/test/plugin_private_test.h"
19 #include "webkit/glue/plugins/test/plugin_schedule_timer_test.h"
20 #include "webkit/glue/plugins/test/plugin_thread_async_call_test.h"
21 #include "webkit/glue/plugins/test/plugin_npobject_lifetime_test.h"
22 #include "webkit/glue/plugins/test/plugin_npobject_proxy_test.h"
23 #include "webkit/glue/plugins/test/plugin_window_size_test.h"
24 #if defined(OS_WIN)
25 #include "webkit/glue/plugins/test/plugin_windowed_test.h"
26 #endif
27 #include "webkit/glue/plugins/test/plugin_windowless_test.h"
28 #include "third_party/npapi/bindings/npapi.h"
29 #include "third_party/npapi/bindings/npruntime.h"
30 10
31 namespace NPAPIClient { 11 namespace NPAPIClient {
32 12
33 NPNetscapeFuncs* PluginClient::host_functions_; 13 NPNetscapeFuncs* PluginClient::host_functions_;
34 14
35 NPError PluginClient::GetEntryPoints(NPPluginFuncs* pFuncs) { 15 NPError PluginClient::GetEntryPoints(NPPluginFuncs* pFuncs) {
36 if (pFuncs == NULL) 16 if (pFuncs == NULL)
37 return NPERR_INVALID_FUNCTABLE_ERROR; 17 return NPERR_INVALID_FUNCTABLE_ERROR;
38 18
39 if (pFuncs->size < sizeof(NPPluginFuncs)) 19 if (pFuncs->size < sizeof(NPPluginFuncs))
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, 73 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode,
94 int16 argc, char* argn[], char* argv[], NPSavedData* saved) { 74 int16 argc, char* argn[], char* argv[], NPSavedData* saved) {
95 if (instance == NULL) 75 if (instance == NULL)
96 return NPERR_INVALID_INSTANCE_ERROR; 76 return NPERR_INVALID_INSTANCE_ERROR;
97 77
98 // We look at the test name requested via the plugin arguments. We match 78 // We look at the test name requested via the plugin arguments. We match
99 // that against a given test and try to instantiate it. 79 // that against a given test and try to instantiate it.
100 80
101 // lookup the name parameter 81 // lookup the name parameter
102 std::string test_name; 82 std::string test_name;
103 for (int name_index = 0; name_index < argc; name_index++) 83 for (int name_index = 0; name_index < argc; name_index++) {
104 if (base::strcasecmp(argn[name_index], "name") == 0) { 84 if (base::strcasecmp(argn[name_index], "name") == 0) {
105 test_name = argv[name_index]; 85 test_name = argv[name_index];
106 break; 86 break;
107 } 87 }
108 88 }
109 if (test_name.empty()) 89 if (test_name.empty())
110 return NPERR_GENERIC_ERROR; // no name found 90 return NPERR_GENERIC_ERROR; // no name found
111 91
112 NPError ret = NPERR_GENERIC_ERROR; 92 NPAPIClient::PluginTest* new_test = NPAPIClient::CreatePluginTest(test_name,
113 bool windowless_plugin = false; 93 instance, NPAPIClient::PluginClient::HostFunctions());
114 94 if (new_test == NULL) {
115 NPAPIClient::PluginTest *new_test = NULL;
116 if (test_name == "arguments") {
117 new_test = new NPAPIClient::PluginArgumentsTest(instance,
118 NPAPIClient::PluginClient::HostFunctions());
119 } else if (test_name == "geturl" || test_name == "geturl_404_response" ||
120 test_name == "geturl_fail_write" ||
121 test_name == "plugin_referrer_test") {
122 new_test = new NPAPIClient::PluginGetURLTest(instance,
123 NPAPIClient::PluginClient::HostFunctions());
124 } else if (test_name == "npobject_proxy") {
125 new_test = new NPAPIClient::NPObjectProxyTest(instance,
126 NPAPIClient::PluginClient::HostFunctions());
127 #if defined(OS_WIN) || defined(OS_MACOSX)
128 // TODO(port): plugin_windowless_test.*.
129 } else if (test_name == "execute_script_delete_in_paint" ||
130 test_name == "execute_script_delete_in_mouse_move" ||
131 test_name == "delete_frame_test" ||
132 test_name == "multiple_instances_sync_calls" ||
133 test_name == "no_hang_if_init_crashes" ||
134 test_name == "convert_point") {
135 new_test = new NPAPIClient::WindowlessPluginTest(instance,
136 NPAPIClient::PluginClient::HostFunctions(), test_name);
137 windowless_plugin = true;
138 #endif
139 } else if (test_name == "getjavascripturl") {
140 new_test = new NPAPIClient::ExecuteGetJavascriptUrlTest(instance,
141 NPAPIClient::PluginClient::HostFunctions());
142 } else if (test_name == "getjavascripturl2") {
143 new_test = new NPAPIClient::ExecuteGetJavascriptUrl2Test(instance,
144 NPAPIClient::PluginClient::HostFunctions());
145 #if defined(OS_WIN)
146 // TODO(port): plugin_window_size_test.*.
147 } else if (test_name == "checkwindowrect") {
148 new_test = new NPAPIClient::PluginWindowSizeTest(instance,
149 NPAPIClient::PluginClient::HostFunctions());
150 #endif
151 } else if (test_name == "self_delete_plugin_stream") {
152 new_test = new NPAPIClient::DeletePluginInStreamTest(instance,
153 NPAPIClient::PluginClient::HostFunctions());
154 #if defined(OS_WIN)
155 // TODO(port): plugin_npobject_lifetime_test.*.
156 } else if (test_name == "npobject_lifetime_test") {
157 new_test = new NPAPIClient::NPObjectLifetimeTest(instance,
158 NPAPIClient::PluginClient::HostFunctions());
159 } else if (test_name == "npobject_lifetime_test_second_instance") {
160 new_test = new NPAPIClient::NPObjectLifetimeTestInstance2(instance,
161 NPAPIClient::PluginClient::HostFunctions());
162 } else if (test_name == "new_fails") {
163 new_test = new NPAPIClient::NewFailsTest(instance,
164 NPAPIClient::PluginClient::HostFunctions());
165 } else if (test_name == "npobject_delete_plugin_in_evaluate") {
166 new_test = new NPAPIClient::NPObjectDeletePluginInNPN_Evaluate(instance,
167 NPAPIClient::PluginClient::HostFunctions());
168 #endif
169 } else if (test_name == "plugin_javascript_open_popup_with_plugin") {
170 new_test = new NPAPIClient::ExecuteJavascriptOpenPopupWithPluginTest(
171 instance, NPAPIClient::PluginClient::HostFunctions());
172 } else if (test_name == "plugin_popup_with_plugin_target") {
173 new_test = new NPAPIClient::ExecuteJavascriptPopupWindowTargetPluginTest(
174 instance, NPAPIClient::PluginClient::HostFunctions());
175 } else if (test_name == "plugin_thread_async_call") {
176 new_test = new NPAPIClient::PluginThreadAsyncCallTest(
177 instance, NPAPIClient::PluginClient::HostFunctions());
178 } else if (test_name == "private") {
179 new_test = new NPAPIClient::PrivateTest(instance,
180 NPAPIClient::PluginClient::HostFunctions());
181 } else if (test_name == "schedule_timer") {
182 new_test = new NPAPIClient::ScheduleTimerTest(
183 instance, NPAPIClient::PluginClient::HostFunctions());
184 #if defined(OS_WIN)
185 // TODO(port): plugin_windowed_test.*.
186 } else if (test_name == "hidden_plugin" ||
187 test_name == "create_instance_in_paint" ||
188 test_name == "alert_in_window_message" ||
189 test_name == "ensure_scripting_works_in_destroy") {
190 new_test = new NPAPIClient::WindowedPluginTest(instance,
191 NPAPIClient::PluginClient::HostFunctions());
192 #endif
193 } else {
194 // If we don't have a test case for this, create a 95 // If we don't have a test case for this, create a
195 // generic one which basically never fails. 96 // generic one which basically never fails.
196 LOG(WARNING) << "Unknown test name '" << test_name 97 LOG(WARNING) << "Unknown test name '" << test_name
197 << "'; using default test."; 98 << "'; using default test.";
198 new_test = new NPAPIClient::PluginTest(instance, 99 new_test = new NPAPIClient::PluginTest(instance,
199 NPAPIClient::PluginClient::HostFunctions()); 100 NPAPIClient::PluginClient::HostFunctions());
200 } 101 }
201 102
202 if (new_test) { 103 NPError ret = new_test->New(mode, argc, (const char**)argn,
203 ret = new_test->New(mode, argc, (const char**)argn, 104 (const char**)argv, saved);
204 (const char**)argv, saved); 105 if ((ret == NPERR_NO_ERROR) && new_test->IsWindowless()) {
205 if ((ret == NPERR_NO_ERROR) && windowless_plugin) { 106 NPAPIClient::PluginClient::HostFunctions()->setvalue(
206 NPAPIClient::PluginClient::HostFunctions()->setvalue( 107 instance, NPPVpluginWindowBool, NULL);
207 instance, NPPVpluginWindowBool, NULL);
208 }
209 } 108 }
210 109
211 return ret; 110 return ret;
212 } 111 }
213 112
214 NPError NPP_Destroy(NPP instance, NPSavedData** save) { 113 NPError NPP_Destroy(NPP instance, NPSavedData** save) {
215 if (instance == NULL) 114 if (instance == NULL)
216 return NPERR_INVALID_INSTANCE_ERROR; 115 return NPERR_INVALID_INSTANCE_ERROR;
217 116
218 NPAPIClient::PluginTest *plugin = 117 NPAPIClient::PluginTest *plugin =
219 (NPAPIClient::PluginTest*)instance->pdata; 118 (NPAPIClient::PluginTest*)instance->pdata;
220 119
221 NPError rv = plugin->Destroy(); 120 NPError rv = plugin->Destroy();
222 delete plugin; 121 delete plugin;
223 return rv; 122 return rv;
224 } 123 }
225 124
226 NPError NPP_SetWindow(NPP instance, NPWindow* pNPWindow) { 125 NPError NPP_SetWindow(NPP instance, NPWindow* pNPWindow) {
227 if (instance == NULL) 126 if (instance == NULL)
228 return NPERR_INVALID_INSTANCE_ERROR; 127 return NPERR_INVALID_INSTANCE_ERROR;
229 128
230 if (pNPWindow->window == NULL) {
231 return NPERR_NO_ERROR;
232 }
233
234 NPAPIClient::PluginTest *plugin = 129 NPAPIClient::PluginTest *plugin =
235 (NPAPIClient::PluginTest*)instance->pdata; 130 (NPAPIClient::PluginTest*)instance->pdata;
236 131
237 return plugin->SetWindow(pNPWindow); 132 return plugin->SetWindow(pNPWindow);
238 } 133 }
239 134
240 NPError NPP_NewStream(NPP instance, NPMIMEType type, 135 NPError NPP_NewStream(NPP instance, NPMIMEType type,
241 NPStream* stream, NPBool seekable, uint16* stype) { 136 NPStream* stream, NPBool seekable, uint16* stype) {
242 if (instance == NULL) 137 if (instance == NULL)
243 return NPERR_INVALID_INSTANCE_ERROR; 138 return NPERR_INVALID_INSTANCE_ERROR;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 (NPAPIClient::PluginTest*)instance->pdata; 226 (NPAPIClient::PluginTest*)instance->pdata;
332 227
333 return plugin->HandleEvent(event); 228 return plugin->HandleEvent(event);
334 } 229 }
335 230
336 void* NPP_GetJavaClass(void) { 231 void* NPP_GetJavaClass(void) {
337 // XXXMB - do work here. 232 // XXXMB - do work here.
338 return NULL; 233 return NULL;
339 } 234 }
340 } // extern "C" 235 } // extern "C"
OLDNEW
« no previous file with comments | « webkit/glue/plugins/test/npapi_test.rc ('k') | webkit/glue/plugins/test/plugin_create_instance_in_paint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698