OLD | NEW |
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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 2961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2972 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); | 2972 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); |
2973 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); | 2973 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); |
2974 EXPECT_EQ(0U, sink_->message_count()); | 2974 EXPECT_EQ(0U, sink_->message_count()); |
2975 | 2975 |
2976 // Let the timer for the debounce queue fire. That should release the queued | 2976 // Let the timer for the debounce queue fire. That should release the queued |
2977 // scroll-end event. Since overscroll has started, but there hasn't been | 2977 // scroll-end event. Since overscroll has started, but there hasn't been |
2978 // enough overscroll to complete the gesture, the overscroll controller | 2978 // enough overscroll to complete the gesture, the overscroll controller |
2979 // will reset the state. The scroll-end should therefore be dispatched to the | 2979 // will reset the state. The scroll-end should therefore be dispatched to the |
2980 // renderer, and the gesture-event-filter should await an ACK for it. | 2980 // renderer, and the gesture-event-filter should await an ACK for it. |
2981 base::MessageLoop::current()->PostDelayedTask( | 2981 base::MessageLoop::current()->PostDelayedTask( |
2982 FROM_HERE, | 2982 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
2983 base::MessageLoop::QuitClosure(), | |
2984 base::TimeDelta::FromMilliseconds(15)); | 2983 base::TimeDelta::FromMilliseconds(15)); |
2985 base::MessageLoop::current()->Run(); | 2984 base::MessageLoop::current()->Run(); |
2986 | 2985 |
2987 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2986 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2988 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2987 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
2989 EXPECT_EQ(1U, sink_->message_count()); | 2988 EXPECT_EQ(1U, sink_->message_count()); |
2990 } | 2989 } |
2991 | 2990 |
2992 // Tests that when touch-events are dispatched to the renderer, the overscroll | 2991 // Tests that when touch-events are dispatched to the renderer, the overscroll |
2993 // gesture deals with them correctly. | 2992 // gesture deals with them correctly. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3080 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3079 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3081 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3080 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3082 ReleaseTouchPoint(0); | 3081 ReleaseTouchPoint(0); |
3083 SendTouchEvent(); | 3082 SendTouchEvent(); |
3084 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3083 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3085 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3084 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3086 | 3085 |
3087 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 3086 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
3088 blink::WebGestureDeviceTouchscreen); | 3087 blink::WebGestureDeviceTouchscreen); |
3089 base::MessageLoop::current()->PostDelayedTask( | 3088 base::MessageLoop::current()->PostDelayedTask( |
3090 FROM_HERE, | 3089 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
3091 base::MessageLoop::QuitClosure(), | |
3092 base::TimeDelta::FromMilliseconds(10)); | 3090 base::TimeDelta::FromMilliseconds(10)); |
3093 base::MessageLoop::current()->Run(); | 3091 base::MessageLoop::current()->Run(); |
3094 EXPECT_EQ(1U, sink_->message_count()); | 3092 EXPECT_EQ(1U, sink_->message_count()); |
3095 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3093 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3096 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3094 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
3097 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 3095 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
3098 } | 3096 } |
3099 | 3097 |
3100 // Tests that touch-gesture end is dispatched to the renderer at the end of a | 3098 // Tests that touch-gesture end is dispatched to the renderer at the end of a |
3101 // touch-gesture initiated overscroll. | 3099 // touch-gesture initiated overscroll. |
(...skipping 25 matching lines...) Expand all Loading... |
3127 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 3125 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
3128 EXPECT_EQ(55.f, overscroll_delta_x()); | 3126 EXPECT_EQ(55.f, overscroll_delta_x()); |
3129 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); | 3127 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); |
3130 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); | 3128 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); |
3131 | 3129 |
3132 // Send end event. | 3130 // Send end event. |
3133 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 3131 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
3134 blink::WebGestureDeviceTouchscreen); | 3132 blink::WebGestureDeviceTouchscreen); |
3135 EXPECT_EQ(0U, sink_->message_count()); | 3133 EXPECT_EQ(0U, sink_->message_count()); |
3136 base::MessageLoop::current()->PostDelayedTask( | 3134 base::MessageLoop::current()->PostDelayedTask( |
3137 FROM_HERE, | 3135 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
3138 base::MessageLoop::QuitClosure(), | |
3139 base::TimeDelta::FromMilliseconds(10)); | 3136 base::TimeDelta::FromMilliseconds(10)); |
3140 base::MessageLoop::current()->Run(); | 3137 base::MessageLoop::current()->Run(); |
3141 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3138 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3142 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3139 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
3143 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 3140 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
3144 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3141 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3145 | 3142 |
3146 // Start scrolling. Receive ACK as it being processed. | 3143 // Start scrolling. Receive ACK as it being processed. |
3147 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 3144 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
3148 blink::WebGestureDeviceTouchscreen); | 3145 blink::WebGestureDeviceTouchscreen); |
(...skipping 14 matching lines...) Expand all Loading... |
3163 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 3160 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
3164 EXPECT_EQ(235.f, overscroll_delta_x()); | 3161 EXPECT_EQ(235.f, overscroll_delta_x()); |
3165 EXPECT_EQ(185.f, overscroll_delegate()->delta_x()); | 3162 EXPECT_EQ(185.f, overscroll_delegate()->delta_x()); |
3166 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); | 3163 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); |
3167 | 3164 |
3168 // Send end event. | 3165 // Send end event. |
3169 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 3166 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
3170 blink::WebGestureDeviceTouchscreen); | 3167 blink::WebGestureDeviceTouchscreen); |
3171 EXPECT_EQ(0U, sink_->message_count()); | 3168 EXPECT_EQ(0U, sink_->message_count()); |
3172 base::MessageLoop::current()->PostDelayedTask( | 3169 base::MessageLoop::current()->PostDelayedTask( |
3173 FROM_HERE, | 3170 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
3174 base::MessageLoop::QuitClosure(), | |
3175 base::TimeDelta::FromMilliseconds(10)); | 3171 base::TimeDelta::FromMilliseconds(10)); |
3176 base::MessageLoop::current()->Run(); | 3172 base::MessageLoop::current()->Run(); |
3177 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3173 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3178 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3174 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
3179 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 3175 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
3180 EXPECT_EQ(1U, sink_->message_count()); | 3176 EXPECT_EQ(1U, sink_->message_count()); |
3181 } | 3177 } |
3182 | 3178 |
3183 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDirectionChange) { | 3179 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDirectionChange) { |
3184 SetUpOverscrollEnvironmentWithDebounce(100); | 3180 SetUpOverscrollEnvironmentWithDebounce(100); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3618 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); | 3614 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); |
3619 view_->InitAsChild(NULL); | 3615 view_->InitAsChild(NULL); |
3620 view_->Show(); | 3616 view_->Show(); |
3621 view_->SetSize(size); | 3617 view_->SetSize(size); |
3622 view_->OnSwapCompositorFrame(0, | 3618 view_->OnSwapCompositorFrame(0, |
3623 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); | 3619 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); |
3624 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); | 3620 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); |
3625 } | 3621 } |
3626 | 3622 |
3627 } // namespace content | 3623 } // namespace content |
OLD | NEW |