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

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc

Issue 1349813002: Enable pinch-zoom telemetry on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@telemetry
Patch Set: feedback Created 5 years, 3 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/input/synthetic_gesture_target_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "content/browser/renderer_host/input/synthetic_gesture.h" 8 #include "content/browser/renderer_host/input/synthetic_gesture.h"
9 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" 9 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" 10 #include "content/browser/renderer_host/input/synthetic_gesture_target.h"
11 #include "content/browser/renderer_host/input/synthetic_pinch_gesture.h" 11 #include "content/browser/renderer_host/input/synthetic_pinch_gesture.h"
12 #include "content/browser/renderer_host/input/synthetic_smooth_drag_gesture.h" 12 #include "content/browser/renderer_host/input/synthetic_smooth_drag_gesture.h"
13 #include "content/browser/renderer_host/input/synthetic_smooth_move_gesture.h" 13 #include "content/browser/renderer_host/input/synthetic_smooth_move_gesture.h"
14 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h" 14 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h"
15 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" 15 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h"
16 #include "content/browser/renderer_host/input/synthetic_touchpad_pinch_gesture.h "
17 #include "content/browser/renderer_host/input/synthetic_touchscreen_pinch_gestur e.h"
16 #include "content/browser/renderer_host/render_widget_host_delegate.h" 18 #include "content/browser/renderer_host/render_widget_host_delegate.h"
17 #include "content/common/input/synthetic_pinch_gesture_params.h" 19 #include "content/common/input/synthetic_pinch_gesture_params.h"
18 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" 20 #include "content/common/input/synthetic_smooth_drag_gesture_params.h"
19 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" 21 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
20 #include "content/common/input/synthetic_tap_gesture_params.h" 22 #include "content/common/input/synthetic_tap_gesture_params.h"
21 #include "content/public/test/mock_render_process_host.h" 23 #include "content/public/test/mock_render_process_host.h"
22 #include "content/public/test/test_browser_context.h" 24 #include "content/public/test/test_browser_context.h"
23 #include "content/test/test_render_view_host.h" 25 #include "content/test/test_render_view_host.h"
24 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
25 #include "third_party/WebKit/public/web/WebInputEvent.h" 27 #include "third_party/WebKit/public/web/WebInputEvent.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 start_to_end_distance_ = mouse_point - start_; 213 start_to_end_distance_ = mouse_point - start_;
212 last_mouse_point_ = mouse_point; 214 last_mouse_point_ = mouse_point;
213 } 215 }
214 } 216 }
215 217
216 private: 218 private:
217 bool started_; 219 bool started_;
218 gfx::PointF start_, last_mouse_point_; 220 gfx::PointF start_, last_mouse_point_;
219 }; 221 };
220 222
221 class MockSyntheticPinchTouchTarget : public MockSyntheticGestureTarget { 223 class MockSyntheticTouchscreenPinchTouchTarget
224 : public MockSyntheticGestureTarget {
222 public: 225 public:
223 enum ZoomDirection { 226 enum ZoomDirection {
224 ZOOM_DIRECTION_UNKNOWN, 227 ZOOM_DIRECTION_UNKNOWN,
225 ZOOM_IN, 228 ZOOM_IN,
226 ZOOM_OUT 229 ZOOM_OUT
227 }; 230 };
228 231
229 MockSyntheticPinchTouchTarget() 232 MockSyntheticTouchscreenPinchTouchTarget()
230 : initial_pointer_distance_(0), 233 : initial_pointer_distance_(0),
231 last_pointer_distance_(0), 234 last_pointer_distance_(0),
232 zoom_direction_(ZOOM_DIRECTION_UNKNOWN), 235 zoom_direction_(ZOOM_DIRECTION_UNKNOWN),
233 started_(false) {} 236 started_(false) {}
234 ~MockSyntheticPinchTouchTarget() override {} 237 ~MockSyntheticTouchscreenPinchTouchTarget() override {}
235 238
236 void DispatchInputEventToPlatform(const WebInputEvent& event) override { 239 void DispatchInputEventToPlatform(const WebInputEvent& event) override {
237 ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type)); 240 ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type));
238 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); 241 const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
239 ASSERT_EQ(touch_event.touchesLength, 2U); 242 ASSERT_EQ(touch_event.touchesLength, 2U);
240 243
241 if (!started_) { 244 if (!started_) {
242 ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart); 245 ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart);
243 246
244 start_0_ = gfx::PointF(touch_event.touches[0].position); 247 start_0_ = gfx::PointF(touch_event.touches[0].position);
(...skipping 19 matching lines...) Expand all
264 else 267 else
265 EXPECT_EQ( 268 EXPECT_EQ(
266 zoom_direction_, 269 zoom_direction_,
267 ComputeZoomDirection(last_pointer_distance_, pointer_distance)); 270 ComputeZoomDirection(last_pointer_distance_, pointer_distance));
268 } 271 }
269 272
270 last_pointer_distance_ = pointer_distance; 273 last_pointer_distance_ = pointer_distance;
271 } 274 }
272 } 275 }
273 276
277 SyntheticGestureParams::GestureSourceType
278 GetDefaultSyntheticGestureSourceType() const override {
279 return SyntheticGestureParams::TOUCH_INPUT;
280 }
281
274 ZoomDirection zoom_direction() const { return zoom_direction_; } 282 ZoomDirection zoom_direction() const { return zoom_direction_; }
275 283
276 float ComputeScaleFactor() const { 284 float ComputeScaleFactor() const {
277 switch (zoom_direction_) { 285 switch (zoom_direction_) {
278 case ZOOM_IN: 286 case ZOOM_IN:
279 return last_pointer_distance_ / 287 return last_pointer_distance_ /
280 (initial_pointer_distance_ + 2 * GetTouchSlopInDips()); 288 (initial_pointer_distance_ + 2 * GetTouchSlopInDips());
281 case ZOOM_OUT: 289 case ZOOM_OUT:
282 return last_pointer_distance_ / 290 return last_pointer_distance_ /
283 (initial_pointer_distance_ - 2 * GetTouchSlopInDips()); 291 (initial_pointer_distance_ - 2 * GetTouchSlopInDips());
(...skipping 14 matching lines...) Expand all
298 } 306 }
299 307
300 float initial_pointer_distance_; 308 float initial_pointer_distance_;
301 float last_pointer_distance_; 309 float last_pointer_distance_;
302 ZoomDirection zoom_direction_; 310 ZoomDirection zoom_direction_;
303 gfx::PointF start_0_; 311 gfx::PointF start_0_;
304 gfx::PointF start_1_; 312 gfx::PointF start_1_;
305 bool started_; 313 bool started_;
306 }; 314 };
307 315
316 class MockSyntheticTouchpadPinchTouchTarget
317 : public MockSyntheticGestureTarget {
318 public:
319 enum ZoomDirection { ZOOM_DIRECTION_UNKNOWN, ZOOM_IN, ZOOM_OUT };
320
321 MockSyntheticTouchpadPinchTouchTarget()
322 : zoom_direction_(ZOOM_DIRECTION_UNKNOWN),
323 started_(false),
324 ended_(false),
325 scale_factor_(1.0f) {}
326 ~MockSyntheticTouchpadPinchTouchTarget() override {}
327
328 void DispatchInputEventToPlatform(const WebInputEvent& event) override {
329 EXPECT_TRUE(WebInputEvent::isGestureEventType(event.type));
330 const blink::WebGestureEvent& gesture_event =
331 static_cast<const blink::WebGestureEvent&>(event);
332
333 if (gesture_event.type == WebInputEvent::GesturePinchBegin) {
334 EXPECT_FALSE(started_);
335 EXPECT_FALSE(ended_);
336 started_ = true;
337 } else if (gesture_event.type == WebInputEvent::GesturePinchEnd) {
338 EXPECT_TRUE(started_);
339 EXPECT_FALSE(ended_);
340 ended_ = true;
341 } else {
342 EXPECT_EQ(WebInputEvent::GesturePinchUpdate, gesture_event.type);
343 EXPECT_TRUE(started_);
344 EXPECT_FALSE(ended_);
345 const float scale = gesture_event.data.pinchUpdate.scale;
346 if (scale != 1.0f) {
347 if (zoom_direction_ == ZOOM_DIRECTION_UNKNOWN) {
348 zoom_direction_ = scale > 1.0f ? ZOOM_IN : ZOOM_OUT;
349 } else if (zoom_direction_ == ZOOM_IN) {
350 EXPECT_GT(scale, 1.0f);
351 } else {
352 EXPECT_EQ(ZOOM_OUT, zoom_direction_);
353 EXPECT_LT(scale, 1.0f);
354 }
355
356 scale_factor_ *= scale;
357 }
358 }
359 }
360
361 SyntheticGestureParams::GestureSourceType
362 GetDefaultSyntheticGestureSourceType() const override {
363 return SyntheticGestureParams::MOUSE_INPUT;
364 }
365
366 ZoomDirection zoom_direction() const { return zoom_direction_; }
367
368 float scale_factor() const { return scale_factor_; }
369
370 private:
371 ZoomDirection zoom_direction_;
372 bool started_;
373 bool ended_;
374 float scale_factor_;
375 };
376
308 class MockSyntheticTapGestureTarget : public MockSyntheticGestureTarget { 377 class MockSyntheticTapGestureTarget : public MockSyntheticGestureTarget {
309 public: 378 public:
310 MockSyntheticTapGestureTarget() : state_(NOT_STARTED) {} 379 MockSyntheticTapGestureTarget() : state_(NOT_STARTED) {}
311 ~MockSyntheticTapGestureTarget() override {} 380 ~MockSyntheticTapGestureTarget() override {}
312 381
313 bool GestureFinished() const { return state_ == FINISHED; } 382 bool GestureFinished() const { return state_ == FINISHED; }
314 gfx::PointF position() const { return position_; } 383 gfx::PointF position() const { return position_; }
315 base::TimeDelta GetDuration() const { return stop_time_ - start_time_; } 384 base::TimeDelta GetDuration() const { return stop_time_ - start_time_; }
316 385
317 protected: 386 protected:
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 params.anchor.SetPoint(432, 89); 1162 params.anchor.SetPoint(432, 89);
1094 params.distances.push_back(gfx::Vector2d(0, -234)); 1163 params.distances.push_back(gfx::Vector2d(0, -234));
1095 params.speed_in_pixels_s = 800; 1164 params.speed_in_pixels_s = 800;
1096 1165
1097 scoped_ptr<SyntheticSmoothScrollGesture> gesture( 1166 scoped_ptr<SyntheticSmoothScrollGesture> gesture(
1098 new SyntheticSmoothScrollGesture(params)); 1167 new SyntheticSmoothScrollGesture(params));
1099 const base::TimeTicks timestamp; 1168 const base::TimeTicks timestamp;
1100 gesture->ForwardInputEvents(timestamp, target_); 1169 gesture->ForwardInputEvents(timestamp, target_);
1101 } 1170 }
1102 1171
1103 TEST_F(SyntheticGestureControllerTest, PinchGestureTouchZoomIn) { 1172 TEST_F(SyntheticGestureControllerTest,
1104 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); 1173 TouchscreenTouchpadPinchGestureTouchZoomIn) {
1105 1174 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
1106 SyntheticPinchGestureParams params; 1175
1107 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 1176 SyntheticPinchGestureParams params;
1108 params.scale_factor = 2.3f; 1177 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
1109 params.anchor.SetPoint(54, 89); 1178 params.scale_factor = 2.3f;
1110 1179 params.anchor.SetPoint(54, 89);
1111 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); 1180
1112 QueueSyntheticGesture(gesture.Pass()); 1181 scoped_ptr<SyntheticTouchscreenPinchGesture> gesture(
1113 FlushInputUntilComplete(); 1182 new SyntheticTouchscreenPinchGesture(params));
1114 1183 QueueSyntheticGesture(gesture.Pass());
1115 MockSyntheticPinchTouchTarget* pinch_target = 1184 FlushInputUntilComplete();
1116 static_cast<MockSyntheticPinchTouchTarget*>(target_); 1185
1117 EXPECT_EQ(1, num_success_); 1186 MockSyntheticTouchscreenPinchTouchTarget* pinch_target =
1118 EXPECT_EQ(0, num_failure_); 1187 static_cast<MockSyntheticTouchscreenPinchTouchTarget*>(target_);
1119 EXPECT_EQ(pinch_target->zoom_direction(), 1188 EXPECT_EQ(1, num_success_);
1120 MockSyntheticPinchTouchTarget::ZOOM_IN); 1189 EXPECT_EQ(0, num_failure_);
1190 EXPECT_EQ(pinch_target->zoom_direction(),
1191 MockSyntheticTouchscreenPinchTouchTarget::ZOOM_IN);
1121 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); 1192 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor());
1122 } 1193 }
1123 1194
1124 TEST_F(SyntheticGestureControllerTest, PinchGestureTouchZoomOut) { 1195 TEST_F(SyntheticGestureControllerTest,
1125 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); 1196 TouchscreenTouchpadPinchGestureTouchZoomOut) {
1197 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
1126 1198
1127 SyntheticPinchGestureParams params; 1199 SyntheticPinchGestureParams params;
1128 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 1200 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
1129 params.scale_factor = 0.4f; 1201 params.scale_factor = 0.4f;
1130 params.anchor.SetPoint(-12, 93); 1202 params.anchor.SetPoint(-12, 93);
1131 1203
1132 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); 1204 scoped_ptr<SyntheticTouchscreenPinchGesture> gesture(
1133 QueueSyntheticGesture(gesture.Pass()); 1205 new SyntheticTouchscreenPinchGesture(params));
1134 FlushInputUntilComplete(); 1206 QueueSyntheticGesture(gesture.Pass());
1135 1207 FlushInputUntilComplete();
1136 MockSyntheticPinchTouchTarget* pinch_target = 1208
1137 static_cast<MockSyntheticPinchTouchTarget*>(target_); 1209 MockSyntheticTouchscreenPinchTouchTarget* pinch_target =
1138 EXPECT_EQ(1, num_success_); 1210 static_cast<MockSyntheticTouchscreenPinchTouchTarget*>(target_);
1139 EXPECT_EQ(0, num_failure_); 1211 EXPECT_EQ(1, num_success_);
1140 EXPECT_EQ(pinch_target->zoom_direction(), 1212 EXPECT_EQ(0, num_failure_);
1141 MockSyntheticPinchTouchTarget::ZOOM_OUT); 1213 EXPECT_EQ(pinch_target->zoom_direction(),
1214 MockSyntheticTouchscreenPinchTouchTarget::ZOOM_OUT);
1142 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); 1215 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor());
1143 } 1216 }
1144 1217
1145 TEST_F(SyntheticGestureControllerTest, PinchGestureTouchNoScaling) { 1218 TEST_F(SyntheticGestureControllerTest,
1146 CreateControllerAndTarget<MockSyntheticPinchTouchTarget>(); 1219 TouchscreenTouchpadPinchGestureTouchNoScaling) {
1220 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
1147 1221
1148 SyntheticPinchGestureParams params; 1222 SyntheticPinchGestureParams params;
1149 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 1223 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
1150 params.scale_factor = 1.0f; 1224 params.scale_factor = 1.0f;
1151 1225
1152 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params)); 1226 scoped_ptr<SyntheticTouchscreenPinchGesture> gesture(
1153 QueueSyntheticGesture(gesture.Pass()); 1227 new SyntheticTouchscreenPinchGesture(params));
1154 FlushInputUntilComplete(); 1228 QueueSyntheticGesture(gesture.Pass());
1155 1229 FlushInputUntilComplete();
1156 MockSyntheticPinchTouchTarget* pinch_target = 1230
1157 static_cast<MockSyntheticPinchTouchTarget*>(target_); 1231 MockSyntheticTouchscreenPinchTouchTarget* pinch_target =
1158 EXPECT_EQ(1, num_success_); 1232 static_cast<MockSyntheticTouchscreenPinchTouchTarget*>(target_);
1159 EXPECT_EQ(0, num_failure_); 1233 EXPECT_EQ(1, num_success_);
1160 EXPECT_EQ(pinch_target->zoom_direction(), 1234 EXPECT_EQ(0, num_failure_);
1161 MockSyntheticPinchTouchTarget::ZOOM_DIRECTION_UNKNOWN); 1235 EXPECT_EQ(pinch_target->zoom_direction(),
1236 MockSyntheticTouchscreenPinchTouchTarget::ZOOM_DIRECTION_UNKNOWN);
1162 EXPECT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor()); 1237 EXPECT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor());
1163 } 1238 }
1164 1239
1240 TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchZoomIn) {
1241 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
1242
1243 SyntheticPinchGestureParams params;
1244 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
1245 params.scale_factor = 2.3f;
1246 params.anchor.SetPoint(54, 89);
1247
1248 scoped_ptr<SyntheticTouchpadPinchGesture> gesture(
1249 new SyntheticTouchpadPinchGesture(params));
1250 QueueSyntheticGesture(gesture.Pass());
1251 FlushInputUntilComplete();
1252
1253 MockSyntheticTouchpadPinchTouchTarget* pinch_target =
1254 static_cast<MockSyntheticTouchpadPinchTouchTarget*>(target_);
1255 EXPECT_EQ(1, num_success_);
1256 EXPECT_EQ(0, num_failure_);
1257 EXPECT_EQ(pinch_target->zoom_direction(),
1258 MockSyntheticTouchpadPinchTouchTarget::ZOOM_IN);
1259 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->scale_factor());
1260 }
1261
1262 TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchZoomOut) {
1263 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
1264
1265 SyntheticPinchGestureParams params;
1266 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
1267 params.scale_factor = 0.4f;
1268 params.anchor.SetPoint(-12, 93);
1269
1270 scoped_ptr<SyntheticTouchpadPinchGesture> gesture(
1271 new SyntheticTouchpadPinchGesture(params));
1272 QueueSyntheticGesture(gesture.Pass());
1273 FlushInputUntilComplete();
1274
1275 MockSyntheticTouchpadPinchTouchTarget* pinch_target =
1276 static_cast<MockSyntheticTouchpadPinchTouchTarget*>(target_);
1277 EXPECT_EQ(1, num_success_);
1278 EXPECT_EQ(0, num_failure_);
1279 EXPECT_EQ(pinch_target->zoom_direction(),
1280 MockSyntheticTouchpadPinchTouchTarget::ZOOM_OUT);
1281 EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->scale_factor());
1282 }
1283
1284 TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchNoScaling) {
1285 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
1286
1287 SyntheticPinchGestureParams params;
1288 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
1289 params.scale_factor = 1.0f;
1290
1291 scoped_ptr<SyntheticTouchpadPinchGesture> gesture(
1292 new SyntheticTouchpadPinchGesture(params));
1293 QueueSyntheticGesture(gesture.Pass());
1294 FlushInputUntilComplete();
1295
1296 MockSyntheticTouchpadPinchTouchTarget* pinch_target =
1297 static_cast<MockSyntheticTouchpadPinchTouchTarget*>(target_);
1298 EXPECT_EQ(1, num_success_);
1299 EXPECT_EQ(0, num_failure_);
1300 EXPECT_EQ(pinch_target->zoom_direction(),
1301 MockSyntheticTouchpadPinchTouchTarget::ZOOM_DIRECTION_UNKNOWN);
1302 EXPECT_EQ(params.scale_factor, pinch_target->scale_factor());
1303 }
1304
1305 // Ensure that if SyntheticPinchGesture is instantiated with TOUCH_INPUT it
1306 // correctly creates a touchscreen gesture.
1307 TEST_F(SyntheticGestureControllerTest, PinchGestureExplicitTouch) {
1308 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
1309
1310 SyntheticPinchGestureParams params;
1311 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
1312 params.scale_factor = 2.3f;
1313 params.anchor.SetPoint(54, 89);
1314
1315 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params));
1316 QueueSyntheticGesture(gesture.Pass());
1317 FlushInputUntilComplete();
1318
1319 // Gesture target will fail expectations if the wrong underlying
1320 // SyntheticPinch*Gesture was instantiated.
1321 }
1322
1323 // Ensure that if SyntheticPinchGesture is instantiated with MOUSE_INPUT it
1324 // correctly creates a touchpad gesture.
1325 TEST_F(SyntheticGestureControllerTest, PinchGestureExplicitMouse) {
1326 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
1327
1328 SyntheticPinchGestureParams params;
1329 params.gesture_source_type = SyntheticGestureParams::MOUSE_INPUT;
1330 params.scale_factor = 2.3f;
1331 params.anchor.SetPoint(54, 89);
1332
1333 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params));
1334 QueueSyntheticGesture(gesture.Pass());
1335 FlushInputUntilComplete();
1336
1337 // Gesture target will fail expectations if the wrong underlying
1338 // SyntheticPinch*Gesture was instantiated.
1339 }
1340
1341 // Ensure that if SyntheticPinchGesture is instantiated with DEFAULT_INPUT it
1342 // correctly creates a touchscreen gesture for a touchscreen controller.
1343 TEST_F(SyntheticGestureControllerTest, PinchGestureDefaultTouch) {
1344 CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
1345
1346 SyntheticPinchGestureParams params;
1347 params.gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT;
1348 params.scale_factor = 2.3f;
1349 params.anchor.SetPoint(54, 89);
1350
1351 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params));
1352 QueueSyntheticGesture(gesture.Pass());
1353 FlushInputUntilComplete();
1354
1355 // Gesture target will fail expectations if the wrong underlying
1356 // SyntheticPinch*Gesture was instantiated.
1357 }
1358
1359 // Ensure that if SyntheticPinchGesture is instantiated with DEFAULT_INPUT it
1360 // correctly creates a touchpad gesture for a touchpad controller.
1361 TEST_F(SyntheticGestureControllerTest, PinchGestureDefaultMouse) {
1362 CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
1363
1364 SyntheticPinchGestureParams params;
1365 params.gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT;
1366 params.scale_factor = 2.3f;
1367 params.anchor.SetPoint(54, 89);
1368
1369 scoped_ptr<SyntheticPinchGesture> gesture(new SyntheticPinchGesture(params));
1370 QueueSyntheticGesture(gesture.Pass());
1371 FlushInputUntilComplete();
1372
1373 // Gesture target will fail expectations if the wrong underlying
1374 // SyntheticPinch*Gesture was instantiated.
1375 }
1376
1165 TEST_F(SyntheticGestureControllerTest, TapGestureTouch) { 1377 TEST_F(SyntheticGestureControllerTest, TapGestureTouch) {
1166 CreateControllerAndTarget<MockSyntheticTapTouchTarget>(); 1378 CreateControllerAndTarget<MockSyntheticTapTouchTarget>();
1167 1379
1168 SyntheticTapGestureParams params; 1380 SyntheticTapGestureParams params;
1169 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; 1381 params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
1170 params.duration_ms = 123; 1382 params.duration_ms = 123;
1171 params.position.SetPoint(87, -124); 1383 params.position.SetPoint(87, -124);
1172 1384
1173 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params)); 1385 scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params));
1174 QueueSyntheticGesture(gesture.Pass()); 1386 QueueSyntheticGesture(gesture.Pass());
(...skipping 29 matching lines...) Expand all
1204 EXPECT_TRUE(tap_target->GestureFinished()); 1416 EXPECT_TRUE(tap_target->GestureFinished());
1205 EXPECT_EQ(tap_target->position(), params.position); 1417 EXPECT_EQ(tap_target->position(), params.position);
1206 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms); 1418 EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms);
1207 EXPECT_GE(GetTotalTime(), 1419 EXPECT_GE(GetTotalTime(),
1208 base::TimeDelta::FromMilliseconds(params.duration_ms)); 1420 base::TimeDelta::FromMilliseconds(params.duration_ms));
1209 } 1421 }
1210 1422
1211 } // namespace 1423 } // namespace
1212 1424
1213 } // namespace content 1425 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/input/synthetic_gesture_target_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698