Chromium Code Reviews| 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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
| 8 #include "base/timer.h" | 8 #include "base/timer.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/browser/renderer_host/backing_store.h" | 10 #include "content/browser/renderer_host/backing_store.h" |
| 11 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 11 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 12 #include "content/browser/renderer_host/gesture_event_filter.h" | 12 #include "content/browser/renderer_host/gesture_event_filter.h" |
| 13 #include "content/browser/renderer_host/tap_suppression_controller.h" | |
|
rjkroege
2012/11/16 16:33:57
these need to be in alphabetical order.
mohsen
2012/11/19 19:30:27
I have put the header I included in the right plac
| |
| 13 #include "content/browser/renderer_host/test_render_view_host.h" | 14 #include "content/browser/renderer_host/test_render_view_host.h" |
| 14 #include "content/browser/renderer_host/touch_event_queue.h" | 15 #include "content/browser/renderer_host/touch_event_queue.h" |
| 15 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
| 16 #include "content/port/browser/render_widget_host_view_port.h" | 17 #include "content/port/browser/render_widget_host_view_port.h" |
| 17 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 21 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 22 #include "content/public/test/mock_render_process_host.h" | 23 #include "content/public/test/mock_render_process_host.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 // Allow poking at a few private members. | 62 // Allow poking at a few private members. |
| 62 using RenderWidgetHostImpl::OnMsgPaintAtSizeAck; | 63 using RenderWidgetHostImpl::OnMsgPaintAtSizeAck; |
| 63 using RenderWidgetHostImpl::OnMsgUpdateRect; | 64 using RenderWidgetHostImpl::OnMsgUpdateRect; |
| 64 using RenderWidgetHostImpl::RendererExited; | 65 using RenderWidgetHostImpl::RendererExited; |
| 65 using RenderWidgetHostImpl::in_flight_size_; | 66 using RenderWidgetHostImpl::in_flight_size_; |
| 66 using RenderWidgetHostImpl::is_hidden_; | 67 using RenderWidgetHostImpl::is_hidden_; |
| 67 using RenderWidgetHostImpl::resize_ack_pending_; | 68 using RenderWidgetHostImpl::resize_ack_pending_; |
| 68 using RenderWidgetHostImpl::gesture_event_filter_; | 69 using RenderWidgetHostImpl::gesture_event_filter_; |
| 69 using RenderWidgetHostImpl::touch_event_queue_; | 70 using RenderWidgetHostImpl::touch_event_queue_; |
| 70 | 71 |
| 72 enum TapSuppressionState { | |
| 73 TSC_NOTHING = TapSuppressionController::NOTHING, | |
| 74 TSC_GFC_IN_PROGRESS = TapSuppressionController::GFC_IN_PROGRESS, | |
| 75 TSC_MD_STASHED = TapSuppressionController::MD_STASHED, | |
| 76 TSC_LAST_CANCEL_STOPPED_FLING = | |
| 77 TapSuppressionController::LAST_CANCEL_STOPPED_FLING, | |
| 78 }; | |
|
mohsen
2012/11/19 19:30:27
Since TapSuppressionController::State enum was not
rjkroege
2012/11/19 22:18:01
This is fine.
| |
| 79 | |
| 71 bool unresponsive_timer_fired() const { | 80 bool unresponsive_timer_fired() const { |
| 72 return unresponsive_timer_fired_; | 81 return unresponsive_timer_fired_; |
| 73 } | 82 } |
| 74 | 83 |
| 75 void set_hung_renderer_delay_ms(int delay_ms) { | 84 void set_hung_renderer_delay_ms(int delay_ms) { |
| 76 hung_renderer_delay_ms_ = delay_ms; | 85 hung_renderer_delay_ms_ = delay_ms; |
| 77 } | 86 } |
| 78 | 87 |
| 79 WebGestureEvent GestureEventLastQueueEvent() { | 88 WebGestureEvent GestureEventLastQueueEvent() { |
| 80 return gesture_event_filter_->coalesced_gesture_events_.back(); | 89 return gesture_event_filter_->coalesced_gesture_events_.back(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 93 } | 102 } |
| 94 | 103 |
| 95 bool ScrollingInProgress() { | 104 bool ScrollingInProgress() { |
| 96 return gesture_event_filter_->scrolling_in_progress_; | 105 return gesture_event_filter_->scrolling_in_progress_; |
| 97 } | 106 } |
| 98 | 107 |
| 99 bool FlingInProgress() { | 108 bool FlingInProgress() { |
| 100 return gesture_event_filter_->fling_in_progress_; | 109 return gesture_event_filter_->fling_in_progress_; |
| 101 } | 110 } |
| 102 | 111 |
| 112 TapSuppressionState TapSuppressionControllerState() { | |
| 113 return static_cast<TapSuppressionState>( | |
| 114 gesture_event_filter_->tap_suppression_controller_->state_); | |
| 115 } | |
| 116 | |
| 103 void set_maximum_tap_gap_time_ms(int delay_ms) { | 117 void set_maximum_tap_gap_time_ms(int delay_ms) { |
| 104 gesture_event_filter_->maximum_tap_gap_time_ms_ = delay_ms; | 118 gesture_event_filter_->maximum_tap_gap_time_ms_ = delay_ms; |
| 105 } | 119 } |
| 106 | 120 |
| 107 void set_debounce_interval_time_ms(int delay_ms) { | 121 void set_debounce_interval_time_ms(int delay_ms) { |
| 108 gesture_event_filter_->debounce_interval_time_ms_ = delay_ms; | 122 gesture_event_filter_->debounce_interval_time_ms_ = delay_ms; |
| 109 } | 123 } |
| 110 | 124 |
| 111 size_t TouchEventQueueSize() { | 125 size_t TouchEventQueueSize() { |
| 112 return touch_event_queue_->GetQueueSize(); | 126 return touch_event_queue_->GetQueueSize(); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 host_->OnMessageReceived(*response); | 437 host_->OnMessageReceived(*response); |
| 424 } | 438 } |
| 425 | 439 |
| 426 void SimulateKeyboardEvent(WebInputEvent::Type type) { | 440 void SimulateKeyboardEvent(WebInputEvent::Type type) { |
| 427 NativeWebKeyboardEvent key_event; | 441 NativeWebKeyboardEvent key_event; |
| 428 key_event.type = type; | 442 key_event.type = type; |
| 429 key_event.windowsKeyCode = ui::VKEY_L; // non-null made up value. | 443 key_event.windowsKeyCode = ui::VKEY_L; // non-null made up value. |
| 430 host_->ForwardKeyboardEvent(key_event); | 444 host_->ForwardKeyboardEvent(key_event); |
| 431 } | 445 } |
| 432 | 446 |
| 447 void SimulateMouseEvent(WebInputEvent::Type type) { | |
| 448 WebMouseWheelEvent mouse_event; | |
| 449 mouse_event.type = type; | |
| 450 host_->ForwardMouseEvent(mouse_event); | |
| 451 } | |
| 452 | |
| 433 void SimulateWheelEvent(float dX, float dY, int modifiers) { | 453 void SimulateWheelEvent(float dX, float dY, int modifiers) { |
| 434 WebMouseWheelEvent wheel_event; | 454 WebMouseWheelEvent wheel_event; |
| 435 wheel_event.type = WebInputEvent::MouseWheel; | 455 wheel_event.type = WebInputEvent::MouseWheel; |
| 436 wheel_event.deltaX = dX; | 456 wheel_event.deltaX = dX; |
| 437 wheel_event.deltaY = dY; | 457 wheel_event.deltaY = dY; |
| 438 wheel_event.modifiers = modifiers; | 458 wheel_event.modifiers = modifiers; |
| 439 host_->ForwardWheelEvent(wheel_event); | 459 host_->ForwardWheelEvent(wheel_event); |
| 440 } | 460 } |
| 441 | 461 |
| 442 // Inject simple synthetic WebGestureEvent instances. | 462 // Inject simple synthetic WebGestureEvent instances. |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1359 WebInputEvent::GestureScrollUpdate, | 1379 WebInputEvent::GestureScrollUpdate, |
| 1360 WebInputEvent::GestureScrollUpdate}; | 1380 WebInputEvent::GestureScrollUpdate}; |
| 1361 | 1381 |
| 1362 for (unsigned i = 0; i < sizeof(expected) / sizeof(WebInputEvent::Type); | 1382 for (unsigned i = 0; i < sizeof(expected) / sizeof(WebInputEvent::Type); |
| 1363 i++) { | 1383 i++) { |
| 1364 WebGestureEvent merged_event = host_->GestureEventQueueEventAt(i); | 1384 WebGestureEvent merged_event = host_->GestureEventQueueEventAt(i); |
| 1365 EXPECT_EQ(expected[i], merged_event.type); | 1385 EXPECT_EQ(expected[i], merged_event.type); |
| 1366 } | 1386 } |
| 1367 } | 1387 } |
| 1368 | 1388 |
| 1389 // Test TapSuppressionController - GestureFlingCancel Ack comes before | |
|
rjkroege
2012/11/16 16:33:57
comments need to be complete sentences. with perio
mohsen
2012/11/19 19:30:27
Done.
| |
| 1390 // MouseDown and everything happens without any delays | |
| 1391 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseFast) { | |
| 1392 process_->sink().ClearMessages(); | |
| 1393 | |
| 1394 // GestureFlingStart | |
| 1395 SimulateGestureFlingStartEvent(0, -10); | |
| 1396 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1397 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1398 EXPECT_EQ(WebInputEvent::GestureFlingStart, | |
| 1399 host_->GestureEventLastQueueEvent().type); | |
| 1400 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1401 host_->TapSuppressionControllerState()); | |
| 1402 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1403 | |
| 1404 // GestureFlingStart Ack | |
| 1405 SendInputEventACK(WebInputEvent::GestureFlingStart, true); | |
| 1406 MessageLoop::current()->RunUntilIdle(); | |
| 1407 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1408 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1409 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1410 host_->TapSuppressionControllerState()); | |
| 1411 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1412 | |
| 1413 // GestureFlingCancel | |
| 1414 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); | |
| 1415 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1416 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1417 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1418 host_->GestureEventLastQueueEvent().type); | |
| 1419 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | |
| 1420 host_->TapSuppressionControllerState()); | |
| 1421 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1422 | |
| 1423 // GestureFlingCancel Ack | |
| 1424 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); | |
| 1425 MessageLoop::current()->RunUntilIdle(); | |
| 1426 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1427 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1428 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | |
| 1429 host_->TapSuppressionControllerState()); | |
| 1430 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1431 | |
| 1432 // MouseDown - Should be suppressed | |
|
rjkroege
2012/11/16 16:33:57
please check if the test sets the tap cancel windo
mohsen
2012/11/19 19:30:27
I don't get this part. Could you please explain mo
rjkroege
2012/11/19 22:18:01
someday, tsc times (kMaxiumTapGapTimeMs, kMaxiumCa
mohsen
2012/11/19 22:51:12
So, this is the same point you mentioned under lin
| |
| 1433 SimulateMouseEvent(WebInputEvent::MouseDown); | |
| 1434 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1435 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1436 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1437 host_->GestureEventLastQueueEvent().type); | |
| 1438 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, | |
| 1439 host_->TapSuppressionControllerState()); | |
| 1440 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1441 | |
| 1442 // MouseUp - Should be suppressed | |
|
rjkroege
2012/11/16 16:33:57
there are two cases: mouseup in the time interval
| |
| 1443 SimulateMouseEvent(WebInputEvent::MouseUp); | |
| 1444 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1445 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1446 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1447 host_->GestureEventLastQueueEvent().type); | |
| 1448 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1449 host_->TapSuppressionControllerState()); | |
| 1450 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1451 } | |
| 1452 | |
| 1453 // Test TapSuppressionController - GestureFlingCancel Ack comes before | |
| 1454 // MouseDown, but there is a small delay between MouseDown and MouseUp | |
| 1455 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseInsufficientlyLateMouseUp) { | |
|
mohsen
2012/11/19 19:30:27
Having a delay between MouseDown and MouseUp has a
rjkroege
2012/11/19 22:18:01
you need this test (but adjusted) for configurable
mohsen
2012/11/19 22:51:12
So, I need to add similar tests in other places we
| |
| 1456 process_->sink().ClearMessages(); | |
| 1457 | |
| 1458 // GestureFlingStart | |
| 1459 SimulateGestureEvent(WebInputEvent::GestureFlingStart); | |
| 1460 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1461 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1462 EXPECT_EQ(WebInputEvent::GestureFlingStart, | |
| 1463 host_->GestureEventLastQueueEvent().type); | |
| 1464 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1465 host_->TapSuppressionControllerState()); | |
| 1466 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1467 | |
| 1468 // GestureFlingStart Ack | |
| 1469 SendInputEventACK(WebInputEvent::GestureFlingStart, true); | |
| 1470 MessageLoop::current()->RunUntilIdle(); | |
| 1471 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1472 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1473 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1474 host_->TapSuppressionControllerState()); | |
| 1475 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1476 | |
| 1477 // GestureFlingCancel | |
| 1478 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); | |
| 1479 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1480 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1481 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1482 host_->GestureEventLastQueueEvent().type); | |
| 1483 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | |
| 1484 host_->TapSuppressionControllerState()); | |
| 1485 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1486 | |
| 1487 // GestureFlingCancel Ack | |
| 1488 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); | |
| 1489 MessageLoop::current()->RunUntilIdle(); | |
| 1490 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1491 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1492 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | |
| 1493 host_->TapSuppressionControllerState()); | |
| 1494 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1495 | |
| 1496 // MouseDown - Should be suppressed | |
| 1497 SimulateMouseEvent(WebInputEvent::MouseDown); | |
| 1498 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1499 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1500 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, | |
| 1501 host_->TapSuppressionControllerState()); | |
| 1502 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1503 | |
| 1504 // Delay - Less than allowed delay between MouseDown and MouseUp to be | |
| 1505 // considered a tap | |
| 1506 MessageLoop::current()->PostDelayedTask(FROM_HERE, | |
| 1507 MessageLoop::QuitClosure(), | |
| 1508 TimeDelta::FromMilliseconds(100)); | |
| 1509 MessageLoop::current()->Run(); | |
| 1510 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1511 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1512 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, | |
| 1513 host_->TapSuppressionControllerState()); | |
| 1514 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1515 | |
| 1516 // MouseUp - Should be suppressed | |
| 1517 SimulateMouseEvent(WebInputEvent::MouseUp); | |
| 1518 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1519 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1520 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1521 host_->TapSuppressionControllerState()); | |
| 1522 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1523 } | |
| 1524 | |
| 1525 // Test TapSuppressionController - GestureFlingCancel Ack comes before | |
| 1526 // MouseDown, but there is a long delay between MouseDown and MouseUp | |
| 1527 TEST_F(RenderWidgetHostTest, GFCAckBeforeMouseSufficientlyLateMouseUp) { | |
| 1528 process_->sink().ClearMessages(); | |
| 1529 | |
| 1530 // GestureFlingStart | |
| 1531 SimulateGestureEvent(WebInputEvent::GestureFlingStart); | |
| 1532 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1533 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1534 EXPECT_EQ(WebInputEvent::GestureFlingStart, | |
| 1535 host_->GestureEventLastQueueEvent().type); | |
| 1536 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1537 host_->TapSuppressionControllerState()); | |
| 1538 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1539 | |
| 1540 // GestureFlingStart Ack | |
| 1541 SendInputEventACK(WebInputEvent::GestureFlingStart, true); | |
| 1542 MessageLoop::current()->RunUntilIdle(); | |
| 1543 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1544 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1545 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1546 host_->TapSuppressionControllerState()); | |
| 1547 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1548 | |
| 1549 // GestureFlingCancel | |
| 1550 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); | |
| 1551 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1552 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1553 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1554 host_->GestureEventLastQueueEvent().type); | |
| 1555 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | |
| 1556 host_->TapSuppressionControllerState()); | |
| 1557 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1558 | |
| 1559 // GestureFlingCancel Ack | |
| 1560 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); | |
| 1561 MessageLoop::current()->RunUntilIdle(); | |
| 1562 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1563 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1564 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | |
| 1565 host_->TapSuppressionControllerState()); | |
| 1566 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1567 | |
| 1568 // MouseDown - Should be suppressed for now | |
| 1569 SimulateMouseEvent(WebInputEvent::MouseDown); | |
| 1570 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1571 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1572 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, | |
| 1573 host_->TapSuppressionControllerState()); | |
| 1574 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1575 | |
| 1576 // Delay - More than allowed delay between MosueDown and MouseUp to be | |
| 1577 // considered a tap. This should release the stashed MouseDown | |
| 1578 MessageLoop::current()->PostDelayedTask(FROM_HERE, | |
| 1579 MessageLoop::QuitClosure(), | |
| 1580 TimeDelta::FromMilliseconds(300)); | |
| 1581 MessageLoop::current()->Run(); | |
| 1582 EXPECT_EQ(3U, process_->sink().message_count()); | |
| 1583 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1584 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1585 host_->TapSuppressionControllerState()); | |
| 1586 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1587 | |
| 1588 // MouseUp - Should not be suppressed | |
| 1589 SimulateMouseEvent(WebInputEvent::MouseUp); | |
| 1590 EXPECT_EQ(4U, process_->sink().message_count()); | |
| 1591 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1592 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1593 host_->TapSuppressionControllerState()); | |
| 1594 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1595 } | |
| 1596 | |
| 1597 // Test TapSuppressionController - Processed GestureFlingCancel Ack comes | |
| 1598 // before MouseDown, but there is a long delay between the Ack and MouseDown | |
| 1599 TEST_F(RenderWidgetHostTest, GFCAckProcessedBeforeMouseLateMouseDown) { | |
| 1600 process_->sink().ClearMessages(); | |
| 1601 | |
| 1602 // GestureFlingStart | |
| 1603 SimulateGestureEvent(WebInputEvent::GestureFlingStart); | |
| 1604 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1605 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1606 EXPECT_EQ(WebInputEvent::GestureFlingStart, | |
| 1607 host_->GestureEventLastQueueEvent().type); | |
| 1608 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1609 host_->TapSuppressionControllerState()); | |
| 1610 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1611 | |
| 1612 // GestureFlingStart Ack | |
| 1613 SendInputEventACK(WebInputEvent::GestureFlingStart, true); | |
| 1614 MessageLoop::current()->RunUntilIdle(); | |
| 1615 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1616 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1617 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1618 host_->TapSuppressionControllerState()); | |
| 1619 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1620 | |
| 1621 // GestureFlingCancel | |
| 1622 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); | |
| 1623 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1624 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1625 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1626 host_->GestureEventLastQueueEvent().type); | |
| 1627 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | |
| 1628 host_->TapSuppressionControllerState()); | |
| 1629 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1630 | |
| 1631 // Processed GestureFlingCancel Ack | |
| 1632 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); | |
| 1633 MessageLoop::current()->RunUntilIdle(); | |
| 1634 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1635 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1636 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | |
| 1637 host_->TapSuppressionControllerState()); | |
| 1638 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1639 | |
| 1640 // Delay - More than allowed delay between GestureFlingCancel and MouseDown | |
| 1641 // to cosider MouseDown associated with GestureFlingCancel | |
| 1642 MessageLoop::current()->PostDelayedTask(FROM_HERE, | |
| 1643 MessageLoop::QuitClosure(), | |
| 1644 TimeDelta::FromMilliseconds(500)); | |
|
rjkroege
2012/11/16 16:33:57
you need to set time window parameters and adjust
mohsen
2012/11/19 19:30:27
These parameters are not configurable by now. For
| |
| 1645 MessageLoop::current()->Run(); | |
| 1646 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1647 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1648 EXPECT_EQ(MockRenderWidgetHost::TSC_LAST_CANCEL_STOPPED_FLING, | |
| 1649 host_->TapSuppressionControllerState()); | |
| 1650 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1651 | |
| 1652 // MouseDown - Should not be suppressed | |
| 1653 SimulateMouseEvent(WebInputEvent::MouseDown); | |
| 1654 EXPECT_EQ(3U, process_->sink().message_count()); | |
| 1655 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1656 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1657 host_->TapSuppressionControllerState()); | |
| 1658 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1659 | |
| 1660 // MouseUp - Should not be suppressed | |
| 1661 SimulateMouseEvent(WebInputEvent::MouseUp); | |
| 1662 EXPECT_EQ(4U, process_->sink().message_count()); | |
| 1663 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1664 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1665 host_->TapSuppressionControllerState()); | |
| 1666 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1667 } | |
| 1668 | |
| 1669 // Test TapSuppressionController - Unprocessed GestureFlingCancel Ack comes | |
| 1670 // after MouseDown and everything happens without any delay | |
| 1671 TEST_F(RenderWidgetHostTest, GFCAckUnprocessedAfterMouseFast) { | |
| 1672 process_->sink().ClearMessages(); | |
| 1673 | |
| 1674 // GestureFlingStart | |
| 1675 SimulateGestureEvent(WebInputEvent::GestureFlingStart); | |
| 1676 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1677 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1678 EXPECT_EQ(WebInputEvent::GestureFlingStart, | |
| 1679 host_->GestureEventLastQueueEvent().type); | |
| 1680 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1681 host_->TapSuppressionControllerState()); | |
| 1682 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1683 | |
| 1684 // GestureFlingStart Ack | |
| 1685 SendInputEventACK(WebInputEvent::GestureFlingStart, true); | |
| 1686 MessageLoop::current()->RunUntilIdle(); | |
| 1687 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1688 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1689 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1690 host_->TapSuppressionControllerState()); | |
| 1691 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1692 | |
| 1693 // GestureFlingCancel | |
| 1694 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); | |
| 1695 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1696 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1697 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1698 host_->GestureEventLastQueueEvent().type); | |
| 1699 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | |
| 1700 host_->TapSuppressionControllerState()); | |
| 1701 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1702 | |
| 1703 // MouseDown - Should be suppressed | |
| 1704 SimulateMouseEvent(WebInputEvent::MouseDown); | |
| 1705 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1706 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1707 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1708 host_->GestureEventLastQueueEvent().type); | |
| 1709 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, | |
| 1710 host_->TapSuppressionControllerState()); | |
| 1711 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1712 | |
| 1713 // Unprocessed GestureFlingCancel Ack | |
| 1714 SendInputEventACK(WebInputEvent::GestureFlingCancel, false); | |
| 1715 MessageLoop::current()->RunUntilIdle(); | |
| 1716 EXPECT_EQ(3U, process_->sink().message_count()); | |
| 1717 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1718 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1719 host_->TapSuppressionControllerState()); | |
| 1720 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1721 | |
| 1722 // MouseUp - Should be suppressed | |
| 1723 SimulateMouseEvent(WebInputEvent::MouseUp); | |
| 1724 EXPECT_EQ(4U, process_->sink().message_count()); | |
| 1725 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1726 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1727 host_->TapSuppressionControllerState()); | |
| 1728 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1729 } | |
| 1730 | |
| 1731 // Test TapSuppressionController - GestureFlingCancel Ack comes after MouseDown | |
|
rjkroege
2012/11/16 16:33:57
this comment is the same as the above. but the tes
mohsen
2012/11/19 19:30:27
Something was messed up in comments. Corrected.
| |
| 1732 // and everything happens without any delay | |
| 1733 TEST_F(RenderWidgetHostTest, GFCAckAfterMouseFast) { | |
| 1734 process_->sink().ClearMessages(); | |
| 1735 | |
| 1736 // GestureFlingStart | |
| 1737 SimulateGestureEvent(WebInputEvent::GestureFlingStart); | |
| 1738 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1739 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1740 EXPECT_EQ(WebInputEvent::GestureFlingStart, | |
| 1741 host_->GestureEventLastQueueEvent().type); | |
| 1742 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1743 host_->TapSuppressionControllerState()); | |
| 1744 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1745 | |
| 1746 // GestureFlingStart Ack | |
| 1747 SendInputEventACK(WebInputEvent::GestureFlingStart, true); | |
| 1748 MessageLoop::current()->RunUntilIdle(); | |
| 1749 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1750 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1751 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1752 host_->TapSuppressionControllerState()); | |
| 1753 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1754 | |
| 1755 // GestureFlingCancel | |
| 1756 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); | |
| 1757 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1758 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1759 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1760 host_->GestureEventLastQueueEvent().type); | |
| 1761 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | |
| 1762 host_->TapSuppressionControllerState()); | |
| 1763 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1764 | |
| 1765 // MouseDown - Should be suppressed | |
| 1766 SimulateMouseEvent(WebInputEvent::MouseDown); | |
| 1767 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1768 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1769 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1770 host_->GestureEventLastQueueEvent().type); | |
| 1771 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, | |
| 1772 host_->TapSuppressionControllerState()); | |
| 1773 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1774 | |
| 1775 // GestureFlingCancel Ack | |
| 1776 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); | |
| 1777 MessageLoop::current()->RunUntilIdle(); | |
| 1778 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1779 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1780 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, | |
| 1781 host_->TapSuppressionControllerState()); | |
| 1782 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1783 | |
| 1784 // MouseUp - Should be suppressed | |
| 1785 SimulateMouseEvent(WebInputEvent::MouseUp); | |
| 1786 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1787 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1788 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1789 host_->TapSuppressionControllerState()); | |
| 1790 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1791 } | |
| 1792 | |
| 1793 // Test TapSuppressionController - GestureFlingCancel Ack comes after MouseDonw | |
|
rjkroege
2012/11/19 22:18:01
MouseDone
mohsen
2012/11/19 22:51:12
Corrected (MouseDown, in fact).
| |
| 1794 // and there is a long delay between the Ack and MouseUp | |
|
rjkroege
2012/11/19 22:18:01
period at the end.
mohsen
2012/11/19 22:51:12
All comments rewritten in full sentence form.
| |
| 1795 TEST_F(RenderWidgetHostTest, GFCAckAfterMouseLateMouseUp) { | |
| 1796 process_->sink().ClearMessages(); | |
| 1797 | |
| 1798 // GestureFlingStart | |
| 1799 SimulateGestureEvent(WebInputEvent::GestureFlingStart); | |
| 1800 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1801 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1802 EXPECT_EQ(WebInputEvent::GestureFlingStart, | |
| 1803 host_->GestureEventLastQueueEvent().type); | |
| 1804 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1805 host_->TapSuppressionControllerState()); | |
| 1806 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1807 | |
| 1808 // GestureFlingStart Ack | |
| 1809 SendInputEventACK(WebInputEvent::GestureFlingStart, true); | |
| 1810 MessageLoop::current()->RunUntilIdle(); | |
| 1811 EXPECT_EQ(1U, process_->sink().message_count()); | |
| 1812 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1813 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1814 host_->TapSuppressionControllerState()); | |
| 1815 EXPECT_TRUE(host_->FlingInProgress()); | |
| 1816 | |
| 1817 // GestureFlingCancel | |
| 1818 SimulateGestureEvent(WebInputEvent::GestureFlingCancel); | |
| 1819 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1820 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1821 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1822 host_->GestureEventLastQueueEvent().type); | |
| 1823 EXPECT_EQ(MockRenderWidgetHost::TSC_GFC_IN_PROGRESS, | |
| 1824 host_->TapSuppressionControllerState()); | |
| 1825 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1826 | |
| 1827 // MouseDown - Should be suppressed for now | |
| 1828 SimulateMouseEvent(WebInputEvent::MouseDown); | |
| 1829 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1830 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | |
| 1831 EXPECT_EQ(WebInputEvent::GestureFlingCancel, | |
| 1832 host_->GestureEventLastQueueEvent().type); | |
| 1833 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, | |
| 1834 host_->TapSuppressionControllerState()); | |
| 1835 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1836 | |
| 1837 // GestureFlingCancel Ack | |
| 1838 SendInputEventACK(WebInputEvent::GestureFlingCancel, true); | |
| 1839 MessageLoop::current()->RunUntilIdle(); | |
| 1840 EXPECT_EQ(2U, process_->sink().message_count()); | |
| 1841 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1842 EXPECT_EQ(MockRenderWidgetHost::TSC_MD_STASHED, | |
| 1843 host_->TapSuppressionControllerState()); | |
| 1844 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1845 | |
| 1846 // Delay - More than allowed delay between MouseDown and MouseUp to be | |
| 1847 // considered as a tap. This should release the stashed MouseDown | |
| 1848 MessageLoop::current()->PostDelayedTask(FROM_HERE, | |
| 1849 MessageLoop::QuitClosure(), | |
| 1850 TimeDelta::FromMilliseconds(300)); | |
| 1851 MessageLoop::current()->Run(); | |
| 1852 EXPECT_EQ(3U, process_->sink().message_count()); | |
| 1853 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1854 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1855 host_->TapSuppressionControllerState()); | |
| 1856 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1857 | |
| 1858 // MouseUp - Should not be suppressed | |
| 1859 SimulateMouseEvent(WebInputEvent::MouseUp); | |
| 1860 EXPECT_EQ(4U, process_->sink().message_count()); | |
| 1861 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | |
| 1862 EXPECT_EQ(MockRenderWidgetHost::TSC_NOTHING, | |
| 1863 host_->TapSuppressionControllerState()); | |
| 1864 EXPECT_FALSE(host_->FlingInProgress()); | |
| 1865 } | |
| 1866 | |
| 1369 // Tests that touch-events are queued properly. | 1867 // Tests that touch-events are queued properly. |
| 1370 TEST_F(RenderWidgetHostTest, TouchEventQueue) { | 1868 TEST_F(RenderWidgetHostTest, TouchEventQueue) { |
| 1371 process_->sink().ClearMessages(); | 1869 process_->sink().ClearMessages(); |
| 1372 | 1870 |
| 1373 PressTouchPoint(1, 1); | 1871 PressTouchPoint(1, 1); |
| 1374 SendTouchEvent(); | 1872 SendTouchEvent(); |
| 1375 EXPECT_EQ(1U, process_->sink().message_count()); | 1873 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1376 process_->sink().ClearMessages(); | 1874 process_->sink().ClearMessages(); |
| 1377 | 1875 |
| 1378 // The second touch should not be sent since one is already in queue. | 1876 // The second touch should not be sent since one is already in queue. |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1793 process_->InitUpdateRectParams(¶ms); | 2291 process_->InitUpdateRectParams(¶ms); |
| 1794 params.scale_factor = params.scale_factor * 2; | 2292 params.scale_factor = params.scale_factor * 2; |
| 1795 | 2293 |
| 1796 EXPECT_EQ(0, process_->bad_msg_count()); | 2294 EXPECT_EQ(0, process_->bad_msg_count()); |
| 1797 host_->OnMsgUpdateRect(params); | 2295 host_->OnMsgUpdateRect(params); |
| 1798 EXPECT_EQ(1, process_->bad_msg_count()); | 2296 EXPECT_EQ(1, process_->bad_msg_count()); |
| 1799 } | 2297 } |
| 1800 #endif | 2298 #endif |
| 1801 | 2299 |
| 1802 } // namespace content | 2300 } // namespace content |
| OLD | NEW |