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

Side by Side Diff: content/shell/renderer/test_runner/TestPlugin.h

Issue 110533009: Import TestRunner library into chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef TestPlugin_h
6 #define TestPlugin_h
7
8 #include <string>
9
10 #include "content/shell/renderer/test_runner/WebScopedPtr.h"
11 #include "third_party/WebKit/public/platform/WebExternalTextureLayer.h"
12 #include "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h"
13 #include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h"
14 #include "third_party/WebKit/public/platform/WebNonCopyable.h"
15 #include "third_party/WebKit/public/web/WebPlugin.h"
16 #include "third_party/WebKit/public/web/WebPluginContainer.h"
17
18 namespace WebTestRunner {
19
20 class WebTestDelegate;
21
22 // A fake implemention of blink::WebPlugin for testing purposes.
23 //
24 // It uses WebGraphicsContext3D to paint a scene consisiting of a primitive
25 // over a background. The primitive and background can be customized using
26 // the following plugin parameters:
27 // primitive: none (default), triangle.
28 // background-color: black (default), red, green, blue.
29 // primitive-color: black (default), red, green, blue.
30 // opacity: [0.0 - 1.0]. Default is 1.0.
31 //
32 // Whether the plugin accepts touch events or not can be customized using the
33 // 'accepts-touch' plugin parameter (defaults to false).
34 class TestPlugin : public blink::WebPlugin, public blink::WebExternalTextureLaye rClient, public blink::WebNonCopyable {
35 public:
36 static TestPlugin* create(blink::WebFrame*, const blink::WebPluginParams&, W ebTestDelegate*);
37 virtual ~TestPlugin();
38
39 static const blink::WebString& mimeType();
40
41 // WebPlugin methods:
42 virtual bool initialize(blink::WebPluginContainer*);
43 virtual void destroy();
44 virtual NPObject* scriptableObject() { return 0; }
45 virtual bool canProcessDrag() const { return m_canProcessDrag; }
46 virtual void paint(blink::WebCanvas*, const blink::WebRect&) { }
47 virtual void updateGeometry(const blink::WebRect& frameRect, const blink::We bRect& clipRect, const blink::WebVector<blink::WebRect>& cutOutsRects, bool isVi sible);
48 virtual void updateFocus(bool) { }
49 virtual void updateVisibility(bool) { }
50 virtual bool acceptsInputEvents() { return true; }
51 virtual bool handleInputEvent(const blink::WebInputEvent&, blink::WebCursorI nfo&);
52 virtual bool handleDragStatusUpdate(blink::WebDragStatus, const blink::WebDr agData&, blink::WebDragOperationsMask, const blink::WebPoint& position, const bl ink::WebPoint& screenPosition);
53 virtual void didReceiveResponse(const blink::WebURLResponse&) { }
54 virtual void didReceiveData(const char* data, int dataLength) { }
55 virtual void didFinishLoading() { }
56 virtual void didFailLoading(const blink::WebURLError&) { }
57 virtual void didFinishLoadingFrameRequest(const blink::WebURL&, void* notify Data) { }
58 virtual void didFailLoadingFrameRequest(const blink::WebURL&, void* notifyDa ta, const blink::WebURLError&) { }
59 virtual bool isPlaceholder() { return false; }
60
61 // WebExternalTextureLayerClient methods:
62 virtual blink::WebGraphicsContext3D* context() { return 0; }
63 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt ernalBitmap*);
64 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&);
65
66 private:
67 TestPlugin(blink::WebFrame*, const blink::WebPluginParams&, WebTestDelegate* );
68
69 enum Primitive {
70 PrimitiveNone,
71 PrimitiveTriangle
72 };
73
74 struct Scene {
75 Primitive primitive;
76 unsigned backgroundColor[3];
77 unsigned primitiveColor[3];
78 float opacity;
79
80 unsigned vbo;
81 unsigned program;
82 int colorLocation;
83 int positionLocation;
84
85 Scene()
86 : primitive(PrimitiveNone)
87 , opacity(1.0f) // Fully opaque.
88 , vbo(0)
89 , program(0)
90 , colorLocation(-1)
91 , positionLocation(-1)
92 {
93 backgroundColor[0] = backgroundColor[1] = backgroundColor[2] = 0;
94 primitiveColor[0] = primitiveColor[1] = primitiveColor[2] = 0;
95 }
96 };
97
98 // Functions for parsing plugin parameters.
99 Primitive parsePrimitive(const blink::WebString&);
100 void parseColor(const blink::WebString&, unsigned color[3]);
101 float parseOpacity(const blink::WebString&);
102 bool parseBoolean(const blink::WebString&);
103
104 // Functions for loading and drawing scene.
105 bool initScene();
106 void drawScene();
107 void destroyScene();
108 bool initProgram();
109 bool initPrimitive();
110 void drawPrimitive();
111 unsigned loadShader(unsigned type, const std::string& source);
112 unsigned loadProgram(const std::string& vertexSource, const std::string& fra gmentSource);
113
114 blink::WebFrame* m_frame;
115 WebTestDelegate* m_delegate;
116 blink::WebPluginContainer* m_container;
117
118 blink::WebRect m_rect;
119 blink::WebGraphicsContext3D* m_context;
120 unsigned m_colorTexture;
121 blink::WebExternalTextureMailbox m_mailbox;
122 bool m_mailboxChanged;
123 unsigned m_framebuffer;
124 Scene m_scene;
125 WebScopedPtr<blink::WebExternalTextureLayer> m_layer;
126
127 blink::WebPluginContainer::TouchEventRequestType m_touchEventRequest;
128 // Requests touch events from the WebPluginContainerImpl multiple times to t ickle webkit.org/b/108381
129 bool m_reRequestTouchEvents;
130 bool m_printEventDetails;
131 bool m_printUserGestureStatus;
132 bool m_canProcessDrag;
133 };
134
135 }
136
137 #endif // TestPlugin_h
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/TestInterfaces.cpp ('k') | content/shell/renderer/test_runner/TestPlugin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698