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