OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/input/web_input_event_builders_mac.h" | 5 #include "content/browser/renderer_host/input/web_input_event_builders_mac.h" |
6 | 6 |
7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 {kVK_Function, ui::DomKey::FN}}; | 556 {kVK_Function, ui::DomKey::FN}}; |
557 | 557 |
558 for (const DomKeyTestCase& entry : table) { | 558 for (const DomKeyTestCase& entry : table) { |
559 NSEvent* mac_event = | 559 NSEvent* mac_event = |
560 BuildFakeKeyEvent(entry.mac_key_code, 0, 0, NSFlagsChanged); | 560 BuildFakeKeyEvent(entry.mac_key_code, 0, 0, NSFlagsChanged); |
561 WebKeyboardEvent web_event = WebKeyboardEventBuilder::Build(mac_event); | 561 WebKeyboardEvent web_event = WebKeyboardEventBuilder::Build(mac_event); |
562 EXPECT_EQ(entry.dom_key, web_event.domKey) << entry.mac_key_code; | 562 EXPECT_EQ(entry.dom_key, web_event.domKey) << entry.mac_key_code; |
563 } | 563 } |
564 } | 564 } |
565 | 565 |
| 566 TEST(WebInputEventBuilderMacTest, ContextMenuKey) { |
| 567 // Context menu is not defined but shows up as 0x6E. |
| 568 const int kVK_ContextMenu = 0x6E; |
| 569 |
| 570 const NSEventType kEventTypeToTest[] = {NSKeyDown, NSKeyUp}; |
| 571 for (auto flags : kEventTypeToTest) { |
| 572 NSEvent* mac_event = BuildFakeKeyEvent(kVK_ContextMenu, 0, 0, flags); |
| 573 WebKeyboardEvent web_event = WebKeyboardEventBuilder::Build(mac_event); |
| 574 EXPECT_EQ(ui::DomKey::CONTEXT_MENU, web_event.domKey); |
| 575 EXPECT_EQ(ui::VKEY_APPS, web_event.windowsKeyCode); |
| 576 } |
| 577 } |
| 578 |
566 // Flaky - https://crbug.com/640457 | 579 // Flaky - https://crbug.com/640457 |
567 // Test that a ui::Event and blink::WebInputEvent made from the same NSEvent | 580 // Test that a ui::Event and blink::WebInputEvent made from the same NSEvent |
568 // have the same values for comparable fields. | 581 // have the same values for comparable fields. |
569 TEST(WebInputEventBuilderMacTest, DISABLED_ScrollWheelMatchesUIEvent) { | 582 TEST(WebInputEventBuilderMacTest, DISABLED_ScrollWheelMatchesUIEvent) { |
570 CGFloat delta_x = 123; | 583 CGFloat delta_x = 123; |
571 CGFloat delta_y = 321; | 584 CGFloat delta_y = 321; |
572 NSPoint location = NSMakePoint(11, 22); | 585 NSPoint location = NSMakePoint(11, 22); |
573 | 586 |
574 // WebMouseWheelEventBuilder requires a non-nil view to map coordinates. So | 587 // WebMouseWheelEventBuilder requires a non-nil view to map coordinates. So |
575 // create a dummy window, but don't show it. It will be released when closed. | 588 // create a dummy window, but don't show it. It will be released when closed. |
(...skipping 18 matching lines...) Expand all Loading... |
594 EXPECT_EQ(web_event.deltaY, ui_event.y_offset()); | 607 EXPECT_EQ(web_event.deltaY, ui_event.y_offset()); |
595 | 608 |
596 EXPECT_EQ(11, web_event.x); | 609 EXPECT_EQ(11, web_event.x); |
597 EXPECT_EQ(web_event.x, ui_event.x()); | 610 EXPECT_EQ(web_event.x, ui_event.x()); |
598 | 611 |
599 // Both ui:: and blink:: events use an origin at the top-left. | 612 // Both ui:: and blink:: events use an origin at the top-left. |
600 EXPECT_EQ(100 - 22, web_event.y); | 613 EXPECT_EQ(100 - 22, web_event.y); |
601 EXPECT_EQ(web_event.y, ui_event.y()); | 614 EXPECT_EQ(web_event.y, ui_event.y()); |
602 [window close]; | 615 [window close]; |
603 } | 616 } |
OLD | NEW |