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

Side by Side Diff: content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm

Issue 2309253006: [Mac] Map ContextMenu key to corresponding DomKey and keyCode (Closed)
Patch Set: dtapuska's review, remove unnecessary debug info 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
« no previous file with comments | « no previous file | ui/events/keycodes/keyboard_code_conversion_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | ui/events/keycodes/keyboard_code_conversion_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698