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

Unified Diff: content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc

Issue 2478423002: Rename SyntheticPointer to SyntheticPointerDriver (Closed)
Patch Set: rename Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
diff --git a/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc b/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
index e4b0f9d22f73427a2a71e9ddcd7e0eb6b5db5553..b2fb9bd97be2091b3260274ce2f7b3a2f22364d7 100644
--- a/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
+++ b/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
@@ -7,7 +7,7 @@
#include "content/browser/renderer_host/input/synthetic_gesture.h"
#include "content/browser/renderer_host/input/synthetic_gesture_target.h"
#include "content/browser/renderer_host/input/synthetic_pointer_action.h"
-#include "content/browser/renderer_host/input/synthetic_touch_pointer.h"
+#include "content/browser/renderer_host/input/synthetic_touch_driver.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/gfx/geometry/point.h"
@@ -120,7 +120,6 @@ class SyntheticPointerActionTest : public testing::Test {
public:
SyntheticPointerActionTest() {
action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- std::fill(index_map_.begin(), index_map_.end(), -1);
num_success_ = 0;
num_failure_ = 0;
}
@@ -130,13 +129,13 @@ class SyntheticPointerActionTest : public testing::Test {
template <typename MockGestureTarget>
void CreateSyntheticPointerActionTarget() {
target_.reset(new MockGestureTarget());
- synthetic_pointer_ = SyntheticPointer::Create(
+ synthetic_pointer_driver_ = SyntheticPointerDriver::Create(
target_->GetDefaultSyntheticGestureSourceType());
}
void ForwardSyntheticPointerAction() {
pointer_action_.reset(new SyntheticPointerAction(
- std::move(action_param_list_), synthetic_pointer_.get(), &index_map_));
+ action_param_list_.get(), synthetic_pointer_driver_.get()));
SyntheticGesture::Result result = pointer_action_->ForwardInputEvents(
base::TimeTicks::Now(), target_.get());
@@ -151,9 +150,8 @@ class SyntheticPointerActionTest : public testing::Test {
int num_failure_;
std::unique_ptr<MockSyntheticPointerActionTarget> target_;
std::unique_ptr<SyntheticGesture> pointer_action_;
- std::unique_ptr<SyntheticPointer> synthetic_pointer_;
+ std::unique_ptr<SyntheticPointerDriver> synthetic_pointer_driver_;
std::unique_ptr<std::vector<SyntheticPointerActionParams>> action_param_list_;
- SyntheticPointerAction::IndexMap index_map_;
};
TEST_F(SyntheticPointerActionTest, PointerTouchAction) {
@@ -163,7 +161,6 @@ TEST_F(SyntheticPointerActionTest, PointerTouchAction) {
SyntheticPointerActionParams params0 = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::PRESS);
params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
- params0.set_index(0);
params0.set_position(gfx::PointF(54, 89));
action_param_list_->push_back(params0);
ForwardSyntheticPointerAction();
@@ -174,23 +171,20 @@ TEST_F(SyntheticPointerActionTest, PointerTouchAction) {
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(index_map_[0], 0);
+ EXPECT_EQ(action_param_list_->at(0).index(), 0);
EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89));
EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed);
ASSERT_EQ(pointer_touch_target->touch_length(), 1U);
// Send a touch move for the first finger and a touch press for the second
// finger.
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params0.set_pointer_action_type(
+ action_param_list_->at(0).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::MOVE);
- params0.set_position(gfx::PointF(133, 156));
+ action_param_list_->at(0).set_position(gfx::PointF(133, 156));
SyntheticPointerActionParams params1 = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::PRESS);
params1.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
- params1.set_index(1);
params1.set_position(gfx::PointF(79, 132));
- action_param_list_->push_back(params0);
action_param_list_->push_back(params1);
ForwardSyntheticPointerAction();
@@ -199,86 +193,49 @@ TEST_F(SyntheticPointerActionTest, PointerTouchAction) {
// The type of the SyntheticWebTouchEvent is the action of the last finger.
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(index_map_[0], 0);
+ EXPECT_EQ(action_param_list_->at(0).index(), 0);
EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(133, 156));
EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StateMoved);
EXPECT_EQ(pointer_touch_target->indexes(1), 1);
- EXPECT_EQ(index_map_[1], 1);
+ EXPECT_EQ(action_param_list_->at(1).index(), 1);
EXPECT_EQ(pointer_touch_target->positions(1), gfx::PointF(79, 132));
EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StatePressed);
ASSERT_EQ(pointer_touch_target->touch_length(), 2U);
// Send a touch move for the second finger.
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params1.set_pointer_action_type(
+ action_param_list_->at(1).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::MOVE);
- params1.set_position(gfx::PointF(87, 253));
- action_param_list_->push_back(params1);
+ action_param_list_->at(1).set_position(gfx::PointF(87, 253));
ForwardSyntheticPointerAction();
EXPECT_EQ(3, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchMove);
EXPECT_EQ(pointer_touch_target->indexes(1), 1);
- EXPECT_EQ(index_map_[1], 1);
+ EXPECT_EQ(action_param_list_->at(1).index(), 1);
EXPECT_EQ(pointer_touch_target->positions(1), gfx::PointF(87, 253));
EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateMoved);
ASSERT_EQ(pointer_touch_target->touch_length(), 2U);
// Send touch releases for both fingers.
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params0.set_pointer_action_type(
+ action_param_list_->at(0).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::RELEASE);
- params1.set_pointer_action_type(
+ action_param_list_->at(1).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::RELEASE);
- action_param_list_->push_back(params0);
- action_param_list_->push_back(params1);
ForwardSyntheticPointerAction();
EXPECT_EQ(4, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchEnd);
EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(index_map_[0], -1);
+ EXPECT_EQ(action_param_list_->at(0).index(), -1);
EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StateReleased);
EXPECT_EQ(pointer_touch_target->indexes(1), 1);
- EXPECT_EQ(index_map_[1], -1);
+ EXPECT_EQ(action_param_list_->at(1).index(), -1);
EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased);
ASSERT_EQ(pointer_touch_target->touch_length(), 2U);
}
-TEST_F(SyntheticPointerActionTest, PointerTouchActionIndexInvalid) {
- CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>();
-
- // Users sent a wrong index for the touch action.
- SyntheticPointerActionParams params0 = SyntheticPointerActionParams(
- SyntheticPointerActionParams::PointerActionType::PRESS);
- params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
- params0.set_index(-1);
- params0.set_position(gfx::PointF(54, 89));
- action_param_list_->push_back(params0);
- ForwardSyntheticPointerAction();
-
- EXPECT_EQ(0, num_success_);
- EXPECT_EQ(1, num_failure_);
-
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params0.set_index(0);
- action_param_list_->push_back(params0);
- ForwardSyntheticPointerAction();
-
- MockSyntheticPointerTouchActionTarget* pointer_touch_target =
- static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get());
- EXPECT_EQ(1, num_success_);
- EXPECT_EQ(1, num_failure_);
- EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
- EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(index_map_[0], 0);
- EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89));
- EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed);
- ASSERT_EQ(pointer_touch_target->touch_length(), 1U);
-}
-
TEST_F(SyntheticPointerActionTest, PointerTouchActionSourceTypeInvalid) {
CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>();
@@ -286,7 +243,6 @@ TEST_F(SyntheticPointerActionTest, PointerTouchActionSourceTypeInvalid) {
SyntheticPointerActionParams params0 = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::PRESS);
params0.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
- params0.set_index(0);
params0.set_position(gfx::PointF(54, 89));
action_param_list_->push_back(params0);
ForwardSyntheticPointerAction();
@@ -294,9 +250,8 @@ TEST_F(SyntheticPointerActionTest, PointerTouchActionSourceTypeInvalid) {
EXPECT_EQ(0, num_success_);
EXPECT_EQ(1, num_failure_);
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
- action_param_list_->push_back(params0);
+ action_param_list_->at(0).gesture_source_type =
+ SyntheticGestureParams::TOUCH_INPUT;
ForwardSyntheticPointerAction();
MockSyntheticPointerTouchActionTarget* pointer_touch_target =
@@ -305,7 +260,7 @@ TEST_F(SyntheticPointerActionTest, PointerTouchActionSourceTypeInvalid) {
EXPECT_EQ(1, num_failure_);
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(index_map_[0], 0);
+ EXPECT_EQ(action_param_list_->at(0).index(), 0);
EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89));
EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed);
ASSERT_EQ(pointer_touch_target->touch_length(), 1U);
@@ -319,7 +274,6 @@ TEST_F(SyntheticPointerActionTest, PointerTouchActionTypeInvalid) {
SyntheticPointerActionParams params0 = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::MOVE);
params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
- params0.set_index(0);
params0.set_position(gfx::PointF(54, 89));
action_param_list_->push_back(params0);
ForwardSyntheticPointerAction();
@@ -327,20 +281,16 @@ TEST_F(SyntheticPointerActionTest, PointerTouchActionTypeInvalid) {
EXPECT_EQ(0, num_success_);
EXPECT_EQ(1, num_failure_);
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params0.set_pointer_action_type(
+ action_param_list_->at(0).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::RELEASE);
- action_param_list_->push_back(params0);
ForwardSyntheticPointerAction();
EXPECT_EQ(0, num_success_);
EXPECT_EQ(2, num_failure_);
// Send a touch press for one finger.
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params0.set_pointer_action_type(
+ action_param_list_->at(0).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::PRESS);
- action_param_list_->push_back(params0);
ForwardSyntheticPointerAction();
MockSyntheticPointerTouchActionTarget* pointer_touch_target =
@@ -349,18 +299,16 @@ TEST_F(SyntheticPointerActionTest, PointerTouchActionTypeInvalid) {
EXPECT_EQ(2, num_failure_);
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(index_map_[0], 0);
+ EXPECT_EQ(action_param_list_->at(0).index(), 0);
EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89));
EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed);
ASSERT_EQ(pointer_touch_target->touch_length(), 1U);
// Cannot send a touch press again without releasing the finger.
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
- params0.set_index(0);
- params0.set_pointer_action_type(
+ action_param_list_->at(0).gesture_source_type =
+ SyntheticGestureParams::TOUCH_INPUT;
+ action_param_list_->at(0).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::PRESS);
- action_param_list_->push_back(params0);
ForwardSyntheticPointerAction();
EXPECT_EQ(1, num_success_);
@@ -374,7 +322,6 @@ TEST_F(SyntheticPointerActionTest, PointerMouseAction) {
SyntheticPointerActionParams params = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::MOVE);
params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
- params.set_index(0);
params.set_position(gfx::PointF(189, 62));
action_param_list_->push_back(params);
ForwardSyntheticPointerAction();
@@ -389,11 +336,9 @@ TEST_F(SyntheticPointerActionTest, PointerMouseAction) {
EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::NoButton);
// Send a mouse down.
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params.set_position(gfx::PointF(189, 62));
- params.set_pointer_action_type(
+ action_param_list_->at(0).set_position(gfx::PointF(189, 62));
+ action_param_list_->at(0).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::PRESS);
- action_param_list_->push_back(params);
ForwardSyntheticPointerAction();
EXPECT_EQ(2, num_success_);
@@ -404,25 +349,22 @@ TEST_F(SyntheticPointerActionTest, PointerMouseAction) {
EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left);
// Send a mouse drag.
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params.set_position(gfx::PointF(326, 298));
- params.set_pointer_action_type(
+ action_param_list_->at(0).set_position(gfx::PointF(326, 298));
+ action_param_list_->at(0).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::MOVE);
- action_param_list_->push_back(params);
ForwardSyntheticPointerAction();
EXPECT_EQ(3, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseMove);
- EXPECT_EQ(pointer_mouse_target->position(), params.position());
+ EXPECT_EQ(pointer_mouse_target->position(),
+ action_param_list_->at(0).position());
EXPECT_EQ(pointer_mouse_target->clickCount(), 1);
EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left);
// Send a mouse up.
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params.set_pointer_action_type(
+ action_param_list_->at(0).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::RELEASE);
- action_param_list_->push_back(params);
ForwardSyntheticPointerAction();
EXPECT_EQ(4, num_success_);
@@ -439,7 +381,6 @@ TEST_F(SyntheticPointerActionTest, PointerMouseActionSourceTypeInvalid) {
SyntheticPointerActionParams params = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::PRESS);
params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
- params.set_index(0);
params.set_position(gfx::PointF(54, 89));
action_param_list_->push_back(params);
ForwardSyntheticPointerAction();
@@ -447,9 +388,8 @@ TEST_F(SyntheticPointerActionTest, PointerMouseActionSourceTypeInvalid) {
EXPECT_EQ(0, num_success_);
EXPECT_EQ(1, num_failure_);
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
- action_param_list_->push_back(params);
+ action_param_list_->at(0).gesture_source_type =
+ SyntheticGestureParams::MOUSE_INPUT;
ForwardSyntheticPointerAction();
MockSyntheticPointerMouseActionTarget* pointer_mouse_target =
@@ -469,7 +409,6 @@ TEST_F(SyntheticPointerActionTest, PointerMouseActionTypeInvalid) {
SyntheticPointerActionParams params = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::MOVE);
params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
- params.set_index(0);
params.set_position(gfx::PointF(189, 62));
action_param_list_->push_back(params);
ForwardSyntheticPointerAction();
@@ -484,20 +423,16 @@ TEST_F(SyntheticPointerActionTest, PointerMouseActionTypeInvalid) {
EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::NoButton);
// Cannot send a mouse up without sending a mouse down first.
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params.set_pointer_action_type(
+ action_param_list_->at(0).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::RELEASE);
- action_param_list_->push_back(params);
ForwardSyntheticPointerAction();
EXPECT_EQ(1, num_success_);
EXPECT_EQ(1, num_failure_);
// Send a mouse down for one finger.
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params.set_pointer_action_type(
+ action_param_list_->at(0).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::PRESS);
- action_param_list_->push_back(params);
ForwardSyntheticPointerAction();
EXPECT_EQ(2, num_success_);
@@ -508,10 +443,8 @@ TEST_F(SyntheticPointerActionTest, PointerMouseActionTypeInvalid) {
EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left);
// Cannot send a mouse down again without releasing the mouse button.
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
- params.set_pointer_action_type(
+ action_param_list_->at(0).set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::PRESS);
- action_param_list_->push_back(params);
ForwardSyntheticPointerAction();
EXPECT_EQ(2, num_success_);

Powered by Google App Engine
This is Rietveld 408576698