1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
// Copyright (c) 2010 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 WEBKIT_MOCKS_MOCK_WEBFRAME_H_
#define WEBKIT_MOCKS_MOCK_WEBFRAME_H_
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPerformance.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "v8/include/v8.h"
using WebKit::WebAnimationController;
using WebKit::WebCanvas;
using WebKit::WebConsoleMessage;
using WebKit::WebData;
using WebKit::WebDocument;
using WebKit::WebElement;
using WebKit::WebFindOptions;
using WebKit::WebFormElement;
using WebKit::WebFrame;
using WebKit::WebHistoryItem;
using WebKit::WebInputElement;
using WebKit::WebNode;
using WebKit::WebPasswordAutocompleteListener;
using WebKit::WebPerformance;
using WebKit::WebRange;
using WebKit::WebRect;
using WebKit::WebURLRequest;
using WebKit::WebSecurityOrigin;
using WebKit::WebScriptSource;
using WebKit::WebSize;
using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebURLLoader;
using WebKit::WebVector;
using WebKit::WebView;
namespace webkit_glue {
class MockWebFrame : public WebKit::WebFrame {
public:
MockWebFrame() {
}
virtual ~MockWebFrame() {
}
MOCK_METHOD2(setReferrerForRequest, void(WebURLRequest&, const WebURL&));
MOCK_METHOD1(dispatchWillSendRequest, void(WebURLRequest&));
// Methods from WebFrame that we don't care to mock.
WEBKIT_API static int instanceCount() { return 0; }
WEBKIT_API static WebFrame* frameForEnteredContext() { return NULL; }
WEBKIT_API static WebFrame* frameForCurrentContext() { return NULL; }
WEBKIT_API static WebFrame* fromFrameOwnerElement(const WebElement&) {
return NULL;
}
virtual WebString name() const {
return WebString();
}
virtual void setName(const WebString&) {}
virtual long long identifier() const {
return 0;
}
virtual WebURL url() const {
return WebURL();
}
virtual WebURL favIconURL() const {
return WebURL();
}
virtual WebURL openSearchDescriptionURL() const {
return WebURL();
}
virtual WebString encoding() const {
return WebString();
}
virtual void setCanHaveScrollbars(bool) {}
virtual WebSize scrollOffset() const {
return WebSize(0,0);
}
virtual WebSize contentsSize() const {
return WebSize();
}
virtual int contentsPreferredWidth() const {
return 0;
}
virtual int documentElementScrollHeight() const {
return 0;
}
virtual bool hasVisibleContent() const {
return false;
}
virtual WebView* view() const {
return NULL;
}
virtual WebFrame* opener() const {
return NULL;
}
virtual WebFrame* parent() const {
return NULL;
}
virtual WebFrame* top() const {
return NULL;
}
virtual WebFrame* firstChild() const {
return NULL;
}
virtual WebFrame* lastChild() const {
return NULL;
}
virtual WebFrame* nextSibling() const {
return NULL;
}
virtual WebFrame* previousSibling() const {
return NULL;
}
virtual WebFrame* traverseNext(bool wrap) const {
return NULL;
}
virtual WebFrame* traversePrevious(bool wrap) const {
return NULL;
}
virtual WebFrame* findChildByName(const WebString& name) const {
return NULL;
}
virtual WebFrame* findChildByExpression(const WebString& xpath) const {
return NULL;
}
virtual WebDocument document() const {
return WebDocument();
}
virtual void forms(WebVector<WebFormElement>&) const {}
virtual WebAnimationController* animationController() {
return NULL;
}
virtual WebPerformance performance() const {
return WebPerformance();
}
virtual WebSecurityOrigin securityOrigin() const {
return WebSecurityOrigin();
}
virtual void grantUniversalAccess() {}
virtual NPObject* windowObject() const {
return NULL;
}
virtual void bindToWindowObject(const WebString& name, NPObject*) {}
virtual void executeScript(const WebScriptSource&) {}
virtual void executeScriptInIsolatedWorld(
int worldId, const WebScriptSource* sources, unsigned numSources,
int extensionGroup) {}
virtual void addMessageToConsole(const WebConsoleMessage&) {}
virtual void collectGarbage() {}
#if WEBKIT_USING_V8
virtual v8::Handle<v8::Value> executeScriptAndReturnValue(
const WebScriptSource&) {
return v8::Handle<v8::Value>();
}
virtual v8::Local<v8::Context> mainWorldScriptContext() const {
return v8::Local<v8::Context>();
}
#endif
virtual bool insertStyleText(const WebString& styleText,
const WebString& elementId) {
return false;
}
virtual void reload(bool ignoreCache = false) {}
virtual void loadRequest(const WebURLRequest&) {}
virtual void loadHistoryItem(const WebHistoryItem&) {}
virtual void loadData(const WebData& data,
const WebString& mimeType,
const WebString& textEncoding,
const WebURL& baseURL,
const WebURL& unreachableURL = WebURL(),
bool replace = false) {}
virtual void loadHTMLString(const WebData& html,
const WebURL& baseURL,
const WebURL& unreachableURL = WebURL(),
bool replace = false) {}
virtual bool isLoading() const {
return false;
}
virtual void stopLoading() {}
virtual WebKit::WebDataSource* provisionalDataSource() const {
return NULL;
}
virtual WebKit::WebDataSource* dataSource() const {
return NULL;
}
virtual WebHistoryItem previousHistoryItem() const {
return WebHistoryItem();
}
virtual WebHistoryItem currentHistoryItem() const {
return WebHistoryItem();
}
virtual void enableViewSourceMode(bool) {}
virtual bool isViewSourceModeEnabled() const {
return false;
}
// The next two methods were mocked above.
// virtual void setReferrerForRequest(WebURLRequest&, const WebURL&) {}
// virtual void dispatchWillSendRequest(WebURLRequest&) {}
virtual WebURLLoader* createAssociatedURLLoader() {
return NULL;
}
virtual void commitDocumentData(const char* data, size_t length) {}
virtual unsigned unloadListenerCount() const {
return 0;
}
virtual bool isProcessingUserGesture() const {
return false;
}
virtual bool willSuppressOpenerInNewFrame() const {
return false;
}
virtual void replaceSelection(const WebString& text) {}
virtual void insertText(const WebString& text) {}
virtual void setMarkedText(const WebString& text,
unsigned location,
unsigned length) {}
virtual void unmarkText() {}
virtual bool hasMarkedText() const {
return false;
}
virtual WebRange markedRange() const {
return WebRange();
}
virtual bool firstRectForCharacterRange(unsigned location,
unsigned length,
WebRect&) const {
return false;
}
virtual bool executeCommand(const WebString&) {
return false;
}
virtual bool executeCommand(const WebString&, const WebString& value) {
return false;
}
virtual bool isCommandEnabled(const WebString&) const {
return false;
}
virtual void enableContinuousSpellChecking(bool) {}
virtual bool isContinuousSpellCheckingEnabled() const {
return false;
}
virtual bool hasSelection() const {
return false;
}
virtual WebRange selectionRange() const {
return WebRange();
}
virtual WebString selectionAsText() const {
return WebString();
}
virtual WebString selectionAsMarkup() const {
return WebString();
}
virtual bool selectWordAroundCaret() {
return false;
}
#if defined(WEBFRAME_PRINTBEGIN_TAKES_NODE)
virtual int printBegin(const WebSize& pageSize,
const WebNode& constrainToNode,
int printerDPI = 72,
bool* useBrowserOverlays = 0) {
#else
virtual int printBegin(const WebSize& pageSize, int printerDPI = 72,
bool* useBrowserOverlays = 0) {
#endif
return 0;
}
virtual float getPrintPageShrink(int page) {
return 0;
}
virtual float printPage(int pageToPrint, WebCanvas*) {
return 0;
}
virtual void printEnd() {}
virtual bool isPageBoxVisible(int pageIndex) {
return false;
}
virtual void pageSizeAndMarginsInPixels(int pageIndex,
WebSize& pageSize,
int& marginTop,
int& marginRight,
int& marginBottom,
int& marginLeft) {}
virtual bool find(int identifier,
const WebString& searchText,
const WebFindOptions& options,
bool wrapWithinFrame,
WebRect* selectionRect) {
return false;
}
virtual void stopFinding(bool clearSelection) {}
virtual void scopeStringMatches(int identifier,
const WebString& searchText,
const WebFindOptions& options,
bool reset) {}
virtual void cancelPendingScopingEffort() {}
virtual void increaseMatchCount(int count, int identifier) {}
virtual void resetMatchCount() {}
virtual bool registerPasswordListener(
WebInputElement,
WebPasswordAutocompleteListener*) {
return false;
}
virtual void notifiyPasswordListenerOfAutocomplete(
const WebInputElement&) {}
virtual WebString contentAsText(size_t maxChars) const {
return WebString();
}
virtual WebString contentAsMarkup() const {
return WebString();
}
virtual WebString renderTreeAsText() const {
return WebString();
}
virtual WebString counterValueForElementById(const WebString& id) const {
return WebString();
}
virtual WebString markerTextForListItem(const WebElement&) const {
return WebString();
}
virtual int pageNumberForElementById(const WebString& id,
float pageWidthInPixels,
float pageHeightInPixels) const {
return 0;
}
virtual WebRect selectionBoundsRect() const {
return WebRect();
}
virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const {
return false;
}
virtual bool pauseSVGAnimation(const WebString& animationId,
double time,
const WebString& elementId) {
return false;
}
virtual WebString layerTreeAsText() const {
return WebString();
}
private:
DISALLOW_COPY_AND_ASSIGN(MockWebFrame);
};
} // namespace webkit_glue
#endif // WEBKIT_MOCKS_MOCK_WEBFRAME_H_
|