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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 181 } |
182 | 182 |
183 protected: | 183 protected: |
184 std::string m_baseURL; | 184 std::string m_baseURL; |
185 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; | 185 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; |
186 | 186 |
187 private: | 187 private: |
188 FrameTestHelpers::WebViewHelper m_helper; | 188 FrameTestHelpers::WebViewHelper m_helper; |
189 }; | 189 }; |
190 | 190 |
191 typedef void (*SettingOverrideFunction)(WebSettings*); | |
192 | |
193 static void DefaultSettingOverride(WebSettings *) | |
194 { | |
195 } | |
196 | |
197 class ParameterizedVisualViewportTest | 191 class ParameterizedVisualViewportTest |
198 : public VisualViewportTest | 192 : public VisualViewportTest |
199 , public testing::WithParamInterface<SettingOverrideFunction> { | 193 , public testing::WithParamInterface<FrameTestHelpers::SettingOverrideFuncti
on> { |
200 public: | 194 public: |
201 void overrideSettings(WebSettings *settings) override | 195 void overrideSettings(WebSettings *settings) override |
202 { | 196 { |
203 GetParam()(settings); | 197 GetParam()(settings); |
204 } | 198 } |
205 }; | 199 }; |
206 | 200 |
207 static void RootLayerScrollsSettingOverride(WebSettings *settings) | |
208 { | |
209 settings->setRootLayerScrolls(true); | |
210 } | |
211 INSTANTIATE_TEST_CASE_P(All, ParameterizedVisualViewportTest, ::testing::Values( | 201 INSTANTIATE_TEST_CASE_P(All, ParameterizedVisualViewportTest, ::testing::Values( |
212 DefaultSettingOverride, | 202 FrameTestHelpers::DefaultSettingOverride, |
213 RootLayerScrollsSettingOverride)); | 203 FrameTestHelpers::RootLayerScrollsSettingOverride)); |
214 | 204 |
215 // Test that resizing the VisualViewport works as expected and that resizing the | 205 // Test that resizing the VisualViewport works as expected and that resizing the |
216 // WebView resizes the VisualViewport. | 206 // WebView resizes the VisualViewport. |
217 TEST_P(ParameterizedVisualViewportTest, TestResize) | 207 TEST_P(ParameterizedVisualViewportTest, TestResize) |
218 { | 208 { |
219 initializeWithDesktopSettings(); | 209 initializeWithDesktopSettings(); |
220 webViewImpl()->resize(IntSize(320, 240)); | 210 webViewImpl()->resize(IntSize(320, 240)); |
221 | 211 |
222 navigateTo("about:blank"); | 212 navigateTo("about:blank"); |
223 forceFullCompositingUpdate(); | 213 forceFullCompositingUpdate(); |
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1859 webViewImpl()->handleInputEvent(pinchUpdate); | 1849 webViewImpl()->handleInputEvent(pinchUpdate); |
1860 | 1850 |
1861 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi
ewport(); | 1851 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi
ewport(); |
1862 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1852 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
1863 | 1853 |
1864 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location()); | 1854 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location()); |
1865 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble()); | 1855 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble()); |
1866 } | 1856 } |
1867 | 1857 |
1868 } // namespace | 1858 } // namespace |
OLD | NEW |