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

Side by Side Diff: Source/web/tests/ScrollingCoordinatorChromiumTest.cpp

Issue 46163008: Revert "Re-land deferred compositing updates with fixed assumptions" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/WebPluginContainerImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 m_webViewImpl->close(); 96 m_webViewImpl->close();
97 m_mainFrame->close(); 97 m_mainFrame->close();
98 } 98 }
99 99
100 void navigateTo(const std::string& url) 100 void navigateTo(const std::string& url)
101 { 101 {
102 FrameTestHelpers::loadFrame(m_webViewImpl->mainFrame(), url); 102 FrameTestHelpers::loadFrame(m_webViewImpl->mainFrame(), url);
103 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests( ); 103 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests( );
104 } 104 }
105 105
106 void forceFullCompositingUpdate()
107 {
108 RenderLayerCompositor* compositor = m_webViewImpl->mainFrameImpl()->fram e()->contentRenderer()->compositor();
109 compositor->updateCompositingLayers(CompositingUpdateFinishAllDeferredWo rk);
110 }
111
112 void registerMockedHttpURLLoad(const std::string& fileName) 106 void registerMockedHttpURLLoad(const std::string& fileName)
113 { 107 {
114 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU RL.c_str()), WebString::fromUTF8(fileName.c_str())); 108 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU RL.c_str()), WebString::fromUTF8(fileName.c_str()));
115 } 109 }
116 110
117 WebLayer* getRootScrollLayer() 111 WebLayer* getRootScrollLayer()
118 { 112 {
119 RenderLayerCompositor* compositor = m_webViewImpl->mainFrameImpl()->fram e()->contentRenderer()->compositor(); 113 RenderLayerCompositor* compositor = m_webViewImpl->mainFrameImpl()->fram e()->contentRenderer()->compositor();
120 ASSERT(compositor); 114 ASSERT(compositor);
121 ASSERT(compositor->scrollLayer()); 115 ASSERT(compositor->scrollLayer());
122 116
123 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); 117 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer();
124 return webScrollLayer; 118 return webScrollLayer;
125 } 119 }
126 120
127 protected: 121 protected:
128 std::string m_baseURL; 122 std::string m_baseURL;
129 MockWebFrameClient m_mockWebFrameClient; 123 MockWebFrameClient m_mockWebFrameClient;
130 FakeWebViewClient m_mockWebViewClient; 124 FakeWebViewClient m_mockWebViewClient;
131 WebViewImpl* m_webViewImpl; 125 WebViewImpl* m_webViewImpl;
132 WebFrame* m_mainFrame; 126 WebFrame* m_mainFrame;
133 }; 127 };
134 128
135 TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingByDefault) 129 TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingByDefault)
136 { 130 {
137 navigateTo("about:blank"); 131 navigateTo("about:blank");
138 forceFullCompositingUpdate();
139 132
140 // Make sure the scrolling coordinator is active. 133 // Make sure the scrolling coordinator is active.
141 FrameView* frameView = m_webViewImpl->mainFrameImpl()->frameView(); 134 FrameView* frameView = m_webViewImpl->mainFrameImpl()->frameView();
142 Page* page = m_webViewImpl->mainFrameImpl()->frame()->page(); 135 Page* page = m_webViewImpl->mainFrameImpl()->frame()->page();
143 ASSERT_TRUE(page->scrollingCoordinator()); 136 ASSERT_TRUE(page->scrollingCoordinator());
144 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView(f rameView)); 137 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView(f rameView));
145 138
146 // Fast scrolling should be enabled by default. 139 // Fast scrolling should be enabled by default.
147 WebLayer* rootScrollLayer = getRootScrollLayer(); 140 WebLayer* rootScrollLayer = getRootScrollLayer();
148 ASSERT_TRUE(rootScrollLayer->scrollable()); 141 ASSERT_TRUE(rootScrollLayer->scrollable());
(...skipping 17 matching lines...) Expand all
166 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer(); 159 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer();
167 if (!graphicsLayer) 160 if (!graphicsLayer)
168 return 0; 161 return 0;
169 return graphicsLayer->platformLayer(); 162 return graphicsLayer->platformLayer();
170 } 163 }
171 164
172 TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingForFixedPosition) 165 TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingForFixedPosition)
173 { 166 {
174 registerMockedHttpURLLoad("fixed-position.html"); 167 registerMockedHttpURLLoad("fixed-position.html");
175 navigateTo(m_baseURL + "fixed-position.html"); 168 navigateTo(m_baseURL + "fixed-position.html");
176 forceFullCompositingUpdate();
177 169
178 // Fixed position should not fall back to main thread scrolling. 170 // Fixed position should not fall back to main thread scrolling.
179 WebLayer* rootScrollLayer = getRootScrollLayer(); 171 WebLayer* rootScrollLayer = getRootScrollLayer();
180 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); 172 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread());
181 173
182 Document* document = m_webViewImpl->mainFrameImpl()->frame()->document(); 174 Document* document = m_webViewImpl->mainFrameImpl()->frame()->document();
183 { 175 {
184 Element* element = document->getElementById("div-tl"); 176 Element* element = document->getElementById("div-tl");
185 ASSERT_TRUE(element); 177 ASSERT_TRUE(element);
186 WebLayer* layer = webLayerFromElement(element); 178 WebLayer* layer = webLayerFromElement(element);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 WebLayerPositionConstraint constraint = layer->positionConstraint(); 243 WebLayerPositionConstraint constraint = layer->positionConstraint();
252 ASSERT_TRUE(constraint.isFixedPosition); 244 ASSERT_TRUE(constraint.isFixedPosition);
253 ASSERT_TRUE(constraint.isFixedToRightEdge && constraint.isFixedToBottomE dge); 245 ASSERT_TRUE(constraint.isFixedToRightEdge && constraint.isFixedToBottomE dge);
254 } 246 }
255 } 247 }
256 248
257 TEST_F(ScrollingCoordinatorChromiumTest, nonFastScrollableRegion) 249 TEST_F(ScrollingCoordinatorChromiumTest, nonFastScrollableRegion)
258 { 250 {
259 registerMockedHttpURLLoad("non-fast-scrollable.html"); 251 registerMockedHttpURLLoad("non-fast-scrollable.html");
260 navigateTo(m_baseURL + "non-fast-scrollable.html"); 252 navigateTo(m_baseURL + "non-fast-scrollable.html");
261 forceFullCompositingUpdate();
262 253
263 WebLayer* rootScrollLayer = getRootScrollLayer(); 254 WebLayer* rootScrollLayer = getRootScrollLayer();
264 WebVector<WebRect> nonFastScrollableRegion = rootScrollLayer->nonFastScrolla bleRegion(); 255 WebVector<WebRect> nonFastScrollableRegion = rootScrollLayer->nonFastScrolla bleRegion();
265 256
266 ASSERT_EQ(1u, nonFastScrollableRegion.size()); 257 ASSERT_EQ(1u, nonFastScrollableRegion.size());
267 ASSERT_EQ(WebRect(8, 8, 10, 10), nonFastScrollableRegion[0]); 258 ASSERT_EQ(WebRect(8, 8, 10, 10), nonFastScrollableRegion[0]);
268 } 259 }
269 260
270 TEST_F(ScrollingCoordinatorChromiumTest, wheelEventHandler) 261 TEST_F(ScrollingCoordinatorChromiumTest, wheelEventHandler)
271 { 262 {
272 registerMockedHttpURLLoad("wheel-event-handler.html"); 263 registerMockedHttpURLLoad("wheel-event-handler.html");
273 navigateTo(m_baseURL + "wheel-event-handler.html"); 264 navigateTo(m_baseURL + "wheel-event-handler.html");
274 forceFullCompositingUpdate();
275 265
276 WebLayer* rootScrollLayer = getRootScrollLayer(); 266 WebLayer* rootScrollLayer = getRootScrollLayer();
277 ASSERT_TRUE(rootScrollLayer->haveWheelEventHandlers()); 267 ASSERT_TRUE(rootScrollLayer->haveWheelEventHandlers());
278 } 268 }
279 269
280 TEST_F(ScrollingCoordinatorChromiumTest, clippedBodyTest) 270 TEST_F(ScrollingCoordinatorChromiumTest, clippedBodyTest)
281 { 271 {
282 registerMockedHttpURLLoad("clipped-body.html"); 272 registerMockedHttpURLLoad("clipped-body.html");
283 navigateTo(m_baseURL + "clipped-body.html"); 273 navigateTo(m_baseURL + "clipped-body.html");
284 forceFullCompositingUpdate();
285 274
286 WebLayer* rootScrollLayer = getRootScrollLayer(); 275 WebLayer* rootScrollLayer = getRootScrollLayer();
287 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); 276 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size());
288 } 277 }
289 278
290 TEST_F(ScrollingCoordinatorChromiumTest, overflowScrolling) 279 TEST_F(ScrollingCoordinatorChromiumTest, overflowScrolling)
291 { 280 {
292 registerMockedHttpURLLoad("overflow-scrolling.html"); 281 registerMockedHttpURLLoad("overflow-scrolling.html");
293 navigateTo(m_baseURL + "overflow-scrolling.html"); 282 navigateTo(m_baseURL + "overflow-scrolling.html");
294 forceFullCompositingUpdate();
295 283
296 // Verify the properties of the accelerated scrolling element starting from the RenderObject 284 // Verify the properties of the accelerated scrolling element starting from the RenderObject
297 // all the way to the WebLayer. 285 // all the way to the WebLayer.
298 Element* scrollableElement = m_webViewImpl->mainFrameImpl()->frame()->docume nt()->getElementById("scrollable"); 286 Element* scrollableElement = m_webViewImpl->mainFrameImpl()->frame()->docume nt()->getElementById("scrollable");
299 ASSERT(scrollableElement); 287 ASSERT(scrollableElement);
300 288
301 RenderObject* renderer = scrollableElement->renderer(); 289 RenderObject* renderer = scrollableElement->renderer();
302 ASSERT_TRUE(renderer->isBox()); 290 ASSERT_TRUE(renderer->isBox());
303 ASSERT_TRUE(renderer->hasLayer()); 291 ASSERT_TRUE(renderer->hasLayer());
304 292
(...skipping 19 matching lines...) Expand all
324 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()->hasConten tsLayer()); 312 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()->hasConten tsLayer());
325 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()); 313 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar());
326 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()->hasContents Layer()); 314 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()->hasContents Layer());
327 #endif 315 #endif
328 } 316 }
329 317
330 TEST_F(ScrollingCoordinatorChromiumTest, overflowHidden) 318 TEST_F(ScrollingCoordinatorChromiumTest, overflowHidden)
331 { 319 {
332 registerMockedHttpURLLoad("overflow-hidden.html"); 320 registerMockedHttpURLLoad("overflow-hidden.html");
333 navigateTo(m_baseURL + "overflow-hidden.html"); 321 navigateTo(m_baseURL + "overflow-hidden.html");
334 forceFullCompositingUpdate();
335 322
336 // Verify the properties of the accelerated scrolling element starting from the RenderObject 323 // Verify the properties of the accelerated scrolling element starting from the RenderObject
337 // all the way to the WebLayer. 324 // all the way to the WebLayer.
338 Element* overflowElement = m_webViewImpl->mainFrameImpl()->frame()->document ()->getElementById("unscrollable-y"); 325 Element* overflowElement = m_webViewImpl->mainFrameImpl()->frame()->document ()->getElementById("unscrollable-y");
339 ASSERT(overflowElement); 326 ASSERT(overflowElement);
340 327
341 RenderObject* renderer = overflowElement->renderer(); 328 RenderObject* renderer = overflowElement->renderer();
342 ASSERT_TRUE(renderer->isBox()); 329 ASSERT_TRUE(renderer->isBox());
343 ASSERT_TRUE(renderer->hasLayer()); 330 ASSERT_TRUE(renderer->hasLayer());
344 331
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 ASSERT_TRUE(webScrollLayer->scrollable()); 367 ASSERT_TRUE(webScrollLayer->scrollable());
381 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); 368 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal());
382 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); 369 ASSERT_TRUE(webScrollLayer->userScrollableVertical());
383 } 370 }
384 371
385 TEST_F(ScrollingCoordinatorChromiumTest, iframeScrolling) 372 TEST_F(ScrollingCoordinatorChromiumTest, iframeScrolling)
386 { 373 {
387 registerMockedHttpURLLoad("iframe-scrolling.html"); 374 registerMockedHttpURLLoad("iframe-scrolling.html");
388 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); 375 registerMockedHttpURLLoad("iframe-scrolling-inner.html");
389 navigateTo(m_baseURL + "iframe-scrolling.html"); 376 navigateTo(m_baseURL + "iframe-scrolling.html");
390 forceFullCompositingUpdate();
391 377
392 // Verify the properties of the accelerated scrolling element starting from the RenderObject 378 // Verify the properties of the accelerated scrolling element starting from the RenderObject
393 // all the way to the WebLayer. 379 // all the way to the WebLayer.
394 Element* scrollableFrame = m_webViewImpl->mainFrameImpl()->frame()->document ()->getElementById("scrollable"); 380 Element* scrollableFrame = m_webViewImpl->mainFrameImpl()->frame()->document ()->getElementById("scrollable");
395 ASSERT_TRUE(scrollableFrame); 381 ASSERT_TRUE(scrollableFrame);
396 382
397 RenderObject* renderer = scrollableFrame->renderer(); 383 RenderObject* renderer = scrollableFrame->renderer();
398 ASSERT_TRUE(renderer); 384 ASSERT_TRUE(renderer);
399 ASSERT_TRUE(renderer->isWidget()); 385 ASSERT_TRUE(renderer->isWidget());
400 386
(...skipping 23 matching lines...) Expand all
424 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()); 410 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar());
425 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()->hasContentsLayer() ); 411 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()->hasContentsLayer() );
426 #endif 412 #endif
427 } 413 }
428 414
429 TEST_F(ScrollingCoordinatorChromiumTest, rtlIframe) 415 TEST_F(ScrollingCoordinatorChromiumTest, rtlIframe)
430 { 416 {
431 registerMockedHttpURLLoad("rtl-iframe.html"); 417 registerMockedHttpURLLoad("rtl-iframe.html");
432 registerMockedHttpURLLoad("rtl-iframe-inner.html"); 418 registerMockedHttpURLLoad("rtl-iframe-inner.html");
433 navigateTo(m_baseURL + "rtl-iframe.html"); 419 navigateTo(m_baseURL + "rtl-iframe.html");
434 forceFullCompositingUpdate();
435 420
436 // Verify the properties of the accelerated scrolling element starting from the RenderObject 421 // Verify the properties of the accelerated scrolling element starting from the RenderObject
437 // all the way to the WebLayer. 422 // all the way to the WebLayer.
438 Element* scrollableFrame = m_webViewImpl->mainFrameImpl()->frame()->document ()->getElementById("scrollable"); 423 Element* scrollableFrame = m_webViewImpl->mainFrameImpl()->frame()->document ()->getElementById("scrollable");
439 ASSERT_TRUE(scrollableFrame); 424 ASSERT_TRUE(scrollableFrame);
440 425
441 RenderObject* renderer = scrollableFrame->renderer(); 426 RenderObject* renderer = scrollableFrame->renderer();
442 ASSERT_TRUE(renderer); 427 ASSERT_TRUE(renderer);
443 ASSERT_TRUE(renderer->isWidget()); 428 ASSERT_TRUE(renderer->isWidget());
444 429
(...skipping 18 matching lines...) Expand all
463 448
464 int expectedScrollPosition = 958 + (innerFrameView->verticalScrollbar()->isO verlayScrollbar() ? 0 : 15); 449 int expectedScrollPosition = 958 + (innerFrameView->verticalScrollbar()->isO verlayScrollbar() ? 0 : 15);
465 ASSERT_EQ(expectedScrollPosition, webScrollLayer->scrollPosition().x); 450 ASSERT_EQ(expectedScrollPosition, webScrollLayer->scrollPosition().x);
466 ASSERT_EQ(expectedScrollPosition, webScrollLayer->maxScrollPosition().width) ; 451 ASSERT_EQ(expectedScrollPosition, webScrollLayer->maxScrollPosition().width) ;
467 } 452 }
468 453
469 TEST_F(ScrollingCoordinatorChromiumTest, setupScrollbarLayerShouldNotCrash) 454 TEST_F(ScrollingCoordinatorChromiumTest, setupScrollbarLayerShouldNotCrash)
470 { 455 {
471 registerMockedHttpURLLoad("setup_scrollbar_layer_crash.html"); 456 registerMockedHttpURLLoad("setup_scrollbar_layer_crash.html");
472 navigateTo(m_baseURL + "setup_scrollbar_layer_crash.html"); 457 navigateTo(m_baseURL + "setup_scrollbar_layer_crash.html");
473 forceFullCompositingUpdate();
474 // This test document setup an iframe with scrollbars, then switch to 458 // This test document setup an iframe with scrollbars, then switch to
475 // an empty document by javascript. 459 // an empty document by javascript.
476 } 460 }
477 461
478 } // namespace 462 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebPluginContainerImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698