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

Side by Side Diff: ui/events/blink/web_input_event_unittest.cc

Issue 2270953002: Merge the mojo blink type converter into ui/events/blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Review Created 4 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
OLDNEW
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/macros.h" 10 #include "base/macros.h"
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 EXPECT_EQ(0, webkit_event.tiltX); 520 EXPECT_EQ(0, webkit_event.tiltX);
521 EXPECT_EQ(0, webkit_event.tiltY); 521 EXPECT_EQ(0, webkit_event.tiltY);
522 EXPECT_TRUE(std::isnan(webkit_event.force)); 522 EXPECT_TRUE(std::isnan(webkit_event.force));
523 EXPECT_EQ(123, webkit_event.x); 523 EXPECT_EQ(123, webkit_event.x);
524 EXPECT_EQ(123, webkit_event.windowX); 524 EXPECT_EQ(123, webkit_event.windowX);
525 EXPECT_EQ(321, webkit_event.y); 525 EXPECT_EQ(321, webkit_event.y);
526 EXPECT_EQ(321, webkit_event.windowY); 526 EXPECT_EQ(321, webkit_event.windowY);
527 } 527 }
528 } 528 }
529 529
530 TEST(WebInputEventTest, KeyEvent) {
531 struct {
532 ui::KeyEvent event;
533 blink::WebInputEvent::Type web_type;
534 int web_modifiers;
535 } tests[] = {
536 {ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE),
537 blink::WebInputEvent::RawKeyDown, 0x0},
538 {ui::KeyEvent(L'B', ui::VKEY_B, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN),
539 blink::WebInputEvent::Char,
540 blink::WebInputEvent::ShiftKey | blink::WebInputEvent::ControlKey},
541 {ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_C, ui::EF_ALT_DOWN),
542 blink::WebInputEvent::KeyUp, blink::WebInputEvent::AltKey}};
543
544 for (size_t i = 0; i < arraysize(tests); i++) {
545 blink::WebKeyboardEvent web_event = MakeWebKeyboardEvent(tests[i].event);
546 ASSERT_TRUE(blink::WebInputEvent::isKeyboardEventType(web_event.type));
547 ASSERT_EQ(tests[i].web_type, web_event.type);
548 ASSERT_EQ(tests[i].web_modifiers, web_event.modifiers);
549 ASSERT_EQ(static_cast<int>(tests[i].event.GetLocatedWindowsKeyboardCode()),
550 web_event.windowsKeyCode);
551 }
552 }
553
554 TEST(WebInputEventTest, WheelEvent) {
555 const int kDeltaX = 14;
556 const int kDeltaY = -3;
557 ui::MouseWheelEvent ui_event(
558 ui::MouseEvent(ui::ET_MOUSEWHEEL, gfx::Point(), gfx::Point(),
559 base::TimeTicks(), 0, 0),
560 kDeltaX, kDeltaY);
561 blink::WebMouseWheelEvent web_event =
562 MakeWebMouseWheelEvent(ui_event, base::Bind(&GetScreenLocationFromEvent));
563 ASSERT_EQ(blink::WebInputEvent::MouseWheel, web_event.type);
564 ASSERT_EQ(0, web_event.modifiers);
565 ASSERT_EQ(kDeltaX, web_event.deltaX);
566 ASSERT_EQ(kDeltaY, web_event.deltaY);
567 }
568
569 TEST(WebInputEventTest, MousePointerEvent) {
570 struct {
571 ui::EventType ui_type;
572 blink::WebInputEvent::Type web_type;
573 int ui_modifiers;
574 int web_modifiers;
575 gfx::Point location;
576 gfx::Point screen_location;
577 } tests[] = {
578 {ui::ET_MOUSE_PRESSED, blink::WebInputEvent::MouseDown, 0x0, 0x0,
579 gfx::Point(3, 5), gfx::Point(113, 125)},
580 {ui::ET_MOUSE_RELEASED, blink::WebInputEvent::MouseUp,
581 ui::EF_LEFT_MOUSE_BUTTON, blink::WebInputEvent::LeftButtonDown,
582 gfx::Point(100, 1), gfx::Point(50, 1)},
583 {ui::ET_MOUSE_MOVED, blink::WebInputEvent::MouseMove,
584 ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON,
585 blink::WebInputEvent::MiddleButtonDown |
586 blink::WebInputEvent::RightButtonDown,
587 gfx::Point(13, 3), gfx::Point(53, 3)},
588 };
589
590 for (size_t i = 0; i < arraysize(tests); i++) {
591 ui::MouseEvent ui_event(tests[i].ui_type, tests[i].location,
592 tests[i].screen_location, base::TimeTicks(),
593 tests[i].ui_modifiers, 0);
594 blink::WebMouseEvent web_event =
595 MakeWebMouseEvent(ui_event, base::Bind(&GetScreenLocationFromEvent));
596 ASSERT_TRUE(blink::WebInputEvent::isMouseEventType(web_event.type));
597 ASSERT_EQ(tests[i].web_type, web_event.type);
598 ASSERT_EQ(tests[i].web_modifiers, web_event.modifiers);
599 ASSERT_EQ(tests[i].location.x(), web_event.x);
600 ASSERT_EQ(tests[i].location.y(), web_event.y);
601 ASSERT_EQ(tests[i].screen_location.x(), web_event.globalX);
602 ASSERT_EQ(tests[i].screen_location.y(), web_event.globalY);
603 }
604 }
605
530 } // namespace ui 606 } // namespace ui
OLDNEW
« content/renderer/mus/compositor_mus_connection.cc ('K') | « ui/events/blink/web_input_event.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698