Commit dd9554f3 authored by abhishek.a21's avatar abhishek.a21 Committed by Commit bot

TestPlugin to chromium c++ style.

Changes:
1) Run clang-format through source and header files.
2) Rename data member variables to use unix_hacker_ style.
3) Rename methods to use CamelCase style.
4) Rename file name to test_plugin.

BUG=331299

Review URL: https://codereview.chromium.org/469943003

Cr-Commit-Position: refs/heads/master@{#293160}
parent d3c60604
...@@ -181,8 +181,6 @@ ...@@ -181,8 +181,6 @@
'shell/renderer/shell_render_process_observer.h', 'shell/renderer/shell_render_process_observer.h',
'shell/renderer/shell_render_view_observer.cc', 'shell/renderer/shell_render_view_observer.cc',
'shell/renderer/shell_render_view_observer.h', 'shell/renderer/shell_render_view_observer.h',
'shell/renderer/test_runner/TestPlugin.cpp',
'shell/renderer/test_runner/TestPlugin.h',
'shell/renderer/test_runner/WebTask.cpp', 'shell/renderer/test_runner/WebTask.cpp',
'shell/renderer/test_runner/WebTask.h', 'shell/renderer/test_runner/WebTask.h',
'shell/renderer/test_runner/WebTestDelegate.h', 'shell/renderer/test_runner/WebTestDelegate.h',
...@@ -234,6 +232,8 @@ ...@@ -234,6 +232,8 @@
'shell/renderer/test_runner/test_common.h', 'shell/renderer/test_runner/test_common.h',
'shell/renderer/test_runner/test_interfaces.cc', 'shell/renderer/test_runner/test_interfaces.cc',
'shell/renderer/test_runner/test_interfaces.h', 'shell/renderer/test_runner/test_interfaces.h',
'shell/renderer/test_runner/test_plugin.cc',
'shell/renderer/test_runner/test_plugin.h',
'shell/renderer/test_runner/test_runner.cc', 'shell/renderer/test_runner/test_runner.cc',
'shell/renderer/test_runner/test_runner.h', 'shell/renderer/test_runner/test_runner.h',
'shell/renderer/test_runner/text_input_controller.cc', 'shell/renderer/test_runner/text_input_controller.cc',
......
...@@ -129,8 +129,6 @@ static_library("content_shell_lib") { ...@@ -129,8 +129,6 @@ static_library("content_shell_lib") {
"renderer/shell_render_process_observer.h", "renderer/shell_render_process_observer.h",
"renderer/shell_render_view_observer.cc", "renderer/shell_render_view_observer.cc",
"renderer/shell_render_view_observer.h", "renderer/shell_render_view_observer.h",
"renderer/test_runner/TestPlugin.cpp",
"renderer/test_runner/TestPlugin.h",
"renderer/test_runner/WebTask.cpp", "renderer/test_runner/WebTask.cpp",
"renderer/test_runner/WebTask.h", "renderer/test_runner/WebTask.h",
"renderer/test_runner/WebTestDelegate.h", "renderer/test_runner/WebTestDelegate.h",
...@@ -182,6 +180,8 @@ static_library("content_shell_lib") { ...@@ -182,6 +180,8 @@ static_library("content_shell_lib") {
"renderer/test_runner/test_common.h", "renderer/test_runner/test_common.h",
"renderer/test_runner/test_interfaces.cc", "renderer/test_runner/test_interfaces.cc",
"renderer/test_runner/test_interfaces.h", "renderer/test_runner/test_interfaces.h",
"renderer/test_runner/test_plugin.cc",
"renderer/test_runner/test_plugin.h",
"renderer/test_runner/test_runner.cc", "renderer/test_runner/test_runner.cc",
"renderer/test_runner/test_runner.h", "renderer/test_runner/test_runner.h",
"renderer/test_runner/text_input_controller.cc", "renderer/test_runner/text_input_controller.cc",
......
This diff is collapsed.
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_TESTPLUGIN_H_
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_TESTPLUGIN_H_
#include <string>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "cc/layers/texture_layer.h"
#include "cc/layers/texture_layer_client.h"
#include "content/public/test/layouttest_support.h"
#include "third_party/WebKit/public/platform/WebExternalTextureLayer.h"
#include "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h"
#include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h"
#include "third_party/WebKit/public/platform/WebLayer.h"
#include "third_party/WebKit/public/web/WebPlugin.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
namespace blink {
class WebFrame;
class WebLayer;
}
namespace content {
class WebTestDelegate;
// A fake implemention of blink::WebPlugin for testing purposes.
//
// It uses WebGraphicsContext3D to paint a scene consisiting of a primitive
// over a background. The primitive and background can be customized using
// the following plugin parameters:
// primitive: none (default), triangle.
// background-color: black (default), red, green, blue.
// primitive-color: black (default), red, green, blue.
// opacity: [0.0 - 1.0]. Default is 1.0.
//
// Whether the plugin accepts touch events or not can be customized using the
// 'accepts-touch' plugin parameter (defaults to false).
class TestPlugin : public blink::WebPlugin, public cc::TextureLayerClient {
public:
static TestPlugin* create(blink::WebFrame*, const blink::WebPluginParams&, WebTestDelegate*);
virtual ~TestPlugin();
static const blink::WebString& mimeType();
static const blink::WebString& canCreateWithoutRendererMimeType();
static const blink::WebString& pluginPersistsMimeType();
static bool isSupportedMimeType(const blink::WebString& mimeType);
// WebPlugin methods:
virtual bool initialize(blink::WebPluginContainer*);
virtual void destroy();
virtual NPObject* scriptableObject();
virtual bool canProcessDrag() const;
virtual void paint(blink::WebCanvas*, const blink::WebRect&) { }
virtual void updateGeometry(const blink::WebRect& frameRect, const blink::WebRect& clipRect, const blink::WebVector<blink::WebRect>& cutOutsRects, bool isVisible);
virtual void updateFocus(bool) { }
virtual void updateVisibility(bool) { }
virtual bool acceptsInputEvents();
virtual bool handleInputEvent(const blink::WebInputEvent&, blink::WebCursorInfo&);
virtual bool handleDragStatusUpdate(blink::WebDragStatus, const blink::WebDragData&, blink::WebDragOperationsMask, const blink::WebPoint& position, const blink::WebPoint& screenPosition);
virtual void didReceiveResponse(const blink::WebURLResponse&) { }
virtual void didReceiveData(const char* data, int dataLength) { }
virtual void didFinishLoading() { }
virtual void didFailLoading(const blink::WebURLError&) { }
virtual void didFinishLoadingFrameRequest(const blink::WebURL&, void* notifyData) { }
virtual void didFailLoadingFrameRequest(const blink::WebURL&, void* notifyData, const blink::WebURLError&) { }
virtual bool isPlaceholder();
// cc::TextureLayerClient methods:
virtual bool PrepareTextureMailbox(
cc::TextureMailbox* mailbox,
scoped_ptr<cc::SingleReleaseCallback>* releaseCallback,
bool useSharedMemory) OVERRIDE;
private:
TestPlugin(blink::WebFrame*, const blink::WebPluginParams&, WebTestDelegate*);
enum Primitive {
PrimitiveNone,
PrimitiveTriangle
};
struct Scene {
Primitive primitive;
unsigned backgroundColor[3];
unsigned primitiveColor[3];
float opacity;
unsigned vbo;
unsigned program;
int colorLocation;
int positionLocation;
Scene()
: primitive(PrimitiveNone)
, opacity(1.0f) // Fully opaque.
, vbo(0)
, program(0)
, colorLocation(-1)
, positionLocation(-1)
{
backgroundColor[0] = backgroundColor[1] = backgroundColor[2] = 0;
primitiveColor[0] = primitiveColor[1] = primitiveColor[2] = 0;
}
};
// Functions for parsing plugin parameters.
Primitive parsePrimitive(const blink::WebString&);
void parseColor(const blink::WebString&, unsigned color[3]);
float parseOpacity(const blink::WebString&);
bool parseBoolean(const blink::WebString&);
// Functions for loading and drawing scene in GL.
bool initScene();
void drawSceneGL();
void destroyScene();
bool initProgram();
bool initPrimitive();
void drawPrimitive();
unsigned loadShader(unsigned type, const std::string& source);
unsigned loadProgram(const std::string& vertexSource, const std::string& fragmentSource);
// Functions for drawing scene in Software.
void drawSceneSoftware(void* memory, size_t bytes);
blink::WebFrame* m_frame;
WebTestDelegate* m_delegate;
blink::WebPluginContainer* m_container;
blink::WebRect m_rect;
blink::WebGraphicsContext3D* m_context;
unsigned m_colorTexture;
cc::TextureMailbox m_textureMailbox;
scoped_ptr<base::SharedMemory> m_sharedBitmap;
bool m_mailboxChanged;
unsigned m_framebuffer;
Scene m_scene;
scoped_refptr<cc::TextureLayer> m_layer;
scoped_ptr<blink::WebLayer> m_webLayer;
blink::WebPluginContainer::TouchEventRequestType m_touchEventRequest;
// Requests touch events from the WebPluginContainerImpl multiple times to tickle webkit.org/b/108381
bool m_reRequestTouchEvents;
bool m_printEventDetails;
bool m_printUserGestureStatus;
bool m_canProcessDrag;
bool m_isPersistent;
bool m_canCreateWithoutRenderer;
DISALLOW_COPY_AND_ASSIGN(TestPlugin);
};
} // namespace content
#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_TESTPLUGIN_H_
This diff is collapsed.
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_PLUGIN_H_
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_PLUGIN_H_
#include <string>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "cc/layers/texture_layer.h"
#include "cc/layers/texture_layer_client.h"
#include "content/public/test/layouttest_support.h"
#include "third_party/WebKit/public/platform/WebExternalTextureLayer.h"
#include "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h"
#include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h"
#include "third_party/WebKit/public/platform/WebLayer.h"
#include "third_party/WebKit/public/web/WebPlugin.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
namespace blink {
class WebFrame;
class WebLayer;
}
namespace content {
class WebTestDelegate;
// A fake implemention of blink::WebPlugin for testing purposes.
//
// It uses WebGraphicsContext3D to paint a scene consisiting of a primitive
// over a background. The primitive and background can be customized using
// the following plugin parameters:
// primitive: none (default), triangle.
// background-color: black (default), red, green, blue.
// primitive-color: black (default), red, green, blue.
// opacity: [0.0 - 1.0]. Default is 1.0.
//
// Whether the plugin accepts touch events or not can be customized using the
// 'accepts-touch' plugin parameter (defaults to false).
class TestPlugin : public blink::WebPlugin, public cc::TextureLayerClient {
public:
static TestPlugin* create(blink::WebFrame* frame,
const blink::WebPluginParams& params,
WebTestDelegate* delegate);
virtual ~TestPlugin();
static const blink::WebString& MimeType();
static const blink::WebString& CanCreateWithoutRendererMimeType();
static const blink::WebString& PluginPersistsMimeType();
static bool IsSupportedMimeType(const blink::WebString& mime_type);
// WebPlugin methods:
virtual bool initialize(blink::WebPluginContainer* container);
virtual void destroy();
virtual NPObject* scriptableObject();
virtual bool canProcessDrag() const;
virtual void paint(blink::WebCanvas* canvas, const blink::WebRect& rect) {}
virtual void updateGeometry(
const blink::WebRect& frame_rect,
const blink::WebRect& clip_rect,
const blink::WebVector<blink::WebRect>& cut_outs_rects,
bool is_visible);
virtual void updateFocus(bool focus) {}
virtual void updateVisibility(bool visibility) {}
virtual bool acceptsInputEvents();
virtual bool handleInputEvent(const blink::WebInputEvent& event,
blink::WebCursorInfo& info);
virtual bool handleDragStatusUpdate(blink::WebDragStatus drag_status,
const blink::WebDragData& data,
blink::WebDragOperationsMask mask,
const blink::WebPoint& position,
const blink::WebPoint& screen_position);
virtual void didReceiveResponse(const blink::WebURLResponse& response) {}
virtual void didReceiveData(const char* data, int data_length) {}
virtual void didFinishLoading() {}
virtual void didFailLoading(const blink::WebURLError& error) {}
virtual void didFinishLoadingFrameRequest(const blink::WebURL& url,
void* notify_data) {}
virtual void didFailLoadingFrameRequest(const blink::WebURL& url,
void* notify_data,
const blink::WebURLError& error) {}
virtual bool isPlaceholder();
// cc::TextureLayerClient methods:
virtual bool PrepareTextureMailbox(
cc::TextureMailbox* mailbox,
scoped_ptr<cc::SingleReleaseCallback>* release_callback,
bool use_shared_memory) OVERRIDE;
private:
TestPlugin(blink::WebFrame* frame,
const blink::WebPluginParams& params,
WebTestDelegate* delegate);
enum Primitive { PrimitiveNone, PrimitiveTriangle };
struct Scene {
Primitive primitive;
unsigned background_color[3];
unsigned primitive_color[3];
float opacity;
unsigned vbo;
unsigned program;
int color_location;
int position_location;
Scene()
: primitive(PrimitiveNone),
opacity(1.0f) // Fully opaque.
,
vbo(0),
program(0),
color_location(-1),
position_location(-1) {
background_color[0] = background_color[1] = background_color[2] = 0;
primitive_color[0] = primitive_color[1] = primitive_color[2] = 0;
}
};
// Functions for parsing plugin parameters.
Primitive ParsePrimitive(const blink::WebString& string);
void ParseColor(const blink::WebString& string, unsigned color[3]);
float ParseOpacity(const blink::WebString& string);
bool ParseBoolean(const blink::WebString& string);
// Functions for loading and drawing scene in GL.
bool InitScene();
void DrawSceneGL();
void DestroyScene();
bool InitProgram();
bool InitPrimitive();
void DrawPrimitive();
unsigned LoadShader(unsigned type, const std::string& source);
unsigned LoadProgram(const std::string& vertex_source,
const std::string& fragment_source);
// Functions for drawing scene in Software.
void DrawSceneSoftware(void* memory, size_t bytes);
blink::WebFrame* frame_;
WebTestDelegate* delegate_;
blink::WebPluginContainer* container_;
blink::WebRect rect_;
blink::WebGraphicsContext3D* context_;
unsigned color_texture_;
cc::TextureMailbox texture_mailbox_;
scoped_ptr<base::SharedMemory> shared_bitmap_;
bool mailbox_changed_;
unsigned framebuffer_;
Scene scene_;
scoped_refptr<cc::TextureLayer> layer_;
scoped_ptr<blink::WebLayer> web_layer_;
blink::WebPluginContainer::TouchEventRequestType touch_event_request_;
// Requests touch events from the WebPluginContainerImpl multiple times to
// tickle webkit.org/b/108381
bool re_request_touch_events_;
bool print_event_details_;
bool print_user_gesture_status_;
bool can_process_drag_;
bool is_persistent_;
bool can_create_without_renderer_;
DISALLOW_COPY_AND_ASSIGN(TestPlugin);
};
} // namespace content
#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_TEST_PLUGIN_H_
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/shell/renderer/test_runner/TestPlugin.h"
#include "content/shell/renderer/test_runner/WebTestDelegate.h" #include "content/shell/renderer/test_runner/WebTestDelegate.h"
#include "content/shell/renderer/test_runner/WebTestInterfaces.h" #include "content/shell/renderer/test_runner/WebTestInterfaces.h"
#include "content/shell/renderer/test_runner/accessibility_controller.h" #include "content/shell/renderer/test_runner/accessibility_controller.h"
...@@ -25,6 +24,7 @@ ...@@ -25,6 +24,7 @@
#include "content/shell/renderer/test_runner/mock_web_user_media_client.h" #include "content/shell/renderer/test_runner/mock_web_user_media_client.h"
#include "content/shell/renderer/test_runner/spell_check_client.h" #include "content/shell/renderer/test_runner/spell_check_client.h"
#include "content/shell/renderer/test_runner/test_interfaces.h" #include "content/shell/renderer/test_runner/test_interfaces.h"
#include "content/shell/renderer/test_runner/test_plugin.h"
#include "content/shell/renderer/test_runner/test_runner.h" #include "content/shell/renderer/test_runner/test_runner.h"
#include "content/shell/renderer/test_runner/web_test_runner.h" #include "content/shell/renderer/test_runner/web_test_runner.h"
// FIXME: Including platform_canvas.h here is a layering violation. // FIXME: Including platform_canvas.h here is a layering violation.
...@@ -789,7 +789,7 @@ bool WebTestProxyBase::CreateView(blink::WebLocalFrame* frame, ...@@ -789,7 +789,7 @@ bool WebTestProxyBase::CreateView(blink::WebLocalFrame* frame,
blink::WebPlugin* WebTestProxyBase::CreatePlugin( blink::WebPlugin* WebTestProxyBase::CreatePlugin(
blink::WebLocalFrame* frame, blink::WebLocalFrame* frame,
const blink::WebPluginParams& params) { const blink::WebPluginParams& params) {
if (TestPlugin::isSupportedMimeType(params.mimeType)) if (TestPlugin::IsSupportedMimeType(params.mimeType))
return TestPlugin::create(frame, params, delegate_); return TestPlugin::create(frame, params, delegate_);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment