2d53c2afec2edd14dccafb8432f74cb9a7d987a3
[platform/framework/web/crosswalk.git] / src / content / shell / renderer / test_runner / TestPlugin.cpp
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/shell/renderer/test_runner/TestPlugin.h"
6
7 #include "base/basictypes.h"
8 #include "content/shell/renderer/test_runner/TestCommon.h"
9 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
10 #include "third_party/WebKit/public/platform/Platform.h"
11 #include "third_party/WebKit/public/platform/WebCompositorSupport.h"
12 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
13 #include "third_party/WebKit/public/web/WebFrame.h"
14 #include "third_party/WebKit/public/web/WebInputEvent.h"
15 #include "third_party/WebKit/public/web/WebKit.h"
16 #include "third_party/WebKit/public/web/WebPluginParams.h"
17 #include "third_party/WebKit/public/web/WebTouchPoint.h"
18 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
19
20 using namespace blink;
21 using namespace std;
22
23 namespace WebTestRunner {
24
25 namespace {
26
27 // GLenum values copied from gl2.h.
28 #define GL_FALSE                  0
29 #define GL_TRUE                   1
30 #define GL_ONE                    1
31 #define GL_TRIANGLES              0x0004
32 #define GL_ONE_MINUS_SRC_ALPHA    0x0303
33 #define GL_DEPTH_TEST             0x0B71
34 #define GL_BLEND                  0x0BE2
35 #define GL_SCISSOR_TEST           0x0B90
36 #define GL_TEXTURE_2D             0x0DE1
37 #define GL_FLOAT                  0x1406
38 #define GL_RGBA                   0x1908
39 #define GL_UNSIGNED_BYTE          0x1401
40 #define GL_TEXTURE_MAG_FILTER     0x2800
41 #define GL_TEXTURE_MIN_FILTER     0x2801
42 #define GL_TEXTURE_WRAP_S         0x2802
43 #define GL_TEXTURE_WRAP_T         0x2803
44 #define GL_NEAREST                0x2600
45 #define GL_COLOR_BUFFER_BIT       0x4000
46 #define GL_CLAMP_TO_EDGE          0x812F
47 #define GL_ARRAY_BUFFER           0x8892
48 #define GL_STATIC_DRAW            0x88E4
49 #define GL_FRAGMENT_SHADER        0x8B30
50 #define GL_VERTEX_SHADER          0x8B31
51 #define GL_COMPILE_STATUS         0x8B81
52 #define GL_LINK_STATUS            0x8B82
53 #define GL_COLOR_ATTACHMENT0      0x8CE0
54 #define GL_FRAMEBUFFER_COMPLETE   0x8CD5
55 #define GL_FRAMEBUFFER            0x8D40
56
57 void premultiplyAlpha(const unsigned colorIn[3], float alpha, float colorOut[4])
58 {
59     for (int i = 0; i < 3; ++i)
60         colorOut[i] = (colorIn[i] / 255.0f) * alpha;
61
62     colorOut[3] = alpha;
63 }
64
65 const char* pointState(WebTouchPoint::State state)
66 {
67     switch (state) {
68     case WebTouchPoint::StateReleased:
69         return "Released";
70     case WebTouchPoint::StatePressed:
71         return "Pressed";
72     case WebTouchPoint::StateMoved:
73         return "Moved";
74     case WebTouchPoint::StateCancelled:
75         return "Cancelled";
76     default:
77         return "Unknown";
78     }
79
80     BLINK_ASSERT_NOT_REACHED();
81     return 0;
82 }
83
84 void printTouchList(WebTestDelegate* delegate, const WebTouchPoint* points, int length)
85 {
86     for (int i = 0; i < length; ++i) {
87         char buffer[100];
88         snprintf(buffer, sizeof(buffer), "* %d, %d: %s\n", points[i].position.x, points[i].position.y, pointState(points[i].state));
89         delegate->printMessage(buffer);
90     }
91 }
92
93 void printEventDetails(WebTestDelegate* delegate, const WebInputEvent& event)
94 {
95     if (WebInputEvent::isTouchEventType(event.type)) {
96         const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event);
97         printTouchList(delegate, touch.touches, touch.touchesLength);
98         printTouchList(delegate, touch.changedTouches, touch.changedTouchesLength);
99         printTouchList(delegate, touch.targetTouches, touch.targetTouchesLength);
100     } else if (WebInputEvent::isMouseEventType(event.type) || event.type == WebInputEvent::MouseWheel) {
101         const WebMouseEvent& mouse = static_cast<const WebMouseEvent&>(event);
102         char buffer[100];
103         snprintf(buffer, sizeof(buffer), "* %d, %d\n", mouse.x, mouse.y);
104         delegate->printMessage(buffer);
105     } else if (WebInputEvent::isGestureEventType(event.type)) {
106         const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(event);
107         char buffer[100];
108         snprintf(buffer, sizeof(buffer), "* %d, %d\n", gesture.x, gesture.y);
109         delegate->printMessage(buffer);
110     }
111 }
112
113 WebPluginContainer::TouchEventRequestType parseTouchEventRequestType(const WebString& string)
114 {
115     if (string == WebString::fromUTF8("raw"))
116         return WebPluginContainer::TouchEventRequestTypeRaw;
117     if (string == WebString::fromUTF8("synthetic"))
118         return WebPluginContainer::TouchEventRequestTypeSynthesizedMouse;
119     return WebPluginContainer::TouchEventRequestTypeNone;
120 }
121
122 void deferredDelete(void* context)
123 {
124     TestPlugin* plugin = static_cast<TestPlugin*>(context);
125     delete plugin;
126 }
127
128 }
129
130
131 TestPlugin::TestPlugin(WebFrame* frame, const WebPluginParams& params, WebTestDelegate* delegate)
132     : m_frame(frame)
133     , m_delegate(delegate)
134     , m_container(0)
135     , m_context(0)
136     , m_colorTexture(0)
137     , m_mailboxChanged(false)
138     , m_framebuffer(0)
139     , m_touchEventRequest(WebPluginContainer::TouchEventRequestTypeNone)
140     , m_reRequestTouchEvents(false)
141     , m_printEventDetails(false)
142     , m_printUserGestureStatus(false)
143     , m_canProcessDrag(false)
144 {
145     const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrimitive, ("primitive"));
146     const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeBackgroundColor, ("background-color"));
147     const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrimitiveColor, ("primitive-color"));
148     const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeOpacity, ("opacity"));
149     const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeAcceptsTouch, ("accepts-touch"));
150     const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeReRequestTouchEvents, ("re-request-touch"));
151     const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrintEventDetails, ("print-event-details"));
152     const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeCanProcessDrag, ("can-process-drag"));
153     const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrintUserGestureStatus, ("print-user-gesture-status"));
154
155     BLINK_ASSERT(params.attributeNames.size() == params.attributeValues.size());
156     size_t size = params.attributeNames.size();
157     for (size_t i = 0; i < size; ++i) {
158         const WebString& attributeName = params.attributeNames[i];
159         const WebString& attributeValue = params.attributeValues[i];
160
161         if (attributeName == kAttributePrimitive)
162             m_scene.primitive = parsePrimitive(attributeValue);
163         else if (attributeName == kAttributeBackgroundColor)
164             parseColor(attributeValue, m_scene.backgroundColor);
165         else if (attributeName == kAttributePrimitiveColor)
166             parseColor(attributeValue, m_scene.primitiveColor);
167         else if (attributeName == kAttributeOpacity)
168             m_scene.opacity = parseOpacity(attributeValue);
169         else if (attributeName == kAttributeAcceptsTouch)
170             m_touchEventRequest = parseTouchEventRequestType(attributeValue);
171         else if (attributeName == kAttributeReRequestTouchEvents)
172             m_reRequestTouchEvents = parseBoolean(attributeValue);
173         else if (attributeName == kAttributePrintEventDetails)
174             m_printEventDetails = parseBoolean(attributeValue);
175         else if (attributeName == kAttributeCanProcessDrag)
176             m_canProcessDrag = parseBoolean(attributeValue);
177         else if (attributeName == kAttributePrintUserGestureStatus)
178             m_printUserGestureStatus = parseBoolean(attributeValue);
179     }
180 }
181
182 TestPlugin::~TestPlugin()
183 {
184 }
185
186 bool TestPlugin::initialize(WebPluginContainer* container)
187 {
188     WebGraphicsContext3D::Attributes attrs;
189     m_context = Platform::current()->createOffscreenGraphicsContext3D(attrs);
190     if (!m_context)
191         return false;
192
193     if (!m_context->makeContextCurrent())
194         return false;
195
196     if (!initScene())
197         return false;
198
199     m_layer = scoped_ptr<WebExternalTextureLayer>(Platform::current()->compositorSupport()->createExternalTextureLayer(this));
200     m_container = container;
201     m_container->setWebLayer(m_layer->layer());
202     if (m_reRequestTouchEvents) {
203         m_container->requestTouchEventType(WebPluginContainer::TouchEventRequestTypeSynthesizedMouse);
204         m_container->requestTouchEventType(WebPluginContainer::TouchEventRequestTypeRaw);
205     }
206     m_container->requestTouchEventType(m_touchEventRequest);
207     m_container->setWantsWheelEvents(true);
208     return true;
209 }
210
211 void TestPlugin::destroy()
212 {
213     if (m_layer.get())
214         m_layer->clearTexture();
215     if (m_container)
216         m_container->setWebLayer(0);
217     m_layer.reset();
218     destroyScene();
219
220     delete m_context;
221     m_context = 0;
222
223     m_container = 0;
224     m_frame = 0;
225
226     Platform::current()->callOnMainThread(deferredDelete, this);
227 }
228
229 NPObject* TestPlugin::scriptableObject()
230 {
231     return 0;
232 }
233
234 bool TestPlugin::canProcessDrag() const
235 {
236     return m_canProcessDrag;
237 }
238
239 void TestPlugin::updateGeometry(const WebRect& frameRect, const WebRect& clipRect, const WebVector<WebRect>& cutOutsRects, bool isVisible)
240 {
241     if (clipRect == m_rect)
242         return;
243     m_rect = clipRect;
244     if (m_rect.isEmpty())
245         return;
246
247     m_context->viewport(0, 0, m_rect.width, m_rect.height);
248
249     m_context->bindTexture(GL_TEXTURE_2D, m_colorTexture);
250     m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
251     m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
252     m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
253     m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
254     m_context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_rect.width, m_rect.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
255     m_context->bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
256     m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_colorTexture, 0);
257
258     drawScene();
259
260     m_context->genMailboxCHROMIUM(m_mailbox.name);
261     m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, m_mailbox.name);
262
263     m_context->flush();
264     m_layer->layer()->invalidate();
265     m_mailboxChanged = true;
266 }
267
268 bool TestPlugin::acceptsInputEvents()
269 {
270     return true;
271 }
272
273 bool TestPlugin::isPlaceholder()
274 {
275     return false;
276 }
277
278 blink::WebGraphicsContext3D* TestPlugin::context()
279 {
280     return 0;
281 }
282
283 bool TestPlugin::prepareMailbox(blink::WebExternalTextureMailbox* mailbox, blink::WebExternalBitmap*)
284 {
285     if (!m_mailboxChanged)
286         return false;
287     *mailbox = m_mailbox;
288     m_mailboxChanged = false;
289     return true;
290 }
291
292 void TestPlugin::mailboxReleased(const blink::WebExternalTextureMailbox&)
293 {
294 }
295
296 TestPlugin::Primitive TestPlugin::parsePrimitive(const WebString& string)
297 {
298     const CR_DEFINE_STATIC_LOCAL(WebString, kPrimitiveNone, ("none"));
299     const CR_DEFINE_STATIC_LOCAL(WebString, kPrimitiveTriangle, ("triangle"));
300
301     Primitive primitive = PrimitiveNone;
302     if (string == kPrimitiveNone)
303         primitive = PrimitiveNone;
304     else if (string == kPrimitiveTriangle)
305         primitive = PrimitiveTriangle;
306     else
307         BLINK_ASSERT_NOT_REACHED();
308     return primitive;
309 }
310
311 // FIXME: This method should already exist. Use it.
312 // For now just parse primary colors.
313 void TestPlugin::parseColor(const WebString& string, unsigned color[3])
314 {
315     color[0] = color[1] = color[2] = 0;
316     if (string == "black")
317         return;
318
319     if (string == "red")
320         color[0] = 255;
321     else if (string == "green")
322         color[1] = 255;
323     else if (string == "blue")
324         color[2] = 255;
325     else
326         BLINK_ASSERT_NOT_REACHED();
327 }
328
329 float TestPlugin::parseOpacity(const WebString& string)
330 {
331     return static_cast<float>(atof(string.utf8().data()));
332 }
333
334 bool TestPlugin::parseBoolean(const WebString& string)
335 {
336     const CR_DEFINE_STATIC_LOCAL(WebString, kPrimitiveTrue, ("true"));
337     return string == kPrimitiveTrue;
338 }
339
340 bool TestPlugin::initScene()
341 {
342     float color[4];
343     premultiplyAlpha(m_scene.backgroundColor, m_scene.opacity, color);
344
345     m_colorTexture = m_context->createTexture();
346     m_framebuffer = m_context->createFramebuffer();
347
348     m_context->viewport(0, 0, m_rect.width, m_rect.height);
349     m_context->disable(GL_DEPTH_TEST);
350     m_context->disable(GL_SCISSOR_TEST);
351
352     m_context->clearColor(color[0], color[1], color[2], color[3]);
353
354     m_context->enable(GL_BLEND);
355     m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
356
357     return m_scene.primitive != PrimitiveNone ? initProgram() && initPrimitive() : true;
358 }
359
360 void TestPlugin::drawScene()
361 {
362     m_context->viewport(0, 0, m_rect.width, m_rect.height);
363     m_context->clear(GL_COLOR_BUFFER_BIT);
364
365     if (m_scene.primitive != PrimitiveNone)
366         drawPrimitive();
367 }
368
369 void TestPlugin::destroyScene()
370 {
371     if (m_scene.program) {
372         m_context->deleteProgram(m_scene.program);
373         m_scene.program = 0;
374     }
375     if (m_scene.vbo) {
376         m_context->deleteBuffer(m_scene.vbo);
377         m_scene.vbo = 0;
378     }
379
380     if (m_framebuffer) {
381         m_context->deleteFramebuffer(m_framebuffer);
382         m_framebuffer = 0;
383     }
384
385     if (m_colorTexture) {
386         m_context->deleteTexture(m_colorTexture);
387         m_colorTexture = 0;
388     }
389 }
390
391 bool TestPlugin::initProgram()
392 {
393     const string vertexSource(
394         "attribute vec4 position;  \n"
395         "void main() {             \n"
396         "  gl_Position = position; \n"
397         "}                         \n"
398     );
399
400     const string fragmentSource(
401         "precision mediump float; \n"
402         "uniform vec4 color;      \n"
403         "void main() {            \n"
404         "  gl_FragColor = color;  \n"
405         "}                        \n"
406     );
407
408     m_scene.program = loadProgram(vertexSource, fragmentSource);
409     if (!m_scene.program)
410         return false;
411
412     m_scene.colorLocation = m_context->getUniformLocation(m_scene.program, "color");
413     m_scene.positionLocation = m_context->getAttribLocation(m_scene.program, "position");
414     return true;
415 }
416
417 bool TestPlugin::initPrimitive()
418 {
419     BLINK_ASSERT(m_scene.primitive == PrimitiveTriangle);
420
421     m_scene.vbo = m_context->createBuffer();
422     if (!m_scene.vbo)
423         return false;
424
425     const float vertices[] = {
426         0.0f,  0.8f, 0.0f,
427         -0.8f, -0.8f, 0.0f,
428         0.8f, -0.8f, 0.0f };
429     m_context->bindBuffer(GL_ARRAY_BUFFER, m_scene.vbo);
430     m_context->bufferData(GL_ARRAY_BUFFER, sizeof(vertices), 0, GL_STATIC_DRAW);
431     m_context->bufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
432     return true;
433 }
434
435 void TestPlugin::drawPrimitive()
436 {
437     BLINK_ASSERT(m_scene.primitive == PrimitiveTriangle);
438     BLINK_ASSERT(m_scene.vbo);
439     BLINK_ASSERT(m_scene.program);
440
441     m_context->useProgram(m_scene.program);
442
443     // Bind primitive color.
444     float color[4];
445     premultiplyAlpha(m_scene.primitiveColor, m_scene.opacity, color);
446     m_context->uniform4f(m_scene.colorLocation, color[0], color[1], color[2], color[3]);
447
448     // Bind primitive vertices.
449     m_context->bindBuffer(GL_ARRAY_BUFFER, m_scene.vbo);
450     m_context->enableVertexAttribArray(m_scene.positionLocation);
451     m_context->vertexAttribPointer(m_scene.positionLocation, 3, GL_FLOAT, GL_FALSE, 0, 0);
452     m_context->drawArrays(GL_TRIANGLES, 0, 3);
453 }
454
455 unsigned TestPlugin::loadShader(unsigned type, const string& source)
456 {
457     unsigned shader = m_context->createShader(type);
458     if (shader) {
459         m_context->shaderSource(shader, source.data());
460         m_context->compileShader(shader);
461
462         int compiled = 0;
463         m_context->getShaderiv(shader, GL_COMPILE_STATUS, &compiled);
464         if (!compiled) {
465             m_context->deleteShader(shader);
466             shader = 0;
467         }
468     }
469     return shader;
470 }
471
472 unsigned TestPlugin::loadProgram(const string& vertexSource, const string& fragmentSource)
473 {
474     unsigned vertexShader = loadShader(GL_VERTEX_SHADER, vertexSource);
475     unsigned fragmentShader = loadShader(GL_FRAGMENT_SHADER, fragmentSource);
476     unsigned program = m_context->createProgram();
477     if (vertexShader && fragmentShader && program) {
478         m_context->attachShader(program, vertexShader);
479         m_context->attachShader(program, fragmentShader);
480         m_context->linkProgram(program);
481
482         int linked = 0;
483         m_context->getProgramiv(program, GL_LINK_STATUS, &linked);
484         if (!linked) {
485             m_context->deleteProgram(program);
486             program = 0;
487         }
488     }
489     if (vertexShader)
490         m_context->deleteShader(vertexShader);
491     if (fragmentShader)
492         m_context->deleteShader(fragmentShader);
493
494     return program;
495 }
496
497 bool TestPlugin::handleInputEvent(const WebInputEvent& event, WebCursorInfo& info)
498 {
499     const char* eventName = 0;
500     switch (event.type) {
501     case WebInputEvent::Undefined:           eventName = "unknown"; break;
502
503     case WebInputEvent::MouseDown:           eventName = "MouseDown"; break;
504     case WebInputEvent::MouseUp:             eventName = "MouseUp"; break;
505     case WebInputEvent::MouseMove:           eventName = "MouseMove"; break;
506     case WebInputEvent::MouseEnter:          eventName = "MouseEnter"; break;
507     case WebInputEvent::MouseLeave:          eventName = "MouseLeave"; break;
508     case WebInputEvent::ContextMenu:         eventName = "ContextMenu"; break;
509
510     case WebInputEvent::MouseWheel:          eventName = "MouseWheel"; break;
511
512     case WebInputEvent::RawKeyDown:          eventName = "RawKeyDown"; break;
513     case WebInputEvent::KeyDown:             eventName = "KeyDown"; break;
514     case WebInputEvent::KeyUp:               eventName = "KeyUp"; break;
515     case WebInputEvent::Char:                eventName = "Char"; break;
516
517     case WebInputEvent::GestureScrollBegin:  eventName = "GestureScrollBegin"; break;
518     case WebInputEvent::GestureScrollEnd:    eventName = "GestureScrollEnd"; break;
519     case WebInputEvent::GestureScrollUpdateWithoutPropagation:
520     case WebInputEvent::GestureScrollUpdate: eventName = "GestureScrollUpdate"; break;
521     case WebInputEvent::GestureFlingStart:   eventName = "GestureFlingStart"; break;
522     case WebInputEvent::GestureFlingCancel:  eventName = "GestureFlingCancel"; break;
523     case WebInputEvent::GestureTap:          eventName = "GestureTap"; break;
524     case WebInputEvent::GestureTapUnconfirmed:
525                                              eventName = "GestureTapUnconfirmed"; break;
526     case WebInputEvent::GestureTapDown:      eventName = "GestureTapDown"; break;
527     case WebInputEvent::GestureShowPress:    eventName = "GestureShowPress"; break;
528     case WebInputEvent::GestureTapCancel:    eventName = "GestureTapCancel"; break;
529     case WebInputEvent::GestureDoubleTap:    eventName = "GestureDoubleTap"; break;
530     case WebInputEvent::GestureTwoFingerTap: eventName = "GestureTwoFingerTap"; break;
531     case WebInputEvent::GestureLongPress:    eventName = "GestureLongPress"; break;
532     case WebInputEvent::GestureLongTap:      eventName = "GestureLongTap"; break;
533     case WebInputEvent::GesturePinchBegin:   eventName = "GesturePinchBegin"; break;
534     case WebInputEvent::GesturePinchEnd:     eventName = "GesturePinchEnd"; break;
535     case WebInputEvent::GesturePinchUpdate:  eventName = "GesturePinchUpdate"; break;
536
537     case WebInputEvent::TouchStart:          eventName = "TouchStart"; break;
538     case WebInputEvent::TouchMove:           eventName = "TouchMove"; break;
539     case WebInputEvent::TouchEnd:            eventName = "TouchEnd"; break;
540     case WebInputEvent::TouchCancel:         eventName = "TouchCancel"; break;
541     }
542
543     m_delegate->printMessage(std::string("Plugin received event: ") + (eventName ? eventName : "unknown") + "\n");
544     if (m_printEventDetails)
545         printEventDetails(m_delegate, event);
546     if (m_printUserGestureStatus)
547         m_delegate->printMessage(std::string("* ") + (WebUserGestureIndicator::isProcessingUserGesture() ? "" : "not ") + "handling user gesture\n");
548     return false;
549 }
550
551 bool TestPlugin::handleDragStatusUpdate(WebDragStatus dragStatus, const WebDragData&, WebDragOperationsMask, const WebPoint& position, const WebPoint& screenPosition)
552 {
553     const char* dragStatusName = 0;
554     switch (dragStatus) {
555     case WebDragStatusEnter:
556         dragStatusName = "DragEnter";
557         break;
558     case WebDragStatusOver:
559         dragStatusName = "DragOver";
560         break;
561     case WebDragStatusLeave:
562         dragStatusName = "DragLeave";
563         break;
564     case WebDragStatusDrop:
565         dragStatusName = "DragDrop";
566         break;
567     case WebDragStatusUnknown:
568         BLINK_ASSERT_NOT_REACHED();
569     }
570     m_delegate->printMessage(std::string("Plugin received event: ") + dragStatusName + "\n");
571     return false;
572 }
573
574 TestPlugin* TestPlugin::create(WebFrame* frame, const WebPluginParams& params, WebTestDelegate* delegate)
575 {
576     return new TestPlugin(frame, params, delegate);
577 }
578
579 const WebString& TestPlugin::mimeType()
580 {
581     const CR_DEFINE_STATIC_LOCAL(WebString, kMimeType, ("application/x-webkit-test-webplugin"));
582     return kMimeType;
583 }
584
585 }