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 "ui/events/blink/web_input_event.h" | 5 #include "ui/events/blink/web_input_event.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 EF_LEFT_MOUSE_BUTTON); | 253 EF_LEFT_MOUSE_BUTTON); |
254 blink::WebMouseEvent webkit_event = | 254 blink::WebMouseEvent webkit_event = |
255 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 255 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
256 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), | 256 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), |
257 webkit_event.modifiers()); | 257 webkit_event.modifiers()); |
258 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), | 258 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), |
259 webkit_event.timeStampSeconds()); | 259 webkit_event.timeStampSeconds()); |
260 EXPECT_EQ(blink::WebMouseEvent::Button::Left, webkit_event.button); | 260 EXPECT_EQ(blink::WebMouseEvent::Button::Left, webkit_event.button); |
261 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type()); | 261 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type()); |
262 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); | 262 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); |
263 EXPECT_EQ(123, webkit_event.x); | 263 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
264 EXPECT_EQ(321, webkit_event.y); | 264 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
265 } | 265 } |
266 { | 266 { |
267 // Left released. | 267 // Left released. |
268 base::TimeTicks timestamp = EventTimeForNow(); | 268 base::TimeTicks timestamp = EventTimeForNow(); |
269 MouseEvent ui_event(ET_MOUSE_RELEASED, gfx::Point(123, 321), | 269 MouseEvent ui_event(ET_MOUSE_RELEASED, gfx::Point(123, 321), |
270 gfx::Point(123, 321), timestamp, 0, | 270 gfx::Point(123, 321), timestamp, 0, |
271 EF_LEFT_MOUSE_BUTTON); | 271 EF_LEFT_MOUSE_BUTTON); |
272 blink::WebMouseEvent webkit_event = | 272 blink::WebMouseEvent webkit_event = |
273 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 273 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
274 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), | 274 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), |
275 webkit_event.modifiers()); | 275 webkit_event.modifiers()); |
276 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), | 276 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), |
277 webkit_event.timeStampSeconds()); | 277 webkit_event.timeStampSeconds()); |
278 EXPECT_EQ(blink::WebMouseEvent::Button::Left, webkit_event.button); | 278 EXPECT_EQ(blink::WebMouseEvent::Button::Left, webkit_event.button); |
279 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type()); | 279 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type()); |
280 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); | 280 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); |
281 EXPECT_EQ(123, webkit_event.x); | 281 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
282 EXPECT_EQ(321, webkit_event.y); | 282 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
283 } | 283 } |
284 { | 284 { |
285 // Middle pressed. | 285 // Middle pressed. |
286 base::TimeTicks timestamp = EventTimeForNow(); | 286 base::TimeTicks timestamp = EventTimeForNow(); |
287 MouseEvent ui_event(ET_MOUSE_PRESSED, gfx::Point(123, 321), | 287 MouseEvent ui_event(ET_MOUSE_PRESSED, gfx::Point(123, 321), |
288 gfx::Point(123, 321), timestamp, EF_MIDDLE_MOUSE_BUTTON, | 288 gfx::Point(123, 321), timestamp, EF_MIDDLE_MOUSE_BUTTON, |
289 EF_MIDDLE_MOUSE_BUTTON); | 289 EF_MIDDLE_MOUSE_BUTTON); |
290 blink::WebMouseEvent webkit_event = | 290 blink::WebMouseEvent webkit_event = |
291 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 291 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
292 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), | 292 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), |
293 webkit_event.modifiers()); | 293 webkit_event.modifiers()); |
294 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), | 294 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), |
295 webkit_event.timeStampSeconds()); | 295 webkit_event.timeStampSeconds()); |
296 EXPECT_EQ(blink::WebMouseEvent::Button::Middle, webkit_event.button); | 296 EXPECT_EQ(blink::WebMouseEvent::Button::Middle, webkit_event.button); |
297 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type()); | 297 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type()); |
298 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); | 298 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); |
299 EXPECT_EQ(123, webkit_event.x); | 299 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
300 EXPECT_EQ(321, webkit_event.y); | 300 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
301 } | 301 } |
302 { | 302 { |
303 // Middle released. | 303 // Middle released. |
304 base::TimeTicks timestamp = EventTimeForNow(); | 304 base::TimeTicks timestamp = EventTimeForNow(); |
305 MouseEvent ui_event(ET_MOUSE_RELEASED, gfx::Point(123, 321), | 305 MouseEvent ui_event(ET_MOUSE_RELEASED, gfx::Point(123, 321), |
306 gfx::Point(123, 321), timestamp, 0, | 306 gfx::Point(123, 321), timestamp, 0, |
307 EF_MIDDLE_MOUSE_BUTTON); | 307 EF_MIDDLE_MOUSE_BUTTON); |
308 blink::WebMouseEvent webkit_event = | 308 blink::WebMouseEvent webkit_event = |
309 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 309 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
310 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), | 310 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), |
311 webkit_event.modifiers()); | 311 webkit_event.modifiers()); |
312 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), | 312 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), |
313 webkit_event.timeStampSeconds()); | 313 webkit_event.timeStampSeconds()); |
314 EXPECT_EQ(blink::WebMouseEvent::Button::Middle, webkit_event.button); | 314 EXPECT_EQ(blink::WebMouseEvent::Button::Middle, webkit_event.button); |
315 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type()); | 315 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type()); |
316 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); | 316 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); |
317 EXPECT_EQ(123, webkit_event.x); | 317 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
318 EXPECT_EQ(321, webkit_event.y); | 318 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
319 } | 319 } |
320 { | 320 { |
321 // Right pressed. | 321 // Right pressed. |
322 base::TimeTicks timestamp = EventTimeForNow(); | 322 base::TimeTicks timestamp = EventTimeForNow(); |
323 MouseEvent ui_event(ET_MOUSE_PRESSED, gfx::Point(123, 321), | 323 MouseEvent ui_event(ET_MOUSE_PRESSED, gfx::Point(123, 321), |
324 gfx::Point(123, 321), timestamp, EF_RIGHT_MOUSE_BUTTON, | 324 gfx::Point(123, 321), timestamp, EF_RIGHT_MOUSE_BUTTON, |
325 EF_RIGHT_MOUSE_BUTTON); | 325 EF_RIGHT_MOUSE_BUTTON); |
326 blink::WebMouseEvent webkit_event = | 326 blink::WebMouseEvent webkit_event = |
327 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 327 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
328 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), | 328 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), |
329 webkit_event.modifiers()); | 329 webkit_event.modifiers()); |
330 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), | 330 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), |
331 webkit_event.timeStampSeconds()); | 331 webkit_event.timeStampSeconds()); |
332 EXPECT_EQ(blink::WebMouseEvent::Button::Right, webkit_event.button); | 332 EXPECT_EQ(blink::WebMouseEvent::Button::Right, webkit_event.button); |
333 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type()); | 333 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type()); |
334 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); | 334 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); |
335 EXPECT_EQ(123, webkit_event.x); | 335 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
336 EXPECT_EQ(321, webkit_event.y); | 336 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
337 } | 337 } |
338 { | 338 { |
339 // Right released. | 339 // Right released. |
340 base::TimeTicks timestamp = EventTimeForNow(); | 340 base::TimeTicks timestamp = EventTimeForNow(); |
341 MouseEvent ui_event(ET_MOUSE_RELEASED, gfx::Point(123, 321), | 341 MouseEvent ui_event(ET_MOUSE_RELEASED, gfx::Point(123, 321), |
342 gfx::Point(123, 321), timestamp, 0, | 342 gfx::Point(123, 321), timestamp, 0, |
343 EF_RIGHT_MOUSE_BUTTON); | 343 EF_RIGHT_MOUSE_BUTTON); |
344 blink::WebMouseEvent webkit_event = | 344 blink::WebMouseEvent webkit_event = |
345 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 345 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
346 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), | 346 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), |
347 webkit_event.modifiers()); | 347 webkit_event.modifiers()); |
348 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), | 348 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), |
349 webkit_event.timeStampSeconds()); | 349 webkit_event.timeStampSeconds()); |
350 EXPECT_EQ(blink::WebMouseEvent::Button::Right, webkit_event.button); | 350 EXPECT_EQ(blink::WebMouseEvent::Button::Right, webkit_event.button); |
351 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type()); | 351 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type()); |
352 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); | 352 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); |
353 EXPECT_EQ(123, webkit_event.x); | 353 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
354 EXPECT_EQ(321, webkit_event.y); | 354 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
355 } | 355 } |
356 { | 356 { |
357 // Moved | 357 // Moved |
358 base::TimeTicks timestamp = EventTimeForNow(); | 358 base::TimeTicks timestamp = EventTimeForNow(); |
359 MouseEvent ui_event(ET_MOUSE_MOVED, gfx::Point(123, 321), | 359 MouseEvent ui_event(ET_MOUSE_MOVED, gfx::Point(123, 321), |
360 gfx::Point(123, 321), timestamp, 0, 0); | 360 gfx::Point(123, 321), timestamp, 0, 0); |
361 blink::WebMouseEvent webkit_event = | 361 blink::WebMouseEvent webkit_event = |
362 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 362 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
363 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), | 363 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), |
364 webkit_event.modifiers()); | 364 webkit_event.modifiers()); |
365 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), | 365 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), |
366 webkit_event.timeStampSeconds()); | 366 webkit_event.timeStampSeconds()); |
367 EXPECT_EQ(blink::WebMouseEvent::Button::NoButton, webkit_event.button); | 367 EXPECT_EQ(blink::WebMouseEvent::Button::NoButton, webkit_event.button); |
368 EXPECT_EQ(blink::WebInputEvent::MouseMove, webkit_event.type()); | 368 EXPECT_EQ(blink::WebInputEvent::MouseMove, webkit_event.type()); |
369 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); | 369 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); |
370 EXPECT_EQ(123, webkit_event.x); | 370 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
371 EXPECT_EQ(321, webkit_event.y); | 371 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
372 } | 372 } |
373 { | 373 { |
374 // Moved with left down | 374 // Moved with left down |
375 base::TimeTicks timestamp = EventTimeForNow(); | 375 base::TimeTicks timestamp = EventTimeForNow(); |
376 MouseEvent ui_event(ET_MOUSE_MOVED, gfx::Point(123, 321), | 376 MouseEvent ui_event(ET_MOUSE_MOVED, gfx::Point(123, 321), |
377 gfx::Point(123, 321), timestamp, EF_LEFT_MOUSE_BUTTON, | 377 gfx::Point(123, 321), timestamp, EF_LEFT_MOUSE_BUTTON, |
378 0); | 378 0); |
379 blink::WebMouseEvent webkit_event = | 379 blink::WebMouseEvent webkit_event = |
380 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 380 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
381 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), | 381 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), |
382 webkit_event.modifiers()); | 382 webkit_event.modifiers()); |
383 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), | 383 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), |
384 webkit_event.timeStampSeconds()); | 384 webkit_event.timeStampSeconds()); |
385 EXPECT_EQ(blink::WebMouseEvent::Button::Left, webkit_event.button); | 385 EXPECT_EQ(blink::WebMouseEvent::Button::Left, webkit_event.button); |
386 EXPECT_EQ(blink::WebInputEvent::MouseMove, webkit_event.type()); | 386 EXPECT_EQ(blink::WebInputEvent::MouseMove, webkit_event.type()); |
387 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); | 387 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); |
388 EXPECT_EQ(123, webkit_event.x); | 388 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
389 EXPECT_EQ(321, webkit_event.y); | 389 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
390 } | 390 } |
391 { | 391 { |
392 // Left with shift pressed. | 392 // Left with shift pressed. |
393 base::TimeTicks timestamp = EventTimeForNow(); | 393 base::TimeTicks timestamp = EventTimeForNow(); |
394 MouseEvent ui_event( | 394 MouseEvent ui_event( |
395 ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321), timestamp, | 395 ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321), timestamp, |
396 EF_LEFT_MOUSE_BUTTON | EF_SHIFT_DOWN, EF_LEFT_MOUSE_BUTTON); | 396 EF_LEFT_MOUSE_BUTTON | EF_SHIFT_DOWN, EF_LEFT_MOUSE_BUTTON); |
397 blink::WebMouseEvent webkit_event = | 397 blink::WebMouseEvent webkit_event = |
398 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 398 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
399 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), | 399 EXPECT_EQ(EventFlagsToWebEventModifiers(ui_event.flags()), |
400 webkit_event.modifiers()); | 400 webkit_event.modifiers()); |
401 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), | 401 EXPECT_FLOAT_EQ(EventTimeStampToSeconds(timestamp), |
402 webkit_event.timeStampSeconds()); | 402 webkit_event.timeStampSeconds()); |
403 EXPECT_EQ(blink::WebMouseEvent::Button::Left, webkit_event.button); | 403 EXPECT_EQ(blink::WebMouseEvent::Button::Left, webkit_event.button); |
404 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type()); | 404 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type()); |
405 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); | 405 EXPECT_EQ(ui_event.GetClickCount(), webkit_event.clickCount); |
406 EXPECT_EQ(123, webkit_event.x); | 406 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
407 EXPECT_EQ(321, webkit_event.y); | 407 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
408 } | 408 } |
409 { | 409 { |
410 // Default values for PointerDetails. | 410 // Default values for PointerDetails. |
411 base::TimeTicks timestamp = EventTimeForNow(); | 411 base::TimeTicks timestamp = EventTimeForNow(); |
412 MouseEvent ui_event(ET_MOUSE_PRESSED, gfx::Point(123, 321), | 412 MouseEvent ui_event(ET_MOUSE_PRESSED, gfx::Point(123, 321), |
413 gfx::Point(123, 321), timestamp, EF_LEFT_MOUSE_BUTTON, | 413 gfx::Point(123, 321), timestamp, EF_LEFT_MOUSE_BUTTON, |
414 EF_LEFT_MOUSE_BUTTON); | 414 EF_LEFT_MOUSE_BUTTON); |
415 blink::WebMouseEvent webkit_event = | 415 blink::WebMouseEvent webkit_event = |
416 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 416 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
417 | 417 |
418 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse, | 418 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse, |
419 webkit_event.pointerType); | 419 webkit_event.pointerType); |
420 EXPECT_EQ(0, webkit_event.tiltX); | 420 EXPECT_EQ(0, webkit_event.tiltX); |
421 EXPECT_EQ(0, webkit_event.tiltY); | 421 EXPECT_EQ(0, webkit_event.tiltY); |
422 EXPECT_TRUE(std::isnan(webkit_event.force)); | 422 EXPECT_TRUE(std::isnan(webkit_event.force)); |
423 EXPECT_EQ(0.0f, webkit_event.tangentialPressure); | 423 EXPECT_EQ(0.0f, webkit_event.tangentialPressure); |
424 EXPECT_EQ(0, webkit_event.twist); | 424 EXPECT_EQ(0, webkit_event.twist); |
425 EXPECT_EQ(123, webkit_event.x); | 425 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
426 EXPECT_EQ(321, webkit_event.y); | 426 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
427 } | 427 } |
428 { | 428 { |
429 // Stylus values for PointerDetails. | 429 // Stylus values for PointerDetails. |
430 base::TimeTicks timestamp = EventTimeForNow(); | 430 base::TimeTicks timestamp = EventTimeForNow(); |
431 MouseEvent ui_event(ET_MOUSE_PRESSED, gfx::Point(123, 321), | 431 MouseEvent ui_event(ET_MOUSE_PRESSED, gfx::Point(123, 321), |
432 gfx::Point(123, 321), timestamp, EF_LEFT_MOUSE_BUTTON, | 432 gfx::Point(123, 321), timestamp, EF_LEFT_MOUSE_BUTTON, |
433 EF_LEFT_MOUSE_BUTTON); | 433 EF_LEFT_MOUSE_BUTTON); |
434 PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, | 434 PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, |
435 /* id */ 63, | 435 /* id */ 63, |
436 /* radius_x */ 0.0f, | 436 /* radius_x */ 0.0f, |
437 /* radius_y */ 0.0f, | 437 /* radius_y */ 0.0f, |
438 /* force */ 0.8f, | 438 /* force */ 0.8f, |
439 /* tilt_x */ 89.5f, | 439 /* tilt_x */ 89.5f, |
440 /* tilt_y */ -89.5f, | 440 /* tilt_y */ -89.5f, |
441 /* tangential_pressure */ 0.6f, | 441 /* tangential_pressure */ 0.6f, |
442 /* twist */ 269); | 442 /* twist */ 269); |
443 ui_event.set_pointer_details(pointer_details); | 443 ui_event.set_pointer_details(pointer_details); |
444 blink::WebMouseEvent webkit_event = | 444 blink::WebMouseEvent webkit_event = |
445 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 445 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
446 | 446 |
447 EXPECT_EQ(blink::WebPointerProperties::PointerType::Pen, | 447 EXPECT_EQ(blink::WebPointerProperties::PointerType::Pen, |
448 webkit_event.pointerType); | 448 webkit_event.pointerType); |
449 EXPECT_EQ(90, webkit_event.tiltX); | 449 EXPECT_EQ(90, webkit_event.tiltX); |
450 EXPECT_EQ(-90, webkit_event.tiltY); | 450 EXPECT_EQ(-90, webkit_event.tiltY); |
451 EXPECT_FLOAT_EQ(0.8f, webkit_event.force); | 451 EXPECT_FLOAT_EQ(0.8f, webkit_event.force); |
452 EXPECT_FLOAT_EQ(0.6f, webkit_event.tangentialPressure); | 452 EXPECT_FLOAT_EQ(0.6f, webkit_event.tangentialPressure); |
453 EXPECT_EQ(269, webkit_event.twist); | 453 EXPECT_EQ(269, webkit_event.twist); |
454 EXPECT_EQ(63, webkit_event.id); | 454 EXPECT_EQ(63, webkit_event.id); |
455 EXPECT_EQ(123, webkit_event.x); | 455 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
456 EXPECT_EQ(321, webkit_event.y); | 456 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
457 } | 457 } |
458 } | 458 } |
459 | 459 |
460 TEST(WebInputEventTest, TestMakeWebMouseWheelEvent) { | 460 TEST(WebInputEventTest, TestMakeWebMouseWheelEvent) { |
461 { | 461 { |
462 // Mouse wheel. | 462 // Mouse wheel. |
463 base::TimeTicks timestamp = EventTimeForNow(); | 463 base::TimeTicks timestamp = EventTimeForNow(); |
464 MouseWheelEvent ui_event(gfx::Vector2d(MouseWheelEvent::kWheelDelta * 2, | 464 MouseWheelEvent ui_event(gfx::Vector2d(MouseWheelEvent::kWheelDelta * 2, |
465 -MouseWheelEvent::kWheelDelta * 2), | 465 -MouseWheelEvent::kWheelDelta * 2), |
466 gfx::Point(123, 321), gfx::Point(123, 321), | 466 gfx::Point(123, 321), gfx::Point(123, 321), |
(...skipping 10 matching lines...) Expand all Loading... |
477 webkit_event.wheelTicksX); | 477 webkit_event.wheelTicksX); |
478 EXPECT_FLOAT_EQ(ui_event.y_offset() / MouseWheelEvent::kWheelDelta, | 478 EXPECT_FLOAT_EQ(ui_event.y_offset() / MouseWheelEvent::kWheelDelta, |
479 webkit_event.wheelTicksY); | 479 webkit_event.wheelTicksY); |
480 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse, | 480 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse, |
481 webkit_event.pointerType); | 481 webkit_event.pointerType); |
482 EXPECT_EQ(0, webkit_event.tiltX); | 482 EXPECT_EQ(0, webkit_event.tiltX); |
483 EXPECT_EQ(0, webkit_event.tiltY); | 483 EXPECT_EQ(0, webkit_event.tiltY); |
484 EXPECT_TRUE(std::isnan(webkit_event.force)); | 484 EXPECT_TRUE(std::isnan(webkit_event.force)); |
485 EXPECT_EQ(0.0f, webkit_event.tangentialPressure); | 485 EXPECT_EQ(0.0f, webkit_event.tangentialPressure); |
486 EXPECT_EQ(0, webkit_event.twist); | 486 EXPECT_EQ(0, webkit_event.twist); |
487 EXPECT_EQ(123, webkit_event.x); | 487 EXPECT_EQ(123, webkit_event.positionInWidget().x); |
488 EXPECT_EQ(321, webkit_event.y); | 488 EXPECT_EQ(321, webkit_event.positionInWidget().y); |
489 } | 489 } |
490 } | 490 } |
491 | 491 |
492 TEST(WebInputEventTest, KeyEvent) { | 492 TEST(WebInputEventTest, KeyEvent) { |
493 struct { | 493 struct { |
494 ui::KeyEvent event; | 494 ui::KeyEvent event; |
495 blink::WebInputEvent::Type web_type; | 495 blink::WebInputEvent::Type web_type; |
496 int web_modifiers; | 496 int web_modifiers; |
497 } tests[] = { | 497 } tests[] = { |
498 {ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE), | 498 {ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 | 551 |
552 for (size_t i = 0; i < arraysize(tests); i++) { | 552 for (size_t i = 0; i < arraysize(tests); i++) { |
553 ui::MouseEvent ui_event(tests[i].ui_type, tests[i].location, | 553 ui::MouseEvent ui_event(tests[i].ui_type, tests[i].location, |
554 tests[i].screen_location, base::TimeTicks(), | 554 tests[i].screen_location, base::TimeTicks(), |
555 tests[i].ui_modifiers, 0); | 555 tests[i].ui_modifiers, 0); |
556 blink::WebMouseEvent web_event = | 556 blink::WebMouseEvent web_event = |
557 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); | 557 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent)); |
558 ASSERT_TRUE(blink::WebInputEvent::isMouseEventType(web_event.type())); | 558 ASSERT_TRUE(blink::WebInputEvent::isMouseEventType(web_event.type())); |
559 ASSERT_EQ(tests[i].web_type, web_event.type()); | 559 ASSERT_EQ(tests[i].web_type, web_event.type()); |
560 ASSERT_EQ(tests[i].web_modifiers, web_event.modifiers()); | 560 ASSERT_EQ(tests[i].web_modifiers, web_event.modifiers()); |
561 ASSERT_EQ(tests[i].location.x(), web_event.x); | 561 ASSERT_EQ(tests[i].location.x(), web_event.positionInWidget().x); |
562 ASSERT_EQ(tests[i].location.y(), web_event.y); | 562 ASSERT_EQ(tests[i].location.y(), web_event.positionInWidget().y); |
563 ASSERT_EQ(tests[i].screen_location.x(), web_event.globalX); | 563 ASSERT_EQ(tests[i].screen_location.x(), web_event.positionInScreen().x); |
564 ASSERT_EQ(tests[i].screen_location.y(), web_event.globalY); | 564 ASSERT_EQ(tests[i].screen_location.y(), web_event.positionInScreen().y); |
565 } | 565 } |
566 } | 566 } |
567 | 567 |
568 } // namespace ui | 568 } // namespace ui |
OLD | NEW |