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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 completed_mode_ = OVERSCROLL_NONE; | 116 completed_mode_ = OVERSCROLL_NONE; |
117 delta_x_ = delta_y_ = 0.f; | 117 delta_x_ = delta_y_ = 0.f; |
118 } | 118 } |
119 | 119 |
120 private: | 120 private: |
121 // Overridden from OverscrollControllerDelegate: | 121 // Overridden from OverscrollControllerDelegate: |
122 virtual gfx::Rect GetVisibleBounds() const OVERRIDE { | 122 virtual gfx::Rect GetVisibleBounds() const OVERRIDE { |
123 return view_->IsShowing() ? view_->GetViewBounds() : gfx::Rect(); | 123 return view_->IsShowing() ? view_->GetViewBounds() : gfx::Rect(); |
124 } | 124 } |
125 | 125 |
126 virtual void OnOverscrollUpdate(float delta_x, float delta_y) OVERRIDE { | 126 virtual bool OnOverscrollUpdate(float delta_x, float delta_y) OVERRIDE { |
127 delta_x_ = delta_x; | 127 delta_x_ = delta_x; |
128 delta_y_ = delta_y; | 128 delta_y_ = delta_y; |
| 129 return true; |
129 } | 130 } |
130 | 131 |
131 virtual void OnOverscrollComplete(OverscrollMode overscroll_mode) OVERRIDE { | 132 virtual void OnOverscrollComplete(OverscrollMode overscroll_mode) OVERRIDE { |
132 EXPECT_EQ(current_mode_, overscroll_mode); | 133 EXPECT_EQ(current_mode_, overscroll_mode); |
133 completed_mode_ = overscroll_mode; | 134 completed_mode_ = overscroll_mode; |
134 current_mode_ = OVERSCROLL_NONE; | 135 current_mode_ = OVERSCROLL_NONE; |
135 } | 136 } |
136 | 137 |
137 virtual void OnOverscrollModeChange(OverscrollMode old_mode, | 138 virtual void OnOverscrollModeChange(OverscrollMode old_mode, |
138 OverscrollMode new_mode) OVERRIDE { | 139 OverscrollMode new_mode) OVERRIDE { |
(...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2527 SimulateGestureScrollUpdateEvent(125, -5, 0); | 2528 SimulateGestureScrollUpdateEvent(125, -5, 0); |
2528 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2529 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
2529 | 2530 |
2530 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2531 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
2531 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2532 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2532 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); | 2533 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
2533 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 2534 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
2534 EXPECT_EQ(0U, sink_->message_count()); | 2535 EXPECT_EQ(0U, sink_->message_count()); |
2535 | 2536 |
2536 // Send another update event, but in the reverse direction. The overscroll | 2537 // Send another update event, but in the reverse direction. The overscroll |
2537 // controller will consume the event, and reset the overscroll mode. | 2538 // controller will not consume the event, because it is not triggering |
| 2539 // gesture-nav. |
2538 SimulateGestureScrollUpdateEvent(-260, 0, 0); | 2540 SimulateGestureScrollUpdateEvent(-260, 0, 0); |
2539 EXPECT_EQ(0U, sink_->message_count()); | 2541 EXPECT_EQ(1U, sink_->message_count()); |
2540 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2542 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2541 | 2543 |
2542 // Since the overscroll mode has been reset, the next scroll update events | 2544 // Since the overscroll mode has been reset, the next scroll update events |
2543 // should reach the renderer. | 2545 // should reach the renderer. |
2544 SimulateGestureScrollUpdateEvent(-20, 0, 0); | 2546 SimulateGestureScrollUpdateEvent(-20, 0, 0); |
2545 EXPECT_EQ(1U, sink_->message_count()); | 2547 EXPECT_EQ(1U, sink_->message_count()); |
2546 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2548 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2547 } | 2549 } |
2548 | 2550 |
2549 // Tests that if a mouse-move event completes the overscroll gesture, future | 2551 // Tests that if a mouse-move event completes the overscroll gesture, future |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2718 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 2720 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
2719 | 2721 |
2720 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 2722 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
2721 blink::WebGestureDeviceTouchscreen); | 2723 blink::WebGestureDeviceTouchscreen); |
2722 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2724 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
2723 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 2725 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
2724 EXPECT_EQ(3U, sink_->message_count()); | 2726 EXPECT_EQ(3U, sink_->message_count()); |
2725 } | 2727 } |
2726 | 2728 |
2727 } // namespace content | 2729 } // namespace content |
OLD | NEW |