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

Side by Side Diff: third_party/WebKit/Source/web/tests/VisualViewportTest.cpp

Issue 2860673002: Change all test cases to use WebViewBase instead of WebViewImpl. (Closed)
Patch Set: Address code review comments. Created 3 years, 7 months 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
OLDNEW
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/BrowserControls.h" 8 #include "core/frame/BrowserControls.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"
11 #include "core/html/HTMLBodyElement.h" 11 #include "core/html/HTMLBodyElement.h"
12 #include "core/html/HTMLElement.h" 12 #include "core/html/HTMLElement.h"
13 #include "core/input/EventHandler.h" 13 #include "core/input/EventHandler.h"
14 #include "core/layout/LayoutObject.h" 14 #include "core/layout/LayoutObject.h"
15 #include "core/layout/api/LayoutViewItem.h" 15 #include "core/layout/api/LayoutViewItem.h"
16 #include "core/layout/compositing/PaintLayerCompositor.h" 16 #include "core/layout/compositing/PaintLayerCompositor.h"
17 #include "core/loader/DocumentLoader.h" 17 #include "core/loader/DocumentLoader.h"
18 #include "core/page/Page.h" 18 #include "core/page/Page.h"
19 #include "core/paint/PaintLayer.h" 19 #include "core/paint/PaintLayer.h"
20 #include "platform/geometry/DoublePoint.h" 20 #include "platform/geometry/DoublePoint.h"
21 #include "platform/geometry/DoubleRect.h" 21 #include "platform/geometry/DoubleRect.h"
22 #include "platform/graphics/CompositorElementId.h" 22 #include "platform/graphics/CompositorElementId.h"
23 #include "platform/graphics/GraphicsLayer.h"
23 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 24 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
24 #include "platform/testing/URLTestHelpers.h" 25 #include "platform/testing/URLTestHelpers.h"
25 #include "platform/testing/UnitTestHelpers.h" 26 #include "platform/testing/UnitTestHelpers.h"
26 #include "public/platform/Platform.h" 27 #include "public/platform/Platform.h"
27 #include "public/platform/WebCachePolicy.h" 28 #include "public/platform/WebCachePolicy.h"
29 #include "public/platform/WebCoalescedInputEvent.h"
28 #include "public/platform/WebInputEvent.h" 30 #include "public/platform/WebInputEvent.h"
29 #include "public/platform/WebLayerTreeView.h" 31 #include "public/platform/WebLayerTreeView.h"
30 #include "public/platform/WebURLLoaderMockFactory.h" 32 #include "public/platform/WebURLLoaderMockFactory.h"
31 #include "public/web/WebContextMenuData.h" 33 #include "public/web/WebContextMenuData.h"
32 #include "public/web/WebDocument.h" 34 #include "public/web/WebDocument.h"
33 #include "public/web/WebFrameClient.h" 35 #include "public/web/WebFrameClient.h"
34 #include "public/web/WebScriptSource.h" 36 #include "public/web/WebScriptSource.h"
35 #include "public/web/WebSettings.h" 37 #include "public/web/WebSettings.h"
36 #include "public/web/WebViewClient.h" 38 #include "public/web/WebViewClient.h"
37 #include "testing/gmock/include/gmock/gmock.h" 39 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 WebLayer* getRootScrollLayer() { 161 WebLayer* getRootScrollLayer() {
160 PaintLayerCompositor* compositor = 162 PaintLayerCompositor* compositor =
161 frame()->ContentLayoutItem().Compositor(); 163 frame()->ContentLayoutItem().Compositor();
162 DCHECK(compositor); 164 DCHECK(compositor);
163 DCHECK(compositor->ScrollLayer()); 165 DCHECK(compositor->ScrollLayer());
164 166
165 WebLayer* webScrollLayer = compositor->ScrollLayer()->PlatformLayer(); 167 WebLayer* webScrollLayer = compositor->ScrollLayer()->PlatformLayer();
166 return webScrollLayer; 168 return webScrollLayer;
167 } 169 }
168 170
169 WebViewImpl* webViewImpl() const { return m_helper.WebView(); } 171 WebViewBase* webViewImpl() const { return m_helper.WebView(); }
170 LocalFrame* frame() const { 172 LocalFrame* frame() const {
171 return m_helper.WebView()->MainFrameImpl()->GetFrame(); 173 return m_helper.WebView()->MainFrameImpl()->GetFrame();
172 } 174 }
173 175
174 static void configureSettings(WebSettings* settings) { 176 static void configureSettings(WebSettings* settings) {
175 settings->SetJavaScriptEnabled(true); 177 settings->SetJavaScriptEnabled(true);
176 settings->SetPreferCompositingToLCDTextEnabled(true); 178 settings->SetPreferCompositingToLCDTextEnabled(true);
177 } 179 }
178 180
179 static void configureAndroidSettings(WebSettings* settings) { 181 static void configureAndroidSettings(WebSettings* settings) {
(...skipping 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after
2108 // when using inert (non-layout affecting) browser controls. 2110 // when using inert (non-layout affecting) browser controls.
2109 TEST_P(VisualViewportTest, ResizeCompositedAndFixedBackground) { 2111 TEST_P(VisualViewportTest, ResizeCompositedAndFixedBackground) {
2110 bool originalInertTopControls = 2112 bool originalInertTopControls =
2111 RuntimeEnabledFeatures::inertTopControlsEnabled(); 2113 RuntimeEnabledFeatures::inertTopControlsEnabled();
2112 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); 2114 RuntimeEnabledFeatures::setInertTopControlsEnabled(true);
2113 2115
2114 std::unique_ptr<FrameTestHelpers::TestWebViewClient> 2116 std::unique_ptr<FrameTestHelpers::TestWebViewClient>
2115 fakeCompositingWebViewClient = 2117 fakeCompositingWebViewClient =
2116 WTF::MakeUnique<FrameTestHelpers::TestWebViewClient>(); 2118 WTF::MakeUnique<FrameTestHelpers::TestWebViewClient>();
2117 FrameTestHelpers::WebViewHelper webViewHelper; 2119 FrameTestHelpers::WebViewHelper webViewHelper;
2118 WebViewImpl* webViewImpl = webViewHelper.Initialize( 2120 WebViewBase* webViewImpl = webViewHelper.Initialize(
2119 true, nullptr, fakeCompositingWebViewClient.get(), nullptr, 2121 true, nullptr, fakeCompositingWebViewClient.get(), nullptr,
2120 &configureAndroidCompositing); 2122 &configureAndroidCompositing);
2121 2123
2122 int pageWidth = 640; 2124 int pageWidth = 640;
2123 int pageHeight = 480; 2125 int pageHeight = 480;
2124 float browserControlsHeight = 50.0f; 2126 float browserControlsHeight = 50.0f;
2125 int smallestHeight = pageHeight - browserControlsHeight; 2127 int smallestHeight = pageHeight - browserControlsHeight;
2126 2128
2127 webViewImpl->ResizeWithBrowserControls(WebSize(pageWidth, pageHeight), 2129 webViewImpl->ResizeWithBrowserControls(WebSize(pageWidth, pageHeight),
2128 browserControlsHeight, false); 2130 browserControlsHeight, false);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 } 2193 }
2192 2194
2193 // Make sure a non-composited background-attachment:fixed background gets 2195 // Make sure a non-composited background-attachment:fixed background gets
2194 // resized when using inert (non-layout affecting) browser controls. 2196 // resized when using inert (non-layout affecting) browser controls.
2195 TEST_P(VisualViewportTest, ResizeNonCompositedAndFixedBackground) { 2197 TEST_P(VisualViewportTest, ResizeNonCompositedAndFixedBackground) {
2196 bool originalInertTopControls = 2198 bool originalInertTopControls =
2197 RuntimeEnabledFeatures::inertTopControlsEnabled(); 2199 RuntimeEnabledFeatures::inertTopControlsEnabled();
2198 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); 2200 RuntimeEnabledFeatures::setInertTopControlsEnabled(true);
2199 2201
2200 FrameTestHelpers::WebViewHelper webViewHelper; 2202 FrameTestHelpers::WebViewHelper webViewHelper;
2201 WebViewImpl* webViewImpl = webViewHelper.Initialize( 2203 WebViewBase* webViewImpl = webViewHelper.Initialize(
2202 true, nullptr, nullptr, nullptr, &configureAndroidNonCompositing); 2204 true, nullptr, nullptr, nullptr, &configureAndroidNonCompositing);
2203 2205
2204 int pageWidth = 640; 2206 int pageWidth = 640;
2205 int pageHeight = 480; 2207 int pageHeight = 480;
2206 float browserControlsHeight = 50.0f; 2208 float browserControlsHeight = 50.0f;
2207 int smallestHeight = pageHeight - browserControlsHeight; 2209 int smallestHeight = pageHeight - browserControlsHeight;
2208 2210
2209 webViewImpl->ResizeWithBrowserControls(WebSize(pageWidth, pageHeight), 2211 webViewImpl->ResizeWithBrowserControls(WebSize(pageWidth, pageHeight),
2210 browserControlsHeight, false); 2212 browserControlsHeight, false);
2211 2213
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2297 // background doesn't cause invalidation or layout. 2299 // background doesn't cause invalidation or layout.
2298 TEST_P(VisualViewportTest, ResizeNonFixedBackgroundNoLayoutOrInvalidation) { 2300 TEST_P(VisualViewportTest, ResizeNonFixedBackgroundNoLayoutOrInvalidation) {
2299 bool originalInertTopControls = 2301 bool originalInertTopControls =
2300 RuntimeEnabledFeatures::inertTopControlsEnabled(); 2302 RuntimeEnabledFeatures::inertTopControlsEnabled();
2301 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); 2303 RuntimeEnabledFeatures::setInertTopControlsEnabled(true);
2302 2304
2303 std::unique_ptr<FrameTestHelpers::TestWebViewClient> 2305 std::unique_ptr<FrameTestHelpers::TestWebViewClient>
2304 fakeCompositingWebViewClient = 2306 fakeCompositingWebViewClient =
2305 WTF::MakeUnique<FrameTestHelpers::TestWebViewClient>(); 2307 WTF::MakeUnique<FrameTestHelpers::TestWebViewClient>();
2306 FrameTestHelpers::WebViewHelper webViewHelper; 2308 FrameTestHelpers::WebViewHelper webViewHelper;
2307 WebViewImpl* webViewImpl = webViewHelper.Initialize( 2309 WebViewBase* webViewImpl = webViewHelper.Initialize(
2308 true, nullptr, fakeCompositingWebViewClient.get(), nullptr, 2310 true, nullptr, fakeCompositingWebViewClient.get(), nullptr,
2309 &configureAndroidCompositing); 2311 &configureAndroidCompositing);
2310 2312
2311 int pageWidth = 640; 2313 int pageWidth = 640;
2312 int pageHeight = 480; 2314 int pageHeight = 480;
2313 float browserControlsHeight = 50.0f; 2315 float browserControlsHeight = 50.0f;
2314 int smallestHeight = pageHeight - browserControlsHeight; 2316 int smallestHeight = pageHeight - browserControlsHeight;
2315 2317
2316 webViewImpl->ResizeWithBrowserControls(WebSize(pageWidth, pageHeight), 2318 webViewImpl->ResizeWithBrowserControls(WebSize(pageWidth, pageHeight),
2317 browserControlsHeight, false); 2319 browserControlsHeight, false);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 2383
2382 TEST_P(VisualViewportTest, InvalidateLayoutViewWhenDocumentSmallerThanView) { 2384 TEST_P(VisualViewportTest, InvalidateLayoutViewWhenDocumentSmallerThanView) {
2383 bool originalInertTopControls = 2385 bool originalInertTopControls =
2384 RuntimeEnabledFeatures::inertTopControlsEnabled(); 2386 RuntimeEnabledFeatures::inertTopControlsEnabled();
2385 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); 2387 RuntimeEnabledFeatures::setInertTopControlsEnabled(true);
2386 2388
2387 std::unique_ptr<FrameTestHelpers::TestWebViewClient> 2389 std::unique_ptr<FrameTestHelpers::TestWebViewClient>
2388 fakeCompositingWebViewClient = 2390 fakeCompositingWebViewClient =
2389 WTF::MakeUnique<FrameTestHelpers::TestWebViewClient>(); 2391 WTF::MakeUnique<FrameTestHelpers::TestWebViewClient>();
2390 FrameTestHelpers::WebViewHelper webViewHelper; 2392 FrameTestHelpers::WebViewHelper webViewHelper;
2391 WebViewImpl* webViewImpl = webViewHelper.Initialize( 2393 WebViewBase* webViewImpl = webViewHelper.Initialize(
2392 true, nullptr, fakeCompositingWebViewClient.get(), nullptr, 2394 true, nullptr, fakeCompositingWebViewClient.get(), nullptr,
2393 &configureAndroidCompositing); 2395 &configureAndroidCompositing);
2394 2396
2395 int pageWidth = 320; 2397 int pageWidth = 320;
2396 int pageHeight = 590; 2398 int pageHeight = 590;
2397 float browserControlsHeight = 50.0f; 2399 float browserControlsHeight = 50.0f;
2398 int largestHeight = pageHeight + browserControlsHeight; 2400 int largestHeight = pageHeight + browserControlsHeight;
2399 2401
2400 webViewImpl->ResizeWithBrowserControls(WebSize(pageWidth, pageHeight), 2402 webViewImpl->ResizeWithBrowserControls(WebSize(pageWidth, pageHeight),
2401 browserControlsHeight, true); 2403 browserControlsHeight, true);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 " body {" 2450 " body {"
2449 " margin: 0px;" 2451 " margin: 0px;"
2450 " }" 2452 " }"
2451 " div { height:110vh; width: 110vw; }" 2453 " div { height:110vh; width: 110vw; }"
2452 "</style>" 2454 "</style>"
2453 "<div></div>", 2455 "<div></div>",
2454 baseURL); 2456 baseURL);
2455 } 2457 }
2456 2458
2457 } // namespace 2459 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698