| 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 "components/test_runner/test_plugin.h" | 5 #include "content/shell/test_runner/test_plugin.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "cc/blink/web_layer_impl.h" | 17 #include "cc/blink/web_layer_impl.h" |
| 18 #include "cc/layers/texture_layer.h" | 18 #include "cc/layers/texture_layer.h" |
| 19 #include "cc/resources/shared_bitmap_manager.h" | 19 #include "cc/resources/shared_bitmap_manager.h" |
| 20 #include "components/test_runner/web_test_delegate.h" | 20 #include "content/shell/test_runner/web_test_delegate.h" |
| 21 #include "gpu/command_buffer/client/gles2_interface.h" | 21 #include "gpu/command_buffer/client/gles2_interface.h" |
| 22 #include "third_party/WebKit/public/platform/Platform.h" | 22 #include "third_party/WebKit/public/platform/Platform.h" |
| 23 #include "third_party/WebKit/public/platform/WebCompositorSupport.h" | 23 #include "third_party/WebKit/public/platform/WebCompositorSupport.h" |
| 24 #include "third_party/WebKit/public/platform/WebGestureEvent.h" | 24 #include "third_party/WebKit/public/platform/WebGestureEvent.h" |
| 25 #include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h" | 25 #include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h" |
| 26 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 26 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 27 #include "third_party/WebKit/public/platform/WebMouseEvent.h" | 27 #include "third_party/WebKit/public/platform/WebMouseEvent.h" |
| 28 #include "third_party/WebKit/public/platform/WebThread.h" | 28 #include "third_party/WebKit/public/platform/WebThread.h" |
| 29 #include "third_party/WebKit/public/platform/WebTouchEvent.h" | 29 #include "third_party/WebKit/public/platform/WebTouchEvent.h" |
| 30 #include "third_party/WebKit/public/platform/WebTouchPoint.h" | 30 #include "third_party/WebKit/public/platform/WebTouchPoint.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 return "Cancelled"; | 65 return "Cancelled"; |
| 66 default: | 66 default: |
| 67 return "Unknown"; | 67 return "Unknown"; |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void PrintTouchList(WebTestDelegate* delegate, | 71 void PrintTouchList(WebTestDelegate* delegate, |
| 72 const blink::WebTouchPoint* points, | 72 const blink::WebTouchPoint* points, |
| 73 int length) { | 73 int length) { |
| 74 for (int i = 0; i < length; ++i) { | 74 for (int i = 0; i < length; ++i) { |
| 75 delegate->PrintMessage(base::StringPrintf("* %.2f, %.2f: %s\n", | 75 delegate->PrintMessage( |
| 76 points[i].position.x, | 76 base::StringPrintf("* %.2f, %.2f: %s\n", points[i].position.x, |
| 77 points[i].position.y, | 77 points[i].position.y, PointState(points[i].state))); |
| 78 PointState(points[i].state))); | |
| 79 } | 78 } |
| 80 } | 79 } |
| 81 | 80 |
| 82 void PrintEventDetails(WebTestDelegate* delegate, | 81 void PrintEventDetails(WebTestDelegate* delegate, |
| 83 const blink::WebInputEvent& event) { | 82 const blink::WebInputEvent& event) { |
| 84 if (blink::WebInputEvent::isTouchEventType(event.type())) { | 83 if (blink::WebInputEvent::isTouchEventType(event.type())) { |
| 85 const blink::WebTouchEvent& touch = | 84 const blink::WebTouchEvent& touch = |
| 86 static_cast<const blink::WebTouchEvent&>(event); | 85 static_cast<const blink::WebTouchEvent&>(event); |
| 87 PrintTouchList(delegate, touch.touches, touch.touchesLength); | 86 PrintTouchList(delegate, touch.touches, touch.touchesLength); |
| 88 } else if (blink::WebInputEvent::isMouseEventType(event.type()) || | 87 } else if (blink::WebInputEvent::isMouseEventType(event.type()) || |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 else if (attribute_name == "supports-keyboard-focus") | 153 else if (attribute_name == "supports-keyboard-focus") |
| 155 supports_keyboard_focus_ = ParseBoolean(attribute_value); | 154 supports_keyboard_focus_ = ParseBoolean(attribute_value); |
| 156 else if (attribute_name == "print-user-gesture-status") | 155 else if (attribute_name == "print-user-gesture-status") |
| 157 print_user_gesture_status_ = ParseBoolean(attribute_value); | 156 print_user_gesture_status_ = ParseBoolean(attribute_value); |
| 158 } | 157 } |
| 159 if (can_create_without_renderer_) | 158 if (can_create_without_renderer_) |
| 160 delegate_->PrintMessage( | 159 delegate_->PrintMessage( |
| 161 std::string("TestPlugin: canCreateWithoutRenderer\n")); | 160 std::string("TestPlugin: canCreateWithoutRenderer\n")); |
| 162 } | 161 } |
| 163 | 162 |
| 164 TestPlugin::~TestPlugin() { | 163 TestPlugin::~TestPlugin() {} |
| 165 } | |
| 166 | 164 |
| 167 bool TestPlugin::initialize(blink::WebPluginContainer* container) { | 165 bool TestPlugin::initialize(blink::WebPluginContainer* container) { |
| 168 DCHECK(container); | 166 DCHECK(container); |
| 169 DCHECK_EQ(this, container->plugin()); | 167 DCHECK_EQ(this, container->plugin()); |
| 170 | 168 |
| 171 container_ = container; | 169 container_ = container; |
| 172 | 170 |
| 173 blink::Platform::ContextAttributes attrs; | 171 blink::Platform::ContextAttributes attrs; |
| 174 attrs.webGLVersion = 1; // We are creating a context through the WebGL APIs. | 172 attrs.webGLVersion = 1; // We are creating a context through the WebGL APIs. |
| 175 blink::WebURL url = container->document().url(); | 173 blink::WebURL url = container->document().url(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 *release_callback = cc::SingleReleaseCallback::Create( | 308 *release_callback = cc::SingleReleaseCallback::Create( |
| 311 base::Bind(&ReleaseSharedMemory, base::Passed(&shared_bitmap_))); | 309 base::Bind(&ReleaseSharedMemory, base::Passed(&shared_bitmap_))); |
| 312 } | 310 } |
| 313 mailbox_changed_ = false; | 311 mailbox_changed_ = false; |
| 314 return true; | 312 return true; |
| 315 } | 313 } |
| 316 | 314 |
| 317 TestPlugin::Primitive TestPlugin::ParsePrimitive( | 315 TestPlugin::Primitive TestPlugin::ParsePrimitive( |
| 318 const blink::WebString& string) { | 316 const blink::WebString& string) { |
| 319 const CR_DEFINE_STATIC_LOCAL(blink::WebString, kPrimitiveNone, ("none")); | 317 const CR_DEFINE_STATIC_LOCAL(blink::WebString, kPrimitiveNone, ("none")); |
| 320 const CR_DEFINE_STATIC_LOCAL( | 318 const CR_DEFINE_STATIC_LOCAL(blink::WebString, kPrimitiveTriangle, |
| 321 blink::WebString, kPrimitiveTriangle, ("triangle")); | 319 ("triangle")); |
| 322 | 320 |
| 323 Primitive primitive = PrimitiveNone; | 321 Primitive primitive = PrimitiveNone; |
| 324 if (string == kPrimitiveNone) | 322 if (string == kPrimitiveNone) |
| 325 primitive = PrimitiveNone; | 323 primitive = PrimitiveNone; |
| 326 else if (string == kPrimitiveTriangle) | 324 else if (string == kPrimitiveTriangle) |
| 327 primitive = PrimitiveTriangle; | 325 primitive = PrimitiveTriangle; |
| 328 else | 326 else |
| 329 NOTREACHED(); | 327 NOTREACHED(); |
| 330 return primitive; | 328 return primitive; |
| 331 } | 329 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 gl_->EnableVertexAttribArray(scene_.position_location); | 489 gl_->EnableVertexAttribArray(scene_.position_location); |
| 492 gl_->VertexAttribPointer(scene_.position_location, 3, GL_FLOAT, GL_FALSE, 0, | 490 gl_->VertexAttribPointer(scene_.position_location, 3, GL_FLOAT, GL_FALSE, 0, |
| 493 nullptr); | 491 nullptr); |
| 494 gl_->DrawArrays(GL_TRIANGLES, 0, 3); | 492 gl_->DrawArrays(GL_TRIANGLES, 0, 3); |
| 495 } | 493 } |
| 496 | 494 |
| 497 GLuint TestPlugin::LoadShader(GLenum type, const std::string& source) { | 495 GLuint TestPlugin::LoadShader(GLenum type, const std::string& source) { |
| 498 GLuint shader = gl_->CreateShader(type); | 496 GLuint shader = gl_->CreateShader(type); |
| 499 if (shader) { | 497 if (shader) { |
| 500 const GLchar* shader_data = source.data(); | 498 const GLchar* shader_data = source.data(); |
| 501 GLint shader_length = strlen(shader_data); //source.length(); | 499 GLint shader_length = strlen(shader_data); // source.length(); |
| 502 gl_->ShaderSource(shader, 1, &shader_data, &shader_length); | 500 gl_->ShaderSource(shader, 1, &shader_data, &shader_length); |
| 503 gl_->CompileShader(shader); | 501 gl_->CompileShader(shader); |
| 504 | 502 |
| 505 int compiled = 0; | 503 int compiled = 0; |
| 506 gl_->GetShaderiv(shader, GL_COMPILE_STATUS, &compiled); | 504 gl_->GetShaderiv(shader, GL_COMPILE_STATUS, &compiled); |
| 507 if (!compiled) { | 505 if (!compiled) { |
| 508 gl_->DeleteShader(shader); | 506 gl_->DeleteShader(shader); |
| 509 shader = 0; | 507 shader = 0; |
| 510 } | 508 } |
| 511 } | 509 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 return false; | 584 return false; |
| 587 } | 585 } |
| 588 | 586 |
| 589 TestPlugin* TestPlugin::create(blink::WebFrame* frame, | 587 TestPlugin* TestPlugin::create(blink::WebFrame* frame, |
| 590 const blink::WebPluginParams& params, | 588 const blink::WebPluginParams& params, |
| 591 WebTestDelegate* delegate) { | 589 WebTestDelegate* delegate) { |
| 592 return new TestPlugin(frame, params, delegate); | 590 return new TestPlugin(frame, params, delegate); |
| 593 } | 591 } |
| 594 | 592 |
| 595 const blink::WebString& TestPlugin::MimeType() { | 593 const blink::WebString& TestPlugin::MimeType() { |
| 596 const CR_DEFINE_STATIC_LOCAL( | 594 const CR_DEFINE_STATIC_LOCAL(blink::WebString, kMimeType, |
| 597 blink::WebString, kMimeType, ("application/x-webkit-test-webplugin")); | 595 ("application/x-webkit-test-webplugin")); |
| 598 return kMimeType; | 596 return kMimeType; |
| 599 } | 597 } |
| 600 | 598 |
| 601 const blink::WebString& TestPlugin::CanCreateWithoutRendererMimeType() { | 599 const blink::WebString& TestPlugin::CanCreateWithoutRendererMimeType() { |
| 602 const CR_DEFINE_STATIC_LOCAL( | 600 const CR_DEFINE_STATIC_LOCAL( |
| 603 blink::WebString, | 601 blink::WebString, kCanCreateWithoutRendererMimeType, |
| 604 kCanCreateWithoutRendererMimeType, | |
| 605 ("application/x-webkit-test-webplugin-can-create-without-renderer")); | 602 ("application/x-webkit-test-webplugin-can-create-without-renderer")); |
| 606 return kCanCreateWithoutRendererMimeType; | 603 return kCanCreateWithoutRendererMimeType; |
| 607 } | 604 } |
| 608 | 605 |
| 609 const blink::WebString& TestPlugin::PluginPersistsMimeType() { | 606 const blink::WebString& TestPlugin::PluginPersistsMimeType() { |
| 610 const CR_DEFINE_STATIC_LOCAL( | 607 const CR_DEFINE_STATIC_LOCAL( |
| 611 blink::WebString, | 608 blink::WebString, kPluginPersistsMimeType, |
| 612 kPluginPersistsMimeType, | |
| 613 ("application/x-webkit-test-webplugin-persistent")); | 609 ("application/x-webkit-test-webplugin-persistent")); |
| 614 return kPluginPersistsMimeType; | 610 return kPluginPersistsMimeType; |
| 615 } | 611 } |
| 616 | 612 |
| 617 bool TestPlugin::IsSupportedMimeType(const blink::WebString& mime_type) { | 613 bool TestPlugin::IsSupportedMimeType(const blink::WebString& mime_type) { |
| 618 return mime_type == TestPlugin::MimeType() || | 614 return mime_type == TestPlugin::MimeType() || |
| 619 mime_type == PluginPersistsMimeType() || | 615 mime_type == PluginPersistsMimeType() || |
| 620 mime_type == CanCreateWithoutRendererMimeType(); | 616 mime_type == CanCreateWithoutRendererMimeType(); |
| 621 } | 617 } |
| 622 | 618 |
| 623 } // namespace test_runner | 619 } // namespace test_runner |
| OLD | NEW |