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

Side by Side Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 11574047: overscroll: Send all gesture-events to the gesture-event filter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add a test. Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/overscroll_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/shared_memory.h" 7 #include "base/shared_memory.h"
8 #include "base/timer.h" 8 #include "base/timer.h"
9 #include "content/browser/browser_thread_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/renderer_host/backing_store.h" 10 #include "content/browser/renderer_host/backing_store.h"
(...skipping 2692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 SimulateWheelEvent(-35, -2, 0); 2703 SimulateWheelEvent(-35, -2, 0);
2704 EXPECT_EQ(1U, process_->sink().message_count()); 2704 EXPECT_EQ(1U, process_->sink().message_count());
2705 SendInputEventACK(WebInputEvent::MouseWheel, false); 2705 SendInputEventACK(WebInputEvent::MouseWheel, false);
2706 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); 2706 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode());
2707 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode()); 2707 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode());
2708 EXPECT_EQ(-55.f, host_->overscroll_delta_x()); 2708 EXPECT_EQ(-55.f, host_->overscroll_delta_x());
2709 EXPECT_EQ(-25.f, host_->overscroll_delegate()->delta_x()); 2709 EXPECT_EQ(-25.f, host_->overscroll_delegate()->delta_x());
2710 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); 2710 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
2711 } 2711 }
2712 2712
2713 TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithFling) {
2714 host_->SetupForOverscrollControllerTest();
2715 process_->sink().ClearMessages();
2716
2717 // Send a wheel event. ACK the event as not processed. This should not
2718 // initiate an overscroll gesture since it doesn't cross the threshold yet.
2719 SimulateWheelEvent(10, -5, 0);
2720 EXPECT_EQ(1U, process_->sink().message_count());
2721 SendInputEventACK(WebInputEvent::MouseWheel, false);
2722 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
2723 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
2724 process_->sink().ClearMessages();
2725
2726 // Scroll some more so as to not overscroll.
2727 SimulateWheelEvent(10, -4, 0);
2728 EXPECT_EQ(1U, process_->sink().message_count());
2729 SendInputEventACK(WebInputEvent::MouseWheel, false);
2730 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
2731 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
2732 process_->sink().ClearMessages();
2733
2734 // Scroll some more to initiate an overscroll.
2735 SimulateWheelEvent(20, -4, 0);
2736 EXPECT_EQ(1U, process_->sink().message_count());
2737 SendInputEventACK(WebInputEvent::MouseWheel, false);
2738 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
2739 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
2740 EXPECT_EQ(40.f, host_->overscroll_delta_x());
2741 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x());
2742 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y());
2743 process_->sink().ClearMessages();
2744 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
2745
2746 // Send a fling start, but with a small velocity, so that the overscroll is
2747 // aborted. The fling should proceed to the renderer, through the gesture
2748 // event filter.
2749 SimulateGestureFlingStartEvent(0.f, 0.f);
2750 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
2751 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
2752 EXPECT_EQ(1U, process_->sink().message_count());
2753 }
2754
2713 // Tests that touch-scroll events are handled correctly by the overscroll 2755 // Tests that touch-scroll events are handled correctly by the overscroll
2714 // controller. This also tests that the overscroll controller and the 2756 // controller. This also tests that the overscroll controller and the
2715 // gesture-event filter play nice with each other. 2757 // gesture-event filter play nice with each other.
2716 TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) { 2758 TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) {
2717 // Turn off debounce handling for test isolation. 2759 // Turn off debounce handling for test isolation.
2718 host_->SetupForOverscrollControllerTest(); 2760 host_->SetupForOverscrollControllerTest();
2719 host_->set_debounce_interval_time_ms(0); 2761 host_->set_debounce_interval_time_ms(0);
2720 process_->sink().ClearMessages(); 2762 process_->sink().ClearMessages();
2721 2763
2722 SimulateGestureEvent(WebInputEvent::GestureScrollBegin); 2764 SimulateGestureEvent(WebInputEvent::GestureScrollBegin);
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
3101 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 3143 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
3102 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3144 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3103 3145
3104 SendInputEventACK(WebKit::WebInputEvent::GestureScrollEnd, false); 3146 SendInputEventACK(WebKit::WebInputEvent::GestureScrollEnd, false);
3105 EXPECT_EQ(0U, process_->sink().message_count()); 3147 EXPECT_EQ(0U, process_->sink().message_count());
3106 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 3148 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
3107 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 3149 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
3108 } 3150 }
3109 3151
3110 } // namespace content 3152 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/overscroll_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698