| OLD | NEW |
| 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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 EXPECT_EQ(980, webViewImpl->mainFrameImpl()->frameView()->contentsSize().wid
th()); | 859 EXPECT_EQ(980, webViewImpl->mainFrameImpl()->frameView()->contentsSize().wid
th()); |
| 860 } | 860 } |
| 861 | 861 |
| 862 TEST_F(WebFrameTest, targetDensityDpiHigh) | 862 TEST_F(WebFrameTest, targetDensityDpiHigh) |
| 863 { | 863 { |
| 864 WebCore::Settings::setMockScrollbarsEnabled(true); | 864 WebCore::Settings::setMockScrollbarsEnabled(true); |
| 865 WebCore::Settings::setUsesOverlayScrollbars(true); | 865 WebCore::Settings::setUsesOverlayScrollbars(true); |
| 866 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html"); | 866 registerMockedHttpURLLoad("viewport-target-densitydpi-high.html"); |
| 867 | 867 |
| 868 FixedLayoutTestWebViewClient client; | 868 FixedLayoutTestWebViewClient client; |
| 869 client.m_screenInfo.deviceScaleFactor = 4.0f / 3.0f; | 869 // high-dpi = 240 |
| 870 float targetDpi = 240.0f; |
| 871 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; |
| 870 int viewportWidth = 640; | 872 int viewportWidth = 640; |
| 871 int viewportHeight = 480; | 873 int viewportHeight = 480; |
| 872 | 874 |
| 873 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-tar
get-densitydpi-high.html", true, 0, &client); | 875 for (size_t i = 0; i < ARRAY_SIZE(deviceScaleFactors); ++i) { |
| 874 m_webView->enableFixedLayoutMode(true); | 876 float deviceScaleFactor = deviceScaleFactors[i]; |
| 875 m_webView->settings()->setViewportEnabled(true); | 877 float deviceDpi = deviceScaleFactor * 160.0f; |
| 876 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); | 878 client.m_screenInfo.deviceScaleFactor = deviceScaleFactor; |
| 877 m_webView->resize(WebSize(viewportWidth, viewportHeight)); | |
| 878 | 879 |
| 879 // high-dpi = 240, device-dpi = 160 | 880 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport
-target-densitydpi-high.html", true, 0, &client); |
| 880 EXPECT_NEAR(viewportWidth * (240.0f / 160.0f), m_webView->fixedLayoutSize().
width, 1.0f); | 881 m_webView->enableFixedLayoutMode(true); |
| 881 EXPECT_NEAR(viewportHeight * (240.0f / 160.0f), m_webView->fixedLayoutSize()
.height, 1.0f); | 882 m_webView->settings()->setViewportEnabled(true); |
| 882 EXPECT_NEAR(160.0f / 240.0f, m_webView->pageScaleFactor(), 0.01f); | 883 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); |
| 884 m_webView->resize(WebSize(viewportWidth, viewportHeight)); |
| 885 |
| 886 // We need to account for the fact that logical pixels are unconditional
ly multiplied by deviceScaleFactor to produce |
| 887 // physical pixels. |
| 888 float viewportRatio = deviceScaleFactor * targetDpi / deviceDpi; |
| 889 EXPECT_NEAR(viewportWidth * viewportRatio, m_webView->fixedLayoutSize().
width, 1.0f); |
| 890 EXPECT_NEAR(viewportHeight * viewportRatio, m_webView->fixedLayoutSize()
.height, 1.0f); |
| 891 EXPECT_NEAR(deviceDpi / (targetDpi * deviceScaleFactor), m_webView->page
ScaleFactor(), 0.01f); |
| 892 |
| 893 m_webView->close(); |
| 894 m_webView = 0; |
| 895 } |
| 883 } | 896 } |
| 884 | 897 |
| 885 TEST_F(WebFrameTest, targetDensityDpiDevice) | 898 TEST_F(WebFrameTest, targetDensityDpiDevice) |
| 886 { | 899 { |
| 887 WebCore::Settings::setMockScrollbarsEnabled(true); | 900 WebCore::Settings::setMockScrollbarsEnabled(true); |
| 888 WebCore::Settings::setUsesOverlayScrollbars(true); | 901 WebCore::Settings::setUsesOverlayScrollbars(true); |
| 889 registerMockedHttpURLLoad("viewport-target-densitydpi-device.html"); | 902 registerMockedHttpURLLoad("viewport-target-densitydpi-device.html"); |
| 890 | 903 |
| 891 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; | 904 float deviceScaleFactors[] = { 1.0f, 4.0f / 3.0f, 2.0f }; |
| 892 | 905 |
| (...skipping 2692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3585 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h
tml", true, 0, &client); | 3598 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h
tml", true, 0, &client); |
| 3586 runPendingTasks(); | 3599 runPendingTasks(); |
| 3587 | 3600 |
| 3588 EXPECT_EQ(client.startLoadingCount(), 2); | 3601 EXPECT_EQ(client.startLoadingCount(), 2); |
| 3589 EXPECT_EQ(client.stopLoadingCount(), 2); | 3602 EXPECT_EQ(client.stopLoadingCount(), 2); |
| 3590 m_webView->close(); | 3603 m_webView->close(); |
| 3591 m_webView = 0; | 3604 m_webView = 0; |
| 3592 } | 3605 } |
| 3593 | 3606 |
| 3594 } // namespace | 3607 } // namespace |
| OLD | NEW |