| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/frame/VisualViewport.h" | 5 #include "core/frame/VisualViewport.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/FrameHost.h" | 8 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 { | 95 { |
| 96 return os << "Context menu location: [" | 96 return os << "Context menu location: [" |
| 97 << data.mousePosition.x << ", " << data.mousePosition.y << "]"; | 97 << data.mousePosition.x << ", " << data.mousePosition.y << "]"; |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 namespace { | 102 namespace { |
| 103 | 103 |
| 104 class VisualViewportTest | 104 class VisualViewportTest |
| 105 : public testing::Test | 105 : public testing::Test { |
| 106 , public FrameTestHelpers::SettingOverrider { | |
| 107 public: | 106 public: |
| 108 VisualViewportTest() | 107 VisualViewportTest() |
| 109 : m_baseURL("http://www.test.com/") | 108 : m_baseURL("http://www.test.com/") |
| 110 , m_helper(this) | |
| 111 { | 109 { |
| 112 } | 110 } |
| 113 | 111 |
| 114 void overrideSettings(WebSettings *settings) override | |
| 115 { | |
| 116 } | |
| 117 | |
| 118 void initializeWithDesktopSettings(void (*overrideSettingsFunc)(WebSettings*
) = 0) | 112 void initializeWithDesktopSettings(void (*overrideSettingsFunc)(WebSettings*
) = 0) |
| 119 { | 113 { |
| 120 if (!overrideSettingsFunc) | 114 if (!overrideSettingsFunc) |
| 121 overrideSettingsFunc = &configureSettings; | 115 overrideSettingsFunc = &configureSettings; |
| 122 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, overri
deSettingsFunc); | 116 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, overri
deSettingsFunc); |
| 123 webViewImpl()->setDefaultPageScaleLimits(1, 4); | 117 webViewImpl()->setDefaultPageScaleLimits(1, 4); |
| 124 } | 118 } |
| 125 | 119 |
| 126 void initializeWithAndroidSettings(void (*overrideSettingsFunc)(WebSettings*
) = 0) | 120 void initializeWithAndroidSettings(void (*overrideSettingsFunc)(WebSettings*
) = 0) |
| 127 { | 121 { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 175 } |
| 182 | 176 |
| 183 protected: | 177 protected: |
| 184 std::string m_baseURL; | 178 std::string m_baseURL; |
| 185 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; | 179 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; |
| 186 | 180 |
| 187 private: | 181 private: |
| 188 FrameTestHelpers::WebViewHelper m_helper; | 182 FrameTestHelpers::WebViewHelper m_helper; |
| 189 }; | 183 }; |
| 190 | 184 |
| 185 typedef bool TestParamRootLayerScrolling; |
| 191 class ParameterizedVisualViewportTest | 186 class ParameterizedVisualViewportTest |
| 192 : public VisualViewportTest | 187 : public VisualViewportTest |
| 193 , public testing::WithParamInterface<FrameTestHelpers::SettingOverrideFuncti
on> { | 188 , public testing::WithParamInterface<TestParamRootLayerScrolling> { |
| 194 public: | 189 public: |
| 195 void overrideSettings(WebSettings *settings) override | 190 ParameterizedVisualViewportTest() |
| 191 : m_originalRootLayerScrollingEnabled(RuntimeEnabledFeatures::rootLayerS
crollingEnabled()) |
| 192 , m_enableRootLayerScrolling(GetParam()) |
| 196 { | 193 { |
| 197 GetParam()(settings); | 194 RuntimeEnabledFeatures::setRootLayerScrollingEnabled(m_enableRootLayerSc
rolling); |
| 198 } | 195 } |
| 196 |
| 197 ~ParameterizedVisualViewportTest() |
| 198 { |
| 199 CHECK_EQ(m_enableRootLayerScrolling, RuntimeEnabledFeatures::rootLayerSc
rollingEnabled()); |
| 200 RuntimeEnabledFeatures::setRootLayerScrollingEnabled(m_originalRootLayer
ScrollingEnabled); |
| 201 } |
| 202 |
| 203 private: |
| 204 bool m_originalRootLayerScrollingEnabled; |
| 205 bool m_enableRootLayerScrolling; |
| 199 }; | 206 }; |
| 200 | 207 |
| 201 INSTANTIATE_TEST_CASE_P(All, ParameterizedVisualViewportTest, ::testing::Values( | 208 INSTANTIATE_TEST_CASE_P(All, ParameterizedVisualViewportTest, ::testing::Bool())
; |
| 202 FrameTestHelpers::DefaultSettingOverride, | |
| 203 FrameTestHelpers::RootLayerScrollsSettingOverride)); | |
| 204 | 209 |
| 205 // Test that resizing the VisualViewport works as expected and that resizing the | 210 // Test that resizing the VisualViewport works as expected and that resizing the |
| 206 // WebView resizes the VisualViewport. | 211 // WebView resizes the VisualViewport. |
| 207 TEST_P(ParameterizedVisualViewportTest, TestResize) | 212 TEST_P(ParameterizedVisualViewportTest, TestResize) |
| 208 { | 213 { |
| 209 initializeWithDesktopSettings(); | 214 initializeWithDesktopSettings(); |
| 210 webViewImpl()->resize(IntSize(320, 240)); | 215 webViewImpl()->resize(IntSize(320, 240)); |
| 211 | 216 |
| 212 navigateTo("about:blank"); | 217 navigateTo("about:blank"); |
| 213 forceFullCompositingUpdate(); | 218 forceFullCompositingUpdate(); |
| (...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1855 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1860 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1856 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(700,
500), ProgrammaticScroll); | 1861 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(700,
500), ProgrammaticScroll); |
| 1857 | 1862 |
| 1858 webViewImpl()->resize(IntSize(400, 300)); | 1863 webViewImpl()->resize(IntSize(400, 300)); |
| 1859 EXPECT_POINT_EQ(DoublePoint(300, 200), frameView.layoutViewportScrollableAre
a()->scrollPositionDouble()); | 1864 EXPECT_POINT_EQ(DoublePoint(300, 200), frameView.layoutViewportScrollableAre
a()->scrollPositionDouble()); |
| 1860 | 1865 |
| 1861 RuntimeEnabledFeatures::setScrollAnchoringEnabled(wasScrollAnchoringEnabled)
; | 1866 RuntimeEnabledFeatures::setScrollAnchoringEnabled(wasScrollAnchoringEnabled)
; |
| 1862 } | 1867 } |
| 1863 | 1868 |
| 1864 } // namespace | 1869 } // namespace |
| OLD | NEW |