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

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

Issue 1839643009: RELEASE_ASSERT -> CHECK and ASSERT -> DCHECK in web. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Return DCHECK_IS_ON checks. Created 4 years, 8 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 /* 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 void registerMockedHttpURLLoad(const std::string& fileName) 79 void registerMockedHttpURLLoad(const std::string& fileName)
80 { 80 {
81 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU RL.c_str()), WebString::fromUTF8(fileName.c_str())); 81 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU RL.c_str()), WebString::fromUTF8(fileName.c_str()));
82 } 82 }
83 83
84 WebLayer* getRootScrollLayer() 84 WebLayer* getRootScrollLayer()
85 { 85 {
86 PaintLayerCompositor* compositor = frame()->contentLayoutObject()->compo sitor(); 86 PaintLayerCompositor* compositor = frame()->contentLayoutObject()->compo sitor();
87 ASSERT(compositor); 87 DCHECK(compositor);
88 ASSERT(compositor->scrollLayer()); 88 DCHECK(compositor->scrollLayer());
89 89
90 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); 90 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer();
91 return webScrollLayer; 91 return webScrollLayer;
92 } 92 }
93 93
94 WebViewImpl* webViewImpl() const { return m_helper.webViewImpl(); } 94 WebViewImpl* webViewImpl() const { return m_helper.webViewImpl(); }
95 LocalFrame* frame() const { return m_helper.webViewImpl()->mainFrameImpl()-> frame(); } 95 LocalFrame* frame() const { return m_helper.webViewImpl()->mainFrameImpl()-> frame(); }
96 96
97 WebLayerTreeView* webLayerTreeView() const { return webViewImpl()->layerTree View(); } 97 WebLayerTreeView* webLayerTreeView() const { return webViewImpl()->layerTree View(); }
98 98
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 151
152 TEST_F(ScrollingCoordinatorTest, fastFractionalScrollingDiv) 152 TEST_F(ScrollingCoordinatorTest, fastFractionalScrollingDiv)
153 { 153 {
154 registerMockedHttpURLLoad("fractional-scroll-div.html"); 154 registerMockedHttpURLLoad("fractional-scroll-div.html");
155 navigateTo(m_baseURL + "fractional-scroll-div.html"); 155 navigateTo(m_baseURL + "fractional-scroll-div.html");
156 forceFullCompositingUpdate(); 156 forceFullCompositingUpdate();
157 157
158 Document* document = frame()->document(); 158 Document* document = frame()->document();
159 Element* scrollableElement = document->getElementById("scroller"); 159 Element* scrollableElement = document->getElementById("scroller");
160 ASSERT(scrollableElement); 160 DCHECK(scrollableElement);
161 161
162 scrollableElement->setScrollTop(1.0); 162 scrollableElement->setScrollTop(1.0);
163 scrollableElement->setScrollLeft(1.0); 163 scrollableElement->setScrollLeft(1.0);
164 forceFullCompositingUpdate(); 164 forceFullCompositingUpdate();
165 165
166 // Make sure the fractional scroll offset change 1.0 -> 1.2 gets propagated 166 // Make sure the fractional scroll offset change 1.0 -> 1.2 gets propagated
167 // to compositor. 167 // to compositor.
168 scrollableElement->setScrollTop(1.2); 168 scrollableElement->setScrollTop(1.2);
169 scrollableElement->setScrollLeft(1.2); 169 scrollableElement->setScrollLeft(1.2);
170 forceFullCompositingUpdate(); 170 forceFullCompositingUpdate();
171 171
172 LayoutObject* layoutObject = scrollableElement->layoutObject(); 172 LayoutObject* layoutObject = scrollableElement->layoutObject();
173 ASSERT_TRUE(layoutObject->isBox()); 173 ASSERT_TRUE(layoutObject->isBox());
174 LayoutBox* box = toLayoutBox(layoutObject); 174 LayoutBox* box = toLayoutBox(layoutObject);
175 ASSERT_TRUE(box->usesCompositedScrolling()); 175 ASSERT_TRUE(box->usesCompositedScrolling());
176 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping(); 176 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping();
177 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer()); 177 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer());
178 ASSERT(compositedLayerMapping->scrollingContentsLayer()); 178 DCHECK(compositedLayerMapping->scrollingContentsLayer());
179 WebLayer* webScrollLayer = compositedLayerMapping->scrollingContentsLayer()- >platformLayer(); 179 WebLayer* webScrollLayer = compositedLayerMapping->scrollingContentsLayer()- >platformLayer();
180 ASSERT_TRUE(webScrollLayer); 180 ASSERT_TRUE(webScrollLayer);
181 ASSERT_NEAR(1.2, webScrollLayer->scrollPositionDouble().x, 0.01); 181 ASSERT_NEAR(1.2, webScrollLayer->scrollPositionDouble().x, 0.01);
182 ASSERT_NEAR(1.2, webScrollLayer->scrollPositionDouble().y, 0.01); 182 ASSERT_NEAR(1.2, webScrollLayer->scrollPositionDouble().y, 0.01);
183 } 183 }
184 184
185 static WebLayer* webLayerFromElement(Element* element) 185 static WebLayer* webLayerFromElement(Element* element)
186 { 186 {
187 if (!element) 187 if (!element)
188 return 0; 188 return 0;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 372
373 TEST_F(ScrollingCoordinatorTest, overflowScrolling) 373 TEST_F(ScrollingCoordinatorTest, overflowScrolling)
374 { 374 {
375 registerMockedHttpURLLoad("overflow-scrolling.html"); 375 registerMockedHttpURLLoad("overflow-scrolling.html");
376 navigateTo(m_baseURL + "overflow-scrolling.html"); 376 navigateTo(m_baseURL + "overflow-scrolling.html");
377 forceFullCompositingUpdate(); 377 forceFullCompositingUpdate();
378 378
379 // Verify the properties of the accelerated scrolling element starting from the LayoutObject 379 // Verify the properties of the accelerated scrolling element starting from the LayoutObject
380 // all the way to the WebLayer. 380 // all the way to the WebLayer.
381 Element* scrollableElement = frame()->document()->getElementById("scrollable "); 381 Element* scrollableElement = frame()->document()->getElementById("scrollable ");
382 ASSERT(scrollableElement); 382 DCHECK(scrollableElement);
383 383
384 LayoutObject* layoutObject = scrollableElement->layoutObject(); 384 LayoutObject* layoutObject = scrollableElement->layoutObject();
385 ASSERT_TRUE(layoutObject->isBox()); 385 ASSERT_TRUE(layoutObject->isBox());
386 ASSERT_TRUE(layoutObject->hasLayer()); 386 ASSERT_TRUE(layoutObject->hasLayer());
387 387
388 LayoutBox* box = toLayoutBox(layoutObject); 388 LayoutBox* box = toLayoutBox(layoutObject);
389 ASSERT_TRUE(box->usesCompositedScrolling()); 389 ASSERT_TRUE(box->usesCompositedScrolling());
390 ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState()); 390 ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState());
391 391
392 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping(); 392 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping();
393 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer()); 393 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer());
394 ASSERT(compositedLayerMapping->scrollingContentsLayer()); 394 DCHECK(compositedLayerMapping->scrollingContentsLayer());
395 395
396 GraphicsLayer* graphicsLayer = compositedLayerMapping->scrollingContentsLaye r(); 396 GraphicsLayer* graphicsLayer = compositedLayerMapping->scrollingContentsLaye r();
397 ASSERT_EQ(box->layer()->getScrollableArea(), graphicsLayer->getScrollableAre a()); 397 ASSERT_EQ(box->layer()->getScrollableArea(), graphicsLayer->getScrollableAre a());
398 398
399 WebLayer* webScrollLayer = compositedLayerMapping->scrollingContentsLayer()- >platformLayer(); 399 WebLayer* webScrollLayer = compositedLayerMapping->scrollingContentsLayer()- >platformLayer();
400 ASSERT_TRUE(webScrollLayer->scrollable()); 400 ASSERT_TRUE(webScrollLayer->scrollable());
401 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); 401 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal());
402 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); 402 ASSERT_TRUE(webScrollLayer->userScrollableVertical());
403 403
404 #if OS(ANDROID) 404 #if OS(ANDROID)
405 // Now verify we've attached impl-side scrollbars onto the scrollbar layers 405 // Now verify we've attached impl-side scrollbars onto the scrollbar layers
406 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()); 406 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar());
407 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()->hasConten tsLayer()); 407 ASSERT_TRUE(compositedLayerMapping->layerForHorizontalScrollbar()->hasConten tsLayer());
408 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()); 408 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar());
409 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()->hasContents Layer()); 409 ASSERT_TRUE(compositedLayerMapping->layerForVerticalScrollbar()->hasContents Layer());
410 #endif 410 #endif
411 } 411 }
412 412
413 TEST_F(ScrollingCoordinatorTest, overflowHidden) 413 TEST_F(ScrollingCoordinatorTest, overflowHidden)
414 { 414 {
415 registerMockedHttpURLLoad("overflow-hidden.html"); 415 registerMockedHttpURLLoad("overflow-hidden.html");
416 navigateTo(m_baseURL + "overflow-hidden.html"); 416 navigateTo(m_baseURL + "overflow-hidden.html");
417 forceFullCompositingUpdate(); 417 forceFullCompositingUpdate();
418 418
419 // Verify the properties of the accelerated scrolling element starting from the LayoutObject 419 // Verify the properties of the accelerated scrolling element starting from the LayoutObject
420 // all the way to the WebLayer. 420 // all the way to the WebLayer.
421 Element* overflowElement = frame()->document()->getElementById("unscrollable -y"); 421 Element* overflowElement = frame()->document()->getElementById("unscrollable -y");
422 ASSERT(overflowElement); 422 DCHECK(overflowElement);
423 423
424 LayoutObject* layoutObject = overflowElement->layoutObject(); 424 LayoutObject* layoutObject = overflowElement->layoutObject();
425 ASSERT_TRUE(layoutObject->isBox()); 425 ASSERT_TRUE(layoutObject->isBox());
426 ASSERT_TRUE(layoutObject->hasLayer()); 426 ASSERT_TRUE(layoutObject->hasLayer());
427 427
428 LayoutBox* box = toLayoutBox(layoutObject); 428 LayoutBox* box = toLayoutBox(layoutObject);
429 ASSERT_TRUE(box->usesCompositedScrolling()); 429 ASSERT_TRUE(box->usesCompositedScrolling());
430 ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState()); 430 ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState());
431 431
432 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping(); 432 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping();
433 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer()); 433 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer());
434 ASSERT(compositedLayerMapping->scrollingContentsLayer()); 434 DCHECK(compositedLayerMapping->scrollingContentsLayer());
435 435
436 GraphicsLayer* graphicsLayer = compositedLayerMapping->scrollingContentsLaye r(); 436 GraphicsLayer* graphicsLayer = compositedLayerMapping->scrollingContentsLaye r();
437 ASSERT_EQ(box->layer()->getScrollableArea(), graphicsLayer->getScrollableAre a()); 437 ASSERT_EQ(box->layer()->getScrollableArea(), graphicsLayer->getScrollableAre a());
438 438
439 WebLayer* webScrollLayer = compositedLayerMapping->scrollingContentsLayer()- >platformLayer(); 439 WebLayer* webScrollLayer = compositedLayerMapping->scrollingContentsLayer()- >platformLayer();
440 ASSERT_TRUE(webScrollLayer->scrollable()); 440 ASSERT_TRUE(webScrollLayer->scrollable());
441 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal()); 441 ASSERT_TRUE(webScrollLayer->userScrollableHorizontal());
442 ASSERT_FALSE(webScrollLayer->userScrollableVertical()); 442 ASSERT_FALSE(webScrollLayer->userScrollableVertical());
443 443
444 overflowElement = frame()->document()->getElementById("unscrollable-x"); 444 overflowElement = frame()->document()->getElementById("unscrollable-x");
445 ASSERT(overflowElement); 445 DCHECK(overflowElement);
446 446
447 layoutObject = overflowElement->layoutObject(); 447 layoutObject = overflowElement->layoutObject();
448 ASSERT_TRUE(layoutObject->isBox()); 448 ASSERT_TRUE(layoutObject->isBox());
449 ASSERT_TRUE(layoutObject->hasLayer()); 449 ASSERT_TRUE(layoutObject->hasLayer());
450 450
451 box = toLayoutBox(layoutObject); 451 box = toLayoutBox(layoutObject);
452 ASSERT_TRUE(box->getScrollableArea()->usesCompositedScrolling()); 452 ASSERT_TRUE(box->getScrollableArea()->usesCompositedScrolling());
453 ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState()); 453 ASSERT_EQ(PaintsIntoOwnBacking, box->layer()->compositingState());
454 454
455 compositedLayerMapping = box->layer()->compositedLayerMapping(); 455 compositedLayerMapping = box->layer()->compositedLayerMapping();
456 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer()); 456 ASSERT_TRUE(compositedLayerMapping->hasScrollingLayer());
457 ASSERT(compositedLayerMapping->scrollingContentsLayer()); 457 DCHECK(compositedLayerMapping->scrollingContentsLayer());
458 458
459 graphicsLayer = compositedLayerMapping->scrollingContentsLayer(); 459 graphicsLayer = compositedLayerMapping->scrollingContentsLayer();
460 ASSERT_EQ(box->layer()->getScrollableArea(), graphicsLayer->getScrollableAre a()); 460 ASSERT_EQ(box->layer()->getScrollableArea(), graphicsLayer->getScrollableAre a());
461 461
462 webScrollLayer = compositedLayerMapping->scrollingContentsLayer()->platformL ayer(); 462 webScrollLayer = compositedLayerMapping->scrollingContentsLayer()->platformL ayer();
463 ASSERT_TRUE(webScrollLayer->scrollable()); 463 ASSERT_TRUE(webScrollLayer->scrollable());
464 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal()); 464 ASSERT_FALSE(webScrollLayer->userScrollableHorizontal());
465 ASSERT_TRUE(webScrollLayer->userScrollableVertical()); 465 ASSERT_TRUE(webScrollLayer->userScrollableVertical());
466 } 466 }
467 467
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 558 }
559 559
560 TEST_F(ScrollingCoordinatorTest, scrollbarsForceMainThreadOrHaveWebScrollbarLaye r) 560 TEST_F(ScrollingCoordinatorTest, scrollbarsForceMainThreadOrHaveWebScrollbarLaye r)
561 { 561 {
562 registerMockedHttpURLLoad("trivial-scroller.html"); 562 registerMockedHttpURLLoad("trivial-scroller.html");
563 navigateTo(m_baseURL + "trivial-scroller.html"); 563 navigateTo(m_baseURL + "trivial-scroller.html");
564 forceFullCompositingUpdate(); 564 forceFullCompositingUpdate();
565 565
566 Document* document = frame()->document(); 566 Document* document = frame()->document();
567 Element* scrollableElement = document->getElementById("scroller"); 567 Element* scrollableElement = document->getElementById("scroller");
568 ASSERT(scrollableElement); 568 DCHECK(scrollableElement);
569 569
570 LayoutObject* layoutObject = scrollableElement->layoutObject(); 570 LayoutObject* layoutObject = scrollableElement->layoutObject();
571 ASSERT_TRUE(layoutObject->isBox()); 571 ASSERT_TRUE(layoutObject->isBox());
572 LayoutBox* box = toLayoutBox(layoutObject); 572 LayoutBox* box = toLayoutBox(layoutObject);
573 ASSERT_TRUE(box->usesCompositedScrolling()); 573 ASSERT_TRUE(box->usesCompositedScrolling());
574 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping(); 574 CompositedLayerMapping* compositedLayerMapping = box->layer()->compositedLay erMapping();
575 GraphicsLayer* scrollbarGraphicsLayer = compositedLayerMapping->layerForVert icalScrollbar(); 575 GraphicsLayer* scrollbarGraphicsLayer = compositedLayerMapping->layerForVert icalScrollbar();
576 ASSERT_TRUE(scrollbarGraphicsLayer); 576 ASSERT_TRUE(scrollbarGraphicsLayer);
577 577
578 bool hasWebScrollbarLayer = !scrollbarGraphicsLayer->drawsContent(); 578 bool hasWebScrollbarLayer = !scrollbarGraphicsLayer->drawsContent();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 EXPECT_FALSE(scrollLayer->shouldScrollOnMainThread()); 622 EXPECT_FALSE(scrollLayer->shouldScrollOnMainThread());
623 623
624 fixedPos->setInlineStyleProperty(CSSPropertyTransform, CSSValueNone); 624 fixedPos->setInlineStyleProperty(CSSPropertyTransform, CSSValueNone);
625 forceFullCompositingUpdate(); 625 forceFullCompositingUpdate();
626 626
627 EXPECT_FALSE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject())->l ayer()->hasCompositedLayerMapping()); 627 EXPECT_FALSE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject())->l ayer()->hasCompositedLayerMapping());
628 EXPECT_TRUE(scrollLayer->shouldScrollOnMainThread()); 628 EXPECT_TRUE(scrollLayer->shouldScrollOnMainThread());
629 } 629 }
630 630
631 } // namespace blink 631 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/ScreenWakeLockTest.cpp ('k') | third_party/WebKit/Source/web/tests/VisualViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698