summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests/WebViewTest.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-09-11 19:54:20 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-09-11 19:54:20 +0200
commit88a04ac016f57c2d78e714682445dff2e7db4ade (patch)
treea48ca81ee3b29953121308168db22532d5b57fe2 /Source/WebKit/chromium/tests/WebViewTest.cpp
parent284837daa07b29d6a63a748544a90b1f5842ac5c (diff)
downloadqtwebkit-88a04ac016f57c2d78e714682445dff2e7db4ade.tar.gz
Imported WebKit commit 42d95198c30c2d1a94a5081181aad0b2be7c316c (http://svn.webkit.org/repository/webkit/trunk@128206)
This includes the rewrite of the configure part of the build system which should fix the QtQuick2 detection and allow for further simplifications in the future
Diffstat (limited to 'Source/WebKit/chromium/tests/WebViewTest.cpp')
-rw-r--r--Source/WebKit/chromium/tests/WebViewTest.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/WebKit/chromium/tests/WebViewTest.cpp b/Source/WebKit/chromium/tests/WebViewTest.cpp
index 4e2553a36..b7ab658de 100644
--- a/Source/WebKit/chromium/tests/WebViewTest.cpp
+++ b/Source/WebKit/chromium/tests/WebViewTest.cpp
@@ -422,6 +422,45 @@ TEST_F(WebViewTest, SetCompositionFromExistingText)
webView->close();
}
+TEST_F(WebViewTest, ResetScrollAndScaleState)
+{
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("hello_world.html"));
+ WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "hello_world.html"));
+ webViewImpl->resize(WebSize(640, 480));
+ EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
+ EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
+
+ // Make the page scale and scroll with the given paremeters.
+ webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84));
+ EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
+ EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width);
+ EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height);
+ webViewImpl->page()->mainFrame()->loader()->history()->saveDocumentAndScrollState();
+
+ // Confirm that restoring the page state restores the parameters.
+ webViewImpl->setPageScaleFactor(1.5f, WebPoint(16, 24));
+ EXPECT_EQ(1.5f, webViewImpl->pageScaleFactor());
+ EXPECT_EQ(16, webViewImpl->mainFrame()->scrollOffset().width);
+ EXPECT_EQ(24, webViewImpl->mainFrame()->scrollOffset().height);
+ webViewImpl->page()->mainFrame()->loader()->history()->restoreScrollPositionAndViewState();
+ EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
+ EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width);
+ EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height);
+ webViewImpl->page()->mainFrame()->loader()->history()->saveDocumentAndScrollState();
+
+ // Confirm that resetting the page state resets both the scale and scroll position, as well
+ // as overwrites the original parameters that were saved to the HistoryController.
+ webViewImpl->resetScrollAndScaleState();
+ EXPECT_EQ(0.0f, webViewImpl->pageScaleFactor());
+ EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
+ EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
+ webViewImpl->page()->mainFrame()->loader()->history()->restoreScrollPositionAndViewState();
+ EXPECT_EQ(0.0f, webViewImpl->pageScaleFactor());
+ EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
+ EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
+ webViewImpl->close();
+}
+
class ContentDetectorClient : public WebViewClient {
public:
ContentDetectorClient() { reset(); }