| Index: cc/trees/layer_tree_host_unittest_scroll.cc
|
| diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
|
| index 5d22eb80aa18cedcc9f3b15617221f99ad168c02..6c0623b699ae072da6060f7a8253fff579740cf7 100644
|
| --- a/cc/trees/layer_tree_host_unittest_scroll.cc
|
| +++ b/cc/trees/layer_tree_host_unittest_scroll.cc
|
| @@ -8,6 +8,7 @@
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/single_thread_task_runner.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| +#include "cc/base/completion_event.h"
|
| #include "cc/input/main_thread_scrolling_reason.h"
|
| #include "cc/layers/layer.h"
|
| #include "cc/layers/layer_impl.h"
|
| @@ -1513,5 +1514,127 @@ TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
|
| RunTest(CompositorMode::THREADED, false);
|
| }
|
|
|
| +class LayerTreeHostScrollTestScrollMFBA : public LayerTreeHostScrollTest {
|
| + public:
|
| + LayerTreeHostScrollTestScrollMFBA()
|
| + : initial_scroll_(10, 20),
|
| + second_scroll_(40, 5),
|
| + scroll_amount_(2, -1),
|
| + num_commits_(0),
|
| + num_scrolls_(0) {}
|
| +
|
| + void InitializeSettings(LayerTreeSettings* settings) override {
|
| + settings->main_frame_before_activation_enabled = true;
|
| + }
|
| +
|
| + void BeginTest() override {
|
| + outer_viewport_container_layer_id_ = layer_tree_host()
|
| + ->outer_viewport_scroll_layer()
|
| + ->scroll_clip_layer()
|
| + ->id();
|
| + layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset(
|
| + initial_scroll_);
|
| + PostSetNeedsCommitToMainThread();
|
| + }
|
| +
|
| + void StartCommitOnImpl() override {
|
| + switch (num_commits_) {
|
| + case 0:
|
| + PostSetNeedsCommitToMainThread();
|
| + break;
|
| + case 1:
|
| + PostSetNeedsCommitToMainThread();
|
| + // Block activation after second commit until third commit is ready.
|
| + GetProxyImplForTest()->BlockNotifyReadyToActivateForTesting(true);
|
| + break;
|
| + case 2:
|
| + // Unblock activation after third commit is ready.
|
| + GetProxyImplForTest()->BlockNotifyReadyToActivateForTesting(false);
|
| + break;
|
| + }
|
| + num_commits_++;
|
| + }
|
| +
|
| + void UpdateLayerTreeHost() override {
|
| + Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer();
|
| + switch (layer_tree_host()->source_frame_number()) {
|
| + case 0:
|
| + EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset());
|
| + break;
|
| + case 1:
|
| + EXPECT_VECTOR_EQ(
|
| + gfx::ScrollOffsetWithDelta(initial_scroll_, scroll_amount_),
|
| + scroll_layer->scroll_offset());
|
| +
|
| + // Pretend like Javascript updated the scroll position itself.
|
| + scroll_layer->SetScrollOffset(second_scroll_);
|
| + break;
|
| + case 2:
|
| + // Third frame does not see a scroll delta because we only did one
|
| + // scroll for the second and third frames.
|
| + EXPECT_VECTOR_EQ(second_scroll_, scroll_layer->scroll_offset());
|
| + break;
|
| + }
|
| + }
|
| +
|
| + void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
|
| + LayerImpl* root = impl->active_tree()->root_layer();
|
| + LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
|
| + EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(scroll_layer));
|
| +
|
| + scroll_layer->SetScrollClipLayer(outer_viewport_container_layer_id_);
|
| + scroll_layer->SetBounds(
|
| + gfx::Size(root->bounds().width() + 100, root->bounds().height() + 100));
|
| + scroll_layer->ScrollBy(scroll_amount_);
|
| +
|
| + switch (num_commits_) {
|
| + case 1:
|
| + EXPECT_VECTOR_EQ(initial_scroll_, ScrollTreeForLayer(scroll_layer)
|
| + ->GetScrollOffsetBaseForTesting(
|
| + scroll_layer->id()));
|
| + EXPECT_VECTOR_EQ(scroll_amount_, ScrollDelta(scroll_layer));
|
| +
|
| + break;
|
| + case 2:
|
| + EXPECT_VECTOR_EQ(second_scroll_, ScrollTreeForLayer(scroll_layer)
|
| + ->GetScrollOffsetBaseForTesting(
|
| + scroll_layer->id()));
|
| + EXPECT_VECTOR_EQ(scroll_amount_, ScrollDelta(scroll_layer));
|
| + break;
|
| + case 3:
|
| + EXPECT_VECTOR_EQ(second_scroll_, ScrollTreeForLayer(scroll_layer)
|
| + ->GetScrollOffsetBaseForTesting(
|
| + scroll_layer->id()));
|
| + // Two scrolls haven't been consumed by the main thread.
|
| + EXPECT_VECTOR_EQ(scroll_amount_, ScrollDelta(scroll_layer));
|
| + EndTest();
|
| + break;
|
| + }
|
| + }
|
| +
|
| + void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
|
| + const gfx::Vector2dF& outer_delta,
|
| + const gfx::Vector2dF& elastic_overscroll_delta,
|
| + float scale,
|
| + float top_controls_delta) override {
|
| + num_scrolls_++;
|
| + }
|
| +
|
| + void AfterTest() override {
|
| + EXPECT_EQ(3, num_commits_);
|
| + EXPECT_EQ(1, num_scrolls_);
|
| + }
|
| +
|
| + private:
|
| + gfx::ScrollOffset initial_scroll_;
|
| + gfx::ScrollOffset second_scroll_;
|
| + gfx::Vector2dF scroll_amount_;
|
| + int num_commits_;
|
| + int num_scrolls_;
|
| + int outer_viewport_container_layer_id_;
|
| +};
|
| +
|
| +MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollMFBA);
|
| +
|
| } // namespace
|
| } // namespace cc
|
|
|