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

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: Rewritten according to aelias@' proposal 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 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 webViewHelper.webView()->settings()->setUseWideViewport(false); 1652 webViewHelper.webView()->settings()->setUseWideViewport(false);
1653 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); 1653 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
1654 webViewHelper.webView()->layout(); 1654 webViewHelper.webView()->layout();
1655 1655
1656 const float pageZoom = 0.25f; 1656 const float pageZoom = 0.25f;
1657 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor / pageZoom , webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width( ), 1.0f); 1657 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor / pageZoom , webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width( ), 1.0f);
1658 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor / pageZoo m, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().heigh t(), 1.0f); 1658 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor / pageZoo m, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().heigh t(), 1.0f);
1659 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f); 1659 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f);
1660 } 1660 }
1661 1661
1662 TEST_F(WebFrameTest, NoUserScalableQuirkIgnoresViewportScale)
1663 {
1664 UseMockScrollbarSettings mockScrollbarSettings;
1665 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html" );
1666
1667 FixedLayoutTestWebViewClient client;
1668 int viewportWidth = 640;
1669 int viewportHeight = 480;
1670
1671 FrameTestHelpers::WebViewHelper webViewHelper;
1672 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user -scalable-no.html", true, 0, &client);
1673 webViewHelper.webView()->settings()->setViewportEnabled(true);
1674 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e);
1675 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
1676 webViewHelper.webView()->layout();
1677
1678 EXPECT_NEAR(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->fra meView()->layoutSize().width(), 1.0f);
1679 EXPECT_NEAR(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fr ameView()->layoutSize().height(), 1.0f);
1680 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f);
1681 }
1682
1683 TEST_F(WebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForNonWideViewport)
1684 {
1685 UseMockScrollbarSettings mockScrollbarSettings;
1686 registerMockedHttpURLLoad("viewport-initial-scale-and-user-scalable-no.html" );
1687
1688 FixedLayoutTestWebViewClient client;
1689 client.m_screenInfo.deviceScaleFactor = 1.33f;
1690 int viewportWidth = 640;
1691 int viewportHeight = 480;
1692
1693 FrameTestHelpers::WebViewHelper webViewHelper;
1694 webViewHelper.initializeAndLoad(m_baseURL + "viewport-initial-scale-and-user -scalable-no.html", true, 0, &client);
1695 webViewHelper.webView()->settings()->setViewportEnabled(true);
1696 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr ue);
1697 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e);
1698 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1699 webViewHelper.webView()->settings()->setUseWideViewport(false);
1700 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
1701 webViewHelper.webView()->layout();
1702
1703 EXPECT_NEAR(viewportWidth * client.m_screenInfo.deviceScaleFactor, webViewHe lper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().width(), 1.0f);
1704 EXPECT_NEAR(viewportHeight * client.m_screenInfo.deviceScaleFactor, webViewH elper.webViewImpl()->mainFrameImpl()->frameView()->layoutSize().height(), 1.0f);
1705 EXPECT_NEAR(1.0f / client.m_screenInfo.deviceScaleFactor, webViewHelper.webV iew()->pageScaleFactor(), 0.01f);
1706 }
1707
1708 TEST_F(WebFrameTest, NoUserScalableQuirkIgnoresViewportScaleForWideViewport)
1709 {
1710 UseMockScrollbarSettings mockScrollbarSettings;
1711 registerMockedHttpURLLoad("viewport-2x-initial-scale-non-user-scalable.html" );
1712
1713 FixedLayoutTestWebViewClient client;
1714 int viewportWidth = 640;
1715 int viewportHeight = 480;
1716
1717 FrameTestHelpers::WebViewHelper webViewHelper;
1718 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale-non-u ser-scalable.html", true, 0, &client);
1719 webViewHelper.webView()->settings()->setViewportEnabled(true);
1720 webViewHelper.webView()->settings()->setViewportMetaNonUserScalableQuirk(tru e);
1721 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
1722 webViewHelper.webView()->settings()->setUseWideViewport(true);
1723 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight));
1724
1725 EXPECT_NEAR(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->fra meView()->layoutSize().width(), 1.0f);
1726 EXPECT_NEAR(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fr ameView()->layoutSize().height(), 1.0f);
1727 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f);
1728 }
1729
1662 class WebFrameResizeTest : public WebFrameTest { 1730 class WebFrameResizeTest : public WebFrameTest {
1663 protected: 1731 protected:
1664 1732
1665 static WebCore::FloatSize computeRelativeOffset(const WebCore::IntPoint& abs oluteOffset, const WebCore::LayoutRect& rect) 1733 static WebCore::FloatSize computeRelativeOffset(const WebCore::IntPoint& abs oluteOffset, const WebCore::LayoutRect& rect)
1666 { 1734 {
1667 WebCore::FloatSize relativeOffset = WebCore::FloatPoint(absoluteOffset) - rect.location(); 1735 WebCore::FloatSize relativeOffset = WebCore::FloatPoint(absoluteOffset) - rect.location();
1668 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height()); 1736 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height());
1669 return relativeOffset; 1737 return relativeOffset;
1670 } 1738 }
1671 1739
(...skipping 3010 matching lines...) Expand 10 before | Expand all | Expand 10 after
4682 4750
4683 FrameTestHelpers::loadFrame(frame, 4751 FrameTestHelpers::loadFrame(frame,
4684 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html ')"); 4752 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html ')");
4685 runPendingTasks(); 4753 runPendingTasks();
4686 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); 4754 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
4687 EXPECT_EQ(client.frame(), iframe); 4755 EXPECT_EQ(client.frame(), iframe);
4688 EXPECT_FALSE(client.replacesCurrentHistoryItem()); 4756 EXPECT_FALSE(client.replacesCurrentHistoryItem());
4689 } 4757 }
4690 4758
4691 } // namespace 4759 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698