diff options
author | annacc@chromium.org <annacc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-17 18:46:38 +0000 |
---|---|---|
committer | annacc@chromium.org <annacc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-17 18:46:38 +0000 |
commit | 6e89290d7d706c0adedaf01713425094d4096526 (patch) | |
tree | 82612f318887b69f4eec4986b686f426021e72dd /webkit/mocks | |
parent | 45568795e2a04e29cefdaad058f55563a98cd970 (diff) | |
download | chromium_src-6e89290d7d706c0adedaf01713425094d4096526.zip chromium_src-6e89290d7d706c0adedaf01713425094d4096526.tar.gz chromium_src-6e89290d7d706c0adedaf01713425094d4096526.tar.bz2 |
moving mocks into webkit/mocks/
The number of mock_... files in webkit/glue is piling up and it makes more sense for them to live in a brand new mocks/ directory.
BUG=None.
TEST=Compiles.
Review URL: http://codereview.chromium.org/5878006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69562 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/mocks')
-rw-r--r-- | webkit/mocks/mock_resource_loader_bridge.h | 44 | ||||
-rw-r--r-- | webkit/mocks/mock_webframe.h | 352 | ||||
-rw-r--r-- | webkit/mocks/mock_weburlloader.h | 36 |
3 files changed, 432 insertions, 0 deletions
diff --git a/webkit/mocks/mock_resource_loader_bridge.h b/webkit/mocks/mock_resource_loader_bridge.h new file mode 100644 index 0000000..5be7d89 --- /dev/null +++ b/webkit/mocks/mock_resource_loader_bridge.h @@ -0,0 +1,44 @@ +// 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_RESOURCE_LOADER_BRIDGE_H_ +#define WEBKIT_MOCKS_MOCK_RESOURCE_LOADER_BRIDGE_H_ + +#include "testing/gmock/include/gmock/gmock.h" +#include "webkit/glue/resource_loader_bridge.h" + +class FilePath; + +namespace webkit_glue { + +class MockResourceLoaderBridge : public webkit_glue::ResourceLoaderBridge { + public: + MockResourceLoaderBridge() { + } + + virtual ~MockResourceLoaderBridge() { + OnDestroy(); + } + + MOCK_METHOD2(AppendDataToUpload, void(const char* data, int data_len)); + MOCK_METHOD4(AppendFileRangeToUpload, + void(const FilePath& file_path, + uint64 offset, + uint64 length, + const base::Time& expected_modification_time)); + MOCK_METHOD1(AppendBlobToUpload, void(const GURL& blob_url)); + MOCK_METHOD1(SetUploadIdentifier, void(int64 identifier)); + MOCK_METHOD1(Start, bool(ResourceLoaderBridge::Peer* peer)); + MOCK_METHOD0(Cancel, void()); + MOCK_METHOD1(SetDefersLoading, void(bool value)); + MOCK_METHOD1(SyncLoad, void(SyncLoadResponse* response)); + MOCK_METHOD0(OnDestroy, void()); + + private: + DISALLOW_COPY_AND_ASSIGN(MockResourceLoaderBridge); +}; + +} // namespace webkit_glue + +#endif // WEBKIT_MOCKS_MOCK_RESOURCE_LOADER_BRIDGE_H_ diff --git a/webkit/mocks/mock_webframe.h b/webkit/mocks/mock_webframe.h new file mode 100644 index 0000000..bdf4c58 --- /dev/null +++ b/webkit/mocks/mock_webframe.h @@ -0,0 +1,352 @@ +// 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/WebKit/chromium/public/WebDocument.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" +#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPerformance.h" +#include "third_party/WebKit/WebKit/chromium/public/WebRange.h" +#include "third_party/WebKit/WebKit/chromium/public/WebRect.h" +#include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" +#include "third_party/WebKit/WebKit/chromium/public/WebSize.h" +#include "third_party/WebKit/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::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; + } + virtual int printBegin(const WebSize& pageSize, int printerDPI = 72, + bool* useBrowserOverlays = 0) { + 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_ diff --git a/webkit/mocks/mock_weburlloader.h b/webkit/mocks/mock_weburlloader.h new file mode 100644 index 0000000..7253faa --- /dev/null +++ b/webkit/mocks/mock_weburlloader.h @@ -0,0 +1,36 @@ +// 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_WEBURLLOADER_H_ +#define WEBKIT_MOCKS_MOCK_WEBURLLOADER_H_ + +#include "testing/gmock/include/gmock/gmock.h" +#include "webkit/glue/weburlloader_impl.h" + +namespace webkit_glue { + +class MockWebURLLoader : public WebKit::WebURLLoader { + public: + MockWebURLLoader() { + } + + virtual ~MockWebURLLoader() { + } + + MOCK_METHOD4(loadSynchronously, void(const WebKit::WebURLRequest& request, + WebKit::WebURLResponse& response, + WebKit::WebURLError& error, + WebKit::WebData& data)); + MOCK_METHOD2(loadAsynchronously, void(const WebKit::WebURLRequest& request, + WebKit::WebURLLoaderClient* client)); + MOCK_METHOD0(cancel, void()); + MOCK_METHOD1(setDefersLoading, void(bool value)); + + private: + DISALLOW_COPY_AND_ASSIGN(MockWebURLLoader); +}; + +} // namespace webkit_glue + +#endif // WEBKIT_MOCKS_MOCK_WEBURLLOADER_H_ |