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