Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 997283002: Coalesce async touch move events until the ack back from render (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing unittests Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 452
453 virtual void ConfigureView(TestView* view) { 453 virtual void ConfigureView(TestView* view) {
454 } 454 }
455 455
456 int64 GetLatencyComponentId() { 456 int64 GetLatencyComponentId() {
457 return host_->GetLatencyComponentId(); 457 return host_->GetLatencyComponentId();
458 } 458 }
459 459
460 void SendInputEventACK(WebInputEvent::Type type, 460 void SendInputEventACK(WebInputEvent::Type type,
461 InputEventAckState ack_result) { 461 InputEventAckState ack_result) {
462 InputHostMsg_HandleInputEvent_ACK_Params ack; 462 DCHECK(!WebInputEvent::isTouchEventType(type));
463 ack.type = type; 463 InputEventAck ack(type, ack_result);
464 ack.state = ack_result;
465 host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); 464 host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack));
466 } 465 }
467 466
467 uint32 LastSentEventID() {
468 uint32 last_sent_event_id = 0;
469 size_t count = process_->sink().message_count();
470 DCHECK_GT(count, 0U);
471 for (size_t i = 0; i < count; ++i) {
472 const WebInputEvent* input_event =
473 GetInputEventFromMessage(*process_->sink().GetMessageAt(i));
474 last_sent_event_id =
475 WebInputEventTraits::GetUniqueTouchEventId(*input_event);
476 }
477 return last_sent_event_id;
478 }
479
468 double GetNextSimulatedEventTimeSeconds() { 480 double GetNextSimulatedEventTimeSeconds() {
469 last_simulated_event_time_seconds_ += simulated_event_time_delta_seconds_; 481 last_simulated_event_time_seconds_ += simulated_event_time_delta_seconds_;
470 return last_simulated_event_time_seconds_; 482 return last_simulated_event_time_seconds_;
471 } 483 }
472 484
473 void SimulateKeyboardEvent(WebInputEvent::Type type) { 485 void SimulateKeyboardEvent(WebInputEvent::Type type) {
474 SimulateKeyboardEvent(type, 0); 486 SimulateKeyboardEvent(type, 0);
475 } 487 }
476 488
477 void SimulateKeyboardEvent(WebInputEvent::Type type, int modifiers) { 489 void SimulateKeyboardEvent(WebInputEvent::Type type, int modifiers) {
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 blink::WebGestureDeviceTouchscreen, 1441 blink::WebGestureDeviceTouchscreen,
1430 ui::LatencyInfo()); 1442 ui::LatencyInfo());
1431 CheckLatencyInfoComponentInMessage( 1443 CheckLatencyInfoComponentInMessage(
1432 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollUpdate); 1444 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollUpdate);
1433 SendInputEventACK(WebInputEvent::GestureScrollUpdate, 1445 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
1434 INPUT_EVENT_ACK_STATE_CONSUMED); 1446 INPUT_EVENT_ACK_STATE_CONSUMED);
1435 1447
1436 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). 1448 // Tests RWHI::ForwardTouchEventWithLatencyInfo().
1437 PressTouchPoint(0, 1); 1449 PressTouchPoint(0, 1);
1438 SendTouchEvent(); 1450 SendTouchEvent();
1451 InputEventAck ack(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED);
1452 ack.unique_touch_event_id = LastSentEventID();
1453 host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack));
1439 CheckLatencyInfoComponentInMessage( 1454 CheckLatencyInfoComponentInMessage(
1440 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); 1455 process_, GetLatencyComponentId(), WebInputEvent::TouchStart);
1441 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED);
1442 } 1456 }
1443 1457
1444 TEST_F(RenderWidgetHostTest, RendererExitedResetsInputRouter) { 1458 TEST_F(RenderWidgetHostTest, RendererExitedResetsInputRouter) {
1445 // RendererExited will delete the view. 1459 // RendererExited will delete the view.
1446 host_->SetView(new TestView(host_.get())); 1460 host_->SetView(new TestView(host_.get()));
1447 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 1461 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
1448 1462
1449 // Make sure the input router is in a fresh state. 1463 // Make sure the input router is in a fresh state.
1450 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); 1464 ASSERT_FALSE(host_->input_router()->HasPendingEvents());
1451 } 1465 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 // Having an initial size set means that the size information had been sent 1507 // Having an initial size set means that the size information had been sent
1494 // with the reqiest to new up the RenderView and so subsequent WasResized 1508 // with the reqiest to new up the RenderView and so subsequent WasResized
1495 // calls should not result in new IPC (unless the size has actually changed). 1509 // calls should not result in new IPC (unless the size has actually changed).
1496 host_->WasResized(); 1510 host_->WasResized();
1497 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID)); 1511 EXPECT_FALSE(process_->sink().GetUniqueMessageMatching(ViewMsg_Resize::ID));
1498 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size); 1512 EXPECT_EQ(initial_size_, host_->old_resize_params_->new_size);
1499 EXPECT_TRUE(host_->resize_ack_pending_); 1513 EXPECT_TRUE(host_->resize_ack_pending_);
1500 } 1514 }
1501 1515
1502 } // namespace content 1516 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698