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

Side by Side Diff: content/shell/renderer/test_runner/test_plugin.cc

Issue 583113002: Abstract class WebTestDelegate to chromium c++ style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update test_runner Created 6 years, 3 months 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
OLDNEW
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/test_plugin.h" 5 #include "content/shell/renderer/test_runner/test_plugin.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 "base/strings/stringprintf.h"
12 #include "content/public/renderer/render_thread.h" 12 #include "content/public/renderer/render_thread.h"
13 #include "content/shell/renderer/test_runner/WebTestDelegate.h" 13 #include "content/shell/renderer/test_runner/web_test_delegate.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"
23 #include "third_party/WebKit/public/web/WebPluginParams.h" 23 #include "third_party/WebKit/public/web/WebPluginParams.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return "Cancelled"; 79 return "Cancelled";
80 default: 80 default:
81 return "Unknown"; 81 return "Unknown";
82 } 82 }
83 } 83 }
84 84
85 void PrintTouchList(WebTestDelegate* delegate, 85 void PrintTouchList(WebTestDelegate* delegate,
86 const blink::WebTouchPoint* points, 86 const blink::WebTouchPoint* points,
87 int length) { 87 int length) {
88 for (int i = 0; i < length; ++i) { 88 for (int i = 0; i < length; ++i) {
89 delegate->printMessage(base::StringPrintf("* %.2f, %.2f: %s\n", 89 delegate->PrintMessage(base::StringPrintf("* %.2f, %.2f: %s\n",
90 points[i].position.x, 90 points[i].position.x,
91 points[i].position.y, 91 points[i].position.y,
92 PointState(points[i].state))); 92 PointState(points[i].state)));
93 } 93 }
94 } 94 }
95 95
96 void PrintEventDetails(WebTestDelegate* delegate, 96 void PrintEventDetails(WebTestDelegate* delegate,
97 const blink::WebInputEvent& event) { 97 const blink::WebInputEvent& event) {
98 if (blink::WebInputEvent::isTouchEventType(event.type)) { 98 if (blink::WebInputEvent::isTouchEventType(event.type)) {
99 const blink::WebTouchEvent& touch = 99 const blink::WebTouchEvent& touch =
100 static_cast<const blink::WebTouchEvent&>(event); 100 static_cast<const blink::WebTouchEvent&>(event);
101 PrintTouchList(delegate, touch.touches, touch.touchesLength); 101 PrintTouchList(delegate, touch.touches, touch.touchesLength);
102 } else if (blink::WebInputEvent::isMouseEventType(event.type) || 102 } else if (blink::WebInputEvent::isMouseEventType(event.type) ||
103 event.type == blink::WebInputEvent::MouseWheel) { 103 event.type == blink::WebInputEvent::MouseWheel) {
104 const blink::WebMouseEvent& mouse = 104 const blink::WebMouseEvent& mouse =
105 static_cast<const blink::WebMouseEvent&>(event); 105 static_cast<const blink::WebMouseEvent&>(event);
106 delegate->printMessage(base::StringPrintf("* %d, %d\n", mouse.x, mouse.y)); 106 delegate->PrintMessage(base::StringPrintf("* %d, %d\n", mouse.x, mouse.y));
107 } else if (blink::WebInputEvent::isGestureEventType(event.type)) { 107 } else if (blink::WebInputEvent::isGestureEventType(event.type)) {
108 const blink::WebGestureEvent& gesture = 108 const blink::WebGestureEvent& gesture =
109 static_cast<const blink::WebGestureEvent&>(event); 109 static_cast<const blink::WebGestureEvent&>(event);
110 delegate->printMessage( 110 delegate->PrintMessage(
111 base::StringPrintf("* %d, %d\n", gesture.x, gesture.y)); 111 base::StringPrintf("* %d, %d\n", gesture.x, gesture.y));
112 } 112 }
113 } 113 }
114 114
115 blink::WebPluginContainer::TouchEventRequestType ParseTouchEventRequestType( 115 blink::WebPluginContainer::TouchEventRequestType ParseTouchEventRequestType(
116 const blink::WebString& string) { 116 const blink::WebString& string) {
117 if (string == blink::WebString::fromUTF8("raw")) 117 if (string == blink::WebString::fromUTF8("raw"))
118 return blink::WebPluginContainer::TouchEventRequestTypeRaw; 118 return blink::WebPluginContainer::TouchEventRequestTypeRaw;
119 if (string == blink::WebString::fromUTF8("synthetic")) 119 if (string == blink::WebString::fromUTF8("synthetic"))
120 return blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse; 120 return blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 else if (attribute_name == kAttributeReRequestTouchEvents) 186 else if (attribute_name == kAttributeReRequestTouchEvents)
187 re_request_touch_events_ = ParseBoolean(attribute_value); 187 re_request_touch_events_ = ParseBoolean(attribute_value);
188 else if (attribute_name == kAttributePrintEventDetails) 188 else if (attribute_name == kAttributePrintEventDetails)
189 print_event_details_ = ParseBoolean(attribute_value); 189 print_event_details_ = ParseBoolean(attribute_value);
190 else if (attribute_name == kAttributeCanProcessDrag) 190 else if (attribute_name == kAttributeCanProcessDrag)
191 can_process_drag_ = ParseBoolean(attribute_value); 191 can_process_drag_ = ParseBoolean(attribute_value);
192 else if (attribute_name == kAttributePrintUserGestureStatus) 192 else if (attribute_name == kAttributePrintUserGestureStatus)
193 print_user_gesture_status_ = ParseBoolean(attribute_value); 193 print_user_gesture_status_ = ParseBoolean(attribute_value);
194 } 194 }
195 if (can_create_without_renderer_) 195 if (can_create_without_renderer_)
196 delegate_->printMessage( 196 delegate_->PrintMessage(
197 std::string("TestPlugin: canCreateWithoutRenderer\n")); 197 std::string("TestPlugin: canCreateWithoutRenderer\n"));
198 } 198 }
199 199
200 TestPlugin::~TestPlugin() { 200 TestPlugin::~TestPlugin() {
201 } 201 }
202 202
203 bool TestPlugin::initialize(blink::WebPluginContainer* container) { 203 bool TestPlugin::initialize(blink::WebPluginContainer* container) {
204 blink::WebGraphicsContext3D::Attributes attrs; 204 blink::WebGraphicsContext3D::Attributes attrs;
205 context_ = 205 context_ =
206 blink::Platform::current()->createOffscreenGraphicsContext3D(attrs); 206 blink::Platform::current()->createOffscreenGraphicsContext3D(attrs);
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 event_name = "TouchMove"; 674 event_name = "TouchMove";
675 break; 675 break;
676 case blink::WebInputEvent::TouchEnd: 676 case blink::WebInputEvent::TouchEnd:
677 event_name = "TouchEnd"; 677 event_name = "TouchEnd";
678 break; 678 break;
679 case blink::WebInputEvent::TouchCancel: 679 case blink::WebInputEvent::TouchCancel:
680 event_name = "TouchCancel"; 680 event_name = "TouchCancel";
681 break; 681 break;
682 } 682 }
683 683
684 delegate_->printMessage(std::string("Plugin received event: ") + 684 delegate_->PrintMessage(std::string("Plugin received event: ") +
685 (event_name ? event_name : "unknown") + "\n"); 685 (event_name ? event_name : "unknown") + "\n");
686 if (print_event_details_) 686 if (print_event_details_)
687 PrintEventDetails(delegate_, event); 687 PrintEventDetails(delegate_, event);
688 if (print_user_gesture_status_) 688 if (print_user_gesture_status_)
689 delegate_->printMessage( 689 delegate_->PrintMessage(
690 std::string("* ") + 690 std::string("* ") +
691 (blink::WebUserGestureIndicator::isProcessingUserGesture() ? "" 691 (blink::WebUserGestureIndicator::isProcessingUserGesture() ? ""
692 : "not ") + 692 : "not ") +
693 "handling user gesture\n"); 693 "handling user gesture\n");
694 if (is_persistent_) 694 if (is_persistent_)
695 delegate_->printMessage(std::string("TestPlugin: isPersistent\n")); 695 delegate_->PrintMessage(std::string("TestPlugin: isPersistent\n"));
696 return false; 696 return false;
697 } 697 }
698 698
699 bool TestPlugin::handleDragStatusUpdate( 699 bool TestPlugin::handleDragStatusUpdate(
700 blink::WebDragStatus drag_status, 700 blink::WebDragStatus drag_status,
701 const blink::WebDragData& data, 701 const blink::WebDragData& data,
702 blink::WebDragOperationsMask mask, 702 blink::WebDragOperationsMask mask,
703 const blink::WebPoint& position, 703 const blink::WebPoint& position,
704 const blink::WebPoint& screen_position) { 704 const blink::WebPoint& screen_position) {
705 const char* drag_status_name = 0; 705 const char* drag_status_name = 0;
706 switch (drag_status) { 706 switch (drag_status) {
707 case blink::WebDragStatusEnter: 707 case blink::WebDragStatusEnter:
708 drag_status_name = "DragEnter"; 708 drag_status_name = "DragEnter";
709 break; 709 break;
710 case blink::WebDragStatusOver: 710 case blink::WebDragStatusOver:
711 drag_status_name = "DragOver"; 711 drag_status_name = "DragOver";
712 break; 712 break;
713 case blink::WebDragStatusLeave: 713 case blink::WebDragStatusLeave:
714 drag_status_name = "DragLeave"; 714 drag_status_name = "DragLeave";
715 break; 715 break;
716 case blink::WebDragStatusDrop: 716 case blink::WebDragStatusDrop:
717 drag_status_name = "DragDrop"; 717 drag_status_name = "DragDrop";
718 break; 718 break;
719 case blink::WebDragStatusUnknown: 719 case blink::WebDragStatusUnknown:
720 NOTREACHED(); 720 NOTREACHED();
721 } 721 }
722 delegate_->printMessage(std::string("Plugin received event: ") + 722 delegate_->PrintMessage(std::string("Plugin received event: ") +
723 drag_status_name + "\n"); 723 drag_status_name + "\n");
724 return false; 724 return false;
725 } 725 }
726 726
727 TestPlugin* TestPlugin::create(blink::WebFrame* frame, 727 TestPlugin* TestPlugin::create(blink::WebFrame* frame,
728 const blink::WebPluginParams& params, 728 const blink::WebPluginParams& params,
729 WebTestDelegate* delegate) { 729 WebTestDelegate* delegate) {
730 return new TestPlugin(frame, params, delegate); 730 return new TestPlugin(frame, params, delegate);
731 } 731 }
732 732
(...skipping 19 matching lines...) Expand all
752 return kPluginPersistsMimeType; 752 return kPluginPersistsMimeType;
753 } 753 }
754 754
755 bool TestPlugin::IsSupportedMimeType(const blink::WebString& mime_type) { 755 bool TestPlugin::IsSupportedMimeType(const blink::WebString& mime_type) {
756 return mime_type == TestPlugin::MimeType() || 756 return mime_type == TestPlugin::MimeType() ||
757 mime_type == PluginPersistsMimeType() || 757 mime_type == PluginPersistsMimeType() ||
758 mime_type == CanCreateWithoutRendererMimeType(); 758 mime_type == CanCreateWithoutRendererMimeType();
759 } 759 }
760 760
761 } // namespace content 761 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/test_interfaces.cc ('k') | content/shell/renderer/test_runner/test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698