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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1646603004: Move scroll event handlers from layer to layer tree view. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_cc_listeners
Patch Set: Rebase Created 4 years, 10 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 957
958 // This point is still inside the non-fast region. 958 // This point is still inside the non-fast region.
959 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), 959 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
960 InputHandler::WHEEL); 960 InputHandler::WHEEL);
961 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 961 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
962 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion, 962 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion,
963 status.main_thread_scrolling_reasons); 963 status.main_thread_scrolling_reasons);
964 } 964 }
965 965
966 TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) { 966 TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) {
967 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); 967 SetupScrollAndContentsLayers(gfx::Size(200, 200));
968 EXPECT_FALSE(scroll_layer->have_scroll_event_handlers()); 968 EXPECT_FALSE(host_impl_->active_tree()->have_scroll_event_handlers());
969 host_impl_->SetViewportSize(gfx::Size(50, 50)); 969 host_impl_->SetViewportSize(gfx::Size(50, 50));
970 DrawFrame(); 970 DrawFrame();
971 971
972 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); 972 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
973 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 973 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
974 InputHandler::GESTURE); 974 InputHandler::GESTURE);
975 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); 975 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
976 host_impl_->ScrollEnd(EndState().get()); 976 host_impl_->ScrollEnd(EndState().get());
977 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); 977 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
978 } 978 }
979 979
980 TEST_F(LayerTreeHostImplTest, ScrollHandlerPresent) { 980 TEST_F(LayerTreeHostImplTest, ScrollHandlerPresent) {
981 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); 981 SetupScrollAndContentsLayers(gfx::Size(200, 200));
982 scroll_layer->SetHaveScrollEventHandlers(true); 982 host_impl_->active_tree()->set_have_scroll_event_handlers(true);
983 host_impl_->SetViewportSize(gfx::Size(50, 50)); 983 host_impl_->SetViewportSize(gfx::Size(50, 50));
984 DrawFrame(); 984 DrawFrame();
985 985
986 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); 986 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
987 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 987 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
988 InputHandler::GESTURE); 988 InputHandler::GESTURE);
989 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler()); 989 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler());
990 host_impl_->ScrollEnd(EndState().get()); 990 host_impl_->ScrollEnd(EndState().get());
991 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); 991 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
992 } 992 }
(...skipping 6982 matching lines...) Expand 10 before | Expand all | Expand 10 after
7975 { 7975 {
7976 set_needs_commit_count = 0; 7976 set_needs_commit_count = 0;
7977 set_needs_redraw_count = 0; 7977 set_needs_redraw_count = 0;
7978 forward_to_main_count = 0; 7978 forward_to_main_count = 0;
7979 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( 7979 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor(
7980 new SimpleSwapPromiseMonitor(NULL, 7980 new SimpleSwapPromiseMonitor(NULL,
7981 host_impl_.get(), 7981 host_impl_.get(),
7982 &set_needs_commit_count, 7982 &set_needs_commit_count,
7983 &set_needs_redraw_count, 7983 &set_needs_redraw_count,
7984 &forward_to_main_count)); 7984 &forward_to_main_count));
7985 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 7985 SetupScrollAndContentsLayers(gfx::Size(100, 100));
7986 7986
7987 // Scrolling normally should not trigger any forwarding. 7987 // Scrolling normally should not trigger any forwarding.
7988 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 7988 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
7989 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 7989 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
7990 InputHandler::GESTURE) 7990 InputHandler::GESTURE)
7991 .thread); 7991 .thread);
7992 EXPECT_TRUE( 7992 EXPECT_TRUE(
7993 host_impl_->ScrollBy( 7993 host_impl_->ScrollBy(
7994 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) 7994 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get())
7995 .did_scroll); 7995 .did_scroll);
7996 host_impl_->ScrollEnd(EndState().get()); 7996 host_impl_->ScrollEnd(EndState().get());
7997 7997
7998 EXPECT_EQ(0, set_needs_commit_count); 7998 EXPECT_EQ(0, set_needs_commit_count);
7999 EXPECT_EQ(1, set_needs_redraw_count); 7999 EXPECT_EQ(1, set_needs_redraw_count);
8000 EXPECT_EQ(0, forward_to_main_count); 8000 EXPECT_EQ(0, forward_to_main_count);
8001 8001
8002 // Scrolling with a scroll handler should defer the swap to the main 8002 // Scrolling with a scroll handler should defer the swap to the main
8003 // thread. 8003 // thread.
8004 scroll_layer->SetHaveScrollEventHandlers(true); 8004 host_impl_->active_tree()->set_have_scroll_event_handlers(true);
8005 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 8005 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
8006 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 8006 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
8007 InputHandler::GESTURE) 8007 InputHandler::GESTURE)
8008 .thread); 8008 .thread);
8009 EXPECT_TRUE( 8009 EXPECT_TRUE(
8010 host_impl_->ScrollBy( 8010 host_impl_->ScrollBy(
8011 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) 8011 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get())
8012 .did_scroll); 8012 .did_scroll);
8013 host_impl_->ScrollEnd(EndState().get()); 8013 host_impl_->ScrollEnd(EndState().get());
8014 8014
(...skipping 1946 matching lines...) Expand 10 before | Expand all | Expand 10 after
9961 // There should not be any jitter measured till we hit the fixed point hits 9961 // There should not be any jitter measured till we hit the fixed point hits
9962 // threshold. 9962 // threshold.
9963 float expected_jitter = 9963 float expected_jitter =
9964 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 9964 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
9965 EXPECT_EQ(jitter, expected_jitter); 9965 EXPECT_EQ(jitter, expected_jitter);
9966 } 9966 }
9967 } 9967 }
9968 9968
9969 } // namespace 9969 } // namespace
9970 } // namespace cc 9970 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698