From 88a04ac016f57c2d78e714682445dff2e7db4ade Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 11 Sep 2012 19:54:20 +0200 Subject: 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 --- Source/WebKit/chromium/tests/WebViewTest.cpp | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'Source/WebKit/chromium/tests/WebViewTest.cpp') 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(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(); } -- cgit v1.2.1