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

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

Issue 2654933003: platform/testing/{URL|Unit}TestHelpers improvements (Closed)
Patch Set: merge master + typo fix 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), blink::testing::webTestDataPath(),
154 WebString::fromUTF8(fileName.c_str())); 155 WebString::fromUTF8(fileName));
156 }
157
158 void registerMockedHttpURLLoad(const std::string& url,
159 const std::string& fileName) {
160 URLTestHelpers::registerMockedURLLoad(
161 toKURL(url), blink::testing::webTestDataPath(fileName));
155 } 162 }
156 163
157 WebLayer* getRootScrollLayer() { 164 WebLayer* getRootScrollLayer() {
158 PaintLayerCompositor* compositor = 165 PaintLayerCompositor* compositor =
159 frame()->contentLayoutItem().compositor(); 166 frame()->contentLayoutItem().compositor();
160 DCHECK(compositor); 167 DCHECK(compositor);
161 DCHECK(compositor->scrollLayer()); 168 DCHECK(compositor->scrollLayer());
162 169
163 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); 170 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer();
164 return webScrollLayer; 171 return webScrollLayer;
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 &configureAndroidCompositing); 2147 &configureAndroidCompositing);
2141 2148
2142 int pageWidth = 640; 2149 int pageWidth = 640;
2143 int pageHeight = 480; 2150 int pageHeight = 480;
2144 float browserControlsHeight = 50.0f; 2151 float browserControlsHeight = 50.0f;
2145 int smallestHeight = pageHeight - browserControlsHeight; 2152 int smallestHeight = pageHeight - browserControlsHeight;
2146 2153
2147 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight), 2154 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight),
2148 browserControlsHeight, false); 2155 browserControlsHeight, false);
2149 2156
2150 URLTestHelpers::registerMockedURLLoad(toKURL("http://example.com/foo.png"), 2157 registerMockedHttpURLLoad("http://example.com/foo.png", "white-1x1.png");
2151 "white-1x1.png");
2152 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); 2158 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
2153 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), 2159 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(),
2154 "<!DOCTYPE html>" 2160 "<!DOCTYPE html>"
2155 "<style>" 2161 "<style>"
2156 " body {" 2162 " body {"
2157 " background: url('foo.png');" 2163 " background: url('foo.png');"
2158 " background-attachment: fixed;" 2164 " background-attachment: fixed;"
2159 " background-size: cover;" 2165 " background-size: cover;"
2160 " background-repeat: no-repeat;" 2166 " background-repeat: no-repeat;"
2161 " }" 2167 " }"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 true, nullptr, nullptr, nullptr, &configureAndroidNonCompositing); 2229 true, nullptr, nullptr, nullptr, &configureAndroidNonCompositing);
2224 2230
2225 int pageWidth = 640; 2231 int pageWidth = 640;
2226 int pageHeight = 480; 2232 int pageHeight = 480;
2227 float browserControlsHeight = 50.0f; 2233 float browserControlsHeight = 50.0f;
2228 int smallestHeight = pageHeight - browserControlsHeight; 2234 int smallestHeight = pageHeight - browserControlsHeight;
2229 2235
2230 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight), 2236 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight),
2231 browserControlsHeight, false); 2237 browserControlsHeight, false);
2232 2238
2233 URLTestHelpers::registerMockedURLLoad(toKURL("http://example.com/foo.png"), 2239 registerMockedHttpURLLoad("http://example.com/foo.png", "white-1x1.png");
2234 "white-1x1.png");
2235 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); 2240 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
2236 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), 2241 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(),
2237 "<!DOCTYPE html>" 2242 "<!DOCTYPE html>"
2238 "<style>" 2243 "<style>"
2239 " body {" 2244 " body {"
2240 " margin: 0px;" 2245 " margin: 0px;"
2241 " background: url('foo.png');" 2246 " background: url('foo.png');"
2242 " background-attachment: fixed;" 2247 " background-attachment: fixed;"
2243 " background-size: cover;" 2248 " background-size: cover;"
2244 " background-repeat: no-repeat;" 2249 " background-repeat: no-repeat;"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2331 &configureAndroidCompositing); 2336 &configureAndroidCompositing);
2332 2337
2333 int pageWidth = 640; 2338 int pageWidth = 640;
2334 int pageHeight = 480; 2339 int pageHeight = 480;
2335 float browserControlsHeight = 50.0f; 2340 float browserControlsHeight = 50.0f;
2336 int smallestHeight = pageHeight - browserControlsHeight; 2341 int smallestHeight = pageHeight - browserControlsHeight;
2337 2342
2338 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight), 2343 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight),
2339 browserControlsHeight, false); 2344 browserControlsHeight, false);
2340 2345
2341 URLTestHelpers::registerMockedURLLoad(toKURL("http://example.com/foo.png"), 2346 registerMockedHttpURLLoad("http://example.com/foo.png", "white-1x1.png");
2342 "white-1x1.png");
2343 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); 2347 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
2344 // This time the background is the default attachment. 2348 // This time the background is the default attachment.
2345 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), 2349 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(),
2346 "<!DOCTYPE html>" 2350 "<!DOCTYPE html>"
2347 "<style>" 2351 "<style>"
2348 " body {" 2352 " body {"
2349 " margin: 0px;" 2353 " margin: 0px;"
2350 " background: url('foo.png');" 2354 " background: url('foo.png');"
2351 " background-size: cover;" 2355 " background-size: cover;"
2352 " background-repeat: no-repeat;" 2356 " background-repeat: no-repeat;"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 " body {" 2475 " body {"
2472 " margin: 0px;" 2476 " margin: 0px;"
2473 " }" 2477 " }"
2474 " div { height:110vh; width: 110vw; }" 2478 " div { height:110vh; width: 110vw; }"
2475 "</style>" 2479 "</style>"
2476 "<div></div>", 2480 "<div></div>",
2477 baseURL); 2481 baseURL);
2478 } 2482 }
2479 2483
2480 } // namespace 2484 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698