Chromium Code Reviews| 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) << web_event.domKey; | |
|
dtapuska
2016/09/07 17:53:25
I don't think you need the "<< web_event.domKey" o
| |
| 575 EXPECT_EQ(ui::VKEY_APPS, web_event.windowsKeyCode) | |
| 576 << web_event.windowsKeyCode; | |
| 577 } | |
| 578 } | |
| 579 | |
| 566 // Flaky - https://crbug.com/640457 | 580 // Flaky - https://crbug.com/640457 |
| 567 // Test that a ui::Event and blink::WebInputEvent made from the same NSEvent | 581 // Test that a ui::Event and blink::WebInputEvent made from the same NSEvent |
| 568 // have the same values for comparable fields. | 582 // have the same values for comparable fields. |
| 569 TEST(WebInputEventBuilderMacTest, DISABLED_ScrollWheelMatchesUIEvent) { | 583 TEST(WebInputEventBuilderMacTest, DISABLED_ScrollWheelMatchesUIEvent) { |
| 570 CGFloat delta_x = 123; | 584 CGFloat delta_x = 123; |
| 571 CGFloat delta_y = 321; | 585 CGFloat delta_y = 321; |
| 572 NSPoint location = NSMakePoint(11, 22); | 586 NSPoint location = NSMakePoint(11, 22); |
| 573 | 587 |
| 574 // WebMouseWheelEventBuilder requires a non-nil view to map coordinates. So | 588 // 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. | 589 // 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()); | 608 EXPECT_EQ(web_event.deltaY, ui_event.y_offset()); |
| 595 | 609 |
| 596 EXPECT_EQ(11, web_event.x); | 610 EXPECT_EQ(11, web_event.x); |
| 597 EXPECT_EQ(web_event.x, ui_event.x()); | 611 EXPECT_EQ(web_event.x, ui_event.x()); |
| 598 | 612 |
| 599 // Both ui:: and blink:: events use an origin at the top-left. | 613 // Both ui:: and blink:: events use an origin at the top-left. |
| 600 EXPECT_EQ(100 - 22, web_event.y); | 614 EXPECT_EQ(100 - 22, web_event.y); |
| 601 EXPECT_EQ(web_event.y, ui_event.y()); | 615 EXPECT_EQ(web_event.y, ui_event.y()); |
| 602 [window close]; | 616 [window close]; |
| 603 } | 617 } |
| OLD | NEW |