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

Side by Side Diff: content/browser/renderer_host/web_input_event_aura_unittest.cc

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/web_input_event_aura.h" 5 #include "content/browser/renderer_host/web_input_event_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/events/base_event_utils.h"
13 #include "ui/events/blink/blink_event_util.h" 14 #include "ui/events/blink/blink_event_util.h"
14 #include "ui/events/event.h" 15 #include "ui/events/event.h"
15 #include "ui/events/event_utils.h" 16 #include "ui/events/event_utils.h"
16 #include "ui/events/keycodes/dom/dom_code.h" 17 #include "ui/events/keycodes/dom/dom_code.h"
17 #include "ui/events/keycodes/dom/dom_key.h" 18 #include "ui/events/keycodes/dom/dom_key.h"
18 #include "ui/events/keycodes/dom/keycode_converter.h" 19 #include "ui/events/keycodes/dom/keycode_converter.h"
19 20
20 #if defined(USE_X11) 21 #if defined(USE_X11)
21 #include <X11/keysym.h> 22 #include <X11/keysym.h>
22 #include <X11/Xlib.h> 23 #include <X11/Xlib.h>
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 << ", ui_keycode:" << test_case.ui_keycode 247 << ", ui_keycode:" << test_case.ui_keycode
247 << ", x_keysym:" << test_case.x_keysym 248 << ", x_keysym:" << test_case.x_keysym
248 << "}, expect: " << test_case.expected_result; 249 << "}, expect: " << test_case.expected_result;
249 } 250 }
250 #endif 251 #endif
251 } 252 }
252 253
253 TEST(WebInputEventAuraTest, TestMakeWebMouseEvent) { 254 TEST(WebInputEventAuraTest, TestMakeWebMouseEvent) {
254 { 255 {
255 // Left pressed. 256 // Left pressed.
256 base::TimeDelta timestamp = ui::EventTimeForNow(); 257 base::TimeTicks timestamp = ui::EventTimeForNow();
257 ui::MouseEvent aura_event( 258 ui::MouseEvent aura_event(
258 ui::ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321), 259 ui::ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321),
259 timestamp, ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 260 timestamp, ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
260 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event); 261 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event);
261 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()), 262 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()),
262 webkit_event.modifiers); 263 webkit_event.modifiers);
263 EXPECT_FLOAT_EQ(timestamp.InSecondsF(), webkit_event.timeStampSeconds); 264 EXPECT_FLOAT_EQ(ui::EventTimeStampToSeconds(timestamp),
265 webkit_event.timeStampSeconds);
264 EXPECT_EQ(blink::WebMouseEvent::ButtonLeft, webkit_event.button); 266 EXPECT_EQ(blink::WebMouseEvent::ButtonLeft, webkit_event.button);
265 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type); 267 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type);
266 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount); 268 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount);
267 EXPECT_EQ(123, webkit_event.x); 269 EXPECT_EQ(123, webkit_event.x);
268 EXPECT_EQ(123, webkit_event.windowX); 270 EXPECT_EQ(123, webkit_event.windowX);
269 EXPECT_EQ(321, webkit_event.y); 271 EXPECT_EQ(321, webkit_event.y);
270 EXPECT_EQ(321, webkit_event.windowY); 272 EXPECT_EQ(321, webkit_event.windowY);
271 } 273 }
272 { 274 {
273 // Left released. 275 // Left released.
274 base::TimeDelta timestamp = ui::EventTimeForNow(); 276 base::TimeTicks timestamp = ui::EventTimeForNow();
275 ui::MouseEvent aura_event(ui::ET_MOUSE_RELEASED, gfx::Point(123, 321), 277 ui::MouseEvent aura_event(ui::ET_MOUSE_RELEASED, gfx::Point(123, 321),
276 gfx::Point(123, 321), timestamp, 0, 278 gfx::Point(123, 321), timestamp, 0,
277 ui::EF_LEFT_MOUSE_BUTTON); 279 ui::EF_LEFT_MOUSE_BUTTON);
278 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event); 280 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event);
279 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()), 281 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()),
280 webkit_event.modifiers); 282 webkit_event.modifiers);
281 EXPECT_FLOAT_EQ(timestamp.InSecondsF(), webkit_event.timeStampSeconds); 283 EXPECT_FLOAT_EQ(ui::EventTimeStampToSeconds(timestamp),
284 webkit_event.timeStampSeconds);
282 EXPECT_EQ(blink::WebMouseEvent::ButtonLeft, webkit_event.button); 285 EXPECT_EQ(blink::WebMouseEvent::ButtonLeft, webkit_event.button);
283 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type); 286 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type);
284 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount); 287 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount);
285 EXPECT_EQ(123, webkit_event.x); 288 EXPECT_EQ(123, webkit_event.x);
286 EXPECT_EQ(123, webkit_event.windowX); 289 EXPECT_EQ(123, webkit_event.windowX);
287 EXPECT_EQ(321, webkit_event.y); 290 EXPECT_EQ(321, webkit_event.y);
288 EXPECT_EQ(321, webkit_event.windowY); 291 EXPECT_EQ(321, webkit_event.windowY);
289 } 292 }
290 { 293 {
291 // Middle pressed. 294 // Middle pressed.
292 base::TimeDelta timestamp = ui::EventTimeForNow(); 295 base::TimeTicks timestamp = ui::EventTimeForNow();
293 ui::MouseEvent aura_event( 296 ui::MouseEvent aura_event(
294 ui::ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321), 297 ui::ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321),
295 timestamp, ui::EF_MIDDLE_MOUSE_BUTTON, ui::EF_MIDDLE_MOUSE_BUTTON); 298 timestamp, ui::EF_MIDDLE_MOUSE_BUTTON, ui::EF_MIDDLE_MOUSE_BUTTON);
296 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event); 299 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event);
297 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()), 300 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()),
298 webkit_event.modifiers); 301 webkit_event.modifiers);
299 EXPECT_FLOAT_EQ(timestamp.InSecondsF(), webkit_event.timeStampSeconds); 302 EXPECT_FLOAT_EQ(ui::EventTimeStampToSeconds(timestamp),
303 webkit_event.timeStampSeconds);
300 EXPECT_EQ(blink::WebMouseEvent::ButtonMiddle, webkit_event.button); 304 EXPECT_EQ(blink::WebMouseEvent::ButtonMiddle, webkit_event.button);
301 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type); 305 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type);
302 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount); 306 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount);
303 EXPECT_EQ(123, webkit_event.x); 307 EXPECT_EQ(123, webkit_event.x);
304 EXPECT_EQ(123, webkit_event.windowX); 308 EXPECT_EQ(123, webkit_event.windowX);
305 EXPECT_EQ(321, webkit_event.y); 309 EXPECT_EQ(321, webkit_event.y);
306 EXPECT_EQ(321, webkit_event.windowY); 310 EXPECT_EQ(321, webkit_event.windowY);
307 } 311 }
308 { 312 {
309 // Middle released. 313 // Middle released.
310 base::TimeDelta timestamp = ui::EventTimeForNow(); 314 base::TimeTicks timestamp = ui::EventTimeForNow();
311 ui::MouseEvent aura_event(ui::ET_MOUSE_RELEASED, gfx::Point(123, 321), 315 ui::MouseEvent aura_event(ui::ET_MOUSE_RELEASED, gfx::Point(123, 321),
312 gfx::Point(123, 321), timestamp, 0, 316 gfx::Point(123, 321), timestamp, 0,
313 ui::EF_MIDDLE_MOUSE_BUTTON); 317 ui::EF_MIDDLE_MOUSE_BUTTON);
314 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event); 318 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event);
315 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()), 319 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()),
316 webkit_event.modifiers); 320 webkit_event.modifiers);
317 EXPECT_FLOAT_EQ(timestamp.InSecondsF(), webkit_event.timeStampSeconds); 321 EXPECT_FLOAT_EQ(ui::EventTimeStampToSeconds(timestamp),
322 webkit_event.timeStampSeconds);
318 EXPECT_EQ(blink::WebMouseEvent::ButtonMiddle, webkit_event.button); 323 EXPECT_EQ(blink::WebMouseEvent::ButtonMiddle, webkit_event.button);
319 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type); 324 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type);
320 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount); 325 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount);
321 EXPECT_EQ(123, webkit_event.x); 326 EXPECT_EQ(123, webkit_event.x);
322 EXPECT_EQ(123, webkit_event.windowX); 327 EXPECT_EQ(123, webkit_event.windowX);
323 EXPECT_EQ(321, webkit_event.y); 328 EXPECT_EQ(321, webkit_event.y);
324 EXPECT_EQ(321, webkit_event.windowY); 329 EXPECT_EQ(321, webkit_event.windowY);
325 } 330 }
326 { 331 {
327 // Right pressed. 332 // Right pressed.
328 base::TimeDelta timestamp = ui::EventTimeForNow(); 333 base::TimeTicks timestamp = ui::EventTimeForNow();
329 ui::MouseEvent aura_event( 334 ui::MouseEvent aura_event(
330 ui::ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321), 335 ui::ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321),
331 timestamp, ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON); 336 timestamp, ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON);
332 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event); 337 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event);
333 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()), 338 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()),
334 webkit_event.modifiers); 339 webkit_event.modifiers);
335 EXPECT_FLOAT_EQ(timestamp.InSecondsF(), webkit_event.timeStampSeconds); 340 EXPECT_FLOAT_EQ(ui::EventTimeStampToSeconds(timestamp),
341 webkit_event.timeStampSeconds);
336 EXPECT_EQ(blink::WebMouseEvent::ButtonRight, webkit_event.button); 342 EXPECT_EQ(blink::WebMouseEvent::ButtonRight, webkit_event.button);
337 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type); 343 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type);
338 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount); 344 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount);
339 EXPECT_EQ(123, webkit_event.x); 345 EXPECT_EQ(123, webkit_event.x);
340 EXPECT_EQ(123, webkit_event.windowX); 346 EXPECT_EQ(123, webkit_event.windowX);
341 EXPECT_EQ(321, webkit_event.y); 347 EXPECT_EQ(321, webkit_event.y);
342 EXPECT_EQ(321, webkit_event.windowY); 348 EXPECT_EQ(321, webkit_event.windowY);
343 } 349 }
344 { 350 {
345 // Right released. 351 // Right released.
346 base::TimeDelta timestamp = ui::EventTimeForNow(); 352 base::TimeTicks timestamp = ui::EventTimeForNow();
347 ui::MouseEvent aura_event(ui::ET_MOUSE_RELEASED, gfx::Point(123, 321), 353 ui::MouseEvent aura_event(ui::ET_MOUSE_RELEASED, gfx::Point(123, 321),
348 gfx::Point(123, 321), timestamp, 0, 354 gfx::Point(123, 321), timestamp, 0,
349 ui::EF_RIGHT_MOUSE_BUTTON); 355 ui::EF_RIGHT_MOUSE_BUTTON);
350 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event); 356 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event);
351 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()), 357 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()),
352 webkit_event.modifiers); 358 webkit_event.modifiers);
353 EXPECT_FLOAT_EQ(timestamp.InSecondsF(), webkit_event.timeStampSeconds); 359 EXPECT_FLOAT_EQ(ui::EventTimeStampToSeconds(timestamp),
360 webkit_event.timeStampSeconds);
354 EXPECT_EQ(blink::WebMouseEvent::ButtonRight, webkit_event.button); 361 EXPECT_EQ(blink::WebMouseEvent::ButtonRight, webkit_event.button);
355 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type); 362 EXPECT_EQ(blink::WebInputEvent::MouseUp, webkit_event.type);
356 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount); 363 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount);
357 EXPECT_EQ(123, webkit_event.x); 364 EXPECT_EQ(123, webkit_event.x);
358 EXPECT_EQ(123, webkit_event.windowX); 365 EXPECT_EQ(123, webkit_event.windowX);
359 EXPECT_EQ(321, webkit_event.y); 366 EXPECT_EQ(321, webkit_event.y);
360 EXPECT_EQ(321, webkit_event.windowY); 367 EXPECT_EQ(321, webkit_event.windowY);
361 } 368 }
362 { 369 {
363 // Moved 370 // Moved
364 base::TimeDelta timestamp = ui::EventTimeForNow(); 371 base::TimeTicks timestamp = ui::EventTimeForNow();
365 ui::MouseEvent aura_event(ui::ET_MOUSE_MOVED, gfx::Point(123, 321), 372 ui::MouseEvent aura_event(ui::ET_MOUSE_MOVED, gfx::Point(123, 321),
366 gfx::Point(123, 321), timestamp, 0, 0); 373 gfx::Point(123, 321), timestamp, 0, 0);
367 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event); 374 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event);
368 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()), 375 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()),
369 webkit_event.modifiers); 376 webkit_event.modifiers);
370 EXPECT_FLOAT_EQ(timestamp.InSecondsF(), webkit_event.timeStampSeconds); 377 EXPECT_FLOAT_EQ(ui::EventTimeStampToSeconds(timestamp),
378 webkit_event.timeStampSeconds);
371 EXPECT_EQ(blink::WebMouseEvent::ButtonNone, webkit_event.button); 379 EXPECT_EQ(blink::WebMouseEvent::ButtonNone, webkit_event.button);
372 EXPECT_EQ(blink::WebInputEvent::MouseMove, webkit_event.type); 380 EXPECT_EQ(blink::WebInputEvent::MouseMove, webkit_event.type);
373 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount); 381 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount);
374 EXPECT_EQ(123, webkit_event.x); 382 EXPECT_EQ(123, webkit_event.x);
375 EXPECT_EQ(123, webkit_event.windowX); 383 EXPECT_EQ(123, webkit_event.windowX);
376 EXPECT_EQ(321, webkit_event.y); 384 EXPECT_EQ(321, webkit_event.y);
377 EXPECT_EQ(321, webkit_event.windowY); 385 EXPECT_EQ(321, webkit_event.windowY);
378 } 386 }
379 { 387 {
380 // Moved with left down 388 // Moved with left down
381 base::TimeDelta timestamp = ui::EventTimeForNow(); 389 base::TimeTicks timestamp = ui::EventTimeForNow();
382 ui::MouseEvent aura_event(ui::ET_MOUSE_MOVED, gfx::Point(123, 321), 390 ui::MouseEvent aura_event(ui::ET_MOUSE_MOVED, gfx::Point(123, 321),
383 gfx::Point(123, 321), timestamp, 391 gfx::Point(123, 321), timestamp,
384 ui::EF_LEFT_MOUSE_BUTTON, 0); 392 ui::EF_LEFT_MOUSE_BUTTON, 0);
385 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event); 393 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event);
386 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()), 394 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()),
387 webkit_event.modifiers); 395 webkit_event.modifiers);
388 EXPECT_FLOAT_EQ(timestamp.InSecondsF(), webkit_event.timeStampSeconds); 396 EXPECT_FLOAT_EQ(ui::EventTimeStampToSeconds(timestamp),
397 webkit_event.timeStampSeconds);
389 EXPECT_EQ(blink::WebMouseEvent::ButtonLeft, webkit_event.button); 398 EXPECT_EQ(blink::WebMouseEvent::ButtonLeft, webkit_event.button);
390 EXPECT_EQ(blink::WebInputEvent::MouseMove, webkit_event.type); 399 EXPECT_EQ(blink::WebInputEvent::MouseMove, webkit_event.type);
391 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount); 400 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount);
392 EXPECT_EQ(123, webkit_event.x); 401 EXPECT_EQ(123, webkit_event.x);
393 EXPECT_EQ(123, webkit_event.windowX); 402 EXPECT_EQ(123, webkit_event.windowX);
394 EXPECT_EQ(321, webkit_event.y); 403 EXPECT_EQ(321, webkit_event.y);
395 EXPECT_EQ(321, webkit_event.windowY); 404 EXPECT_EQ(321, webkit_event.windowY);
396 } 405 }
397 { 406 {
398 // Left with shift pressed. 407 // Left with shift pressed.
399 base::TimeDelta timestamp = ui::EventTimeForNow(); 408 base::TimeTicks timestamp = ui::EventTimeForNow();
400 ui::MouseEvent aura_event(ui::ET_MOUSE_PRESSED, gfx::Point(123, 321), 409 ui::MouseEvent aura_event(ui::ET_MOUSE_PRESSED, gfx::Point(123, 321),
401 gfx::Point(123, 321), timestamp, 410 gfx::Point(123, 321), timestamp,
402 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_SHIFT_DOWN, 411 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_SHIFT_DOWN,
403 ui::EF_LEFT_MOUSE_BUTTON); 412 ui::EF_LEFT_MOUSE_BUTTON);
404 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event); 413 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event);
405 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()), 414 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()),
406 webkit_event.modifiers); 415 webkit_event.modifiers);
407 EXPECT_FLOAT_EQ(timestamp.InSecondsF(), webkit_event.timeStampSeconds); 416 EXPECT_FLOAT_EQ(ui::EventTimeStampToSeconds(timestamp),
417 webkit_event.timeStampSeconds);
408 EXPECT_EQ(blink::WebMouseEvent::ButtonLeft, webkit_event.button); 418 EXPECT_EQ(blink::WebMouseEvent::ButtonLeft, webkit_event.button);
409 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type); 419 EXPECT_EQ(blink::WebInputEvent::MouseDown, webkit_event.type);
410 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount); 420 EXPECT_EQ(aura_event.GetClickCount(), webkit_event.clickCount);
411 EXPECT_EQ(123, webkit_event.x); 421 EXPECT_EQ(123, webkit_event.x);
412 EXPECT_EQ(123, webkit_event.windowX); 422 EXPECT_EQ(123, webkit_event.windowX);
413 EXPECT_EQ(321, webkit_event.y); 423 EXPECT_EQ(321, webkit_event.y);
414 EXPECT_EQ(321, webkit_event.windowY); 424 EXPECT_EQ(321, webkit_event.windowY);
415 } 425 }
416 { 426 {
417 // Default values for PointerDetails. 427 // Default values for PointerDetails.
418 base::TimeDelta timestamp = ui::EventTimeForNow(); 428 base::TimeTicks timestamp = ui::EventTimeForNow();
419 ui::MouseEvent aura_event( 429 ui::MouseEvent aura_event(
420 ui::ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321), 430 ui::ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321),
421 timestamp, ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 431 timestamp, ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
422 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event); 432 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event);
423 433
424 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse, 434 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse,
425 webkit_event.pointerType); 435 webkit_event.pointerType);
426 EXPECT_EQ(0, webkit_event.tiltX); 436 EXPECT_EQ(0, webkit_event.tiltX);
427 EXPECT_EQ(0, webkit_event.tiltY); 437 EXPECT_EQ(0, webkit_event.tiltY);
428 EXPECT_TRUE(std::isnan(webkit_event.force)); 438 EXPECT_TRUE(std::isnan(webkit_event.force));
429 EXPECT_EQ(123, webkit_event.x); 439 EXPECT_EQ(123, webkit_event.x);
430 EXPECT_EQ(123, webkit_event.windowX); 440 EXPECT_EQ(123, webkit_event.windowX);
431 EXPECT_EQ(321, webkit_event.y); 441 EXPECT_EQ(321, webkit_event.y);
432 EXPECT_EQ(321, webkit_event.windowY); 442 EXPECT_EQ(321, webkit_event.windowY);
433 } 443 }
434 { 444 {
435 // Stylus values for PointerDetails. 445 // Stylus values for PointerDetails.
436 base::TimeDelta timestamp = ui::EventTimeForNow(); 446 base::TimeTicks timestamp = ui::EventTimeForNow();
437 ui::MouseEvent aura_event( 447 ui::MouseEvent aura_event(
438 ui::ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321), 448 ui::ET_MOUSE_PRESSED, gfx::Point(123, 321), gfx::Point(123, 321),
439 timestamp, ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 449 timestamp, ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
440 aura_event.set_pointer_details( 450 aura_event.set_pointer_details(
441 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_PEN, 451 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_PEN,
442 /* radius_x */ 0.0f, 452 /* radius_x */ 0.0f,
443 /* radius_y */ 0.0f, 453 /* radius_y */ 0.0f,
444 /* force */ 0.8f, 454 /* force */ 0.8f,
445 /* tilt_x */ 89.5f, 455 /* tilt_x */ 89.5f,
446 /* tilt_y */ -89.5f)); 456 /* tilt_y */ -89.5f));
447 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event); 457 blink::WebMouseEvent webkit_event = MakeWebMouseEvent(aura_event);
448 458
449 EXPECT_EQ(blink::WebPointerProperties::PointerType::Pen, 459 EXPECT_EQ(blink::WebPointerProperties::PointerType::Pen,
450 webkit_event.pointerType); 460 webkit_event.pointerType);
451 EXPECT_EQ(90, webkit_event.tiltX); 461 EXPECT_EQ(90, webkit_event.tiltX);
452 EXPECT_EQ(-90, webkit_event.tiltY); 462 EXPECT_EQ(-90, webkit_event.tiltY);
453 EXPECT_FLOAT_EQ(0.8f, webkit_event.force); 463 EXPECT_FLOAT_EQ(0.8f, webkit_event.force);
454 EXPECT_EQ(123, webkit_event.x); 464 EXPECT_EQ(123, webkit_event.x);
455 EXPECT_EQ(123, webkit_event.windowX); 465 EXPECT_EQ(123, webkit_event.windowX);
456 EXPECT_EQ(321, webkit_event.y); 466 EXPECT_EQ(321, webkit_event.y);
457 EXPECT_EQ(321, webkit_event.windowY); 467 EXPECT_EQ(321, webkit_event.windowY);
458 } 468 }
459 } 469 }
460 470
461 TEST(WebInputEventAuraTest, TestMakeWebMouseWheelEvent) { 471 TEST(WebInputEventAuraTest, TestMakeWebMouseWheelEvent) {
462 { 472 {
463 // Mouse wheel. 473 // Mouse wheel.
464 base::TimeDelta timestamp = ui::EventTimeForNow(); 474 base::TimeTicks timestamp = ui::EventTimeForNow();
465 ui::MouseWheelEvent aura_event( 475 ui::MouseWheelEvent aura_event(
466 gfx::Vector2d(ui::MouseWheelEvent::kWheelDelta * 2, 476 gfx::Vector2d(ui::MouseWheelEvent::kWheelDelta * 2,
467 -ui::MouseWheelEvent::kWheelDelta * 2), 477 -ui::MouseWheelEvent::kWheelDelta * 2),
468 gfx::Point(123, 321), gfx::Point(123, 321), timestamp, 0, 0); 478 gfx::Point(123, 321), gfx::Point(123, 321), timestamp, 0, 0);
469 blink::WebMouseWheelEvent webkit_event = MakeWebMouseWheelEvent(aura_event); 479 blink::WebMouseWheelEvent webkit_event = MakeWebMouseWheelEvent(aura_event);
470 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()), 480 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()),
471 webkit_event.modifiers); 481 webkit_event.modifiers);
472 EXPECT_FLOAT_EQ(timestamp.InSecondsF(), webkit_event.timeStampSeconds); 482 EXPECT_FLOAT_EQ(ui::EventTimeStampToSeconds(timestamp),
483 webkit_event.timeStampSeconds);
473 EXPECT_EQ(blink::WebMouseEvent::ButtonNone, webkit_event.button); 484 EXPECT_EQ(blink::WebMouseEvent::ButtonNone, webkit_event.button);
474 EXPECT_EQ(blink::WebInputEvent::MouseWheel, webkit_event.type); 485 EXPECT_EQ(blink::WebInputEvent::MouseWheel, webkit_event.type);
475 EXPECT_FLOAT_EQ(aura_event.x_offset() / 53.0f, webkit_event.wheelTicksX); 486 EXPECT_FLOAT_EQ(aura_event.x_offset() / 53.0f, webkit_event.wheelTicksX);
476 EXPECT_FLOAT_EQ(aura_event.y_offset() / 53.0f, webkit_event.wheelTicksY); 487 EXPECT_FLOAT_EQ(aura_event.y_offset() / 53.0f, webkit_event.wheelTicksY);
477 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse, 488 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse,
478 webkit_event.pointerType); 489 webkit_event.pointerType);
479 EXPECT_EQ(0, webkit_event.tiltX); 490 EXPECT_EQ(0, webkit_event.tiltX);
480 EXPECT_EQ(0, webkit_event.tiltY); 491 EXPECT_EQ(0, webkit_event.tiltY);
481 EXPECT_TRUE(std::isnan(webkit_event.force)); 492 EXPECT_TRUE(std::isnan(webkit_event.force));
482 EXPECT_EQ(123, webkit_event.x); 493 EXPECT_EQ(123, webkit_event.x);
483 EXPECT_EQ(123, webkit_event.windowX); 494 EXPECT_EQ(123, webkit_event.windowX);
484 EXPECT_EQ(321, webkit_event.y); 495 EXPECT_EQ(321, webkit_event.y);
485 EXPECT_EQ(321, webkit_event.windowY); 496 EXPECT_EQ(321, webkit_event.windowY);
486 } 497 }
487 { 498 {
488 // Mouse wheel with shift and no x offset. 499 // Mouse wheel with shift and no x offset.
489 base::TimeDelta timestamp = ui::EventTimeForNow(); 500 base::TimeTicks timestamp = ui::EventTimeForNow();
490 ui::MouseWheelEvent aura_event( 501 ui::MouseWheelEvent aura_event(
491 gfx::Vector2d(0, -ui::MouseWheelEvent::kWheelDelta * 2), 502 gfx::Vector2d(0, -ui::MouseWheelEvent::kWheelDelta * 2),
492 gfx::Point(123, 321), gfx::Point(123, 321), timestamp, 503 gfx::Point(123, 321), gfx::Point(123, 321), timestamp,
493 ui::EF_SHIFT_DOWN, 0); 504 ui::EF_SHIFT_DOWN, 0);
494 blink::WebMouseWheelEvent webkit_event = MakeWebMouseWheelEvent(aura_event); 505 blink::WebMouseWheelEvent webkit_event = MakeWebMouseWheelEvent(aura_event);
495 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()), 506 EXPECT_EQ(ui::EventFlagsToWebEventModifiers(aura_event.flags()),
496 webkit_event.modifiers); 507 webkit_event.modifiers);
497 EXPECT_FLOAT_EQ(timestamp.InSecondsF(), webkit_event.timeStampSeconds); 508 EXPECT_FLOAT_EQ(ui::EventTimeStampToSeconds(timestamp),
509 webkit_event.timeStampSeconds);
498 EXPECT_EQ(blink::WebMouseEvent::ButtonNone, webkit_event.button); 510 EXPECT_EQ(blink::WebMouseEvent::ButtonNone, webkit_event.button);
499 EXPECT_EQ(blink::WebInputEvent::MouseWheel, webkit_event.type); 511 EXPECT_EQ(blink::WebInputEvent::MouseWheel, webkit_event.type);
500 EXPECT_FLOAT_EQ(aura_event.y_offset() / 53.0f, webkit_event.wheelTicksX); 512 EXPECT_FLOAT_EQ(aura_event.y_offset() / 53.0f, webkit_event.wheelTicksX);
501 EXPECT_FLOAT_EQ(0, webkit_event.wheelTicksY); 513 EXPECT_FLOAT_EQ(0, webkit_event.wheelTicksY);
502 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse, 514 EXPECT_EQ(blink::WebPointerProperties::PointerType::Mouse,
503 webkit_event.pointerType); 515 webkit_event.pointerType);
504 EXPECT_EQ(0, webkit_event.tiltX); 516 EXPECT_EQ(0, webkit_event.tiltX);
505 EXPECT_EQ(0, webkit_event.tiltY); 517 EXPECT_EQ(0, webkit_event.tiltY);
506 EXPECT_TRUE(std::isnan(webkit_event.force)); 518 EXPECT_TRUE(std::isnan(webkit_event.force));
507 EXPECT_EQ(123, webkit_event.x); 519 EXPECT_EQ(123, webkit_event.x);
508 EXPECT_EQ(123, webkit_event.windowX); 520 EXPECT_EQ(123, webkit_event.windowX);
509 EXPECT_EQ(321, webkit_event.y); 521 EXPECT_EQ(321, webkit_event.y);
510 EXPECT_EQ(321, webkit_event.windowY); 522 EXPECT_EQ(321, webkit_event.windowY);
511 } 523 }
512 } 524 }
513 525
514 } // namespace content 526 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/web_input_event_aura.cc ('k') | content/browser/renderer_host/web_input_event_aurawin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698