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