| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "content/shell/renderer/test_runner/TestPlugin.h" | 5 #include "content/shell/renderer/test_runner/TestPlugin.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/strings/stringprintf.h" | |
| 12 #include "content/public/renderer/render_thread.h" | 11 #include "content/public/renderer/render_thread.h" |
| 12 #include "content/shell/renderer/test_runner/TestCommon.h" |
| 13 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 13 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
| 16 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
| 17 #include "third_party/WebKit/public/platform/Platform.h" | 17 #include "third_party/WebKit/public/platform/Platform.h" |
| 18 #include "third_party/WebKit/public/platform/WebCompositorSupport.h" | 18 #include "third_party/WebKit/public/platform/WebCompositorSupport.h" |
| 19 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 19 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 20 #include "third_party/WebKit/public/web/WebFrame.h" | 20 #include "third_party/WebKit/public/web/WebFrame.h" |
| 21 #include "third_party/WebKit/public/web/WebInputEvent.h" | 21 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 22 #include "third_party/WebKit/public/web/WebKit.h" | 22 #include "third_party/WebKit/public/web/WebKit.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 case WebTouchPoint::StateCancelled: | 80 case WebTouchPoint::StateCancelled: |
| 81 return "Cancelled"; | 81 return "Cancelled"; |
| 82 default: | 82 default: |
| 83 return "Unknown"; | 83 return "Unknown"; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 void printTouchList(WebTestDelegate* delegate, const WebTouchPoint* points, int
length) | 87 void printTouchList(WebTestDelegate* delegate, const WebTouchPoint* points, int
length) |
| 88 { | 88 { |
| 89 for (int i = 0; i < length; ++i) { | 89 for (int i = 0; i < length; ++i) { |
| 90 base::StringPrintf("* %.2f, %.2f: %s\n", | 90 char buffer[100]; |
| 91 points[i].position.x, | 91 snprintf(buffer, |
| 92 points[i].position.y, | 92 sizeof(buffer), |
| 93 pointState(points[i].state)); | 93 "* %.2f, %.2f: %s\n", |
| 94 points[i].position.x, |
| 95 points[i].position.y, |
| 96 pointState(points[i].state)); |
| 97 delegate->printMessage(buffer); |
| 94 } | 98 } |
| 95 } | 99 } |
| 96 | 100 |
| 97 void printEventDetails(WebTestDelegate* delegate, const WebInputEvent& event) | 101 void printEventDetails(WebTestDelegate* delegate, const WebInputEvent& event) |
| 98 { | 102 { |
| 99 if (WebInputEvent::isTouchEventType(event.type)) { | 103 if (WebInputEvent::isTouchEventType(event.type)) { |
| 100 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event); | 104 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event); |
| 101 printTouchList(delegate, touch.touches, touch.touchesLength); | 105 printTouchList(delegate, touch.touches, touch.touchesLength); |
| 102 printTouchList(delegate, touch.changedTouches, touch.changedTouchesLengt
h); | 106 printTouchList(delegate, touch.changedTouches, touch.changedTouchesLengt
h); |
| 103 printTouchList(delegate, touch.targetTouches, touch.targetTouchesLength)
; | 107 printTouchList(delegate, touch.targetTouches, touch.targetTouchesLength)
; |
| 104 } else if (WebInputEvent::isMouseEventType(event.type) || event.type == WebI
nputEvent::MouseWheel) { | 108 } else if (WebInputEvent::isMouseEventType(event.type) || event.type == WebI
nputEvent::MouseWheel) { |
| 105 const WebMouseEvent& mouse = static_cast<const WebMouseEvent&>(event); | 109 const WebMouseEvent& mouse = static_cast<const WebMouseEvent&>(event); |
| 106 base::StringPrintf("* %d, %d\n", mouse.x, mouse.y); | 110 char buffer[100]; |
| 111 snprintf(buffer, sizeof(buffer), "* %d, %d\n", mouse.x, mouse.y); |
| 112 delegate->printMessage(buffer); |
| 107 } else if (WebInputEvent::isGestureEventType(event.type)) { | 113 } else if (WebInputEvent::isGestureEventType(event.type)) { |
| 108 const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(eve
nt); | 114 const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(eve
nt); |
| 109 base::StringPrintf("* %d, %d\n", gesture.x, gesture.y); | 115 char buffer[100]; |
| 116 snprintf(buffer, sizeof(buffer), "* %d, %d\n", gesture.x, gesture.y); |
| 117 delegate->printMessage(buffer); |
| 110 } | 118 } |
| 111 } | 119 } |
| 112 | 120 |
| 113 WebPluginContainer::TouchEventRequestType parseTouchEventRequestType(const WebSt
ring& string) | 121 WebPluginContainer::TouchEventRequestType parseTouchEventRequestType(const WebSt
ring& string) |
| 114 { | 122 { |
| 115 if (string == WebString::fromUTF8("raw")) | 123 if (string == WebString::fromUTF8("raw")) |
| 116 return WebPluginContainer::TouchEventRequestTypeRaw; | 124 return WebPluginContainer::TouchEventRequestTypeRaw; |
| 117 if (string == WebString::fromUTF8("synthetic")) | 125 if (string == WebString::fromUTF8("synthetic")) |
| 118 return WebPluginContainer::TouchEventRequestTypeSynthesizedMouse; | 126 return WebPluginContainer::TouchEventRequestTypeSynthesizedMouse; |
| 119 return WebPluginContainer::TouchEventRequestTypeNone; | 127 return WebPluginContainer::TouchEventRequestTypeNone; |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 } | 684 } |
| 677 | 685 |
| 678 bool TestPlugin::isSupportedMimeType(const WebString& mimeType) | 686 bool TestPlugin::isSupportedMimeType(const WebString& mimeType) |
| 679 { | 687 { |
| 680 return mimeType == TestPlugin::mimeType() | 688 return mimeType == TestPlugin::mimeType() |
| 681 || mimeType == pluginPersistsMimeType() | 689 || mimeType == pluginPersistsMimeType() |
| 682 || mimeType == canCreateWithoutRendererMimeType(); | 690 || mimeType == canCreateWithoutRendererMimeType(); |
| 683 } | 691 } |
| 684 | 692 |
| 685 } // namespace content | 693 } // namespace content |
| OLD | NEW |