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; | |
esprehn
2016/08/25 23:59:24
again
| |
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)); | |
esprehn
2016/08/25 23:59:24
this doesn't seem better to copy pasta this all ov
| |
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 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1925 | 1930 |
1926 EXPECT_POINT_EQ( | 1931 EXPECT_POINT_EQ( |
1927 DoublePoint(), | 1932 DoublePoint(), |
1928 frameView.layoutViewportScrollableArea()->scrollPositionDouble()); | 1933 frameView.layoutViewportScrollableArea()->scrollPositionDouble()); |
1929 EXPECT_EQ(600, scroller->scrollTop()); | 1934 EXPECT_EQ(600, scroller->scrollTop()); |
1930 | 1935 |
1931 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); | 1936 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); |
1932 } | 1937 } |
1933 | 1938 |
1934 } // namespace | 1939 } // namespace |
OLD | NEW |