diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 22:52:56 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 22:52:56 +0000 |
commit | 35724643015a301b2b939faa9c8c214c015a8847 (patch) | |
tree | a0a2b3a8cfd162beb9d349d92a2eeb458d09c560 | |
parent | 4515537477150f6bd01203b4a7f351c04973f71d (diff) | |
download | chromium_src-35724643015a301b2b939faa9c8c214c015a8847.zip chromium_src-35724643015a301b2b939faa9c8c214c015a8847.tar.gz chromium_src-35724643015a301b2b939faa9c8c214c015a8847.tar.bz2 |
Remove MockWebFrame in favour of MockWebFrameClient and update corresponding tests.
This should help reduce WebKit gardening pain since all WebFrame implementations will reside in WebKit itself.
BUG=none
TEST=test_shell_tests
Review URL: http://codereview.chromium.org/6973051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85343 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/glue/media/buffered_data_source_unittest.cc | 22 | ||||
-rw-r--r-- | webkit/glue/media/buffered_resource_loader_unittest.cc | 23 | ||||
-rw-r--r-- | webkit/glue/media/simple_data_source_unittest.cc | 25 | ||||
-rw-r--r-- | webkit/mocks/mock_webframe.cc | 447 | ||||
-rw-r--r-- | webkit/mocks/mock_webframe.h | 250 | ||||
-rw-r--r-- | webkit/mocks/mock_webframeclient.h | 16 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.gypi | 3 |
7 files changed, 59 insertions, 727 deletions
diff --git a/webkit/glue/media/buffered_data_source_unittest.cc b/webkit/glue/media/buffered_data_source_unittest.cc index e66ea9a..4e53ba0 100644 --- a/webkit/glue/media/buffered_data_source_unittest.cc +++ b/webkit/glue/media/buffered_data_source_unittest.cc @@ -9,10 +9,9 @@ #include "media/base/mock_filter_host.h" #include "media/base/mock_filters.h" #include "net/base/net_errors.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "webkit/glue/media/buffered_data_source.h" -#include "webkit/mocks/mock_webframe.h" +#include "webkit/mocks/mock_webframeclient.h" using ::testing::_; using ::testing::Assign; @@ -30,6 +29,9 @@ using ::testing::StrictMock; using ::testing::NiceMock; using ::testing::WithArgs; +using WebKit::WebFrame; +using WebKit::WebView; + namespace webkit_glue { static const char* kHttpUrl = "http://test"; @@ -90,16 +92,18 @@ class MockBufferedResourceLoader : public BufferedResourceLoader { class BufferedDataSourceTest : public testing::Test { public: - BufferedDataSourceTest() { + BufferedDataSourceTest() + : view_(WebView::create(NULL)) { + view_->initializeMainFrame(&client_); message_loop_ = MessageLoop::current(); - // Prepare test data. for (size_t i = 0; i < sizeof(data_); ++i) { data_[i] = i; } } virtual ~BufferedDataSourceTest() { + view_->close(); } void ExpectCreateAndStartResourceLoader(int start_error) { @@ -119,10 +123,8 @@ class BufferedDataSourceTest : public testing::Test { // Saves the url first. gurl_ = GURL(url); - frame_.reset(new NiceMock<MockWebFrame>()); - data_source_ = new MockBufferedDataSource(MessageLoop::current(), - frame_.get()); + view_->mainFrame()); data_source_->set_host(&host_); scoped_refptr<NiceMock<MockBufferedResourceLoader> > first_loader( @@ -360,7 +362,9 @@ class BufferedDataSourceTest : public testing::Test { scoped_refptr<NiceMock<MockBufferedResourceLoader> > loader_; scoped_refptr<MockBufferedDataSource> data_source_; - scoped_ptr<NiceMock<MockWebFrame> > frame_; + + MockWebFrameClient client_; + WebView* view_; StrictMock<media::MockFilterHost> host_; GURL gurl_; diff --git a/webkit/glue/media/buffered_resource_loader_unittest.cc b/webkit/glue/media/buffered_resource_loader_unittest.cc index 03fd360d..29f1a64 100644 --- a/webkit/glue/media/buffered_resource_loader_unittest.cc +++ b/webkit/glue/media/buffered_resource_loader_unittest.cc @@ -9,12 +9,12 @@ #include "net/base/net_errors.h" #include "net/http/http_util.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "webkit/glue/media/buffered_resource_loader.h" -#include "webkit/mocks/mock_webframe.h" +#include "webkit/mocks/mock_webframeclient.h" #include "webkit/mocks/mock_weburlloader.h" using ::testing::_; @@ -33,8 +33,8 @@ using ::testing::StrictMock; using ::testing::NiceMock; using ::testing::WithArgs; +using WebKit::WebString; using WebKit::WebURLError; -using WebKit::WebFrameClient; using WebKit::WebURLResponse; using WebKit::WebView; @@ -67,12 +67,17 @@ ACTION_P(RequestCanceled, loader) { class BufferedResourceLoaderTest : public testing::Test { public: - BufferedResourceLoaderTest() { - for (int i = 0; i < kDataSize; ++i) + BufferedResourceLoaderTest() + : view_(WebView::create(NULL)) { + view_->initializeMainFrame(&client_); + + for (int i = 0; i < kDataSize; ++i) { data_[i] = i; + } } virtual ~BufferedResourceLoaderTest() { + view_->close(); } void Initialize(const char* url, int first_position, int last_position) { @@ -80,8 +85,6 @@ class BufferedResourceLoaderTest : public testing::Test { first_position_ = first_position; last_position_ = last_position; - frame_.reset(new NiceMock<MockWebFrame>()); - url_loader_ = new NiceMock<MockWebURLLoader>(); loader_ = new BufferedResourceLoader(gurl_, first_position_, last_position_); @@ -99,7 +102,7 @@ class BufferedResourceLoaderTest : public testing::Test { loader_->Start( NewCallback(this, &BufferedResourceLoaderTest::StartCallback), NewCallback(this, &BufferedResourceLoaderTest::NetworkCallback), - frame_.get()); + view_->mainFrame()); } void FullResponse(int64 instance_size) { @@ -231,7 +234,9 @@ class BufferedResourceLoaderTest : public testing::Test { scoped_refptr<BufferedResourceLoader> loader_; NiceMock<MockWebURLLoader>* url_loader_; - scoped_ptr<NiceMock<MockWebFrame> > frame_; + + MockWebFrameClient client_; + WebView* view_; uint8 data_[kDataSize]; diff --git a/webkit/glue/media/simple_data_source_unittest.cc b/webkit/glue/media/simple_data_source_unittest.cc index 61e41f2..264b685 100644 --- a/webkit/glue/media/simple_data_source_unittest.cc +++ b/webkit/glue/media/simple_data_source_unittest.cc @@ -7,13 +7,13 @@ #include "media/base/mock_filter_host.h" #include "media/base/mock_filters.h" #include "net/base/net_errors.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoader.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "webkit/glue/media/simple_data_source.h" -#include "webkit/mocks/mock_webframe.h" +#include "webkit/mocks/mock_webframeclient.h" #include "webkit/mocks/mock_weburlloader.h" using ::testing::_; @@ -31,6 +31,7 @@ using WebKit::WebURLError; using WebKit::WebURLLoader; using WebKit::WebURLRequest; using WebKit::WebURLResponse; +using WebKit::WebView; namespace webkit_glue { @@ -49,24 +50,27 @@ static const char kHttpRedirectToDifferentDomainUrl2[] = "http://test2/ing"; class SimpleDataSourceTest : public testing::Test { public: - SimpleDataSourceTest() { + SimpleDataSourceTest() + : view_(WebView::create(NULL)) { + view_->initializeMainFrame(&client_); + for (int i = 0; i < kDataSize; ++i) { data_[i] = i; } } virtual ~SimpleDataSourceTest() { + view_->close(); } void InitializeDataSource(const char* url, media::MockStatusCallback* callback) { gurl_ = GURL(url); - frame_.reset(new NiceMock<MockWebFrame>()); url_loader_ = new NiceMock<MockWebURLLoader>(); data_source_ = new SimpleDataSource(MessageLoop::current(), - frame_.get()); + view_->mainFrame()); // There is no need to provide a message loop to data source. data_source_->set_host(&host_); @@ -114,8 +118,8 @@ class SimpleDataSourceTest : public testing::Test { void Redirect(const char* url) { GURL redirectUrl(url); - WebKit::WebURLRequest newRequest(redirectUrl); - WebKit::WebURLResponse redirectResponse(gurl_); + WebURLRequest newRequest(redirectUrl); + WebURLResponse redirectResponse(gurl_); data_source_->willSendRequest(url_loader_, newRequest, redirectResponse); @@ -149,7 +153,9 @@ class SimpleDataSourceTest : public testing::Test { NiceMock<MockWebURLLoader>* url_loader_; scoped_refptr<SimpleDataSource> data_source_; StrictMock<media::MockFilterHost> host_; - scoped_ptr<NiceMock<MockWebFrame> > frame_; + + MockWebFrameClient client_; + WebView* view_; char data_[kDataSize]; @@ -178,11 +184,10 @@ TEST_F(SimpleDataSourceTest, InitializeFile) { } TEST_F(SimpleDataSourceTest, InitializeData) { - frame_.reset(new NiceMock<MockWebFrame>()); url_loader_ = new NiceMock<MockWebURLLoader>(); data_source_ = new SimpleDataSource(MessageLoop::current(), - frame_.get()); + view_->mainFrame()); // There is no need to provide a message loop to data source. data_source_->set_host(&host_); data_source_->SetURLLoaderForTest(url_loader_); diff --git a/webkit/mocks/mock_webframe.cc b/webkit/mocks/mock_webframe.cc deleted file mode 100644 index 733486a..0000000 --- a/webkit/mocks/mock_webframe.cc +++ /dev/null @@ -1,447 +0,0 @@ -// Copyright (c) 2011 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. - -#include "webkit/mocks/mock_webframe.h" - -#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" - -namespace webkit_glue { - -MockWebFrame::MockWebFrame() {} - -MockWebFrame::~MockWebFrame() {} - -WebString MockWebFrame::name() const { - return WebString(); -} - -void MockWebFrame::setName(const WebString&) {} - -long long MockWebFrame::identifier() const { - return 0; -} - -WebURL MockWebFrame::url() const { - return WebURL(); -} - -WebURL MockWebFrame::favIconURL() const { - return WebURL(); -} - -WebURL MockWebFrame::openSearchDescriptionURL() const { - return WebURL(); -} - -WebString MockWebFrame::encoding() const { - return WebString(); -} - -void MockWebFrame::setCanHaveScrollbars(bool) {} - -WebSize MockWebFrame::scrollOffset() const { - return WebSize(0,0); -} - -void MockWebFrame::setScrollOffset(const WebSize&) {} - -WebSize MockWebFrame::contentsSize() const { - return WebSize(); -} - -int MockWebFrame::contentsPreferredWidth() const { - return 0; -} - -int MockWebFrame::documentElementScrollHeight() const { - return 0; -} - -bool MockWebFrame::hasVisibleContent() const { - return false; -} - -WebView* MockWebFrame::view() const { - return NULL; -} - -WebFrame* MockWebFrame::opener() const { - return NULL; -} - -void MockWebFrame::clearOpener() { -} - -WebFrame* MockWebFrame::parent() const { - return NULL; -} - -WebFrame* MockWebFrame::top() const { - return NULL; -} - -WebFrame* MockWebFrame::firstChild() const { - return NULL; -} - -WebFrame* MockWebFrame::lastChild() const { - return NULL; -} - -WebFrame* MockWebFrame::nextSibling() const { - return NULL; -} - -WebFrame* MockWebFrame::previousSibling() const { - return NULL; -} - -WebFrame* MockWebFrame::traverseNext(bool wrap) const { - return NULL; -} - -WebFrame* MockWebFrame::traversePrevious(bool wrap) const { - return NULL; -} - -WebFrame* MockWebFrame::findChildByName(const WebString& name) const { - return NULL; -} - -WebFrame* MockWebFrame::findChildByExpression(const WebString& xpath) const { - return NULL; -} - -WebDocument MockWebFrame::document() const { - return WebDocument(); -} - -void MockWebFrame::forms(WebVector<WebFormElement>&) const {} - -WebAnimationController* MockWebFrame::animationController() { - return NULL; -} - -WebPerformance MockWebFrame::performance() const { - return WebPerformance(); -} - -WebSecurityOrigin MockWebFrame::securityOrigin() const { - return WebSecurityOrigin(); -} - -void MockWebFrame::grantUniversalAccess() {} - -NPObject* MockWebFrame::windowObject() const { - return NULL; -} - -void MockWebFrame::bindToWindowObject(const WebString& name, NPObject*) {} - -void MockWebFrame::executeScript(const WebScriptSource&) {} - -void MockWebFrame::executeScriptInIsolatedWorld( - int worldId, const WebScriptSource* sources, unsigned numSources, - int extensionGroup) {} - -void MockWebFrame::addMessageToConsole(const WebConsoleMessage&) {} - -void MockWebFrame::collectGarbage() {} - -#if WEBKIT_USING_V8 -v8::Handle<v8::Value> MockWebFrame::executeScriptAndReturnValue( - const WebScriptSource&) { - return v8::Handle<v8::Value>(); -} - -v8::Local<v8::Context> MockWebFrame::mainWorldScriptContext() const { - return v8::Local<v8::Context>(); -} - -#ifdef WEB_FILE_SYSTEM_TYPE_EXTERNAL -v8::Handle<v8::Value> MockWebFrame::createFileSystem( - WebKit::WebFileSystem::Type type, const WebString& name, - const WebString& path) { - return v8::Handle<v8::Value>(); -} - -v8::Handle<v8::Value> MockWebFrame::createFileEntry( - WebKit::WebFileSystem::Type type, const WebString& fileSystemName, - const WebString& fileSystemPath, const WebString& filePath, - bool isDirectory) { - return v8::Handle<v8::Value>(); -} -#else -v8::Handle<v8::Value> MockWebFrame::createFileSystem( - int type, const WebString& name, - const WebString& path) { - return v8::Handle<v8::Value>(); -} - -v8::Handle<v8::Value> MockWebFrame::createFileEntry( - int type, const WebString& fileSystemName, - const WebString& fileSystemPath, const WebString& filePath, - bool isDirectory) { - return v8::Handle<v8::Value>(); -} -#endif -#endif - - -bool MockWebFrame::insertStyleText(const WebString& styleText, - const WebString& elementId) { - return false; -} - -void MockWebFrame::reload(bool ignoreCache) {} - -void MockWebFrame::loadRequest(const WebURLRequest&) {} - -void MockWebFrame::loadHistoryItem(const WebHistoryItem&) {} - -void MockWebFrame::loadData(const WebData& data, - const WebString& mimeType, - const WebString& textEncoding, - const WebURL& baseURL, - const WebURL& unreachableURL, - bool replace) {} - -void MockWebFrame::loadHTMLString(const WebData& html, - const WebURL& baseURL, - const WebURL& unreachableURL, - bool replace) {} - -bool MockWebFrame::isLoading() const { - return false; -} - -void MockWebFrame::stopLoading() {} - -WebKit::WebDataSource* MockWebFrame::provisionalDataSource() const { - return NULL; -} - -WebKit::WebDataSource* MockWebFrame::dataSource() const { - return NULL; -} - -WebHistoryItem MockWebFrame::previousHistoryItem() const { - return WebHistoryItem(); -} - -WebHistoryItem MockWebFrame::currentHistoryItem() const { - return WebHistoryItem(); -} - -void MockWebFrame::enableViewSourceMode(bool) {} - -bool MockWebFrame::isViewSourceModeEnabled() const { - return false; -} - -// TODO(bbudge) remove once WebKit change lands. -WebURLLoader* MockWebFrame::createAssociatedURLLoader() { - return NULL; -} - -WebURLLoader* MockWebFrame::createAssociatedURLLoader( - const WebURLLoaderOptions& options) { - return NULL; -} - -void MockWebFrame::commitDocumentData(const char* data, size_t length) {} - -unsigned MockWebFrame::unloadListenerCount() const { - return 0; -} - -bool MockWebFrame::isProcessingUserGesture() const { - return false; -} - -bool MockWebFrame::willSuppressOpenerInNewFrame() const { - return false; -} - -void MockWebFrame::replaceSelection(const WebString& text) {} - -void MockWebFrame::insertText(const WebString& text) {} - -void MockWebFrame::setMarkedText(const WebString& text, - unsigned location, - unsigned length) {} - -void MockWebFrame::unmarkText() {} - -bool MockWebFrame::hasMarkedText() const { - return false; -} - -WebRange MockWebFrame::markedRange() const { - return WebRange(); -} - -bool MockWebFrame::firstRectForCharacterRange(unsigned location, - unsigned length, - WebRect&) const { - return false; -} - -size_t MockWebFrame::characterIndexForPoint(const WebPoint&) const { - return 0U; -} - -bool MockWebFrame::executeCommand(const WebString&) { - return false; -} - -bool MockWebFrame::executeCommand(const WebString&, const WebString& value) { - return false; -} - -bool MockWebFrame::isCommandEnabled(const WebString&) const { - return false; -} - -void MockWebFrame::enableContinuousSpellChecking(bool) {} - -bool MockWebFrame::isContinuousSpellCheckingEnabled() const { - return false; -} - -bool MockWebFrame::hasSelection() const { - return false; -} - -WebRange MockWebFrame::selectionRange() const { - return WebRange(); -} - -WebString MockWebFrame::selectionAsText() const { - return WebString(); -} - -WebString MockWebFrame::selectionAsMarkup() const { - return WebString(); -} - -bool MockWebFrame::selectWordAroundCaret() { - return false; -} - -void MockWebFrame::selectRange(const WebPoint& start, const WebPoint& end) { -} - -int MockWebFrame::printBegin(const WebSize& pageSize, - const WebNode& constrainToNode, - int printerDPI, - bool* useBrowserOverlays) { - return 0; -} - -float MockWebFrame::getPrintPageShrink(int page) { - return 0; -} - -float MockWebFrame::printPage(int pageToPrint, WebCanvas*) { - return 0; -} - -void MockWebFrame::printEnd() {} - -bool MockWebFrame::isPageBoxVisible(int pageIndex) { - return false; -} - -void MockWebFrame::pageSizeAndMarginsInPixels(int pageIndex, - WebSize& pageSize, - int& marginTop, - int& marginRight, - int& marginBottom, - int& marginLeft) {} - -bool MockWebFrame::find(int identifier, - const WebString& searchText, - const WebFindOptions& options, - bool wrapWithinFrame, - WebRect* selectionRect) { - return false; -} - -void MockWebFrame::stopFinding(bool clearSelection) {} - -void MockWebFrame::scopeStringMatches(int identifier, - const WebString& searchText, - const WebFindOptions& options, - bool reset) {} - -void MockWebFrame::cancelPendingScopingEffort() {} - -void MockWebFrame::increaseMatchCount(int count, int identifier) {} - -void MockWebFrame::resetMatchCount() {} - -bool MockWebFrame::registerPasswordListener( - WebInputElement, - WebPasswordAutocompleteListener*) { - return false; -} - -void MockWebFrame::notifiyPasswordListenerOfAutocomplete( - const WebInputElement&) {} - -WebString MockWebFrame::contentAsText(size_t maxChars) const { - return WebString(); -} - -WebString MockWebFrame::contentAsMarkup() const { - return WebString(); -} - -WebString MockWebFrame::renderTreeAsText(bool showDebugInfo) const { - return WebString(); -} - -WebString MockWebFrame::renderTreeAsText() const { - return WebString(); -} - -WebString MockWebFrame::counterValueForElementById(const WebString& id) const { - return WebString(); -} - -WebString MockWebFrame::markerTextForListItem(const WebElement&) const { - return WebString(); -} - -int MockWebFrame::pageNumberForElementById(const WebString& id, - float pageWidthInPixels, - float pageHeightInPixels) const { - return 0; -} - -WebRect MockWebFrame::selectionBoundsRect() const { - return WebRect(); -} - -bool MockWebFrame::selectionStartHasSpellingMarkerFor(int from, - int length) const { - return false; -} - -bool MockWebFrame::pauseSVGAnimation(const WebString& animationId, - double time, - const WebString& elementId) { - return false; -} - -WebString MockWebFrame::layerTreeAsText(bool showDebugInfo) const { - return WebString(); -} - -WebString MockWebFrame::layerTreeAsText() const { - return WebString(); -} - -} // namespace webkit_glue diff --git a/webkit/mocks/mock_webframe.h b/webkit/mocks/mock_webframe.h deleted file mode 100644 index 91f544b..0000000 --- a/webkit/mocks/mock_webframe.h +++ /dev/null @@ -1,250 +0,0 @@ -// Copyright (c) 2011 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/WebPoint.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" - -// TODO(bbudge) remove once this is declared in WebFrame.h -namespace WebKit { - - struct WebURLLoaderOptions; - -}; - -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::WebPoint; -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::WebURLLoaderOptions; -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; - virtual void setName(const WebString&); - virtual long long identifier() const; - virtual WebURL url() const; - virtual WebURL favIconURL() const; - virtual WebURL openSearchDescriptionURL() const; - virtual WebString encoding() const; - virtual void setCanHaveScrollbars(bool); - virtual WebSize scrollOffset() const; - virtual void setScrollOffset(const WebSize&); - virtual WebSize contentsSize() const; - virtual int contentsPreferredWidth() const; - virtual int documentElementScrollHeight() const; - virtual bool hasVisibleContent() const; - virtual WebView* view() const; - virtual WebFrame* opener() const; - virtual void clearOpener(); - virtual WebFrame* parent() const; - virtual WebFrame* top() const; - virtual WebFrame* firstChild() const; - virtual WebFrame* lastChild() const; - virtual WebFrame* nextSibling() const; - virtual WebFrame* previousSibling() const; - virtual WebFrame* traverseNext(bool wrap) const; - virtual WebFrame* traversePrevious(bool wrap) const; - virtual WebFrame* findChildByName(const WebString& name) const; - virtual WebFrame* findChildByExpression(const WebString& xpath) const; - virtual WebDocument document() const; - virtual void forms(WebVector<WebFormElement>&) const; - virtual WebAnimationController* animationController(); - virtual WebPerformance performance() const; - virtual WebSecurityOrigin securityOrigin() const; - virtual void grantUniversalAccess(); - virtual NPObject* windowObject() const; - 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&); - virtual v8::Local<v8::Context> mainWorldScriptContext() const; -#ifdef WEB_FILE_SYSTEM_TYPE_EXTERNAL - virtual v8::Handle<v8::Value> createFileSystem( - WebKit::WebFileSystem::Type type, const WebString& name, - const WebString& path); - virtual v8::Handle<v8::Value> createFileEntry( - WebKit::WebFileSystem::Type type, const WebString& fileSystemName, - const WebString& fileSystemPath, const WebString& filePath, - bool isDirectory); -#else - virtual v8::Handle<v8::Value> createFileSystem( - int type, const WebString& name, - const WebString& path); - virtual v8::Handle<v8::Value> createFileEntry( - int type, const WebString& fileSystemName, - const WebString& fileSystemPath, const WebString& filePath, - bool isDirectory); -#endif -#endif - virtual bool insertStyleText(const WebString& styleText, - const WebString& elementId); - 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; - virtual void stopLoading(); - virtual WebKit::WebDataSource* provisionalDataSource() const; - virtual WebKit::WebDataSource* dataSource() const; - virtual WebHistoryItem previousHistoryItem() const; - virtual WebHistoryItem currentHistoryItem() const; - virtual void enableViewSourceMode(bool); - virtual bool isViewSourceModeEnabled() const; - // The next two methods were mocked above. - // virtual void setReferrerForRequest(WebURLRequest&, const WebURL&) {} - // virtual void dispatchWillSendRequest(WebURLRequest&) {} - // TODO(bbudge) remove once WebKit change lands. - virtual WebURLLoader* createAssociatedURLLoader(); - virtual WebURLLoader* createAssociatedURLLoader( - const WebURLLoaderOptions& options); - virtual void commitDocumentData(const char* data, size_t length); - virtual unsigned unloadListenerCount() const; - virtual bool isProcessingUserGesture() const; - virtual bool willSuppressOpenerInNewFrame() const; - 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; - virtual WebRange markedRange() const; - virtual bool firstRectForCharacterRange(unsigned location, - unsigned length, - WebRect&) const; - virtual size_t characterIndexForPoint(const WebPoint&) const; - virtual bool executeCommand(const WebString&); - virtual bool executeCommand(const WebString&, const WebString& value); - virtual bool isCommandEnabled(const WebString&) const; - virtual void enableContinuousSpellChecking(bool); - virtual bool isContinuousSpellCheckingEnabled() const; - virtual bool hasSelection() const; - virtual WebRange selectionRange() const; - virtual WebString selectionAsText() const; - virtual WebString selectionAsMarkup() const; - virtual bool selectWordAroundCaret(); - virtual void selectRange(const WebPoint& start, const WebPoint& end); - virtual int printBegin(const WebSize& pageSize, - const WebNode& constrainToNode, - int printerDPI = 72, - bool* useBrowserOverlays = 0); - virtual float getPrintPageShrink(int page); - virtual float printPage(int pageToPrint, WebCanvas*); - virtual void printEnd(); - virtual bool isPageBoxVisible(int pageIndex); - 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); - 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*); - virtual void notifiyPasswordListenerOfAutocomplete( - const WebInputElement&); - virtual WebString contentAsText(size_t maxChars) const; - virtual WebString contentAsMarkup() const; - virtual WebString renderTreeAsText(bool showDebugInfo) const; - virtual WebString renderTreeAsText() const; - virtual WebString counterValueForElementById(const WebString& id) const; - virtual WebString markerTextForListItem(const WebElement&) const; - virtual int pageNumberForElementById(const WebString& id, - float pageWidthInPixels, - float pageHeightInPixels) const; - virtual WebRect selectionBoundsRect() const; - virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const; - virtual bool pauseSVGAnimation(const WebString& animationId, - double time, - const WebString& elementId); - virtual WebString layerTreeAsText(bool showDebugInfo) const; - virtual WebString layerTreeAsText() const; - - private: - DISALLOW_COPY_AND_ASSIGN(MockWebFrame); -}; - -} // namespace webkit_glue - -#endif // WEBKIT_MOCKS_MOCK_WEBFRAME_H_ diff --git a/webkit/mocks/mock_webframeclient.h b/webkit/mocks/mock_webframeclient.h new file mode 100644 index 0000000..6f13811 --- /dev/null +++ b/webkit/mocks/mock_webframeclient.h @@ -0,0 +1,16 @@ +// Copyright (c) 2011 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_WEBFRAMECLIENT_H_ +#define WEBKIT_MOCKS_MOCK_WEBFRAMECLIENT_H_ + +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" + +namespace webkit_glue { + +class MockWebFrameClient : public WebKit::WebFrameClient {}; + +} // namespace webkit_glue + +#endif // WEBKIT_MOCKS_MOCK_WEBFRAMECLIENT_H_ diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi index e2ea35b..2cfb78a 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -411,8 +411,7 @@ '../../glue/webkit_glue_unittest.cc', '../../glue/webview_unittest.cc', '../../mocks/mock_resource_loader_bridge.h', - '../../mocks/mock_webframe.cc', - '../../mocks/mock_webframe.h', + '../../mocks/mock_webframeclient.h', '../../mocks/mock_weburlloader.cc', '../../mocks/mock_weburlloader.h', '../../plugins/npapi/plugin_group_unittest.cc', |