| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <tuple> | 10 #include <tuple> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/location.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 16 #include "base/memory/shared_memory.h" | 17 #include "base/memory/shared_memory.h" |
| 17 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 18 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
| 20 #include "base/single_thread_task_runner.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/test/simple_test_tick_clock.h" | 22 #include "base/test/simple_test_tick_clock.h" |
| 23 #include "base/threading/thread_task_runner_handle.h" |
| 21 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 22 #include "cc/output/begin_frame_args.h" | 25 #include "cc/output/begin_frame_args.h" |
| 23 #include "cc/output/compositor_frame.h" | 26 #include "cc/output/compositor_frame.h" |
| 24 #include "cc/output/compositor_frame_metadata.h" | 27 #include "cc/output/compositor_frame_metadata.h" |
| 25 #include "cc/output/copy_output_request.h" | 28 #include "cc/output/copy_output_request.h" |
| 26 #include "cc/surfaces/surface.h" | 29 #include "cc/surfaces/surface.h" |
| 27 #include "cc/surfaces/surface_manager.h" | 30 #include "cc/surfaces/surface_manager.h" |
| 28 #include "components/display_compositor/gl_helper.h" | 31 #include "components/display_compositor/gl_helper.h" |
| 29 #include "content/browser/browser_thread_impl.h" | 32 #include "content/browser/browser_thread_impl.h" |
| 30 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" | 33 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
| (...skipping 3396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3427 EXPECT_EQ(55.f, overscroll_delta_x()); | 3430 EXPECT_EQ(55.f, overscroll_delta_x()); |
| 3428 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); | 3431 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); |
| 3429 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); | 3432 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); |
| 3430 EXPECT_EQ(0U, sink_->message_count()); | 3433 EXPECT_EQ(0U, sink_->message_count()); |
| 3431 | 3434 |
| 3432 // Let the timer for the debounce queue fire. That should release the queued | 3435 // Let the timer for the debounce queue fire. That should release the queued |
| 3433 // scroll-end event. Since overscroll has started, but there hasn't been | 3436 // scroll-end event. Since overscroll has started, but there hasn't been |
| 3434 // enough overscroll to complete the gesture, the overscroll controller | 3437 // enough overscroll to complete the gesture, the overscroll controller |
| 3435 // will reset the state. The scroll-end should therefore be dispatched to the | 3438 // will reset the state. The scroll-end should therefore be dispatched to the |
| 3436 // renderer, and the gesture-event-filter should await an ACK for it. | 3439 // renderer, and the gesture-event-filter should await an ACK for it. |
| 3437 base::MessageLoop::current()->PostDelayedTask( | 3440 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 3438 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 3441 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 3439 base::TimeDelta::FromMilliseconds(15)); | 3442 base::TimeDelta::FromMilliseconds(15)); |
| 3440 base::MessageLoop::current()->Run(); | 3443 base::MessageLoop::current()->Run(); |
| 3441 | 3444 |
| 3442 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3445 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3443 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3446 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3444 EXPECT_EQ(1U, sink_->message_count()); | 3447 EXPECT_EQ(1U, sink_->message_count()); |
| 3445 } | 3448 } |
| 3446 | 3449 |
| 3447 // Tests that when touch-events are dispatched to the renderer, the overscroll | 3450 // Tests that when touch-events are dispatched to the renderer, the overscroll |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3534 SendTouchEvent(); | 3537 SendTouchEvent(); |
| 3535 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3538 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3536 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3539 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3537 ReleaseTouchPoint(0); | 3540 ReleaseTouchPoint(0); |
| 3538 SendTouchEvent(); | 3541 SendTouchEvent(); |
| 3539 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3542 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3540 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3543 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3541 | 3544 |
| 3542 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 3545 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
| 3543 blink::WebGestureDeviceTouchscreen); | 3546 blink::WebGestureDeviceTouchscreen); |
| 3544 base::MessageLoop::current()->PostDelayedTask( | 3547 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 3545 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 3548 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 3546 base::TimeDelta::FromMilliseconds(10)); | 3549 base::TimeDelta::FromMilliseconds(10)); |
| 3547 base::MessageLoop::current()->Run(); | 3550 base::MessageLoop::current()->Run(); |
| 3548 EXPECT_EQ(1U, sink_->message_count()); | 3551 EXPECT_EQ(1U, sink_->message_count()); |
| 3549 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3552 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3550 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3553 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3551 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 3554 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
| 3552 } | 3555 } |
| 3553 | 3556 |
| 3554 // Tests that touch-gesture end is dispatched to the renderer at the end of a | 3557 // Tests that touch-gesture end is dispatched to the renderer at the end of a |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3580 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); | 3583 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
| 3581 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 3584 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
| 3582 EXPECT_EQ(55.f, overscroll_delta_x()); | 3585 EXPECT_EQ(55.f, overscroll_delta_x()); |
| 3583 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); | 3586 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); |
| 3584 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); | 3587 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); |
| 3585 | 3588 |
| 3586 // Send end event. | 3589 // Send end event. |
| 3587 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 3590 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
| 3588 blink::WebGestureDeviceTouchscreen); | 3591 blink::WebGestureDeviceTouchscreen); |
| 3589 EXPECT_EQ(0U, sink_->message_count()); | 3592 EXPECT_EQ(0U, sink_->message_count()); |
| 3590 base::MessageLoop::current()->PostDelayedTask( | 3593 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 3591 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 3594 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 3592 base::TimeDelta::FromMilliseconds(10)); | 3595 base::TimeDelta::FromMilliseconds(10)); |
| 3593 base::MessageLoop::current()->Run(); | 3596 base::MessageLoop::current()->Run(); |
| 3594 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3597 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3595 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3598 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3596 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 3599 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
| 3597 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3600 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3598 | 3601 |
| 3599 // Start scrolling. Receive ACK as it being processed. | 3602 // Start scrolling. Receive ACK as it being processed. |
| 3600 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 3603 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3615 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); | 3618 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
| 3616 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 3619 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
| 3617 EXPECT_EQ(235.f, overscroll_delta_x()); | 3620 EXPECT_EQ(235.f, overscroll_delta_x()); |
| 3618 EXPECT_EQ(185.f, overscroll_delegate()->delta_x()); | 3621 EXPECT_EQ(185.f, overscroll_delegate()->delta_x()); |
| 3619 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); | 3622 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); |
| 3620 | 3623 |
| 3621 // Send end event. | 3624 // Send end event. |
| 3622 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 3625 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
| 3623 blink::WebGestureDeviceTouchscreen); | 3626 blink::WebGestureDeviceTouchscreen); |
| 3624 EXPECT_EQ(0U, sink_->message_count()); | 3627 EXPECT_EQ(0U, sink_->message_count()); |
| 3625 base::MessageLoop::current()->PostDelayedTask( | 3628 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 3626 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 3629 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 3627 base::TimeDelta::FromMilliseconds(10)); | 3630 base::TimeDelta::FromMilliseconds(10)); |
| 3628 base::MessageLoop::current()->Run(); | 3631 base::MessageLoop::current()->Run(); |
| 3629 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3632 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3630 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3633 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3631 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 3634 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
| 3632 EXPECT_EQ(1U, sink_->message_count()); | 3635 EXPECT_EQ(1U, sink_->message_count()); |
| 3633 } | 3636 } |
| 3634 | 3637 |
| 3635 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDirectionChange) { | 3638 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDirectionChange) { |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4484 view()->OnGestureEvent(&gesture_event); | 4487 view()->OnGestureEvent(&gesture_event); |
| 4485 | 4488 |
| 4486 EXPECT_TRUE(delegate->context_menu_request_received()); | 4489 EXPECT_TRUE(delegate->context_menu_request_received()); |
| 4487 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); | 4490 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); |
| 4488 #endif | 4491 #endif |
| 4489 | 4492 |
| 4490 RenderViewHostFactory::set_is_real_render_view_host(false); | 4493 RenderViewHostFactory::set_is_real_render_view_host(false); |
| 4491 } | 4494 } |
| 4492 | 4495 |
| 4493 } // namespace content | 4496 } // namespace content |
| OLD | NEW |