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" |
11 #include "content/public/renderer/render_thread.h" | 12 #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 char buffer[100]; | 90 delegate->printMessage(base::StringPrintf("* %.2f, %.2f: %s\n", |
91 snprintf(buffer, | 91 points[i].position.x, |
92 sizeof(buffer), | 92 points[i].position.y, |
93 "* %.2f, %.2f: %s\n", | 93 pointState(points[i].state))); |
94 points[i].position.x, | |
95 points[i].position.y, | |
96 pointState(points[i].state)); | |
97 delegate->printMessage(buffer); | |
98 } | 94 } |
99 } | 95 } |
100 | 96 |
101 void printEventDetails(WebTestDelegate* delegate, const WebInputEvent& event) | 97 void printEventDetails(WebTestDelegate* delegate, const WebInputEvent& event) |
102 { | 98 { |
103 if (WebInputEvent::isTouchEventType(event.type)) { | 99 if (WebInputEvent::isTouchEventType(event.type)) { |
104 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event); | 100 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event); |
105 printTouchList(delegate, touch.touches, touch.touchesLength); | 101 printTouchList(delegate, touch.touches, touch.touchesLength); |
106 printTouchList(delegate, touch.changedTouches, touch.changedTouchesLengt
h); | 102 printTouchList(delegate, touch.changedTouches, touch.changedTouchesLengt
h); |
107 printTouchList(delegate, touch.targetTouches, touch.targetTouchesLength)
; | 103 printTouchList(delegate, touch.targetTouches, touch.targetTouchesLength)
; |
108 } else if (WebInputEvent::isMouseEventType(event.type) || event.type == WebI
nputEvent::MouseWheel) { | 104 } else if (WebInputEvent::isMouseEventType(event.type) || event.type == WebI
nputEvent::MouseWheel) { |
109 const WebMouseEvent& mouse = static_cast<const WebMouseEvent&>(event); | 105 const WebMouseEvent& mouse = static_cast<const WebMouseEvent&>(event); |
110 char buffer[100]; | 106 delegate->printMessage( |
111 snprintf(buffer, sizeof(buffer), "* %d, %d\n", mouse.x, mouse.y); | 107 base::StringPrintf("* %d, %d\n", mouse.x, mouse.y)); |
112 delegate->printMessage(buffer); | |
113 } else if (WebInputEvent::isGestureEventType(event.type)) { | 108 } else if (WebInputEvent::isGestureEventType(event.type)) { |
114 const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(eve
nt); | 109 const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(eve
nt); |
115 char buffer[100]; | 110 delegate->printMessage( |
116 snprintf(buffer, sizeof(buffer), "* %d, %d\n", gesture.x, gesture.y); | 111 base::StringPrintf("* %d, %d\n", gesture.x, gesture.y)); |
117 delegate->printMessage(buffer); | |
118 } | 112 } |
119 } | 113 } |
120 | 114 |
121 WebPluginContainer::TouchEventRequestType parseTouchEventRequestType(const WebSt
ring& string) | 115 WebPluginContainer::TouchEventRequestType parseTouchEventRequestType(const WebSt
ring& string) |
122 { | 116 { |
123 if (string == WebString::fromUTF8("raw")) | 117 if (string == WebString::fromUTF8("raw")) |
124 return WebPluginContainer::TouchEventRequestTypeRaw; | 118 return WebPluginContainer::TouchEventRequestTypeRaw; |
125 if (string == WebString::fromUTF8("synthetic")) | 119 if (string == WebString::fromUTF8("synthetic")) |
126 return WebPluginContainer::TouchEventRequestTypeSynthesizedMouse; | 120 return WebPluginContainer::TouchEventRequestTypeSynthesizedMouse; |
127 return WebPluginContainer::TouchEventRequestTypeNone; | 121 return WebPluginContainer::TouchEventRequestTypeNone; |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 } | 678 } |
685 | 679 |
686 bool TestPlugin::isSupportedMimeType(const WebString& mimeType) | 680 bool TestPlugin::isSupportedMimeType(const WebString& mimeType) |
687 { | 681 { |
688 return mimeType == TestPlugin::mimeType() | 682 return mimeType == TestPlugin::mimeType() |
689 || mimeType == pluginPersistsMimeType() | 683 || mimeType == pluginPersistsMimeType() |
690 || mimeType == canCreateWithoutRendererMimeType(); | 684 || mimeType == canCreateWithoutRendererMimeType(); |
691 } | 685 } |
692 | 686 |
693 } // namespace content | 687 } // namespace content |
OLD | NEW |