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

Side by Side Diff: content/test/layout_tests/runner/TestPlugin.cpp

Issue 110533009: Import TestRunner library into chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years 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
(Empty)
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 /*
6 * Copyright (C) 2011 Google Inc. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #include "content/test/layout_tests/runner/TestPlugin.h"
31
32 #include "content/test/layout_tests/runner/TestCommon.h"
33 #include "third_party/WebKit/public/platform/Platform.h"
34 #include "third_party/WebKit/public/platform/WebCompositorSupport.h"
35 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
36 #include "content/public/test/layout_tests/WebTestDelegate.h"
37 #include "third_party/WebKit/public/web/WebFrame.h"
38 #include "third_party/WebKit/public/web/WebInputEvent.h"
39 #include "third_party/WebKit/public/web/WebKit.h"
40 #include "third_party/WebKit/public/web/WebPluginParams.h"
41 #include "third_party/WebKit/public/web/WebTouchPoint.h"
42 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
43
44 using namespace blink;
45 using namespace std;
46
47 namespace WebTestRunner {
48
49 namespace {
50
51 // GLenum values copied from gl2.h.
52 #define GL_FALSE 0
53 #define GL_TRUE 1
54 #define GL_ONE 1
55 #define GL_TRIANGLES 0x0004
56 #define GL_ONE_MINUS_SRC_ALPHA 0x0303
57 #define GL_DEPTH_TEST 0x0B71
58 #define GL_BLEND 0x0BE2
59 #define GL_SCISSOR_TEST 0x0B90
60 #define GL_TEXTURE_2D 0x0DE1
61 #define GL_FLOAT 0x1406
62 #define GL_RGBA 0x1908
63 #define GL_UNSIGNED_BYTE 0x1401
64 #define GL_TEXTURE_MAG_FILTER 0x2800
65 #define GL_TEXTURE_MIN_FILTER 0x2801
66 #define GL_TEXTURE_WRAP_S 0x2802
67 #define GL_TEXTURE_WRAP_T 0x2803
68 #define GL_NEAREST 0x2600
69 #define GL_COLOR_BUFFER_BIT 0x4000
70 #define GL_CLAMP_TO_EDGE 0x812F
71 #define GL_ARRAY_BUFFER 0x8892
72 #define GL_STATIC_DRAW 0x88E4
73 #define GL_FRAGMENT_SHADER 0x8B30
74 #define GL_VERTEX_SHADER 0x8B31
75 #define GL_COMPILE_STATUS 0x8B81
76 #define GL_LINK_STATUS 0x8B82
77 #define GL_COLOR_ATTACHMENT0 0x8CE0
78 #define GL_FRAMEBUFFER_COMPLETE 0x8CD5
79 #define GL_FRAMEBUFFER 0x8D40
80
81 void premultiplyAlpha(const unsigned colorIn[3], float alpha, float colorOut[4])
82 {
83 for (int i = 0; i < 3; ++i)
84 colorOut[i] = (colorIn[i] / 255.0f) * alpha;
85
86 colorOut[3] = alpha;
87 }
88
89 const char* pointState(WebTouchPoint::State state)
90 {
91 switch (state) {
92 case WebTouchPoint::StateReleased:
93 return "Released";
94 case WebTouchPoint::StatePressed:
95 return "Pressed";
96 case WebTouchPoint::StateMoved:
97 return "Moved";
98 case WebTouchPoint::StateCancelled:
99 return "Cancelled";
100 default:
101 return "Unknown";
102 }
103
104 BLINK_ASSERT_NOT_REACHED();
105 return 0;
106 }
107
108 void printTouchList(WebTestDelegate* delegate, const WebTouchPoint* points, int length)
109 {
110 for (int i = 0; i < length; ++i) {
111 char buffer[100];
112 snprintf(buffer, sizeof(buffer), "* %d, %d: %s\n", points[i].position.x, points[i].position.y, pointState(points[i].state));
113 delegate->printMessage(buffer);
114 }
115 }
116
117 void printEventDetails(WebTestDelegate* delegate, const WebInputEvent& event)
118 {
119 if (WebInputEvent::isTouchEventType(event.type)) {
120 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event);
121 printTouchList(delegate, touch.touches, touch.touchesLength);
122 printTouchList(delegate, touch.changedTouches, touch.changedTouchesLengt h);
123 printTouchList(delegate, touch.targetTouches, touch.targetTouchesLength) ;
124 } else if (WebInputEvent::isMouseEventType(event.type) || event.type == WebI nputEvent::MouseWheel) {
125 const WebMouseEvent& mouse = static_cast<const WebMouseEvent&>(event);
126 char buffer[100];
127 snprintf(buffer, sizeof(buffer), "* %d, %d\n", mouse.x, mouse.y);
128 delegate->printMessage(buffer);
129 } else if (WebInputEvent::isGestureEventType(event.type)) {
130 const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(eve nt);
131 char buffer[100];
132 snprintf(buffer, sizeof(buffer), "* %d, %d\n", gesture.x, gesture.y);
133 delegate->printMessage(buffer);
134 }
135 }
136
137 WebPluginContainer::TouchEventRequestType parseTouchEventRequestType(const WebSt ring& string)
138 {
139 if (string == WebString::fromUTF8("raw"))
140 return WebPluginContainer::TouchEventRequestTypeRaw;
141 if (string == WebString::fromUTF8("synthetic"))
142 return WebPluginContainer::TouchEventRequestTypeSynthesizedMouse;
143 return WebPluginContainer::TouchEventRequestTypeNone;
144 }
145
146 void deferredDelete(void* context)
147 {
148 TestPlugin* plugin = static_cast<TestPlugin*>(context);
149 delete plugin;
150 }
151
152 }
153
154
155 TestPlugin::TestPlugin(WebFrame* frame, const WebPluginParams& params, WebTestDe legate* delegate)
156 : m_frame(frame)
157 , m_delegate(delegate)
158 , m_container(0)
159 , m_context(0)
160 , m_colorTexture(0)
161 , m_mailboxChanged(false)
162 , m_framebuffer(0)
163 , m_touchEventRequest(WebPluginContainer::TouchEventRequestTypeNone)
164 , m_reRequestTouchEvents(false)
165 , m_printEventDetails(false)
166 , m_printUserGestureStatus(false)
167 , m_canProcessDrag(false)
168 {
169 static const WebString kAttributePrimitive = WebString::fromUTF8("primitive" );
170 static const WebString kAttributeBackgroundColor = WebString::fromUTF8("back ground-color");
171 static const WebString kAttributePrimitiveColor = WebString::fromUTF8("primi tive-color");
172 static const WebString kAttributeOpacity = WebString::fromUTF8("opacity");
173 static const WebString kAttributeAcceptsTouch = WebString::fromUTF8("accepts -touch");
174 static const WebString kAttributeReRequestTouchEvents = WebString::fromUTF8( "re-request-touch");
175 static const WebString kAttributePrintEventDetails = WebString::fromUTF8("pr int-event-details");
176 static const WebString kAttributeCanProcessDrag = WebString::fromUTF8("can-p rocess-drag");
177 static const WebString kAttributePrintUserGestureStatus = WebString::fromUTF 8("print-user-gesture-status");
178
179 BLINK_ASSERT(params.attributeNames.size() == params.attributeValues.size());
180 size_t size = params.attributeNames.size();
181 for (size_t i = 0; i < size; ++i) {
182 const WebString& attributeName = params.attributeNames[i];
183 const WebString& attributeValue = params.attributeValues[i];
184
185 if (attributeName == kAttributePrimitive)
186 m_scene.primitive = parsePrimitive(attributeValue);
187 else if (attributeName == kAttributeBackgroundColor)
188 parseColor(attributeValue, m_scene.backgroundColor);
189 else if (attributeName == kAttributePrimitiveColor)
190 parseColor(attributeValue, m_scene.primitiveColor);
191 else if (attributeName == kAttributeOpacity)
192 m_scene.opacity = parseOpacity(attributeValue);
193 else if (attributeName == kAttributeAcceptsTouch)
194 m_touchEventRequest = parseTouchEventRequestType(attributeValue);
195 else if (attributeName == kAttributeReRequestTouchEvents)
196 m_reRequestTouchEvents = parseBoolean(attributeValue);
197 else if (attributeName == kAttributePrintEventDetails)
198 m_printEventDetails = parseBoolean(attributeValue);
199 else if (attributeName == kAttributeCanProcessDrag)
200 m_canProcessDrag = parseBoolean(attributeValue);
201 else if (attributeName == kAttributePrintUserGestureStatus)
202 m_printUserGestureStatus = parseBoolean(attributeValue);
203 }
204 }
205
206 TestPlugin::~TestPlugin()
207 {
208 }
209
210 bool TestPlugin::initialize(WebPluginContainer* container)
211 {
212 WebGraphicsContext3D::Attributes attrs;
213 m_context = Platform::current()->createOffscreenGraphicsContext3D(attrs);
214 if (!m_context)
215 return false;
216
217 if (!m_context->makeContextCurrent())
218 return false;
219
220 if (!initScene())
221 return false;
222
223 m_layer = WebScopedPtr<WebExternalTextureLayer>(Platform::current()->composi torSupport()->createExternalTextureLayer(this));
224 m_container = container;
225 m_container->setWebLayer(m_layer->layer());
226 if (m_reRequestTouchEvents) {
227 m_container->requestTouchEventType(WebPluginContainer::TouchEventRequest TypeSynthesizedMouse);
228 m_container->requestTouchEventType(WebPluginContainer::TouchEventRequest TypeRaw);
229 }
230 m_container->requestTouchEventType(m_touchEventRequest);
231 m_container->setWantsWheelEvents(true);
232 return true;
233 }
234
235 void TestPlugin::destroy()
236 {
237 if (m_layer.get())
238 m_layer->clearTexture();
239 if (m_container)
240 m_container->setWebLayer(0);
241 m_layer.reset();
242 destroyScene();
243
244 delete m_context;
245 m_context = 0;
246
247 m_container = 0;
248 m_frame = 0;
249
250 Platform::current()->callOnMainThread(deferredDelete, this);
251 }
252
253 void TestPlugin::updateGeometry(const WebRect& frameRect, const WebRect& clipRec t, const WebVector<WebRect>& cutOutsRects, bool isVisible)
254 {
255 if (clipRect == m_rect)
256 return;
257 m_rect = clipRect;
258 if (m_rect.isEmpty())
259 return;
260
261 m_context->reshapeWithScaleFactor(m_rect.width, m_rect.height, 1.f);
262 m_context->viewport(0, 0, m_rect.width, m_rect.height);
263
264 m_context->bindTexture(GL_TEXTURE_2D, m_colorTexture);
265 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
266 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
267 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) ;
268 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) ;
269 m_context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_rect.width, m_rect.height , 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
270 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
271 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEX TURE_2D, m_colorTexture, 0);
272
273 drawScene();
274
275 m_context->genMailboxCHROMIUM(m_mailbox.name);
276 m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, m_mailbox.name);
277
278 m_context->flush();
279 m_layer->layer()->invalidate();
280 m_mailboxChanged = true;
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 static const WebString kPrimitiveNone = WebString::fromUTF8("none");
299 static const WebString kPrimitiveTriangle = WebString::fromUTF8("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 static const WebString kPrimitiveTrue = WebString::fromUTF8("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, "colo r");
413 m_scene.positionLocation = m_context->getAttribLocation(m_scene.program, "po sition");
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], co lor[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_FAL SE, 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& fragm entSource)
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& inf o)
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"; b reak;
518 case WebInputEvent::GestureScrollEnd: eventName = "GestureScrollEnd"; bre ak;
519 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
520 case WebInputEvent::GestureScrollUpdate: eventName = "GestureScrollUpdate"; break;
521 case WebInputEvent::GestureFlingStart: eventName = "GestureFlingStart"; br eak;
522 case WebInputEvent::GestureFlingCancel: eventName = "GestureFlingCancel"; b reak;
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"; bre ak;
528 case WebInputEvent::GestureTapCancel: eventName = "GestureTapCancel"; bre ak;
529 case WebInputEvent::GestureDoubleTap: eventName = "GestureDoubleTap"; bre ak;
530 case WebInputEvent::GestureTwoFingerTap: eventName = "GestureTwoFingerTap"; break;
531 case WebInputEvent::GestureLongPress: eventName = "GestureLongPress"; bre ak;
532 case WebInputEvent::GestureLongTap: eventName = "GestureLongTap"; break ;
533 case WebInputEvent::GesturePinchBegin: eventName = "GesturePinchBegin"; br eak;
534 case WebInputEvent::GesturePinchEnd: eventName = "GesturePinchEnd"; brea k;
535 case WebInputEvent::GesturePinchUpdate: eventName = "GesturePinchUpdate"; b reak;
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::i sProcessingUserGesture() ? "" : "not ") + "handling user gesture\n");
548 return false;
549 }
550
551 bool TestPlugin::handleDragStatusUpdate(WebDragStatus dragStatus, const WebDragD ata&, WebDragOperationsMask, const WebPoint& position, const WebPoint& screenPos ition)
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: ") + dragStatus Name + "\n");
571 return false;
572 }
573
574 TestPlugin* TestPlugin::create(WebFrame* frame, const WebPluginParams& params, W ebTestDelegate* delegate)
575 {
576 return new TestPlugin(frame, params, delegate);
577 }
578
579 const WebString& TestPlugin::mimeType()
580 {
581 static const WebString kMimeType = WebString::fromUTF8("application/x-webkit -test-webplugin");
582 return kMimeType;
583 }
584
585 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698