Index: cc/trees/layer_tree_host_impl_unittest.cc |
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc |
index 7ffa6831a92d75042bbcd3437802578bf00ed521..4e3230b32fb9afda7ca53428105e19b6074efd6a 100644 |
--- a/cc/trees/layer_tree_host_impl_unittest.cc |
+++ b/cc/trees/layer_tree_host_impl_unittest.cc |
@@ -1558,192 +1558,160 @@ class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { |
base::TimeTicks fake_current_physical_time_; |
}; |
-#define SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST() \ |
- gfx::Size viewport_size(10, 10); \ |
- gfx::Size content_size(100, 100); \ |
- \ |
- LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = \ |
- new LayerTreeHostImplOverridePhysicalTime(settings, this, &proxy_, \ |
- shared_bitmap_manager_.get(), \ |
- &stats_instrumentation_); \ |
- host_impl_ = make_scoped_ptr(host_impl_override_time); \ |
- host_impl_->InitializeRenderer(CreateOutputSurface()); \ |
- host_impl_->SetViewportSize(viewport_size); \ |
- \ |
- scoped_ptr<LayerImpl> root = \ |
- LayerImpl::Create(host_impl_->active_tree(), 1); \ |
- root->SetBounds(viewport_size); \ |
- \ |
- scoped_ptr<LayerImpl> scroll = \ |
- LayerImpl::Create(host_impl_->active_tree(), 2); \ |
- scroll->SetScrollClipLayer(root->id()); \ |
- scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); \ |
- root->SetBounds(viewport_size); \ |
- scroll->SetBounds(content_size); \ |
- scroll->SetContentBounds(content_size); \ |
- scroll->SetIsContainerForFixedPositionLayers(true); \ |
- \ |
- scoped_ptr<LayerImpl> contents = \ |
- LayerImpl::Create(host_impl_->active_tree(), 3); \ |
- contents->SetDrawsContent(true); \ |
- contents->SetBounds(content_size); \ |
- contents->SetContentBounds(content_size); \ |
- \ |
- scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \ |
- SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, \ |
- VERTICAL, 10, 0, false, true); \ |
- EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \ |
- \ |
- scroll->AddChild(contents.Pass()); \ |
- root->AddChild(scroll.Pass()); \ |
- root->SetHasRenderSurface(true); \ |
- scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ |
- root->AddChild(scrollbar.Pass()); \ |
- \ |
- host_impl_->active_tree()->SetRootLayer(root.Pass()); \ |
- host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, \ |
- Layer::INVALID_ID); \ |
- host_impl_->active_tree()->DidBecomeActive(); \ |
- DrawFrame(); |
- |
-TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { |
- LayerTreeSettings settings; |
- settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; |
- settings.scrollbar_fade_delay_ms = 20; |
- settings.scrollbar_fade_duration_ms = 20; |
- |
- SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); |
+class LayerTreeHostImplTestScrollbarAnimation : public LayerTreeHostImplTest { |
+ protected: |
+ void SetupLayers(LayerTreeSettings settings) { |
+ gfx::Size viewport_size(10, 10); |
+ gfx::Size content_size(100, 100); |
+ |
+ LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = |
+ new LayerTreeHostImplOverridePhysicalTime(settings, this, &proxy_, |
+ shared_bitmap_manager_.get(), |
+ &stats_instrumentation_); |
+ host_impl_ = make_scoped_ptr(host_impl_override_time); |
+ host_impl_->InitializeRenderer(CreateOutputSurface()); |
+ host_impl_->SetViewportSize(viewport_size); |
- base::TimeTicks fake_now = gfx::FrameTime::Now(); |
+ scoped_ptr<LayerImpl> root = |
+ LayerImpl::Create(host_impl_->active_tree(), 1); |
+ root->SetBounds(viewport_size); |
- EXPECT_FALSE(did_request_animate_); |
- EXPECT_FALSE(did_request_redraw_); |
- EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
- EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
+ scoped_ptr<LayerImpl> scroll = |
+ LayerImpl::Create(host_impl_->active_tree(), 2); |
+ scroll->SetScrollClipLayer(root->id()); |
+ scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
+ root->SetBounds(viewport_size); |
+ scroll->SetBounds(content_size); |
+ scroll->SetContentBounds(content_size); |
+ scroll->SetIsContainerForFixedPositionLayers(true); |
- // If no scroll happened during a scroll gesture, it should have no effect. |
- host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
- host_impl_->ScrollEnd(); |
- EXPECT_FALSE(did_request_animate_); |
- EXPECT_FALSE(did_request_redraw_); |
- EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
- EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
+ scoped_ptr<LayerImpl> contents = |
+ LayerImpl::Create(host_impl_->active_tree(), 3); |
+ contents->SetDrawsContent(true); |
+ contents->SetBounds(content_size); |
+ contents->SetContentBounds(content_size); |
- // After a scroll, a fade animation should be scheduled about 20ms from now. |
- host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 5)); |
- EXPECT_FALSE(did_request_animate_); |
- EXPECT_TRUE(did_request_redraw_); |
- did_request_redraw_ = false; |
- EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
- EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
+ scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
+ SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, |
+ VERTICAL, 10, 0, false, true); |
+ EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); |
- host_impl_->ScrollEnd(); |
- EXPECT_FALSE(did_request_animate_); |
- EXPECT_FALSE(did_request_redraw_); |
- EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), requested_animation_delay_); |
- EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
- |
- fake_now += requested_animation_delay_; |
- requested_animation_delay_ = base::TimeDelta(); |
- animation_task_.Run(); |
- animation_task_ = base::Closure(); |
- EXPECT_TRUE(did_request_animate_); |
- did_request_animate_ = false; |
- EXPECT_FALSE(did_request_redraw_); |
+ scroll->AddChild(contents.Pass()); |
+ root->AddChild(scroll.Pass()); |
+ root->SetHasRenderSurface(true); |
+ scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); |
+ root->AddChild(scrollbar.Pass()); |
- // After the fade begins, we should start getting redraws instead of a |
- // scheduled animation. |
- host_impl_->Animate(fake_now); |
- EXPECT_TRUE(did_request_animate_); |
- did_request_animate_ = false; |
- EXPECT_TRUE(did_request_redraw_); |
- did_request_redraw_ = false; |
- EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
- EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
+ host_impl_->active_tree()->SetRootLayer(root.Pass()); |
+ host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, |
+ Layer::INVALID_ID); |
+ host_impl_->active_tree()->DidBecomeActive(); |
+ DrawFrame(); |
+ } |
- // Setting the scroll offset outside a scroll should also cause the scrollbar |
- // to appear and to schedule a fade. |
- host_impl_->InnerViewportScrollLayer()->PushScrollOffsetFromMainThread( |
- gfx::ScrollOffset(5, 5)); |
- EXPECT_FALSE(did_request_animate_); |
- EXPECT_FALSE(did_request_redraw_); |
- EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), requested_animation_delay_); |
- EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
- requested_animation_delay_ = base::TimeDelta(); |
- animation_task_ = base::Closure(); |
- |
- // Unnecessarily Fade animation of solid color scrollbar is not triggered. |
- host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
- EXPECT_FALSE(did_request_animate_); |
- EXPECT_TRUE(did_request_redraw_); |
- did_request_redraw_ = false; |
- EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
- EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
+ void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
+ LayerTreeSettings settings; |
+ settings.scrollbar_animator = animator; |
+ settings.scrollbar_fade_delay_ms = 20; |
+ settings.scrollbar_fade_duration_ms = 20; |
- host_impl_->ScrollEnd(); |
- EXPECT_FALSE(did_request_animate_); |
- EXPECT_FALSE(did_request_redraw_); |
- EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
- EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
-} |
+ SetupLayers(settings); |
-TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { |
- LayerTreeSettings settings; |
- settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; |
- settings.scrollbar_fade_delay_ms = 20; |
- settings.scrollbar_fade_duration_ms = 20; |
- settings.use_pinch_zoom_scrollbars = true; |
+ base::TimeTicks fake_now = gfx::FrameTime::Now(); |
- SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); |
+ EXPECT_FALSE(did_request_animate_); |
+ EXPECT_FALSE(did_request_redraw_); |
+ EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
+ EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
- base::TimeTicks fake_now = gfx::FrameTime::Now(); |
+ // If no scroll happened during a scroll gesture, it should have no effect. |
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
+ host_impl_->ScrollEnd(); |
+ EXPECT_FALSE(did_request_animate_); |
+ EXPECT_FALSE(did_request_redraw_); |
+ EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
+ EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
- host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); |
+ // After a scroll, a scrollbar animation should be scheduled about 20ms from |
+ // now. |
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 5)); |
+ EXPECT_FALSE(did_request_animate_); |
+ EXPECT_TRUE(did_request_redraw_); |
+ did_request_redraw_ = false; |
+ EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
+ EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
- EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
- EXPECT_FALSE(did_request_animate_); |
+ host_impl_->ScrollEnd(); |
+ EXPECT_FALSE(did_request_animate_); |
+ EXPECT_FALSE(did_request_redraw_); |
+ EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
+ requested_animation_delay_); |
+ EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
+ |
+ fake_now += requested_animation_delay_; |
+ requested_animation_delay_ = base::TimeDelta(); |
+ animation_task_.Run(); |
+ animation_task_ = base::Closure(); |
+ EXPECT_TRUE(did_request_animate_); |
+ did_request_animate_ = false; |
+ EXPECT_FALSE(did_request_redraw_); |
- // If no scroll happened during a scroll gesture, it should have no effect. |
- host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
- host_impl_->ScrollEnd(); |
- EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
- EXPECT_FALSE(did_request_animate_); |
- EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
+ // After the scrollbar animation begins, we should start getting redraws. |
+ host_impl_->Animate(fake_now); |
+ EXPECT_TRUE(did_request_animate_); |
+ did_request_animate_ = false; |
+ EXPECT_TRUE(did_request_redraw_); |
+ did_request_redraw_ = false; |
+ EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
+ EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
- // After a scroll, no fade animation should be scheduled. |
- host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
- host_impl_->ScrollEnd(); |
- did_request_redraw_ = false; |
- EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
- EXPECT_FALSE(did_request_animate_); |
- requested_animation_delay_ = base::TimeDelta(); |
+ // Setting the scroll offset outside a scroll should also cause the |
+ // scrollbar to appear and to schedule a scrollbar animation. |
+ host_impl_->InnerViewportScrollLayer()->PushScrollOffsetFromMainThread( |
+ gfx::ScrollOffset(5, 5)); |
+ EXPECT_FALSE(did_request_animate_); |
+ EXPECT_FALSE(did_request_redraw_); |
+ EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
+ requested_animation_delay_); |
+ EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
+ requested_animation_delay_ = base::TimeDelta(); |
+ animation_task_ = base::Closure(); |
+ |
+ // Scrollbar animation is not triggered unnecessarily. |
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
+ EXPECT_FALSE(did_request_animate_); |
+ EXPECT_TRUE(did_request_redraw_); |
+ did_request_redraw_ = false; |
+ EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
+ EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
- // We should not see any draw requests. |
- fake_now += base::TimeDelta::FromMilliseconds(25); |
- EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
- EXPECT_FALSE(did_request_animate_); |
+ host_impl_->ScrollEnd(); |
+ EXPECT_FALSE(did_request_animate_); |
+ EXPECT_FALSE(did_request_redraw_); |
+ EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
+ EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
- // Make page scale > min so that subsequent scrolls will trigger fades. |
- host_impl_->SetPageScaleOnActiveTree(1.1f); |
+ // Changing page scale triggers scrollbar animation. |
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); |
+ host_impl_->SetPageScaleOnActiveTree(1.1f); |
+ EXPECT_FALSE(did_request_animate_); |
+ EXPECT_FALSE(did_request_redraw_); |
+ EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
+ requested_animation_delay_); |
+ EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
+ requested_animation_delay_ = base::TimeDelta(); |
+ animation_task_ = base::Closure(); |
+ } |
+}; |
- // After a scroll, a fade animation should be scheduled about 20ms from now. |
- host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); |
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
- host_impl_->ScrollEnd(); |
- did_request_redraw_ = false; |
- EXPECT_LT(base::TimeDelta::FromMilliseconds(19), requested_animation_delay_); |
- EXPECT_FALSE(did_request_animate_); |
- requested_animation_delay_ = base::TimeDelta(); |
- animation_task_.Run(); |
+TEST_F(LayerTreeHostImplTestScrollbarAnimation, LinearFade) { |
+ RunTest(LayerTreeSettings::LINEAR_FADE); |
+} |
- // After the fade begins, we should start getting redraws instead of a |
- // scheduled animation. |
- fake_now += base::TimeDelta::FromMilliseconds(25); |
- host_impl_->Animate(fake_now); |
- EXPECT_TRUE(did_request_animate_); |
+TEST_F(LayerTreeHostImplTestScrollbarAnimation, Thinning) { |
+ RunTest(LayerTreeSettings::THINNING); |
} |
void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( |
@@ -1960,6 +1928,16 @@ class DidDrawCheckLayer : public LayerImpl { |
did_draw_called_ = false; |
} |
+ static void IgnoreResult(scoped_ptr<CopyOutputResult> result) {} |
+ |
+ void AddCopyRequest() { |
+ ScopedPtrVector<CopyOutputRequest> requests; |
+ requests.push_back( |
+ CopyOutputRequest::CreateRequest(base::Bind(&IgnoreResult))); |
+ SetHasRenderSurface(true); |
+ PassCopyRequests(&requests); |
+ } |
+ |
protected: |
DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) |
: LayerImpl(tree_impl, id), |
@@ -2189,89 +2167,132 @@ class MissingTextureAnimatingLayer : public DidDrawCheckLayer { |
bool had_incomplete_tile_; |
}; |
-TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { |
- host_impl_->active_tree()->SetRootLayer( |
- DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
- DidDrawCheckLayer* root = |
- static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
- root->SetHasRenderSurface(true); |
- bool tile_missing = false; |
- bool had_incomplete_tile = false; |
- bool is_animating = false; |
- root->AddChild( |
- MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
- 2, |
- tile_missing, |
- had_incomplete_tile, |
- is_animating, |
- host_impl_->resource_provider())); |
- |
- LayerTreeHostImpl::FrameData frame; |
+struct PrepareToDrawSuccessTestCase { |
+ struct State { |
+ bool has_missing_tile = false; |
+ bool has_incomplete_tile = false; |
+ bool is_animating = false; |
+ bool has_copy_request = false; |
+ }; |
+ bool high_res_required = false; |
+ State layer_before; |
+ State layer_between; |
+ State layer_after; |
+ DrawResult expected_result; |
+ |
+ explicit PrepareToDrawSuccessTestCase(DrawResult result) |
+ : expected_result(result) {} |
+}; |
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame); |
-} |
+TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsAndFails) { |
+ std::vector<PrepareToDrawSuccessTestCase> cases; |
+ |
+ // 0. Default case. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ // 1. Animated layer first. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_before.is_animating = true; |
+ // 2. Animated layer between. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_between.is_animating = true; |
+ // 3. Animated layer last. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_after.is_animating = true; |
+ // 4. Missing tile first. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_before.has_missing_tile = true; |
+ // 5. Missing tile between. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_between.has_missing_tile = true; |
+ // 6. Missing tile last. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_after.has_missing_tile = true; |
+ // 7. Incomplete tile first. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_before.has_incomplete_tile = true; |
+ // 8. Incomplete tile between. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_between.has_incomplete_tile = true; |
+ // 9. Incomplete tile last. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_after.has_incomplete_tile = true; |
+ // 10. Animation with missing tile. |
+ cases.push_back( |
+ PrepareToDrawSuccessTestCase(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS)); |
+ cases.back().layer_between.has_missing_tile = true; |
+ cases.back().layer_between.is_animating = true; |
+ // 11. Animation with missing tile and copy request after. Must succeed |
+ // because the animation checkerboard means we'll get a new frame and the copy |
+ // request's layer may be destroyed. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_between.has_missing_tile = true; |
+ cases.back().layer_between.is_animating = true; |
+ cases.back().layer_after.has_copy_request = true; |
+ // 12. Animation with missing tile and copy request before. Must succeed |
+ // because the animation checkerboard means we'll get a new frame and the copy |
+ // request's layer may be destroyed. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_between.has_missing_tile = true; |
+ cases.back().layer_between.is_animating = true; |
+ cases.back().layer_before.has_copy_request = true; |
+ // 13. Animation with incomplete tile. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_between.has_incomplete_tile = true; |
+ cases.back().layer_between.is_animating = true; |
+ |
+ // 14. High res required. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().high_res_required = true; |
+ // 15. High res required with incomplete tile. |
+ cases.push_back( |
+ PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
+ cases.back().high_res_required = true; |
+ cases.back().layer_between.has_incomplete_tile = true; |
+ // 16. High res required with missing tile. |
+ cases.push_back( |
+ PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
+ cases.back().high_res_required = true; |
+ cases.back().layer_between.has_missing_tile = true; |
+ |
+ // 17. High res required is higher priority than animating missing tiles. |
+ cases.push_back( |
+ PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
+ cases.back().high_res_required = true; |
+ cases.back().layer_between.has_missing_tile = true; |
+ cases.back().layer_after.has_missing_tile = true; |
+ cases.back().layer_after.is_animating = true; |
+ // 18. High res required is higher priority than animating missing tiles. |
+ cases.push_back( |
+ PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
+ cases.back().high_res_required = true; |
+ cases.back().layer_between.has_missing_tile = true; |
+ cases.back().layer_before.has_missing_tile = true; |
+ cases.back().layer_before.is_animating = true; |
+ |
+ // 19. High res required is higher priority than copy requests. |
+ cases.push_back( |
+ PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
+ cases.back().high_res_required = true; |
+ cases.back().layer_between.has_missing_tile = true; |
+ cases.back().layer_after.has_copy_request = true; |
+ // 20. High res required is higher priority than copy requests. |
+ cases.push_back( |
+ PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
+ cases.back().high_res_required = true; |
+ cases.back().layer_between.has_missing_tile = true; |
+ cases.back().layer_before.has_copy_request = true; |
+ // 21. High res required is higher priority than copy requests. |
+ cases.push_back( |
+ PrepareToDrawSuccessTestCase(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT)); |
+ cases.back().high_res_required = true; |
+ cases.back().layer_between.has_missing_tile = true; |
+ cases.back().layer_between.has_copy_request = true; |
-TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { |
host_impl_->active_tree()->SetRootLayer( |
DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
DidDrawCheckLayer* root = |
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
root->SetHasRenderSurface(true); |
- bool tile_missing = false; |
- bool had_incomplete_tile = false; |
- bool is_animating = true; |
- root->AddChild( |
- MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
- 2, |
- tile_missing, |
- had_incomplete_tile, |
- is_animating, |
- host_impl_->resource_provider())); |
- |
- LayerTreeHostImpl::FrameData frame; |
- |
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame); |
-} |
- |
-TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { |
- host_impl_->active_tree()->SetRootLayer( |
- DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
- DidDrawCheckLayer* root = |
- static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
- root->SetHasRenderSurface(true); |
- |
- LayerTreeHostImpl::FrameData frame; |
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame); |
- host_impl_->SwapBuffers(frame); |
- |
- bool tile_missing = true; |
- bool had_incomplete_tile = false; |
- bool is_animating = false; |
- root->AddChild( |
- MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
- 4, |
- tile_missing, |
- had_incomplete_tile, |
- is_animating, |
- host_impl_->resource_provider())); |
- LayerTreeHostImpl::FrameData frame2; |
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
- host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame2); |
-} |
- |
-TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { |
- host_impl_->active_tree()->SetRootLayer( |
- DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
- DidDrawCheckLayer* root = |
- static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
- root->SetHasRenderSurface(true); |
LayerTreeHostImpl::FrameData frame; |
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
@@ -2279,117 +2300,83 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { |
host_impl_->DidDrawAllLayers(frame); |
host_impl_->SwapBuffers(frame); |
- bool tile_missing = false; |
- bool had_incomplete_tile = true; |
- bool is_animating = false; |
- root->AddChild( |
- MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
- 4, |
- tile_missing, |
- had_incomplete_tile, |
- is_animating, |
- host_impl_->resource_provider())); |
- LayerTreeHostImpl::FrameData frame2; |
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
- host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame2); |
-} |
+ for (size_t i = 0; i < cases.size(); ++i) { |
+ const auto& testcase = cases[i]; |
+ std::vector<LayerImpl*> to_remove; |
+ for (auto* child : root->children()) |
+ to_remove.push_back(child); |
+ for (auto* child : to_remove) |
+ root->RemoveChild(child); |
+ |
+ std::ostringstream scope; |
+ scope << "Test case: " << i; |
+ SCOPED_TRACE(scope.str()); |
+ |
+ root->AddChild(MissingTextureAnimatingLayer::Create( |
+ host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, |
+ testcase.layer_before.has_incomplete_tile, |
+ testcase.layer_before.is_animating, host_impl_->resource_provider())); |
+ DidDrawCheckLayer* before = |
+ static_cast<DidDrawCheckLayer*>(root->children().back()); |
+ if (testcase.layer_before.has_copy_request) |
+ before->AddCopyRequest(); |
+ |
+ root->AddChild(MissingTextureAnimatingLayer::Create( |
+ host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, |
+ testcase.layer_between.has_incomplete_tile, |
+ testcase.layer_between.is_animating, host_impl_->resource_provider())); |
+ DidDrawCheckLayer* between = |
+ static_cast<DidDrawCheckLayer*>(root->children().back()); |
+ if (testcase.layer_between.has_copy_request) |
+ between->AddCopyRequest(); |
+ |
+ root->AddChild(MissingTextureAnimatingLayer::Create( |
+ host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, |
+ testcase.layer_after.has_incomplete_tile, |
+ testcase.layer_after.is_animating, host_impl_->resource_provider())); |
+ DidDrawCheckLayer* after = |
+ static_cast<DidDrawCheckLayer*>(root->children().back()); |
+ if (testcase.layer_after.has_copy_request) |
+ after->AddCopyRequest(); |
+ |
+ if (testcase.high_res_required) |
+ host_impl_->SetRequiresHighResToDraw(); |
-TEST_F(LayerTreeHostImplTest, |
- PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { |
- host_impl_->active_tree()->SetRootLayer( |
- DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
- DidDrawCheckLayer* root = |
- static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
- root->SetHasRenderSurface(true); |
- |
- LayerTreeHostImpl::FrameData frame; |
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame); |
- host_impl_->SwapBuffers(frame); |
- |
- bool tile_missing = true; |
- bool had_incomplete_tile = false; |
- bool is_animating = true; |
- root->AddChild( |
- MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
- 6, |
- tile_missing, |
- had_incomplete_tile, |
- is_animating, |
- host_impl_->resource_provider())); |
- LayerTreeHostImpl::FrameData frame2; |
- EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, |
- host_impl_->PrepareToDraw(&frame2)); |
- host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame2); |
+ LayerTreeHostImpl::FrameData frame; |
+ EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); |
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
+ host_impl_->DidDrawAllLayers(frame); |
+ host_impl_->SwapBuffers(frame); |
+ } |
} |
TEST_F(LayerTreeHostImplTest, |
- PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { |
- host_impl_->active_tree()->SetRootLayer( |
- DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
- DidDrawCheckLayer* root = |
- static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
- root->SetHasRenderSurface(true); |
- |
- LayerTreeHostImpl::FrameData frame; |
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame); |
- host_impl_->SwapBuffers(frame); |
- |
- bool tile_missing = false; |
- bool had_incomplete_tile = true; |
- bool is_animating = true; |
- root->AddChild( |
- MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
- 6, |
- tile_missing, |
- had_incomplete_tile, |
- is_animating, |
- host_impl_->resource_provider())); |
- LayerTreeHostImpl::FrameData frame2; |
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
- host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame2); |
-} |
- |
-TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { |
- host_impl_->active_tree()->SetRootLayer( |
- DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
- DidDrawCheckLayer* root = |
- static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
- root->SetHasRenderSurface(true); |
- |
- LayerTreeHostImpl::FrameData frame; |
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame); |
- host_impl_->SwapBuffers(frame); |
- |
- bool tile_missing = false; |
- bool had_incomplete_tile = false; |
- bool is_animating = false; |
- root->AddChild( |
- MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
- 8, |
- tile_missing, |
- had_incomplete_tile, |
- is_animating, |
- host_impl_->resource_provider())); |
- host_impl_->SetRequiresHighResToDraw(); |
- LayerTreeHostImpl::FrameData frame2; |
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
- host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame2); |
-} |
+ PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { |
+ CreateHostImpl(DefaultSettings(), |
+ FakeOutputSurface::CreateAlwaysDrawAndSwap3d()); |
+ EXPECT_TRUE(host_impl_->output_surface() |
+ ->capabilities() |
+ .draw_and_swap_full_viewport_every_frame); |
+ |
+ std::vector<PrepareToDrawSuccessTestCase> cases; |
+ |
+ // 0. Default case. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ // 1. Animation with missing tile. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().layer_between.has_missing_tile = true; |
+ cases.back().layer_between.is_animating = true; |
+ // 2. High res required with incomplete tile. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().high_res_required = true; |
+ cases.back().layer_between.has_incomplete_tile = true; |
+ // 3. High res required with missing tile. |
+ cases.push_back(PrepareToDrawSuccessTestCase(DRAW_SUCCESS)); |
+ cases.back().high_res_required = true; |
+ cases.back().layer_between.has_missing_tile = true; |
-TEST_F(LayerTreeHostImplTest, |
- PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { |
host_impl_->active_tree()->SetRootLayer( |
- DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
+ DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
DidDrawCheckLayer* root = |
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
root->SetHasRenderSurface(true); |
@@ -2400,54 +2387,54 @@ TEST_F(LayerTreeHostImplTest, |
host_impl_->DidDrawAllLayers(frame); |
host_impl_->SwapBuffers(frame); |
- bool tile_missing = false; |
- bool had_incomplete_tile = true; |
- bool is_animating = false; |
- root->AddChild( |
- MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
- 8, |
- tile_missing, |
- had_incomplete_tile, |
- is_animating, |
- host_impl_->resource_provider())); |
- host_impl_->SetRequiresHighResToDraw(); |
- LayerTreeHostImpl::FrameData frame2; |
- EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
- host_impl_->PrepareToDraw(&frame2)); |
- host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame2); |
-} |
+ for (size_t i = 0; i < cases.size(); ++i) { |
+ const auto& testcase = cases[i]; |
+ std::vector<LayerImpl*> to_remove; |
+ for (auto* child : root->children()) |
+ to_remove.push_back(child); |
+ for (auto* child : to_remove) |
+ root->RemoveChild(child); |
+ |
+ std::ostringstream scope; |
+ scope << "Test case: " << i; |
+ SCOPED_TRACE(scope.str()); |
+ |
+ root->AddChild(MissingTextureAnimatingLayer::Create( |
+ host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, |
+ testcase.layer_before.has_incomplete_tile, |
+ testcase.layer_before.is_animating, host_impl_->resource_provider())); |
+ DidDrawCheckLayer* before = |
+ static_cast<DidDrawCheckLayer*>(root->children().back()); |
+ if (testcase.layer_before.has_copy_request) |
+ before->AddCopyRequest(); |
+ |
+ root->AddChild(MissingTextureAnimatingLayer::Create( |
+ host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, |
+ testcase.layer_between.has_incomplete_tile, |
+ testcase.layer_between.is_animating, host_impl_->resource_provider())); |
+ DidDrawCheckLayer* between = |
+ static_cast<DidDrawCheckLayer*>(root->children().back()); |
+ if (testcase.layer_between.has_copy_request) |
+ between->AddCopyRequest(); |
+ |
+ root->AddChild(MissingTextureAnimatingLayer::Create( |
+ host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, |
+ testcase.layer_after.has_incomplete_tile, |
+ testcase.layer_after.is_animating, host_impl_->resource_provider())); |
+ DidDrawCheckLayer* after = |
+ static_cast<DidDrawCheckLayer*>(root->children().back()); |
+ if (testcase.layer_after.has_copy_request) |
+ after->AddCopyRequest(); |
+ |
+ if (testcase.high_res_required) |
+ host_impl_->SetRequiresHighResToDraw(); |
-TEST_F(LayerTreeHostImplTest, |
- PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { |
- host_impl_->active_tree()->SetRootLayer( |
- DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
- DidDrawCheckLayer* root = |
- static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
- root->SetHasRenderSurface(true); |
- |
- LayerTreeHostImpl::FrameData frame; |
- EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
- host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame); |
- host_impl_->SwapBuffers(frame); |
- |
- bool tile_missing = true; |
- bool had_incomplete_tile = false; |
- bool is_animating = false; |
- root->AddChild( |
- MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
- 8, |
- tile_missing, |
- had_incomplete_tile, |
- is_animating, |
- host_impl_->resource_provider())); |
- host_impl_->SetRequiresHighResToDraw(); |
- LayerTreeHostImpl::FrameData frame2; |
- EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
- host_impl_->PrepareToDraw(&frame2)); |
- host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
- host_impl_->DidDrawAllLayers(frame2); |
+ LayerTreeHostImpl::FrameData frame; |
+ EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); |
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
+ host_impl_->DidDrawAllLayers(frame); |
+ host_impl_->SwapBuffers(frame); |
+ } |
} |
TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
@@ -6530,9 +6517,10 @@ TEST_F(LayerTreeHostImplTest, ForcedDrawToSoftwareDeviceBasicRender) { |
EXPECT_EQ(1, software_device->frames_began_); |
EXPECT_EQ(1, software_device->frames_ended_); |
- // Call other API methods that are likely to hit NULL pointer in this mode. |
- EXPECT_TRUE(host_impl_->AsValue().get()); |
- EXPECT_TRUE(host_impl_->ActivationStateAsValue().get()); |
+ // Call another API method that is likely to hit nullptr in this mode. |
+ scoped_refptr<base::trace_event::TracedValue> state = |
+ make_scoped_refptr(new base::trace_event::TracedValue()); |
+ host_impl_->ActivationStateAsValueInto(state.get()); |
} |
TEST_F(LayerTreeHostImplTest, |
@@ -7117,7 +7105,7 @@ TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { |
host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
} |
-TEST_F(LayerTreeHostImplTest, ScrollInvisibleScroller) { |
+TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { |
gfx::Size content_size(100, 100); |
SetupScrollAndContentsLayers(content_size); |
@@ -7141,13 +7129,50 @@ TEST_F(LayerTreeHostImplTest, ScrollInvisibleScroller) { |
// any layer that is a drawn RSLL member, then we can ignore the hit. |
// |
// Why SCROLL_STARTED? In this case, it's because we've bubbled out and |
- // started overscrolling the inner viewport. |
+ // started scrolling the inner viewport. |
EXPECT_EQ(InputHandler::SCROLL_STARTED, |
host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
EXPECT_EQ(2, host_impl_->CurrentlyScrollingLayer()->id()); |
} |
+TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleDescendent) { |
+ gfx::Size content_size(100, 100); |
+ SetupScrollAndContentsLayers(content_size); |
+ |
+ LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
+ LayerImpl* root_scroll_layer = host_impl_->active_tree()->LayerById(2); |
+ |
+ scoped_ptr<LayerImpl> invisible_scroll_layer = |
+ CreateScrollableLayer(7, content_size, root); |
+ invisible_scroll_layer->SetDrawsContent(false); |
+ |
+ scoped_ptr<LayerImpl> child_layer = |
+ LayerImpl::Create(host_impl_->active_tree(), 8); |
+ child_layer->SetDrawsContent(false); |
+ |
+ scoped_ptr<LayerImpl> grand_child_layer = |
+ LayerImpl::Create(host_impl_->active_tree(), 9); |
+ grand_child_layer->SetDrawsContent(true); |
+ grand_child_layer->SetBounds(content_size); |
+ grand_child_layer->SetContentBounds(content_size); |
+ // Move the grand child so it's not hit by our test point. |
+ grand_child_layer->SetPosition(gfx::PointF(10.f, 10.f)); |
+ |
+ child_layer->AddChild(grand_child_layer.Pass()); |
+ invisible_scroll_layer->AddChild(child_layer.Pass()); |
+ root_scroll_layer->AddChild(invisible_scroll_layer.Pass()); |
+ |
+ DrawFrame(); |
+ |
+ // We should have scrolled |invisible_scroll_layer| as it was hit and it has |
+ // a descendant which is a drawn RSLL member. |
+ EXPECT_EQ(InputHandler::SCROLL_STARTED, |
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
+ |
+ EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
+} |
+ |
TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleScrollChild) { |
// This test case is very similar to the one above with one key difference: |
// the invisible scroller has a scroll child that is indeed draw contents. |
@@ -7193,12 +7218,9 @@ TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleScrollChild) { |
DrawFrame(); |
- // We should not have scrolled |child_scroll| even though we technically "hit" |
- // it. The reason for this is that if the scrolling the scroll would not move |
- // any layer that is a drawn RSLL member, then we can ignore the hit. |
- // |
- // Why SCROLL_STARTED? In this case, it's because we've bubbled out and |
- // started overscrolling the inner viewport. |
+ // We should have scrolled |child_scroll| even though it is invisible. |
+ // The reason for this is that if the scrolling the scroll would move a layer |
+ // that is a drawn RSLL member, then we should accept this hit. |
EXPECT_EQ(InputHandler::SCROLL_STARTED, |
host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
@@ -7495,7 +7517,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
float offset = top_controls_height_ - residue; |
EXPECT_TRUE( |
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
- EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
+ EXPECT_FLOAT_EQ(-offset, |
+ host_impl_->top_controls_manager()->ControlsTopOffset()); |
EXPECT_EQ(gfx::Vector2dF().ToString(), |
scroll_layer->CurrentScrollOffset().ToString()); |
@@ -7554,7 +7577,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { |
float offset = top_controls_height_ - residue; |
EXPECT_TRUE( |
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
- EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
+ EXPECT_FLOAT_EQ(-offset, |
+ host_impl_->top_controls_manager()->ControlsTopOffset()); |
EXPECT_EQ(gfx::Vector2dF().ToString(), |
scroll_layer->CurrentScrollOffset().ToString()); |
@@ -7624,7 +7648,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { |
float offset = top_controls_height_ - residue; |
EXPECT_TRUE( |
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
- EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
+ EXPECT_FLOAT_EQ(-offset, |
+ host_impl_->top_controls_manager()->ControlsTopOffset()); |
EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
scroll_layer->CurrentScrollOffset().ToString()); |
@@ -7687,7 +7712,8 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, |
float offset = top_controls_height_ - residue; |
EXPECT_TRUE( |
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
- EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
+ EXPECT_FLOAT_EQ(-offset, |
+ host_impl_->top_controls_manager()->ControlsTopOffset()); |
EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
scroll_layer->CurrentScrollOffset().ToString()); |