| OLD | NEW |
| 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 Loading... |
| 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 |
| 106 void registerMockedHttpURLLoad(const std::string& fileName) | 112 void registerMockedHttpURLLoad(const std::string& fileName) |
| 107 { | 113 { |
| 108 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); | 114 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); |
| 109 } | 115 } |
| 110 | 116 |
| 111 WebLayer* getRootScrollLayer() | 117 WebLayer* getRootScrollLayer() |
| 112 { | 118 { |
| 113 RenderLayerCompositor* compositor = m_webViewImpl->mainFrameImpl()->fram
e()->contentRenderer()->compositor(); | 119 RenderLayerCompositor* compositor = m_webViewImpl->mainFrameImpl()->fram
e()->contentRenderer()->compositor(); |
| 114 ASSERT(compositor); | 120 ASSERT(compositor); |
| 115 ASSERT(compositor->scrollLayer()); | 121 ASSERT(compositor->scrollLayer()); |
| 116 | 122 |
| 117 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); | 123 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); |
| 118 return webScrollLayer; | 124 return webScrollLayer; |
| 119 } | 125 } |
| 120 | 126 |
| 121 protected: | 127 protected: |
| 122 std::string m_baseURL; | 128 std::string m_baseURL; |
| 123 MockWebFrameClient m_mockWebFrameClient; | 129 MockWebFrameClient m_mockWebFrameClient; |
| 124 FakeWebViewClient m_mockWebViewClient; | 130 FakeWebViewClient m_mockWebViewClient; |
| 125 WebViewImpl* m_webViewImpl; | 131 WebViewImpl* m_webViewImpl; |
| 126 WebFrame* m_mainFrame; | 132 WebFrame* m_mainFrame; |
| 127 }; | 133 }; |
| 128 | 134 |
| 129 TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingByDefault) | 135 TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingByDefault) |
| 130 { | 136 { |
| 131 navigateTo("about:blank"); | 137 navigateTo("about:blank"); |
| 138 forceFullCompositingUpdate(); |
| 132 | 139 |
| 133 // Make sure the scrolling coordinator is active. | 140 // Make sure the scrolling coordinator is active. |
| 134 FrameView* frameView = m_webViewImpl->mainFrameImpl()->frameView(); | 141 FrameView* frameView = m_webViewImpl->mainFrameImpl()->frameView(); |
| 135 Page* page = m_webViewImpl->mainFrameImpl()->frame()->page(); | 142 Page* page = m_webViewImpl->mainFrameImpl()->frame()->page(); |
| 136 ASSERT_TRUE(page->scrollingCoordinator()); | 143 ASSERT_TRUE(page->scrollingCoordinator()); |
| 137 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView(f
rameView)); | 144 ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView(f
rameView)); |
| 138 | 145 |
| 139 // Fast scrolling should be enabled by default. | 146 // Fast scrolling should be enabled by default. |
| 140 WebLayer* rootScrollLayer = getRootScrollLayer(); | 147 WebLayer* rootScrollLayer = getRootScrollLayer(); |
| 141 ASSERT_TRUE(rootScrollLayer->scrollable()); | 148 ASSERT_TRUE(rootScrollLayer->scrollable()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 159 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer(); | 166 GraphicsLayer* graphicsLayer = compositedLayerMapping->mainGraphicsLayer(); |
| 160 if (!graphicsLayer) | 167 if (!graphicsLayer) |
| 161 return 0; | 168 return 0; |
| 162 return graphicsLayer->platformLayer(); | 169 return graphicsLayer->platformLayer(); |
| 163 } | 170 } |
| 164 | 171 |
| 165 TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingForFixedPosition) | 172 TEST_F(ScrollingCoordinatorChromiumTest, fastScrollingForFixedPosition) |
| 166 { | 173 { |
| 167 registerMockedHttpURLLoad("fixed-position.html"); | 174 registerMockedHttpURLLoad("fixed-position.html"); |
| 168 navigateTo(m_baseURL + "fixed-position.html"); | 175 navigateTo(m_baseURL + "fixed-position.html"); |
| 176 forceFullCompositingUpdate(); |
| 169 | 177 |
| 170 // Fixed position should not fall back to main thread scrolling. | 178 // Fixed position should not fall back to main thread scrolling. |
| 171 WebLayer* rootScrollLayer = getRootScrollLayer(); | 179 WebLayer* rootScrollLayer = getRootScrollLayer(); |
| 172 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); | 180 ASSERT_FALSE(rootScrollLayer->shouldScrollOnMainThread()); |
| 173 | 181 |
| 174 Document* document = m_webViewImpl->mainFrameImpl()->frame()->document(); | 182 Document* document = m_webViewImpl->mainFrameImpl()->frame()->document(); |
| 175 { | 183 { |
| 176 Element* element = document->getElementById("div-tl"); | 184 Element* element = document->getElementById("div-tl"); |
| 177 ASSERT_TRUE(element); | 185 ASSERT_TRUE(element); |
| 178 WebLayer* layer = webLayerFromElement(element); | 186 WebLayer* layer = webLayerFromElement(element); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 WebLayerPositionConstraint constraint = layer->positionConstraint(); | 251 WebLayerPositionConstraint constraint = layer->positionConstraint(); |
| 244 ASSERT_TRUE(constraint.isFixedPosition); | 252 ASSERT_TRUE(constraint.isFixedPosition); |
| 245 ASSERT_TRUE(constraint.isFixedToRightEdge && constraint.isFixedToBottomE
dge); | 253 ASSERT_TRUE(constraint.isFixedToRightEdge && constraint.isFixedToBottomE
dge); |
| 246 } | 254 } |
| 247 } | 255 } |
| 248 | 256 |
| 249 TEST_F(ScrollingCoordinatorChromiumTest, nonFastScrollableRegion) | 257 TEST_F(ScrollingCoordinatorChromiumTest, nonFastScrollableRegion) |
| 250 { | 258 { |
| 251 registerMockedHttpURLLoad("non-fast-scrollable.html"); | 259 registerMockedHttpURLLoad("non-fast-scrollable.html"); |
| 252 navigateTo(m_baseURL + "non-fast-scrollable.html"); | 260 navigateTo(m_baseURL + "non-fast-scrollable.html"); |
| 261 forceFullCompositingUpdate(); |
| 253 | 262 |
| 254 WebLayer* rootScrollLayer = getRootScrollLayer(); | 263 WebLayer* rootScrollLayer = getRootScrollLayer(); |
| 255 WebVector<WebRect> nonFastScrollableRegion = rootScrollLayer->nonFastScrolla
bleRegion(); | 264 WebVector<WebRect> nonFastScrollableRegion = rootScrollLayer->nonFastScrolla
bleRegion(); |
| 256 | 265 |
| 257 ASSERT_EQ(1u, nonFastScrollableRegion.size()); | 266 ASSERT_EQ(1u, nonFastScrollableRegion.size()); |
| 258 ASSERT_EQ(WebRect(8, 8, 10, 10), nonFastScrollableRegion[0]); | 267 ASSERT_EQ(WebRect(8, 8, 10, 10), nonFastScrollableRegion[0]); |
| 259 } | 268 } |
| 260 | 269 |
| 261 TEST_F(ScrollingCoordinatorChromiumTest, wheelEventHandler) | 270 TEST_F(ScrollingCoordinatorChromiumTest, wheelEventHandler) |
| 262 { | 271 { |
| 263 registerMockedHttpURLLoad("wheel-event-handler.html"); | 272 registerMockedHttpURLLoad("wheel-event-handler.html"); |
| 264 navigateTo(m_baseURL + "wheel-event-handler.html"); | 273 navigateTo(m_baseURL + "wheel-event-handler.html"); |
| 274 forceFullCompositingUpdate(); |
| 265 | 275 |
| 266 WebLayer* rootScrollLayer = getRootScrollLayer(); | 276 WebLayer* rootScrollLayer = getRootScrollLayer(); |
| 267 ASSERT_TRUE(rootScrollLayer->haveWheelEventHandlers()); | 277 ASSERT_TRUE(rootScrollLayer->haveWheelEventHandlers()); |
| 268 } | 278 } |
| 269 | 279 |
| 270 TEST_F(ScrollingCoordinatorChromiumTest, clippedBodyTest) | 280 TEST_F(ScrollingCoordinatorChromiumTest, clippedBodyTest) |
| 271 { | 281 { |
| 272 registerMockedHttpURLLoad("clipped-body.html"); | 282 registerMockedHttpURLLoad("clipped-body.html"); |
| 273 navigateTo(m_baseURL + "clipped-body.html"); | 283 navigateTo(m_baseURL + "clipped-body.html"); |
| 284 forceFullCompositingUpdate(); |
| 274 | 285 |
| 275 WebLayer* rootScrollLayer = getRootScrollLayer(); | 286 WebLayer* rootScrollLayer = getRootScrollLayer(); |
| 276 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); | 287 ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size()); |
| 277 } | 288 } |
| 278 | 289 |
| 279 TEST_F(ScrollingCoordinatorChromiumTest, overflowScrolling) | 290 TEST_F(ScrollingCoordinatorChromiumTest, overflowScrolling) |
| 280 { | 291 { |
| 281 registerMockedHttpURLLoad("overflow-scrolling.html"); | 292 registerMockedHttpURLLoad("overflow-scrolling.html"); |
| 282 navigateTo(m_baseURL + "overflow-scrolling.html"); | 293 navigateTo(m_baseURL + "overflow-scrolling.html"); |
| 294 forceFullCompositingUpdate(); |
| 283 | 295 |
| 284 // Verify the properties of the accelerated scrolling element starting from
the RenderObject | 296 // Verify the properties of the accelerated scrolling element starting from
the RenderObject |
| 285 // all the way to the WebLayer. | 297 // all the way to the WebLayer. |
| 286 Element* scrollableElement = m_webViewImpl->mainFrameImpl()->frame()->docume
nt()->getElementById("scrollable"); | 298 Element* scrollableElement = m_webViewImpl->mainFrameImpl()->frame()->docume
nt()->getElementById("scrollable"); |
| 287 ASSERT(scrollableElement); | 299 ASSERT(scrollableElement); |
| 288 | 300 |
| 289 RenderObject* renderer = scrollableElement->renderer(); | 301 RenderObject* renderer = scrollableElement->renderer(); |
| 290 ASSERT_TRUE(renderer->isBoxModelObject()); | 302 ASSERT_TRUE(renderer->isBoxModelObject()); |
| 291 ASSERT_TRUE(renderer->hasLayer()); | 303 ASSERT_TRUE(renderer->hasLayer()); |
| 292 | 304 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 311 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()); | 323 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()); |
| 312 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()->hasContents
Layer()); | 324 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()->hasContents
Layer()); |
| 313 #endif | 325 #endif |
| 314 } | 326 } |
| 315 | 327 |
| 316 TEST_F(ScrollingCoordinatorChromiumTest, iframeScrolling) | 328 TEST_F(ScrollingCoordinatorChromiumTest, iframeScrolling) |
| 317 { | 329 { |
| 318 registerMockedHttpURLLoad("iframe-scrolling.html"); | 330 registerMockedHttpURLLoad("iframe-scrolling.html"); |
| 319 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); | 331 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); |
| 320 navigateTo(m_baseURL + "iframe-scrolling.html"); | 332 navigateTo(m_baseURL + "iframe-scrolling.html"); |
| 333 forceFullCompositingUpdate(); |
| 321 | 334 |
| 322 // Verify the properties of the accelerated scrolling element starting from
the RenderObject | 335 // Verify the properties of the accelerated scrolling element starting from
the RenderObject |
| 323 // all the way to the WebLayer. | 336 // all the way to the WebLayer. |
| 324 Element* scrollableFrame = m_webViewImpl->mainFrameImpl()->frame()->document
()->getElementById("scrollable"); | 337 Element* scrollableFrame = m_webViewImpl->mainFrameImpl()->frame()->document
()->getElementById("scrollable"); |
| 325 ASSERT_TRUE(scrollableFrame); | 338 ASSERT_TRUE(scrollableFrame); |
| 326 | 339 |
| 327 RenderObject* renderer = scrollableFrame->renderer(); | 340 RenderObject* renderer = scrollableFrame->renderer(); |
| 328 ASSERT_TRUE(renderer); | 341 ASSERT_TRUE(renderer); |
| 329 ASSERT_TRUE(renderer->isWidget()); | 342 ASSERT_TRUE(renderer->isWidget()); |
| 330 | 343 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 354 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()); | 367 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()); |
| 355 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()->hasContentsLayer()
); | 368 ASSERT_TRUE(innerCompositor->layerForVerticalScrollbar()->hasContentsLayer()
); |
| 356 #endif | 369 #endif |
| 357 } | 370 } |
| 358 | 371 |
| 359 TEST_F(ScrollingCoordinatorChromiumTest, rtlIframe) | 372 TEST_F(ScrollingCoordinatorChromiumTest, rtlIframe) |
| 360 { | 373 { |
| 361 registerMockedHttpURLLoad("rtl-iframe.html"); | 374 registerMockedHttpURLLoad("rtl-iframe.html"); |
| 362 registerMockedHttpURLLoad("rtl-iframe-inner.html"); | 375 registerMockedHttpURLLoad("rtl-iframe-inner.html"); |
| 363 navigateTo(m_baseURL + "rtl-iframe.html"); | 376 navigateTo(m_baseURL + "rtl-iframe.html"); |
| 377 forceFullCompositingUpdate(); |
| 364 | 378 |
| 365 // Verify the properties of the accelerated scrolling element starting from
the RenderObject | 379 // Verify the properties of the accelerated scrolling element starting from
the RenderObject |
| 366 // all the way to the WebLayer. | 380 // all the way to the WebLayer. |
| 367 Element* scrollableFrame = m_webViewImpl->mainFrameImpl()->frame()->document
()->getElementById("scrollable"); | 381 Element* scrollableFrame = m_webViewImpl->mainFrameImpl()->frame()->document
()->getElementById("scrollable"); |
| 368 ASSERT_TRUE(scrollableFrame); | 382 ASSERT_TRUE(scrollableFrame); |
| 369 | 383 |
| 370 RenderObject* renderer = scrollableFrame->renderer(); | 384 RenderObject* renderer = scrollableFrame->renderer(); |
| 371 ASSERT_TRUE(renderer); | 385 ASSERT_TRUE(renderer); |
| 372 ASSERT_TRUE(renderer->isWidget()); | 386 ASSERT_TRUE(renderer->isWidget()); |
| 373 | 387 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 392 | 406 |
| 393 int expectedScrollPosition = 958 + (innerFrameView->verticalScrollbar()->isO
verlayScrollbar() ? 0 : 15); | 407 int expectedScrollPosition = 958 + (innerFrameView->verticalScrollbar()->isO
verlayScrollbar() ? 0 : 15); |
| 394 ASSERT_EQ(expectedScrollPosition, webScrollLayer->scrollPosition().x); | 408 ASSERT_EQ(expectedScrollPosition, webScrollLayer->scrollPosition().x); |
| 395 ASSERT_EQ(expectedScrollPosition, webScrollLayer->maxScrollPosition().width)
; | 409 ASSERT_EQ(expectedScrollPosition, webScrollLayer->maxScrollPosition().width)
; |
| 396 } | 410 } |
| 397 | 411 |
| 398 TEST_F(ScrollingCoordinatorChromiumTest, setupScrollbarLayerShouldNotCrash) | 412 TEST_F(ScrollingCoordinatorChromiumTest, setupScrollbarLayerShouldNotCrash) |
| 399 { | 413 { |
| 400 registerMockedHttpURLLoad("setup_scrollbar_layer_crash.html"); | 414 registerMockedHttpURLLoad("setup_scrollbar_layer_crash.html"); |
| 401 navigateTo(m_baseURL + "setup_scrollbar_layer_crash.html"); | 415 navigateTo(m_baseURL + "setup_scrollbar_layer_crash.html"); |
| 416 forceFullCompositingUpdate(); |
| 402 // This test document setup an iframe with scrollbars, then switch to | 417 // This test document setup an iframe with scrollbars, then switch to |
| 403 // an empty document by javascript. | 418 // an empty document by javascript. |
| 404 } | 419 } |
| 405 | 420 |
| 406 } // namespace | 421 } // namespace |
| OLD | NEW |