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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2235 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); | 2235 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); |
2236 | 2236 |
2237 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 2237 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
2238 WebGestureEvent::Touchscreen); | 2238 WebGestureEvent::Touchscreen); |
2239 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2239 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
2240 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 2240 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
2241 EXPECT_EQ(3U, process_->sink().message_count()); | 2241 EXPECT_EQ(3U, process_->sink().message_count()); |
2242 } | 2242 } |
2243 | 2243 |
2244 std::string GetInputMessageTypes(RenderWidgetHostProcess* process) { | 2244 std::string GetInputMessageTypes(RenderWidgetHostProcess* process) { |
2245 const WebInputEvent* event = NULL; | |
2246 ui::LatencyInfo latency_info; | |
2247 bool is_keyboard_shortcut; | |
2248 std::string result; | 2245 std::string result; |
2249 for (size_t i = 0; i < process->sink().message_count(); ++i) { | 2246 for (size_t i = 0; i < process->sink().message_count(); ++i) { |
2250 const IPC::Message *message = process->sink().GetMessageAt(i); | 2247 const IPC::Message *message = process->sink().GetMessageAt(i); |
2251 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); | 2248 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); |
2252 EXPECT_TRUE(InputMsg_HandleInputEvent::Read( | 2249 InputMsg_HandleInputEvent::Param params; |
2253 message, &event, &latency_info, &is_keyboard_shortcut)); | 2250 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); |
| 2251 const WebInputEvent* event = params.a; |
2254 if (i != 0) | 2252 if (i != 0) |
2255 result += " "; | 2253 result += " "; |
2256 result += WebInputEventTraits::GetName(event->type); | 2254 result += WebInputEventTraits::GetName(event->type); |
2257 } | 2255 } |
2258 process->sink().ClearMessages(); | 2256 process->sink().ClearMessages(); |
2259 return result; | 2257 return result; |
2260 } | 2258 } |
2261 | 2259 |
2262 TEST_F(RenderWidgetHostTest, TouchEmulator) { | 2260 TEST_F(RenderWidgetHostTest, TouchEmulator) { |
2263 simulated_event_time_delta_seconds_ = 0.1; | 2261 simulated_event_time_delta_seconds_ = 0.1; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2566 | 2564 |
2567 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 2565 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
2568 | 2566 |
2569 EXPECT_TRUE(host_->mock_input_router()->message_received_); | 2567 EXPECT_TRUE(host_->mock_input_router()->message_received_); |
2570 } | 2568 } |
2571 | 2569 |
2572 | 2570 |
2573 void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process, | 2571 void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process, |
2574 int64 component_id, | 2572 int64 component_id, |
2575 WebInputEvent::Type input_type) { | 2573 WebInputEvent::Type input_type) { |
2576 const WebInputEvent* event = NULL; | |
2577 ui::LatencyInfo latency_info; | |
2578 bool is_keyboard_shortcut; | |
2579 const IPC::Message* message = process->sink().GetUniqueMessageMatching( | 2574 const IPC::Message* message = process->sink().GetUniqueMessageMatching( |
2580 InputMsg_HandleInputEvent::ID); | 2575 InputMsg_HandleInputEvent::ID); |
2581 ASSERT_TRUE(message); | 2576 ASSERT_TRUE(message); |
2582 EXPECT_TRUE(InputMsg_HandleInputEvent::Read( | 2577 InputMsg_HandleInputEvent::Param params; |
2583 message, &event, &latency_info, &is_keyboard_shortcut)); | 2578 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms)); |
| 2579 ui::LatencyInfo latency_info = params.b; |
2584 EXPECT_TRUE(latency_info.FindLatency( | 2580 EXPECT_TRUE(latency_info.FindLatency( |
2585 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 2581 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
2586 component_id, | 2582 component_id, |
2587 NULL)); | 2583 NULL)); |
2588 process->sink().ClearMessages(); | 2584 process->sink().ClearMessages(); |
2589 } | 2585 } |
2590 | 2586 |
2591 // Tests that after input event passes through RWHI through ForwardXXXEvent() | 2587 // Tests that after input event passes through RWHI through ForwardXXXEvent() |
2592 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component | 2588 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component |
2593 // ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will always present in the | 2589 // ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will always present in the |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2638 | 2634 |
2639 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). | 2635 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). |
2640 PressTouchPoint(0, 1); | 2636 PressTouchPoint(0, 1); |
2641 SendTouchEvent(); | 2637 SendTouchEvent(); |
2642 CheckLatencyInfoComponentInMessage( | 2638 CheckLatencyInfoComponentInMessage( |
2643 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); | 2639 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); |
2644 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | 2640 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); |
2645 } | 2641 } |
2646 | 2642 |
2647 } // namespace content | 2643 } // namespace content |
OLD | NEW |