Chromium Code Reviews| 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 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)); |
|
Adam Rice
2014/08/05 06:16:16
Bug: delegate->printMessage() has gone missing. In
Abhishek
2014/08/05 06:27:07
sorry !
Are we still going to use snprintf here fo
Adam Rice
2014/08/05 06:31:56
No. printMessage takes a string argument. Assign t
Abhishek
2014/08/05 07:22:49
Done.
| |
| 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 base::StringPrintf("* %d, %d\n", mouse.x, mouse.y); |
| 111 snprintf(buffer, sizeof(buffer), "* %d, %d\n", mouse.x, mouse.y); | |
| 112 delegate->printMessage(buffer); | |
| 113 } else if (WebInputEvent::isGestureEventType(event.type)) { | 107 } else if (WebInputEvent::isGestureEventType(event.type)) { |
| 114 const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(eve nt); | 108 const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(eve nt); |
| 115 char buffer[100]; | 109 base::StringPrintf("* %d, %d\n", gesture.x, gesture.y); |
| 116 snprintf(buffer, sizeof(buffer), "* %d, %d\n", gesture.x, gesture.y); | |
| 117 delegate->printMessage(buffer); | |
| 118 } | 110 } |
| 119 } | 111 } |
| 120 | 112 |
| 121 WebPluginContainer::TouchEventRequestType parseTouchEventRequestType(const WebSt ring& string) | 113 WebPluginContainer::TouchEventRequestType parseTouchEventRequestType(const WebSt ring& string) |
| 122 { | 114 { |
| 123 if (string == WebString::fromUTF8("raw")) | 115 if (string == WebString::fromUTF8("raw")) |
| 124 return WebPluginContainer::TouchEventRequestTypeRaw; | 116 return WebPluginContainer::TouchEventRequestTypeRaw; |
| 125 if (string == WebString::fromUTF8("synthetic")) | 117 if (string == WebString::fromUTF8("synthetic")) |
| 126 return WebPluginContainer::TouchEventRequestTypeSynthesizedMouse; | 118 return WebPluginContainer::TouchEventRequestTypeSynthesizedMouse; |
| 127 return WebPluginContainer::TouchEventRequestTypeNone; | 119 return WebPluginContainer::TouchEventRequestTypeNone; |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 } | 676 } |
| 685 | 677 |
| 686 bool TestPlugin::isSupportedMimeType(const WebString& mimeType) | 678 bool TestPlugin::isSupportedMimeType(const WebString& mimeType) |
| 687 { | 679 { |
| 688 return mimeType == TestPlugin::mimeType() | 680 return mimeType == TestPlugin::mimeType() |
| 689 || mimeType == pluginPersistsMimeType() | 681 || mimeType == pluginPersistsMimeType() |
| 690 || mimeType == canCreateWithoutRendererMimeType(); | 682 || mimeType == canCreateWithoutRendererMimeType(); |
| 691 } | 683 } |
| 692 | 684 |
| 693 } // namespace content | 685 } // namespace content |
| OLD | NEW |