Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: Source/web/tests/WebFrameTest.cpp

Issue 53053002: [Android WebView] Add a legacy quirk for 'user-scalable=no' case (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move the setting into WebSettingsImpl Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 webViewHelper.webView()->settings()->setUseWideViewport(false); 1633 webViewHelper.webView()->settings()->setUseWideViewport(false);
1634 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); 1634 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
1635 webViewHelper.webView()->layout(); 1635 webViewHelper.webView()->layout();
1636 1636
1637 const float pageZoom = 0.25f; 1637 const float pageZoom = 0.25f;
1638 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor / pageZoom , webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width( ), 1.0f); 1638 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor / pageZoom , webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width( ), 1.0f);
1639 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor / pageZoo m, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().heigh t(), 1.0f); 1639 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor / pageZoo m, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().heigh t(), 1.0f);
1640 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f); 1640 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f);
1641 } 1641 }
1642 1642
1643 TEST_F(WebFrameTest, NoUserScalableQuirkIgnoresViewportScale)
1644 {
1645 UseMockScrollbarSettings mockScrollbarSettings;
1646 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html" );
1647
1648 FixedLayoutTestWebViewClient client;
1649 int viewportWidth = 640;
1650 int viewportHeight = 480;
1651
1652 FrameTestHelpers::WebViewHelper webViewHelper;
1653 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user -scalable-no.html", true, 0, &client);
1654 webViewHelper.webView()->settings()->setViewportEnabled(true);
1655 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e);
1656 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
1657 webViewHelper.webView()->layout();
1658
1659 EXPECT_NEAR(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->fra meView()->layoutSize().width(), 1.0f);
1660 EXPECT_NEAR(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fr ameView()->layoutSize().height(), 1.0f);
1661 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f);
1662 }
1663
1664 TEST_F(WebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForNonWideViewport)
1665 {
1666 UseMockScrollbarSettings mockScrollbarSettings;
1667 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html" );
1668
1669 FixedLayoutTestWebViewClient client;
1670 client.m_screenInfo.deviceScaleFactor = 1.33f;
1671 int viewportWidth = 640;
1672 int viewportHeight = 480;
1673
1674 FrameTestHelpers::WebViewHelper webViewHelper;
1675 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user -scalable-no.html", true, 0, &client);
1676 webViewHelper.webView()->settings()->setViewportEnabled(true);
1677 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr ue);
1678 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e);
1679 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1680 webViewHelper.webView()->settings()->setUseWideViewport(false);
1681 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
1682 webViewHelper.webView()->layout();
1683
1684 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHe lper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f);
1685 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewH elper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f);
1686 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f);
1687 }
1688
1689 TEST_F(WebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForWideViewport)
1690 {
1691 UseMockScrollbarSettings mockScrollbarSettings;
1692 registerMockedHttpURLLoad("viewport-2x-initial-scale-non-user-scalable.html" );
1693
1694 FixedLayoutTestWebViewClient client;
1695 int viewportWidth = 640;
1696 int viewportHeight = 480;
1697
1698 FrameTestHelpers::WebViewHelper webViewHelper;
1699 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale-non-u ser-scalable.html", true, 0, &client);
1700 webViewHelper.webView()->settings()->setViewportEnabled(true);
1701 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e);
1702 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1703 webViewHelper.webView()->settings()->setUseWideViewport(true);
1704 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
1705
1706 EXPECT_NEAR(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->fra meView()->layoutSize().width(), 1.0f);
1707 EXPECT_NEAR(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fr ameView()->layoutSize().height(), 1.0f);
1708 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f);
1709 }
1710
1643 class WebFrameResizeTest : public WebFrameTest { 1711 class WebFrameResizeTest : public WebFrameTest {
1644 protected: 1712 protected:
1645 1713
1646 static WebCore::FloatSize computeRelativeOffset(const WebCore::IntPoint& abs oluteOffset, const WebCore::LayoutRect& rect) 1714 static WebCore::FloatSize computeRelativeOffset(const WebCore::IntPoint& abs oluteOffset, const WebCore::LayoutRect& rect)
1647 { 1715 {
1648 WebCore::FloatSize relativeOffset = WebCore::FloatPoint(absoluteOffset) - rect.location(); 1716 WebCore::FloatSize relativeOffset = WebCore::FloatPoint(absoluteOffset) - rect.location();
1649 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height()); 1717 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height());
1650 return relativeOffset; 1718 return relativeOffset;
1651 } 1719 }
1652 1720
(...skipping 2945 matching lines...) Expand 10 before | Expand all | Expand 10 after
4598 4666
4599 FrameTestHelpers::loadFrame(frame, 4667 FrameTestHelpers::loadFrame(frame,
4600 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html ')"); 4668 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html ')");
4601 runPendingTasks(); 4669 runPendingTasks();
4602 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); 4670 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
4603 EXPECT_EQ(client.frame(), iframe); 4671 EXPECT_EQ(client.frame(), iframe);
4604 EXPECT_FALSE(client.replacesCurrentHistoryItem()); 4672 EXPECT_FALSE(client.replacesCurrentHistoryItem());
4605 } 4673 }
4606 4674
4607 } // namespace 4675 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698