| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/input/synthetic_gesture_controller.h" | 5 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1465 static_cast<MockSyntheticTapMouseTarget*>(target_); | 1465 static_cast<MockSyntheticTapMouseTarget*>(target_); |
| 1466 EXPECT_EQ(1, num_success_); | 1466 EXPECT_EQ(1, num_success_); |
| 1467 EXPECT_EQ(0, num_failure_); | 1467 EXPECT_EQ(0, num_failure_); |
| 1468 EXPECT_TRUE(tap_target->GestureFinished()); | 1468 EXPECT_TRUE(tap_target->GestureFinished()); |
| 1469 EXPECT_EQ(tap_target->position(), params.position); | 1469 EXPECT_EQ(tap_target->position(), params.position); |
| 1470 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); | 1470 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); |
| 1471 EXPECT_GE(GetTotalTime(), | 1471 EXPECT_GE(GetTotalTime(), |
| 1472 base::TimeDelta::FromMilliseconds(params.duration_ms)); | 1472 base::TimeDelta::FromMilliseconds(params.duration_ms)); |
| 1473 } | 1473 } |
| 1474 | 1474 |
| 1475 TEST_F(SyntheticGestureControllerTest, PointerTouchAction) { | |
| 1476 CreateControllerAndTarget<MockSyntheticPointerTouchActionTarget>(); | |
| 1477 | |
| 1478 SyntheticPointerActionParams params = SyntheticPointerActionParams( | |
| 1479 SyntheticPointerActionParams::PointerActionType::PRESS); | |
| 1480 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | |
| 1481 params.set_index(0); | |
| 1482 params.set_position(gfx::PointF(54, 89)); | |
| 1483 SyntheticTouchPointer synthetic_pointer; | |
| 1484 | |
| 1485 std::unique_ptr<SyntheticPointerAction> gesture( | |
| 1486 new SyntheticPointerAction(params, &synthetic_pointer)); | |
| 1487 QueueSyntheticGesture(std::move(gesture)); | |
| 1488 FlushInputUntilComplete(); | |
| 1489 | |
| 1490 MockSyntheticPointerTouchActionTarget* pointer_touch_target = | |
| 1491 static_cast<MockSyntheticPointerTouchActionTarget*>(target_); | |
| 1492 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); | |
| 1493 EXPECT_EQ(pointer_touch_target->positions(0), params.position()); | |
| 1494 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); | |
| 1495 ASSERT_EQ(pointer_touch_target->touch_length(), 1U); | |
| 1496 | |
| 1497 params.set_index(1); | |
| 1498 params.set_position(gfx::PointF(79, 132)); | |
| 1499 gesture.reset(new SyntheticPointerAction(params, &synthetic_pointer)); | |
| 1500 QueueSyntheticGesture(std::move(gesture)); | |
| 1501 FlushInputUntilComplete(); | |
| 1502 | |
| 1503 pointer_touch_target = | |
| 1504 static_cast<MockSyntheticPointerTouchActionTarget*>(target_); | |
| 1505 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); | |
| 1506 EXPECT_EQ(pointer_touch_target->indexes(1), params.index()); | |
| 1507 EXPECT_EQ(pointer_touch_target->positions(1), params.position()); | |
| 1508 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StatePressed); | |
| 1509 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); | |
| 1510 | |
| 1511 params.set_pointer_action_type( | |
| 1512 SyntheticPointerActionParams::PointerActionType::MOVE); | |
| 1513 params.set_position(gfx::PointF(133, 156)); | |
| 1514 gesture.reset(new SyntheticPointerAction(params, &synthetic_pointer)); | |
| 1515 QueueSyntheticGesture(std::move(gesture)); | |
| 1516 FlushInputUntilComplete(); | |
| 1517 | |
| 1518 pointer_touch_target = | |
| 1519 static_cast<MockSyntheticPointerTouchActionTarget*>(target_); | |
| 1520 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchMove); | |
| 1521 EXPECT_EQ(pointer_touch_target->positions(1), params.position()); | |
| 1522 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateMoved); | |
| 1523 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); | |
| 1524 | |
| 1525 params.set_pointer_action_type( | |
| 1526 SyntheticPointerActionParams::PointerActionType::RELEASE); | |
| 1527 gesture.reset(new SyntheticPointerAction(params, &synthetic_pointer)); | |
| 1528 QueueSyntheticGesture(std::move(gesture)); | |
| 1529 FlushInputUntilComplete(); | |
| 1530 | |
| 1531 pointer_touch_target = | |
| 1532 static_cast<MockSyntheticPointerTouchActionTarget*>(target_); | |
| 1533 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchEnd); | |
| 1534 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased); | |
| 1535 } | |
| 1536 | |
| 1537 } // namespace | 1475 } // namespace |
| 1538 | 1476 |
| 1539 } // namespace content | 1477 } // namespace content |
| OLD | NEW |