diff options
| author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-25 15:09:11 +0200 |
|---|---|---|
| committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-25 15:09:11 +0200 |
| commit | a89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd (patch) | |
| tree | b7abd9f49ae1d4d2e426a5883bfccd42b8e2ee12 /Source/WebKit/chromium/tests/WebFrameTest.cpp | |
| parent | 8d473cf9743f1d30a16a27114e93bd5af5648d23 (diff) | |
| download | qtwebkit-a89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd.tar.gz | |
Imported WebKit commit eb5c1b8fe4d4b1b90b5137433fc58a91da0e6878 (http://svn.webkit.org/repository/webkit/trunk@118516)
Diffstat (limited to 'Source/WebKit/chromium/tests/WebFrameTest.cpp')
| -rw-r--r-- | Source/WebKit/chromium/tests/WebFrameTest.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp index 74251f3e8..a6ab77fc1 100644 --- a/Source/WebKit/chromium/tests/WebFrameTest.cpp +++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp @@ -34,11 +34,13 @@ #include "Frame.h" #include "FrameTestHelpers.h" +#include "FrameView.h" #include "ResourceError.h" #include "WebDocument.h" #include "WebFindOptions.h" #include "WebFormElement.h" #include "WebFrameClient.h" +#include "WebFrameImpl.h" #include "WebRange.h" #include "WebScriptSource.h" #include "WebSearchableFormData.h" @@ -243,6 +245,43 @@ TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag) // Force the layout to happen before leaving the test. webView->mainFrame()->contentAsText(1024).utf8(); } + +TEST_F(WebFrameTest, FixedLayoutInitializeAtMinimumPageScale) +{ + registerMockedHttpURLLoad("fixed_layout.html"); + + FixedLayoutTestWebViewClient client; + client.m_screenInfo.horizontalDPI = 160; + int viewportWidth = 640; + int viewportHeight = 480; + client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight); + + // Make sure we initialize to minimum scale, even if the window size + // only becomes available after the load begins. + WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout.html", true, 0, &client)); + webViewImpl->enableFixedLayoutMode(true); + webViewImpl->settings()->setViewportEnabled(true); + webViewImpl->resize(WebSize(viewportWidth, viewportHeight)); + + int defaultFixedLayoutWidth = 980; + float minimumPageScaleFactor = viewportWidth / (float) defaultFixedLayoutWidth; + EXPECT_EQ(minimumPageScaleFactor, webViewImpl->pageScaleFactor()); + + // Assume the user has pinch zoomed to page scale factor 2. + float userPinchPageScaleFactor = 2; + webViewImpl->setPageScaleFactorPreservingScrollOffset(userPinchPageScaleFactor); + webViewImpl->mainFrameImpl()->frameView()->layout(); + + // Make sure we don't reset to initial scale if the page continues to load. + bool isNewNavigation; + webViewImpl->didCommitLoad(&isNewNavigation, false); + webViewImpl->didChangeContentsSize(); + EXPECT_EQ(userPinchPageScaleFactor, webViewImpl->pageScaleFactor()); + + // Make sure we don't reset to initial scale if the viewport size changes. + webViewImpl->resize(WebSize(viewportWidth, viewportHeight + 100)); + EXPECT_EQ(userPinchPageScaleFactor, webViewImpl->pageScaleFactor()); +} #endif #if ENABLE(GESTURE_EVENTS) |
