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

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

Issue 2654933003: platform/testing/{URL|Unit}TestHelpers improvements (Closed)
Patch Set: cleanup Created 3 years, 10 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/FrameHost.h" 9 #include "core/frame/FrameHost.h"
10 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
11 #include "core/frame/LocalFrame.h" 11 #include "core/frame/LocalFrame.h"
12 #include "core/html/HTMLBodyElement.h" 12 #include "core/html/HTMLBodyElement.h"
13 #include "core/html/HTMLElement.h" 13 #include "core/html/HTMLElement.h"
14 #include "core/input/EventHandler.h" 14 #include "core/input/EventHandler.h"
15 #include "core/layout/LayoutObject.h" 15 #include "core/layout/LayoutObject.h"
16 #include "core/layout/api/LayoutViewItem.h" 16 #include "core/layout/api/LayoutViewItem.h"
17 #include "core/layout/compositing/PaintLayerCompositor.h" 17 #include "core/layout/compositing/PaintLayerCompositor.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/testing/RuntimeEnabledFeaturesTestHelpers.h" 23 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
24 #include "platform/testing/URLTestHelpers.h" 24 #include "platform/testing/URLTestHelpers.h"
25 #include "platform/testing/UnitTestHelpers.h"
25 #include "public/platform/Platform.h" 26 #include "public/platform/Platform.h"
26 #include "public/platform/WebCachePolicy.h" 27 #include "public/platform/WebCachePolicy.h"
27 #include "public/platform/WebInputEvent.h" 28 #include "public/platform/WebInputEvent.h"
28 #include "public/platform/WebLayerTreeView.h" 29 #include "public/platform/WebLayerTreeView.h"
29 #include "public/platform/WebURLLoaderMockFactory.h" 30 #include "public/platform/WebURLLoaderMockFactory.h"
30 #include "public/web/WebCache.h" 31 #include "public/web/WebCache.h"
31 #include "public/web/WebContextMenuData.h" 32 #include "public/web/WebContextMenuData.h"
32 #include "public/web/WebDocument.h" 33 #include "public/web/WebDocument.h"
33 #include "public/web/WebFrameClient.h" 34 #include "public/web/WebFrameClient.h"
34 #include "public/web/WebScriptSource.h" 35 #include "public/web/WebScriptSource.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 ::std::ostream& operator<<(::std::ostream& os, const WebContextMenuData& data) { 103 ::std::ostream& operator<<(::std::ostream& os, const WebContextMenuData& data) {
103 return os << "Context menu location: [" << data.mousePosition.x << ", " 104 return os << "Context menu location: [" << data.mousePosition.x << ", "
104 << data.mousePosition.y << "]"; 105 << data.mousePosition.y << "]";
105 } 106 }
106 } 107 }
107 108
108 namespace { 109 namespace {
109 110
110 typedef bool TestParamRootLayerScrolling; 111 typedef bool TestParamRootLayerScrolling;
111 class VisualViewportTest 112 class VisualViewportTest
112 : public testing::Test, 113 : public ::testing::Test,
113 public testing::WithParamInterface<TestParamRootLayerScrolling>, 114 public ::testing::WithParamInterface<TestParamRootLayerScrolling>,
114 private ScopedRootLayerScrollingForTest { 115 private ScopedRootLayerScrollingForTest {
115 public: 116 public:
116 VisualViewportTest() 117 VisualViewportTest()
117 : ScopedRootLayerScrollingForTest(GetParam()), 118 : ScopedRootLayerScrollingForTest(GetParam()),
118 m_baseURL("http://www.test.com/") {} 119 m_baseURL("http://www.test.com/") {}
119 120
120 void initializeWithDesktopSettings( 121 void initializeWithDesktopSettings(
121 void (*overrideSettingsFunc)(WebSettings*) = 0) { 122 void (*overrideSettingsFunc)(WebSettings*) = 0) {
122 if (!overrideSettingsFunc) 123 if (!overrideSettingsFunc)
123 overrideSettingsFunc = &configureSettings; 124 overrideSettingsFunc = &configureSettings;
(...skipping 18 matching lines...) Expand all
142 143
143 void navigateTo(const std::string& url) { 144 void navigateTo(const std::string& url) {
144 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url); 145 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url);
145 } 146 }
146 147
147 void forceFullCompositingUpdate() { 148 void forceFullCompositingUpdate() {
148 webViewImpl()->updateAllLifecyclePhases(); 149 webViewImpl()->updateAllLifecyclePhases();
149 } 150 }
150 151
151 void registerMockedHttpURLLoad(const std::string& fileName) { 152 void registerMockedHttpURLLoad(const std::string& fileName) {
152 URLTestHelpers::registerMockedURLFromBaseURL( 153 URLTestHelpers::registerMockedURLLoadFromBase(
153 WebString::fromUTF8(m_baseURL.c_str()), 154 WebString::fromUTF8(m_baseURL.c_str()),
Takashi Toyoshima 2017/01/26 10:57:58 removing c_str
155 blink::testing::webTestDataPath(),
154 WebString::fromUTF8(fileName.c_str())); 156 WebString::fromUTF8(fileName.c_str()));
155 } 157 }
156 158
159 void registerMockedHttpURLLoad(const std::string& url,
160 const std::string& fileName) {
161 URLTestHelpers::registerMockedURLLoad(
162 toKURL(url), blink::testing::webTestDataPath(fileName));
163 }
164
157 WebLayer* getRootScrollLayer() { 165 WebLayer* getRootScrollLayer() {
158 PaintLayerCompositor* compositor = 166 PaintLayerCompositor* compositor =
159 frame()->contentLayoutItem().compositor(); 167 frame()->contentLayoutItem().compositor();
160 DCHECK(compositor); 168 DCHECK(compositor);
161 DCHECK(compositor->scrollLayer()); 169 DCHECK(compositor->scrollLayer());
162 170
163 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); 171 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer();
164 return webScrollLayer; 172 return webScrollLayer;
165 } 173 }
166 174
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 &configureAndroidCompositing); 2148 &configureAndroidCompositing);
2141 2149
2142 int pageWidth = 640; 2150 int pageWidth = 640;
2143 int pageHeight = 480; 2151 int pageHeight = 480;
2144 float browserControlsHeight = 50.0f; 2152 float browserControlsHeight = 50.0f;
2145 int smallestHeight = pageHeight - browserControlsHeight; 2153 int smallestHeight = pageHeight - browserControlsHeight;
2146 2154
2147 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight), 2155 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight),
2148 browserControlsHeight, false); 2156 browserControlsHeight, false);
2149 2157
2150 URLTestHelpers::registerMockedURLLoad(toKURL("http://example.com/foo.png"), 2158 registerMockedHttpURLLoad("http://example.com/foo.png", "white-1x1.png");
2151 "white-1x1.png");
2152 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); 2159 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
2153 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), 2160 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(),
2154 "<!DOCTYPE html>" 2161 "<!DOCTYPE html>"
2155 "<style>" 2162 "<style>"
2156 " body {" 2163 " body {"
2157 " background: url('foo.png');" 2164 " background: url('foo.png');"
2158 " background-attachment: fixed;" 2165 " background-attachment: fixed;"
2159 " background-size: cover;" 2166 " background-size: cover;"
2160 " background-repeat: no-repeat;" 2167 " background-repeat: no-repeat;"
2161 " }" 2168 " }"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 true, nullptr, nullptr, nullptr, &configureAndroidNonCompositing); 2230 true, nullptr, nullptr, nullptr, &configureAndroidNonCompositing);
2224 2231
2225 int pageWidth = 640; 2232 int pageWidth = 640;
2226 int pageHeight = 480; 2233 int pageHeight = 480;
2227 float browserControlsHeight = 50.0f; 2234 float browserControlsHeight = 50.0f;
2228 int smallestHeight = pageHeight - browserControlsHeight; 2235 int smallestHeight = pageHeight - browserControlsHeight;
2229 2236
2230 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight), 2237 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight),
2231 browserControlsHeight, false); 2238 browserControlsHeight, false);
2232 2239
2233 URLTestHelpers::registerMockedURLLoad(toKURL("http://example.com/foo.png"), 2240 registerMockedHttpURLLoad("http://example.com/foo.png", "white-1x1.png");
2234 "white-1x1.png");
2235 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); 2241 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
2236 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), 2242 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(),
2237 "<!DOCTYPE html>" 2243 "<!DOCTYPE html>"
2238 "<style>" 2244 "<style>"
2239 " body {" 2245 " body {"
2240 " margin: 0px;" 2246 " margin: 0px;"
2241 " background: url('foo.png');" 2247 " background: url('foo.png');"
2242 " background-attachment: fixed;" 2248 " background-attachment: fixed;"
2243 " background-size: cover;" 2249 " background-size: cover;"
2244 " background-repeat: no-repeat;" 2250 " background-repeat: no-repeat;"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2331 &configureAndroidCompositing); 2337 &configureAndroidCompositing);
2332 2338
2333 int pageWidth = 640; 2339 int pageWidth = 640;
2334 int pageHeight = 480; 2340 int pageHeight = 480;
2335 float browserControlsHeight = 50.0f; 2341 float browserControlsHeight = 50.0f;
2336 int smallestHeight = pageHeight - browserControlsHeight; 2342 int smallestHeight = pageHeight - browserControlsHeight;
2337 2343
2338 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight), 2344 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight),
2339 browserControlsHeight, false); 2345 browserControlsHeight, false);
2340 2346
2341 URLTestHelpers::registerMockedURLLoad(toKURL("http://example.com/foo.png"), 2347 registerMockedHttpURLLoad("http://example.com/foo.png", "white-1x1.png");
2342 "white-1x1.png");
2343 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); 2348 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
2344 // This time the background is the default attachment. 2349 // This time the background is the default attachment.
2345 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), 2350 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(),
2346 "<!DOCTYPE html>" 2351 "<!DOCTYPE html>"
2347 "<style>" 2352 "<style>"
2348 " body {" 2353 " body {"
2349 " margin: 0px;" 2354 " margin: 0px;"
2350 " background: url('foo.png');" 2355 " background: url('foo.png');"
2351 " background-size: cover;" 2356 " background-size: cover;"
2352 " background-repeat: no-repeat;" 2357 " background-repeat: no-repeat;"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 " body {" 2476 " body {"
2472 " margin: 0px;" 2477 " margin: 0px;"
2473 " }" 2478 " }"
2474 " div { height:110vh; width: 110vw; }" 2479 " div { height:110vh; width: 110vw; }"
2475 "</style>" 2480 "</style>"
2476 "<div></div>", 2481 "<div></div>",
2477 baseURL); 2482 baseURL);
2478 } 2483 }
2479 2484
2480 } // namespace 2485 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698