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

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

Issue 1577263004: Communicate whether passive event listeners exist to cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_wheel_passive_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
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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); 710 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta));
711 } 711 }
712 712
713 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { 713 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) {
714 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 714 SetupScrollAndContentsLayers(gfx::Size(100, 100));
715 host_impl_->SetViewportSize(gfx::Size(50, 50)); 715 host_impl_->SetViewportSize(gfx::Size(50, 50));
716 DrawFrame(); 716 DrawFrame();
717 717
718 // With registered event handlers, wheel scrolls don't necessarily 718 // With registered event handlers, wheel scrolls don't necessarily
719 // have to go to the main thread. 719 // have to go to the main thread.
720 host_impl_->active_tree()->set_have_wheel_event_handlers(true); 720 host_impl_->active_tree()->set_event_listener_properties(
721 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking);
721 InputHandler::ScrollStatus status = 722 InputHandler::ScrollStatus status =
722 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 723 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
723 InputHandler::WHEEL); 724 InputHandler::WHEEL);
724 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 725 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
725 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers, 726 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers,
726 status.main_thread_scrolling_reasons); 727 status.main_thread_scrolling_reasons);
727 728
728 // But gesture scrolls can still be handled. 729 // But gesture scrolls can still be handled.
729 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 730 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
730 InputHandler::GESTURE); 731 InputHandler::GESTURE);
731 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 732 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
732 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 733 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
733 status.main_thread_scrolling_reasons); 734 status.main_thread_scrolling_reasons);
734 host_impl_->ScrollEnd(EndState().get()); 735 host_impl_->ScrollEnd(EndState().get());
735 736
736 // And if the handlers go away, wheel scrolls can again be processed 737 // And if the handlers go away, wheel scrolls can again be processed
737 // on impl (despite the scroll-blocks-on mode). 738 // on impl (despite the scroll-blocks-on mode).
Rick Byers 2016/02/04 22:18:57 Looks like we missed updating the comment and test
738 host_impl_->active_tree()->set_have_wheel_event_handlers(false); 739 host_impl_->active_tree()->set_event_listener_properties(
740 EventListenerClass::kMouseWheel, EventListenerProperties::kNone);
739 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 741 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
740 InputHandler::WHEEL); 742 InputHandler::WHEEL);
741 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 743 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
742 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, 744 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
743 status.main_thread_scrolling_reasons); 745 status.main_thread_scrolling_reasons);
744 host_impl_->ScrollEnd(EndState().get()); 746 host_impl_->ScrollEnd(EndState().get());
745 } 747 }
746 748
747 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { 749 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) {
748 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 750 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100));
(...skipping 9212 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 9963 // There should not be any jitter measured till we hit the fixed point hits
9962 // threshold. 9964 // threshold.
9963 float expected_jitter = 9965 float expected_jitter =
9964 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 9966 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
9965 EXPECT_EQ(jitter, expected_jitter); 9967 EXPECT_EQ(jitter, expected_jitter);
9966 } 9968 }
9967 } 9969 }
9968 9970
9969 } // namespace 9971 } // namespace
9970 } // namespace cc 9972 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698