Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/time/time.h" | 6 #include "base/time/time.h" |
| 7 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 7 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
| 8 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 8 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
| 9 #include "content/browser/renderer_host/input/synthetic_pointer_action.h" | 9 #include "content/browser/renderer_host/input/synthetic_pointer_action.h" |
| 10 #include "content/browser/renderer_host/input/synthetic_touch_pointer.h" | 10 #include "content/browser/renderer_host/input/synthetic_touch_driver.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "third_party/WebKit/public/web/WebInputEvent.h" | 12 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 13 #include "ui/gfx/geometry/point.h" | 13 #include "ui/gfx/geometry/point.h" |
| 14 #include "ui/gfx/geometry/point_f.h" | 14 #include "ui/gfx/geometry/point_f.h" |
| 15 | 15 |
| 16 using blink::WebInputEvent; | 16 using blink::WebInputEvent; |
| 17 using blink::WebTouchEvent; | 17 using blink::WebTouchEvent; |
| 18 using blink::WebMouseEvent; | 18 using blink::WebMouseEvent; |
| 19 using blink::WebTouchPoint; | 19 using blink::WebTouchPoint; |
| 20 | 20 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 private: | 113 private: |
| 114 gfx::PointF position_; | 114 gfx::PointF position_; |
| 115 int clickCount_; | 115 int clickCount_; |
| 116 WebMouseEvent::Button button_; | 116 WebMouseEvent::Button button_; |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 class SyntheticPointerActionTest : public testing::Test { | 119 class SyntheticPointerActionTest : public testing::Test { |
| 120 public: | 120 public: |
| 121 SyntheticPointerActionTest() { | 121 SyntheticPointerActionTest() { |
| 122 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 122 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); |
| 123 std::fill(index_map_.begin(), index_map_.end(), -1); | |
| 124 num_success_ = 0; | 123 num_success_ = 0; |
| 125 num_failure_ = 0; | 124 num_failure_ = 0; |
| 126 } | 125 } |
| 127 ~SyntheticPointerActionTest() override {} | 126 ~SyntheticPointerActionTest() override {} |
| 128 | 127 |
| 129 protected: | 128 protected: |
| 130 template <typename MockGestureTarget> | 129 template <typename MockGestureTarget> |
| 131 void CreateSyntheticPointerActionTarget() { | 130 void CreateSyntheticPointerActionTarget() { |
| 132 target_.reset(new MockGestureTarget()); | 131 target_.reset(new MockGestureTarget()); |
| 133 synthetic_pointer_ = SyntheticPointer::Create( | 132 synthetic_pointer_driver_ = SyntheticPointerDriver::Create( |
| 134 target_->GetDefaultSyntheticGestureSourceType()); | 133 target_->GetDefaultSyntheticGestureSourceType()); |
| 135 } | 134 } |
| 136 | 135 |
| 137 void ForwardSyntheticPointerAction() { | 136 void ForwardSyntheticPointerAction() { |
| 138 pointer_action_.reset(new SyntheticPointerAction( | 137 pointer_action_.reset(new SyntheticPointerAction( |
| 139 std::move(action_param_list_), synthetic_pointer_.get(), &index_map_)); | 138 action_param_list_.get(), synthetic_pointer_driver_.get())); |
| 140 | 139 |
| 141 SyntheticGesture::Result result = pointer_action_->ForwardInputEvents( | 140 SyntheticGesture::Result result = pointer_action_->ForwardInputEvents( |
| 142 base::TimeTicks::Now(), target_.get()); | 141 base::TimeTicks::Now(), target_.get()); |
| 143 | 142 |
| 144 if (result == SyntheticGesture::GESTURE_FINISHED) | 143 if (result == SyntheticGesture::GESTURE_FINISHED) |
| 145 num_success_++; | 144 num_success_++; |
| 146 else | 145 else |
| 147 num_failure_++; | 146 num_failure_++; |
| 148 } | 147 } |
| 149 | 148 |
| 150 int num_success_; | 149 int num_success_; |
| 151 int num_failure_; | 150 int num_failure_; |
| 152 std::unique_ptr<MockSyntheticPointerActionTarget> target_; | 151 std::unique_ptr<MockSyntheticPointerActionTarget> target_; |
| 153 std::unique_ptr<SyntheticGesture> pointer_action_; | 152 std::unique_ptr<SyntheticGesture> pointer_action_; |
| 154 std::unique_ptr<SyntheticPointer> synthetic_pointer_; | 153 std::unique_ptr<SyntheticPointerDriver> synthetic_pointer_driver_; |
| 155 std::unique_ptr<std::vector<SyntheticPointerActionParams>> action_param_list_; | 154 std::unique_ptr<std::vector<SyntheticPointerActionParams>> action_param_list_; |
| 156 SyntheticPointerAction::IndexMap index_map_; | |
| 157 }; | 155 }; |
| 158 | 156 |
| 159 TEST_F(SyntheticPointerActionTest, PointerTouchAction) { | 157 TEST_F(SyntheticPointerActionTest, PointerTouchAction) { |
| 160 CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>(); | 158 CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>(); |
| 161 | 159 |
| 162 // Send a touch press for one finger. | 160 // Send a touch press for one finger. |
| 163 SyntheticPointerActionParams params0 = SyntheticPointerActionParams( | 161 SyntheticPointerActionParams params0 = SyntheticPointerActionParams( |
| 164 SyntheticPointerActionParams::PointerActionType::PRESS); | 162 SyntheticPointerActionParams::PointerActionType::PRESS); |
| 165 params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 163 params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| 166 params0.set_index(0); | |
| 167 params0.set_position(gfx::PointF(54, 89)); | 164 params0.set_position(gfx::PointF(54, 89)); |
| 168 action_param_list_->push_back(params0); | 165 action_param_list_->push_back(params0); |
| 169 ForwardSyntheticPointerAction(); | 166 ForwardSyntheticPointerAction(); |
| 170 | 167 |
| 171 MockSyntheticPointerTouchActionTarget* pointer_touch_target = | 168 MockSyntheticPointerTouchActionTarget* pointer_touch_target = |
| 172 static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get()); | 169 static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get()); |
| 173 EXPECT_EQ(1, num_success_); | 170 EXPECT_EQ(1, num_success_); |
| 174 EXPECT_EQ(0, num_failure_); | 171 EXPECT_EQ(0, num_failure_); |
| 175 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); | 172 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); |
| 176 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | 173 EXPECT_EQ(pointer_touch_target->indexes(0), 0); |
| 177 EXPECT_EQ(index_map_[0], 0); | 174 EXPECT_EQ(action_param_list_->at(0).index(), 0); |
| 178 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); | 175 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); |
| 179 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); | 176 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); |
| 180 ASSERT_EQ(pointer_touch_target->touch_length(), 1U); | 177 ASSERT_EQ(pointer_touch_target->touch_length(), 1U); |
| 181 | 178 |
| 182 // Send a touch move for the first finger and a touch press for the second | 179 // Send a touch move for the first finger and a touch press for the second |
| 183 // finger. | 180 // finger. |
| 184 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 181 action_param_list_->at(0).set_pointer_action_type( |
| 185 params0.set_pointer_action_type( | |
| 186 SyntheticPointerActionParams::PointerActionType::MOVE); | 182 SyntheticPointerActionParams::PointerActionType::MOVE); |
| 187 params0.set_position(gfx::PointF(133, 156)); | 183 action_param_list_->at(0).set_position(gfx::PointF(133, 156)); |
| 188 SyntheticPointerActionParams params1 = SyntheticPointerActionParams( | 184 SyntheticPointerActionParams params1 = SyntheticPointerActionParams( |
| 189 SyntheticPointerActionParams::PointerActionType::PRESS); | 185 SyntheticPointerActionParams::PointerActionType::PRESS); |
| 190 params1.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 186 params1.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| 191 params1.set_index(1); | |
| 192 params1.set_position(gfx::PointF(79, 132)); | 187 params1.set_position(gfx::PointF(79, 132)); |
| 193 action_param_list_->push_back(params0); | |
| 194 action_param_list_->push_back(params1); | 188 action_param_list_->push_back(params1); |
| 195 ForwardSyntheticPointerAction(); | 189 ForwardSyntheticPointerAction(); |
| 196 | 190 |
| 197 EXPECT_EQ(2, num_success_); | 191 EXPECT_EQ(2, num_success_); |
| 198 EXPECT_EQ(0, num_failure_); | 192 EXPECT_EQ(0, num_failure_); |
| 199 // The type of the SyntheticWebTouchEvent is the action of the last finger. | 193 // The type of the SyntheticWebTouchEvent is the action of the last finger. |
| 200 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); | 194 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); |
| 201 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | 195 EXPECT_EQ(pointer_touch_target->indexes(0), 0); |
| 202 EXPECT_EQ(index_map_[0], 0); | 196 EXPECT_EQ(action_param_list_->at(0).index(), 0); |
| 203 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(133, 156)); | 197 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(133, 156)); |
| 204 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StateMoved); | 198 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StateMoved); |
| 205 EXPECT_EQ(pointer_touch_target->indexes(1), 1); | 199 EXPECT_EQ(pointer_touch_target->indexes(1), 1); |
| 206 EXPECT_EQ(index_map_[1], 1); | 200 EXPECT_EQ(action_param_list_->at(1).index(), 1); |
| 207 EXPECT_EQ(pointer_touch_target->positions(1), gfx::PointF(79, 132)); | 201 EXPECT_EQ(pointer_touch_target->positions(1), gfx::PointF(79, 132)); |
| 208 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StatePressed); | 202 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StatePressed); |
| 209 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); | 203 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); |
| 210 | 204 |
| 211 // Send a touch move for the second finger. | 205 // Send a touch move for the second finger. |
| 212 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 206 action_param_list_->at(1).set_pointer_action_type( |
| 213 params1.set_pointer_action_type( | |
| 214 SyntheticPointerActionParams::PointerActionType::MOVE); | 207 SyntheticPointerActionParams::PointerActionType::MOVE); |
| 215 params1.set_position(gfx::PointF(87, 253)); | 208 action_param_list_->at(1).set_position(gfx::PointF(87, 253)); |
| 216 action_param_list_->push_back(params1); | |
| 217 ForwardSyntheticPointerAction(); | 209 ForwardSyntheticPointerAction(); |
| 218 | 210 |
| 219 EXPECT_EQ(3, num_success_); | 211 EXPECT_EQ(3, num_success_); |
| 220 EXPECT_EQ(0, num_failure_); | 212 EXPECT_EQ(0, num_failure_); |
| 221 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchMove); | 213 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchMove); |
| 222 EXPECT_EQ(pointer_touch_target->indexes(1), 1); | 214 EXPECT_EQ(pointer_touch_target->indexes(1), 1); |
| 223 EXPECT_EQ(index_map_[1], 1); | 215 EXPECT_EQ(action_param_list_->at(1).index(), 1); |
| 224 EXPECT_EQ(pointer_touch_target->positions(1), gfx::PointF(87, 253)); | 216 EXPECT_EQ(pointer_touch_target->positions(1), gfx::PointF(87, 253)); |
| 225 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateMoved); | 217 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateMoved); |
| 226 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); | 218 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); |
| 227 | 219 |
| 228 // Send touch releases for both fingers. | 220 // Send touch releases for both fingers. |
| 229 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 221 action_param_list_->at(0).set_pointer_action_type( |
| 230 params0.set_pointer_action_type( | 222 SyntheticPointerActionParams::PointerActionType::RELEASE); |
| 231 SyntheticPointerActionParams::PointerActionType::RELEASE); | 223 action_param_list_->at(1).set_pointer_action_type( |
| 232 params1.set_pointer_action_type( | 224 SyntheticPointerActionParams::PointerActionType::RELEASE); |
| 233 SyntheticPointerActionParams::PointerActionType::RELEASE); | 225 ForwardSyntheticPointerAction(); |
| 226 | |
| 227 EXPECT_EQ(4, num_success_); | |
| 228 EXPECT_EQ(0, num_failure_); | |
| 229 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchEnd); | |
| 230 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | |
| 231 EXPECT_EQ(action_param_list_->at(0).index(), -1); | |
| 232 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StateReleased); | |
| 233 EXPECT_EQ(pointer_touch_target->indexes(1), 1); | |
| 234 EXPECT_EQ(action_param_list_->at(1).index(), -1); | |
| 235 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased); | |
| 236 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); | |
| 237 } | |
| 238 | |
| 239 TEST_F(SyntheticPointerActionTest, PointerTouchActionWithIdle) { | |
|
tdresser
2016/11/12 19:50:55
It's difficult to tell what this test is doing bec
lanwei
2016/11/14 04:20:54
Done.
| |
| 240 CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>(); | |
| 241 | |
| 242 // Send a touch press for one finger. | |
| 243 SyntheticPointerActionParams params0 = SyntheticPointerActionParams( | |
| 244 SyntheticPointerActionParams::PointerActionType::PRESS); | |
| 245 params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | |
| 246 params0.set_position(gfx::PointF(54, 89)); | |
| 247 SyntheticPointerActionParams params1 = SyntheticPointerActionParams( | |
| 248 SyntheticPointerActionParams::PointerActionType::PRESS); | |
| 249 params1.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | |
| 250 params1.set_position(gfx::PointF(79, 132)); | |
| 234 action_param_list_->push_back(params0); | 251 action_param_list_->push_back(params0); |
| 235 action_param_list_->push_back(params1); | 252 action_param_list_->push_back(params1); |
| 236 ForwardSyntheticPointerAction(); | 253 ForwardSyntheticPointerAction(); |
| 237 | 254 |
| 238 EXPECT_EQ(4, num_success_); | |
| 239 EXPECT_EQ(0, num_failure_); | |
| 240 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchEnd); | |
| 241 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | |
| 242 EXPECT_EQ(index_map_[0], -1); | |
| 243 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StateReleased); | |
| 244 EXPECT_EQ(pointer_touch_target->indexes(1), 1); | |
| 245 EXPECT_EQ(index_map_[1], -1); | |
| 246 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased); | |
| 247 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); | |
| 248 } | |
| 249 | |
| 250 TEST_F(SyntheticPointerActionTest, PointerTouchActionIndexInvalid) { | |
| 251 CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>(); | |
| 252 | |
| 253 // Users sent a wrong index for the touch action. | |
| 254 SyntheticPointerActionParams params0 = SyntheticPointerActionParams( | |
| 255 SyntheticPointerActionParams::PointerActionType::PRESS); | |
| 256 params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | |
| 257 params0.set_index(-1); | |
| 258 params0.set_position(gfx::PointF(54, 89)); | |
| 259 action_param_list_->push_back(params0); | |
| 260 ForwardSyntheticPointerAction(); | |
| 261 | |
| 262 EXPECT_EQ(0, num_success_); | |
| 263 EXPECT_EQ(1, num_failure_); | |
| 264 | |
| 265 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | |
| 266 params0.set_index(0); | |
| 267 action_param_list_->push_back(params0); | |
| 268 ForwardSyntheticPointerAction(); | |
| 269 | |
| 270 MockSyntheticPointerTouchActionTarget* pointer_touch_target = | 255 MockSyntheticPointerTouchActionTarget* pointer_touch_target = |
| 271 static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get()); | 256 static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get()); |
| 272 EXPECT_EQ(1, num_success_); | 257 EXPECT_EQ(1, num_success_); |
| 273 EXPECT_EQ(1, num_failure_); | 258 EXPECT_EQ(0, num_failure_); |
| 274 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); | 259 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); |
| 275 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | 260 EXPECT_EQ(pointer_touch_target->indexes(0), 0); |
| 276 EXPECT_EQ(index_map_[0], 0); | 261 EXPECT_EQ(action_param_list_->at(0).index(), 0); |
| 277 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); | 262 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); |
| 278 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); | 263 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); |
| 279 ASSERT_EQ(pointer_touch_target->touch_length(), 1U); | 264 EXPECT_EQ(pointer_touch_target->indexes(1), 1); |
| 265 EXPECT_EQ(action_param_list_->at(1).index(), 1); | |
| 266 EXPECT_EQ(pointer_touch_target->positions(1), gfx::PointF(79, 132)); | |
| 267 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StatePressed); | |
| 268 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); | |
| 269 | |
| 270 // Send a touch release for the second finger and not move the first finger. | |
| 271 action_param_list_->at(0).set_pointer_action_type( | |
| 272 SyntheticPointerActionParams::PointerActionType::IDLE); | |
| 273 action_param_list_->at(1).set_pointer_action_type( | |
| 274 SyntheticPointerActionParams::PointerActionType::RELEASE); | |
| 275 | |
| 276 ForwardSyntheticPointerAction(); | |
| 277 | |
| 278 EXPECT_EQ(2, num_success_); | |
| 279 EXPECT_EQ(0, num_failure_); | |
| 280 // The type of the SyntheticWebTouchEvent is the action of the last finger. | |
| 281 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchEnd); | |
| 282 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | |
| 283 EXPECT_EQ(action_param_list_->at(0).index(), 0); | |
| 284 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); | |
| 285 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); | |
| 286 EXPECT_EQ(pointer_touch_target->indexes(1), 1); | |
| 287 EXPECT_EQ(action_param_list_->at(1).index(), -1); | |
| 288 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased); | |
| 289 ASSERT_EQ(pointer_touch_target->touch_length(), 2U); | |
| 290 | |
| 291 // Send a touch press for the second finger and not move the first finger. | |
| 292 action_param_list_->at(0).set_pointer_action_type( | |
| 293 SyntheticPointerActionParams::PointerActionType::IDLE); | |
| 294 action_param_list_->at(1).set_pointer_action_type( | |
| 295 SyntheticPointerActionParams::PointerActionType::PRESS); | |
| 296 action_param_list_->at(1).set_position(gfx::PointF(123, 69)); | |
| 297 | |
| 298 ForwardSyntheticPointerAction(); | |
| 299 | |
| 300 EXPECT_EQ(3, num_success_); | |
| 301 EXPECT_EQ(0, num_failure_); | |
| 302 // The type of the SyntheticWebTouchEvent is the action of the last finger. | |
| 303 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); | |
|
tdresser
2016/11/12 19:50:55
Should we add some helpers to make this cleaner?
| |
| 304 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | |
| 305 EXPECT_EQ(action_param_list_->at(0).index(), 0); | |
| 306 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); | |
| 307 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); | |
| 308 EXPECT_EQ(pointer_touch_target->indexes(1), 1); | |
| 309 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased); | |
| 310 EXPECT_EQ(pointer_touch_target->indexes(2), 2); | |
| 311 EXPECT_EQ(action_param_list_->at(1).index(), 2); | |
| 312 EXPECT_EQ(pointer_touch_target->positions(2), gfx::PointF(123, 69)); | |
| 313 EXPECT_EQ(pointer_touch_target->states(2), WebTouchPoint::StatePressed); | |
| 314 ASSERT_EQ(pointer_touch_target->touch_length(), 3U); | |
| 315 | |
| 316 // Send a touch release for the second finger and not move the first finger. | |
| 317 action_param_list_->at(0).set_pointer_action_type( | |
| 318 SyntheticPointerActionParams::PointerActionType::IDLE); | |
| 319 action_param_list_->at(1).set_pointer_action_type( | |
| 320 SyntheticPointerActionParams::PointerActionType::RELEASE); | |
| 321 | |
| 322 ForwardSyntheticPointerAction(); | |
| 323 | |
| 324 EXPECT_EQ(4, num_success_); | |
| 325 EXPECT_EQ(0, num_failure_); | |
| 326 // The type of the SyntheticWebTouchEvent is the action of the last finger. | |
| 327 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchEnd); | |
| 328 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | |
| 329 EXPECT_EQ(action_param_list_->at(0).index(), 0); | |
| 330 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); | |
| 331 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); | |
| 332 EXPECT_EQ(pointer_touch_target->indexes(1), 1); | |
| 333 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased); | |
| 334 EXPECT_EQ(pointer_touch_target->indexes(2), 2); | |
| 335 EXPECT_EQ(action_param_list_->at(1).index(), -1); | |
| 336 EXPECT_EQ(pointer_touch_target->states(2), WebTouchPoint::StateReleased); | |
| 337 ASSERT_EQ(pointer_touch_target->touch_length(), 3U); | |
| 338 | |
| 339 // Send a touch press for the second finger and not move the first finger. | |
| 340 action_param_list_->at(0).set_pointer_action_type( | |
| 341 SyntheticPointerActionParams::PointerActionType::IDLE); | |
| 342 action_param_list_->at(1).set_pointer_action_type( | |
| 343 SyntheticPointerActionParams::PointerActionType::PRESS); | |
| 344 action_param_list_->at(1).set_position(gfx::PointF(93, 72)); | |
| 345 | |
| 346 ForwardSyntheticPointerAction(); | |
| 347 | |
| 348 EXPECT_EQ(5, num_success_); | |
| 349 EXPECT_EQ(0, num_failure_); | |
| 350 // The type of the SyntheticWebTouchEvent is the action of the last finger. | |
| 351 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); | |
| 352 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | |
| 353 EXPECT_EQ(action_param_list_->at(0).index(), 0); | |
| 354 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); | |
| 355 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); | |
| 356 EXPECT_EQ(pointer_touch_target->indexes(1), 1); | |
| 357 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased); | |
| 358 EXPECT_EQ(pointer_touch_target->indexes(2), 2); | |
| 359 EXPECT_EQ(pointer_touch_target->states(2), WebTouchPoint::StateReleased); | |
| 360 EXPECT_EQ(pointer_touch_target->indexes(3), 3); | |
| 361 EXPECT_EQ(action_param_list_->at(1).index(), 3); | |
| 362 EXPECT_EQ(pointer_touch_target->positions(3), gfx::PointF(93, 72)); | |
| 363 EXPECT_EQ(pointer_touch_target->states(3), WebTouchPoint::StatePressed); | |
| 364 ASSERT_EQ(pointer_touch_target->touch_length(), 4U); | |
| 365 | |
| 366 // Send a touch release for the second finger and not move the first finger. | |
| 367 action_param_list_->at(0).set_pointer_action_type( | |
| 368 SyntheticPointerActionParams::PointerActionType::IDLE); | |
| 369 action_param_list_->at(1).set_pointer_action_type( | |
| 370 SyntheticPointerActionParams::PointerActionType::RELEASE); | |
| 371 | |
| 372 ForwardSyntheticPointerAction(); | |
| 373 | |
| 374 EXPECT_EQ(6, num_success_); | |
| 375 EXPECT_EQ(0, num_failure_); | |
| 376 // The type of the SyntheticWebTouchEvent is the action of the last finger. | |
| 377 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchEnd); | |
| 378 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | |
| 379 EXPECT_EQ(action_param_list_->at(0).index(), 0); | |
|
tdresser
2016/11/12 19:50:55
What is the index here? We should make sure that w
| |
| 380 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); | |
| 381 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); | |
| 382 EXPECT_EQ(pointer_touch_target->indexes(1), 1); | |
| 383 EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased); | |
| 384 EXPECT_EQ(pointer_touch_target->indexes(2), 2); | |
| 385 EXPECT_EQ(pointer_touch_target->states(2), WebTouchPoint::StateReleased); | |
| 386 EXPECT_EQ(pointer_touch_target->indexes(3), 3); | |
| 387 EXPECT_EQ(action_param_list_->at(1).index(), -1); | |
| 388 EXPECT_EQ(pointer_touch_target->states(3), WebTouchPoint::StateReleased); | |
| 389 ASSERT_EQ(pointer_touch_target->touch_length(), 4U); | |
| 280 } | 390 } |
| 281 | 391 |
| 282 TEST_F(SyntheticPointerActionTest, PointerTouchActionSourceTypeInvalid) { | 392 TEST_F(SyntheticPointerActionTest, PointerTouchActionSourceTypeInvalid) { |
| 283 CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>(); | 393 CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>(); |
| 284 | 394 |
| 285 // Users' gesture source type does not match with the touch action. | 395 // Users' gesture source type does not match with the touch action. |
| 286 SyntheticPointerActionParams params0 = SyntheticPointerActionParams( | 396 SyntheticPointerActionParams params0 = SyntheticPointerActionParams( |
| 287 SyntheticPointerActionParams::PointerActionType::PRESS); | 397 SyntheticPointerActionParams::PointerActionType::PRESS); |
| 288 params0.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; | 398 params0.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; |
| 289 params0.set_index(0); | |
| 290 params0.set_position(gfx::PointF(54, 89)); | 399 params0.set_position(gfx::PointF(54, 89)); |
| 291 action_param_list_->push_back(params0); | 400 action_param_list_->push_back(params0); |
| 292 ForwardSyntheticPointerAction(); | 401 ForwardSyntheticPointerAction(); |
| 293 | 402 |
| 294 EXPECT_EQ(0, num_success_); | 403 EXPECT_EQ(0, num_success_); |
| 295 EXPECT_EQ(1, num_failure_); | 404 EXPECT_EQ(1, num_failure_); |
| 296 | 405 |
| 297 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 406 action_param_list_->at(0).gesture_source_type = |
| 298 params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 407 SyntheticGestureParams::TOUCH_INPUT; |
| 299 action_param_list_->push_back(params0); | |
| 300 ForwardSyntheticPointerAction(); | 408 ForwardSyntheticPointerAction(); |
| 301 | 409 |
| 302 MockSyntheticPointerTouchActionTarget* pointer_touch_target = | 410 MockSyntheticPointerTouchActionTarget* pointer_touch_target = |
| 303 static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get()); | 411 static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get()); |
| 304 EXPECT_EQ(1, num_success_); | 412 EXPECT_EQ(1, num_success_); |
| 305 EXPECT_EQ(1, num_failure_); | 413 EXPECT_EQ(1, num_failure_); |
| 306 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); | 414 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); |
| 307 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | 415 EXPECT_EQ(pointer_touch_target->indexes(0), 0); |
| 308 EXPECT_EQ(index_map_[0], 0); | 416 EXPECT_EQ(action_param_list_->at(0).index(), 0); |
| 309 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); | 417 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); |
| 310 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); | 418 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); |
| 311 ASSERT_EQ(pointer_touch_target->touch_length(), 1U); | 419 ASSERT_EQ(pointer_touch_target->touch_length(), 1U); |
| 312 } | 420 } |
| 313 | 421 |
| 314 TEST_F(SyntheticPointerActionTest, PointerTouchActionTypeInvalid) { | 422 TEST_F(SyntheticPointerActionTest, PointerTouchActionTypeInvalid) { |
| 315 CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>(); | 423 CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>(); |
| 316 | 424 |
| 317 // Cannot send a touch move or touch release without sending a touch press | 425 // Cannot send a touch move or touch release without sending a touch press |
| 318 // first. | 426 // first. |
| 319 SyntheticPointerActionParams params0 = SyntheticPointerActionParams( | 427 SyntheticPointerActionParams params0 = SyntheticPointerActionParams( |
| 320 SyntheticPointerActionParams::PointerActionType::MOVE); | 428 SyntheticPointerActionParams::PointerActionType::MOVE); |
| 321 params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 429 params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| 322 params0.set_index(0); | |
| 323 params0.set_position(gfx::PointF(54, 89)); | 430 params0.set_position(gfx::PointF(54, 89)); |
| 324 action_param_list_->push_back(params0); | 431 action_param_list_->push_back(params0); |
| 325 ForwardSyntheticPointerAction(); | 432 ForwardSyntheticPointerAction(); |
| 326 | 433 |
| 327 EXPECT_EQ(0, num_success_); | 434 EXPECT_EQ(0, num_success_); |
| 328 EXPECT_EQ(1, num_failure_); | 435 EXPECT_EQ(1, num_failure_); |
| 329 | 436 |
| 330 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 437 action_param_list_->at(0).set_pointer_action_type( |
| 331 params0.set_pointer_action_type( | |
| 332 SyntheticPointerActionParams::PointerActionType::RELEASE); | 438 SyntheticPointerActionParams::PointerActionType::RELEASE); |
| 333 action_param_list_->push_back(params0); | |
| 334 ForwardSyntheticPointerAction(); | 439 ForwardSyntheticPointerAction(); |
| 335 | 440 |
| 336 EXPECT_EQ(0, num_success_); | 441 EXPECT_EQ(0, num_success_); |
| 337 EXPECT_EQ(2, num_failure_); | 442 EXPECT_EQ(2, num_failure_); |
| 338 | 443 |
| 339 // Send a touch press for one finger. | 444 // Send a touch press for one finger. |
| 340 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 445 action_param_list_->at(0).set_pointer_action_type( |
| 341 params0.set_pointer_action_type( | |
| 342 SyntheticPointerActionParams::PointerActionType::PRESS); | 446 SyntheticPointerActionParams::PointerActionType::PRESS); |
| 343 action_param_list_->push_back(params0); | |
| 344 ForwardSyntheticPointerAction(); | 447 ForwardSyntheticPointerAction(); |
| 345 | 448 |
| 346 MockSyntheticPointerTouchActionTarget* pointer_touch_target = | 449 MockSyntheticPointerTouchActionTarget* pointer_touch_target = |
| 347 static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get()); | 450 static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get()); |
| 348 EXPECT_EQ(1, num_success_); | 451 EXPECT_EQ(1, num_success_); |
| 349 EXPECT_EQ(2, num_failure_); | 452 EXPECT_EQ(2, num_failure_); |
| 350 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); | 453 EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart); |
| 351 EXPECT_EQ(pointer_touch_target->indexes(0), 0); | 454 EXPECT_EQ(pointer_touch_target->indexes(0), 0); |
| 352 EXPECT_EQ(index_map_[0], 0); | 455 EXPECT_EQ(action_param_list_->at(0).index(), 0); |
| 353 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); | 456 EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89)); |
| 354 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); | 457 EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed); |
| 355 ASSERT_EQ(pointer_touch_target->touch_length(), 1U); | 458 ASSERT_EQ(pointer_touch_target->touch_length(), 1U); |
| 356 | 459 |
| 357 // Cannot send a touch press again without releasing the finger. | 460 // Cannot send a touch press again without releasing the finger. |
| 358 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 461 action_param_list_->at(0).gesture_source_type = |
| 359 params0.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 462 SyntheticGestureParams::TOUCH_INPUT; |
| 360 params0.set_index(0); | 463 action_param_list_->at(0).set_pointer_action_type( |
| 361 params0.set_pointer_action_type( | |
| 362 SyntheticPointerActionParams::PointerActionType::PRESS); | 464 SyntheticPointerActionParams::PointerActionType::PRESS); |
| 363 action_param_list_->push_back(params0); | |
| 364 ForwardSyntheticPointerAction(); | 465 ForwardSyntheticPointerAction(); |
| 365 | 466 |
| 366 EXPECT_EQ(1, num_success_); | 467 EXPECT_EQ(1, num_success_); |
| 367 EXPECT_EQ(3, num_failure_); | 468 EXPECT_EQ(3, num_failure_); |
| 368 } | 469 } |
| 369 | 470 |
| 370 TEST_F(SyntheticPointerActionTest, PointerMouseAction) { | 471 TEST_F(SyntheticPointerActionTest, PointerMouseAction) { |
| 371 CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>(); | 472 CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>(); |
| 372 | 473 |
| 373 // Send a mouse move. | 474 // Send a mouse move. |
| 374 SyntheticPointerActionParams params = SyntheticPointerActionParams( | 475 SyntheticPointerActionParams params = SyntheticPointerActionParams( |
| 375 SyntheticPointerActionParams::PointerActionType::MOVE); | 476 SyntheticPointerActionParams::PointerActionType::MOVE); |
| 376 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; | 477 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; |
| 377 params.set_index(0); | |
| 378 params.set_position(gfx::PointF(189, 62)); | 478 params.set_position(gfx::PointF(189, 62)); |
| 379 action_param_list_->push_back(params); | 479 action_param_list_->push_back(params); |
| 380 ForwardSyntheticPointerAction(); | 480 ForwardSyntheticPointerAction(); |
| 381 | 481 |
| 382 MockSyntheticPointerMouseActionTarget* pointer_mouse_target = | 482 MockSyntheticPointerMouseActionTarget* pointer_mouse_target = |
| 383 static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get()); | 483 static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get()); |
| 384 EXPECT_EQ(1, num_success_); | 484 EXPECT_EQ(1, num_success_); |
| 385 EXPECT_EQ(0, num_failure_); | 485 EXPECT_EQ(0, num_failure_); |
| 386 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseMove); | 486 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseMove); |
| 387 EXPECT_EQ(pointer_mouse_target->position(), params.position()); | 487 EXPECT_EQ(pointer_mouse_target->position(), params.position()); |
| 388 EXPECT_EQ(pointer_mouse_target->clickCount(), 0); | 488 EXPECT_EQ(pointer_mouse_target->clickCount(), 0); |
| 389 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::NoButton); | 489 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::NoButton); |
| 390 | 490 |
| 391 // Send a mouse down. | 491 // Send a mouse down. |
| 392 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 492 action_param_list_->at(0).set_position(gfx::PointF(189, 62)); |
| 393 params.set_position(gfx::PointF(189, 62)); | 493 action_param_list_->at(0).set_pointer_action_type( |
| 394 params.set_pointer_action_type( | |
| 395 SyntheticPointerActionParams::PointerActionType::PRESS); | 494 SyntheticPointerActionParams::PointerActionType::PRESS); |
| 396 action_param_list_->push_back(params); | |
| 397 ForwardSyntheticPointerAction(); | 495 ForwardSyntheticPointerAction(); |
| 398 | 496 |
| 399 EXPECT_EQ(2, num_success_); | 497 EXPECT_EQ(2, num_success_); |
| 400 EXPECT_EQ(0, num_failure_); | 498 EXPECT_EQ(0, num_failure_); |
| 401 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseDown); | 499 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseDown); |
| 402 EXPECT_EQ(pointer_mouse_target->position(), params.position()); | 500 EXPECT_EQ(pointer_mouse_target->position(), params.position()); |
| 403 EXPECT_EQ(pointer_mouse_target->clickCount(), 1); | 501 EXPECT_EQ(pointer_mouse_target->clickCount(), 1); |
| 404 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left); | 502 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left); |
| 405 | 503 |
| 406 // Send a mouse drag. | 504 // Send a mouse drag. |
| 407 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 505 action_param_list_->at(0).set_position(gfx::PointF(326, 298)); |
| 408 params.set_position(gfx::PointF(326, 298)); | 506 action_param_list_->at(0).set_pointer_action_type( |
| 409 params.set_pointer_action_type( | |
| 410 SyntheticPointerActionParams::PointerActionType::MOVE); | 507 SyntheticPointerActionParams::PointerActionType::MOVE); |
| 411 action_param_list_->push_back(params); | |
| 412 ForwardSyntheticPointerAction(); | 508 ForwardSyntheticPointerAction(); |
| 413 | 509 |
| 414 EXPECT_EQ(3, num_success_); | 510 EXPECT_EQ(3, num_success_); |
| 415 EXPECT_EQ(0, num_failure_); | 511 EXPECT_EQ(0, num_failure_); |
| 416 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseMove); | 512 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseMove); |
| 417 EXPECT_EQ(pointer_mouse_target->position(), params.position()); | 513 EXPECT_EQ(pointer_mouse_target->position(), |
| 514 action_param_list_->at(0).position()); | |
| 418 EXPECT_EQ(pointer_mouse_target->clickCount(), 1); | 515 EXPECT_EQ(pointer_mouse_target->clickCount(), 1); |
| 419 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left); | 516 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left); |
| 420 | 517 |
| 421 // Send a mouse up. | 518 // Send a mouse up. |
| 422 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 519 action_param_list_->at(0).set_pointer_action_type( |
| 423 params.set_pointer_action_type( | |
| 424 SyntheticPointerActionParams::PointerActionType::RELEASE); | 520 SyntheticPointerActionParams::PointerActionType::RELEASE); |
| 425 action_param_list_->push_back(params); | |
| 426 ForwardSyntheticPointerAction(); | 521 ForwardSyntheticPointerAction(); |
| 427 | 522 |
| 428 EXPECT_EQ(4, num_success_); | 523 EXPECT_EQ(4, num_success_); |
| 429 EXPECT_EQ(0, num_failure_); | 524 EXPECT_EQ(0, num_failure_); |
| 430 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseUp); | 525 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseUp); |
| 431 EXPECT_EQ(pointer_mouse_target->clickCount(), 1); | 526 EXPECT_EQ(pointer_mouse_target->clickCount(), 1); |
| 432 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left); | 527 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left); |
| 433 } | 528 } |
| 434 | 529 |
| 435 TEST_F(SyntheticPointerActionTest, PointerMouseActionSourceTypeInvalid) { | 530 TEST_F(SyntheticPointerActionTest, PointerMouseActionSourceTypeInvalid) { |
| 436 CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>(); | 531 CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>(); |
| 437 | 532 |
| 438 // Users' gesture source type does not match with the mouse action. | 533 // Users' gesture source type does not match with the mouse action. |
| 439 SyntheticPointerActionParams params = SyntheticPointerActionParams( | 534 SyntheticPointerActionParams params = SyntheticPointerActionParams( |
| 440 SyntheticPointerActionParams::PointerActionType::PRESS); | 535 SyntheticPointerActionParams::PointerActionType::PRESS); |
| 441 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; | 536 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
| 442 params.set_index(0); | |
| 443 params.set_position(gfx::PointF(54, 89)); | 537 params.set_position(gfx::PointF(54, 89)); |
| 444 action_param_list_->push_back(params); | 538 action_param_list_->push_back(params); |
| 445 ForwardSyntheticPointerAction(); | 539 ForwardSyntheticPointerAction(); |
| 446 | 540 |
| 447 EXPECT_EQ(0, num_success_); | 541 EXPECT_EQ(0, num_success_); |
| 448 EXPECT_EQ(1, num_failure_); | 542 EXPECT_EQ(1, num_failure_); |
| 449 | 543 |
| 450 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 544 action_param_list_->at(0).gesture_source_type = |
| 451 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; | 545 SyntheticGestureParams::MOUSE_INPUT; |
| 452 action_param_list_->push_back(params); | |
| 453 ForwardSyntheticPointerAction(); | 546 ForwardSyntheticPointerAction(); |
| 454 | 547 |
| 455 MockSyntheticPointerMouseActionTarget* pointer_mouse_target = | 548 MockSyntheticPointerMouseActionTarget* pointer_mouse_target = |
| 456 static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get()); | 549 static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get()); |
| 457 EXPECT_EQ(1, num_success_); | 550 EXPECT_EQ(1, num_success_); |
| 458 EXPECT_EQ(1, num_failure_); | 551 EXPECT_EQ(1, num_failure_); |
| 459 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseDown); | 552 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseDown); |
| 460 EXPECT_EQ(pointer_mouse_target->position(), params.position()); | 553 EXPECT_EQ(pointer_mouse_target->position(), params.position()); |
| 461 EXPECT_EQ(pointer_mouse_target->clickCount(), 1); | 554 EXPECT_EQ(pointer_mouse_target->clickCount(), 1); |
| 462 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left); | 555 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left); |
| 463 } | 556 } |
| 464 | 557 |
| 465 TEST_F(SyntheticPointerActionTest, PointerMouseActionTypeInvalid) { | 558 TEST_F(SyntheticPointerActionTest, PointerMouseActionTypeInvalid) { |
| 466 CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>(); | 559 CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>(); |
| 467 | 560 |
| 468 // Send a mouse move. | 561 // Send a mouse move. |
| 469 SyntheticPointerActionParams params = SyntheticPointerActionParams( | 562 SyntheticPointerActionParams params = SyntheticPointerActionParams( |
| 470 SyntheticPointerActionParams::PointerActionType::MOVE); | 563 SyntheticPointerActionParams::PointerActionType::MOVE); |
| 471 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; | 564 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT; |
| 472 params.set_index(0); | |
| 473 params.set_position(gfx::PointF(189, 62)); | 565 params.set_position(gfx::PointF(189, 62)); |
| 474 action_param_list_->push_back(params); | 566 action_param_list_->push_back(params); |
| 475 ForwardSyntheticPointerAction(); | 567 ForwardSyntheticPointerAction(); |
| 476 | 568 |
| 477 MockSyntheticPointerMouseActionTarget* pointer_mouse_target = | 569 MockSyntheticPointerMouseActionTarget* pointer_mouse_target = |
| 478 static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get()); | 570 static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get()); |
| 479 EXPECT_EQ(1, num_success_); | 571 EXPECT_EQ(1, num_success_); |
| 480 EXPECT_EQ(0, num_failure_); | 572 EXPECT_EQ(0, num_failure_); |
| 481 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseMove); | 573 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseMove); |
| 482 EXPECT_EQ(pointer_mouse_target->position(), params.position()); | 574 EXPECT_EQ(pointer_mouse_target->position(), params.position()); |
| 483 EXPECT_EQ(pointer_mouse_target->clickCount(), 0); | 575 EXPECT_EQ(pointer_mouse_target->clickCount(), 0); |
| 484 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::NoButton); | 576 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::NoButton); |
| 485 | 577 |
| 486 // Cannot send a mouse up without sending a mouse down first. | 578 // Cannot send a mouse up without sending a mouse down first. |
| 487 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 579 action_param_list_->at(0).set_pointer_action_type( |
| 488 params.set_pointer_action_type( | |
| 489 SyntheticPointerActionParams::PointerActionType::RELEASE); | 580 SyntheticPointerActionParams::PointerActionType::RELEASE); |
| 490 action_param_list_->push_back(params); | |
| 491 ForwardSyntheticPointerAction(); | 581 ForwardSyntheticPointerAction(); |
| 492 | 582 |
| 493 EXPECT_EQ(1, num_success_); | 583 EXPECT_EQ(1, num_success_); |
| 494 EXPECT_EQ(1, num_failure_); | 584 EXPECT_EQ(1, num_failure_); |
| 495 | 585 |
| 496 // Send a mouse down for one finger. | 586 // Send a mouse down for one finger. |
| 497 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 587 action_param_list_->at(0).set_pointer_action_type( |
| 498 params.set_pointer_action_type( | |
| 499 SyntheticPointerActionParams::PointerActionType::PRESS); | 588 SyntheticPointerActionParams::PointerActionType::PRESS); |
| 500 action_param_list_->push_back(params); | |
| 501 ForwardSyntheticPointerAction(); | 589 ForwardSyntheticPointerAction(); |
| 502 | 590 |
| 503 EXPECT_EQ(2, num_success_); | 591 EXPECT_EQ(2, num_success_); |
| 504 EXPECT_EQ(1, num_failure_); | 592 EXPECT_EQ(1, num_failure_); |
| 505 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseDown); | 593 EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseDown); |
| 506 EXPECT_EQ(pointer_mouse_target->position(), params.position()); | 594 EXPECT_EQ(pointer_mouse_target->position(), params.position()); |
| 507 EXPECT_EQ(pointer_mouse_target->clickCount(), 1); | 595 EXPECT_EQ(pointer_mouse_target->clickCount(), 1); |
| 508 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left); | 596 EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left); |
| 509 | 597 |
| 510 // Cannot send a mouse down again without releasing the mouse button. | 598 // Cannot send a mouse down again without releasing the mouse button. |
| 511 action_param_list_.reset(new std::vector<SyntheticPointerActionParams>()); | 599 action_param_list_->at(0).set_pointer_action_type( |
| 512 params.set_pointer_action_type( | |
| 513 SyntheticPointerActionParams::PointerActionType::PRESS); | 600 SyntheticPointerActionParams::PointerActionType::PRESS); |
| 514 action_param_list_->push_back(params); | |
| 515 ForwardSyntheticPointerAction(); | 601 ForwardSyntheticPointerAction(); |
| 516 | 602 |
| 517 EXPECT_EQ(2, num_success_); | 603 EXPECT_EQ(2, num_success_); |
| 518 EXPECT_EQ(2, num_failure_); | 604 EXPECT_EQ(2, num_failure_); |
| 519 } | 605 } |
| 520 | 606 |
| 521 } // namespace | 607 } // namespace |
| 522 | 608 |
| 523 } // namespace content | 609 } // namespace content |
| OLD | NEW |