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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 | 459 |
460 virtual void ConfigureView(TestView* view) { | 460 virtual void ConfigureView(TestView* view) { |
461 } | 461 } |
462 | 462 |
463 int64 GetLatencyComponentId() { | 463 int64 GetLatencyComponentId() { |
464 return host_->GetLatencyComponentId(); | 464 return host_->GetLatencyComponentId(); |
465 } | 465 } |
466 | 466 |
467 void SendInputEventACK(WebInputEvent::Type type, | 467 void SendInputEventACK(WebInputEvent::Type type, |
468 InputEventAckState ack_result) { | 468 InputEventAckState ack_result) { |
469 InputHostMsg_HandleInputEvent_ACK_Params ack; | 469 DCHECK(!WebInputEvent::isTouchEventType(type)); |
470 ack.type = type; | 470 InputEventAck ack(type, ack_result); |
471 ack.state = ack_result; | |
472 host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); | 471 host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); |
473 } | 472 } |
474 | 473 |
475 double GetNextSimulatedEventTimeSeconds() { | 474 double GetNextSimulatedEventTimeSeconds() { |
476 last_simulated_event_time_seconds_ += simulated_event_time_delta_seconds_; | 475 last_simulated_event_time_seconds_ += simulated_event_time_delta_seconds_; |
477 return last_simulated_event_time_seconds_; | 476 return last_simulated_event_time_seconds_; |
478 } | 477 } |
479 | 478 |
480 void SimulateKeyboardEvent(WebInputEvent::Type type) { | 479 void SimulateKeyboardEvent(WebInputEvent::Type type) { |
481 SimulateKeyboardEvent(type, 0); | 480 SimulateKeyboardEvent(type, 0); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 ui_latency); | 543 ui_latency); |
545 } | 544 } |
546 | 545 |
547 // Set the timestamp for the touch-event. | 546 // Set the timestamp for the touch-event. |
548 void SetTouchTimestamp(base::TimeDelta timestamp) { | 547 void SetTouchTimestamp(base::TimeDelta timestamp) { |
549 touch_event_.SetTimestamp(timestamp); | 548 touch_event_.SetTimestamp(timestamp); |
550 } | 549 } |
551 | 550 |
552 // Sends a touch event (irrespective of whether the page has a touch-event | 551 // Sends a touch event (irrespective of whether the page has a touch-event |
553 // handler or not). | 552 // handler or not). |
554 void SendTouchEvent() { | 553 uint32 SendTouchEvent() { |
| 554 uint32 touch_event_id = touch_event_.uniqueTouchEventId; |
555 host_->ForwardTouchEventWithLatencyInfo(touch_event_, ui::LatencyInfo()); | 555 host_->ForwardTouchEventWithLatencyInfo(touch_event_, ui::LatencyInfo()); |
556 | 556 |
557 touch_event_.ResetPoints(); | 557 touch_event_.ResetPoints(); |
| 558 return touch_event_id; |
558 } | 559 } |
559 | 560 |
560 int PressTouchPoint(int x, int y) { | 561 int PressTouchPoint(int x, int y) { |
561 return touch_event_.PressPoint(x, y); | 562 return touch_event_.PressPoint(x, y); |
562 } | 563 } |
563 | 564 |
564 void MoveTouchPoint(int index, int x, int y) { | 565 void MoveTouchPoint(int index, int x, int y) { |
565 touch_event_.MovePoint(index, x, y); | 566 touch_event_.MovePoint(index, x, y); |
566 } | 567 } |
567 | 568 |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 SimulateGestureEventWithLatencyInfo(WebInputEvent::GestureScrollUpdate, | 1476 SimulateGestureEventWithLatencyInfo(WebInputEvent::GestureScrollUpdate, |
1476 blink::WebGestureDeviceTouchscreen, | 1477 blink::WebGestureDeviceTouchscreen, |
1477 ui::LatencyInfo()); | 1478 ui::LatencyInfo()); |
1478 CheckLatencyInfoComponentInMessage( | 1479 CheckLatencyInfoComponentInMessage( |
1479 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollUpdate); | 1480 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollUpdate); |
1480 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1481 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
1481 INPUT_EVENT_ACK_STATE_CONSUMED); | 1482 INPUT_EVENT_ACK_STATE_CONSUMED); |
1482 | 1483 |
1483 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). | 1484 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). |
1484 PressTouchPoint(0, 1); | 1485 PressTouchPoint(0, 1); |
1485 SendTouchEvent(); | 1486 uint32 touch_event_id = SendTouchEvent(); |
| 1487 InputEventAck ack(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1488 touch_event_id); |
| 1489 host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); |
1486 CheckLatencyInfoComponentInMessage( | 1490 CheckLatencyInfoComponentInMessage( |
1487 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); | 1491 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); |
1488 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | |
1489 } | 1492 } |
1490 | 1493 |
1491 TEST_F(RenderWidgetHostTest, RendererExitedResetsInputRouter) { | 1494 TEST_F(RenderWidgetHostTest, RendererExitedResetsInputRouter) { |
1492 // RendererExited will delete the view. | 1495 // RendererExited will delete the view. |
1493 host_->SetView(new TestView(host_.get())); | 1496 host_->SetView(new TestView(host_.get())); |
1494 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | 1497 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
1495 | 1498 |
1496 // Make sure the input router is in a fresh state. | 1499 // Make sure the input router is in a fresh state. |
1497 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1500 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
1498 } | 1501 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 // Having an initial size set means that the size information had been sent | 1543 // Having an initial size set means that the size information had been sent |
1541 // with the reqiest to new up the RenderView and so subsequent WasResized | 1544 // with the reqiest to new up the RenderView and so subsequent WasResized |
1542 // calls should not result in new IPC (unless the size has actually changed). | 1545 // calls should not result in new IPC (unless the size has actually changed). |
1543 host_->WasResized(); | 1546 host_->WasResized(); |
1544 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); | 1547 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); |
1545 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); | 1548 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); |
1546 EXPECT_TRUE(host_->resize_ack_pending_); | 1549 EXPECT_TRUE(host_->resize_ack_pending_); |
1547 } | 1550 } |
1548 | 1551 |
1549 } // namespace content | 1552 } // namespace content |
OLD | NEW |