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

Unified Diff: content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm

Issue 1374933002: Fix false negatives in system key events recognition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/input/web_input_event_builders_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm
diff --git a/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm b/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm
index 0d5cc56d302edeb55d061520fba08596ab096eab..2c550651e5c94872aace03ec85c3ff3b8f7d0e2a 100644
--- a/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm
+++ b/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm
@@ -5,6 +5,7 @@
#include "content/browser/renderer_host/input/web_input_event_builders_mac.h"
#import <Cocoa/Cocoa.h>
+#include <Carbon/Carbon.h>
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/keycodes/dom/dom_code.h"
@@ -207,3 +208,39 @@ TEST(WebInputEventBuilderMacTest, MissingUndocumentedModifierFlags) {
EXPECT_EQ(WebInputEvent::KeyUp, web_event.type);
}
}
+
+// Test system key events recognition.
+TEST(WebInputEventBuilderMacTest, SystemKeyEvents) {
+ // Cmd + B should not be treated as system event.
+ NSEvent* macEvent =
+ BuildFakeKeyEvent(kVK_ANSI_B, 'B', NSCommandKeyMask, NSKeyDown);
+ WebKeyboardEvent webEvent = WebKeyboardEventBuilder::Build(macEvent);
+ EXPECT_FALSE(webEvent.isSystemKey);
+
+ // Cmd + I should not be treated as system event.
+ macEvent = BuildFakeKeyEvent(kVK_ANSI_I, 'I', NSCommandKeyMask, NSKeyDown);
+ webEvent = WebKeyboardEventBuilder::Build(macEvent);
+ EXPECT_FALSE(webEvent.isSystemKey);
+
+ // Cmd + <some other modifier> + <B|I> should be treated as system event.
+ macEvent = BuildFakeKeyEvent(kVK_ANSI_B, 'B',
+ NSCommandKeyMask | NSShiftKeyMask, NSKeyDown);
+ webEvent = WebKeyboardEventBuilder::Build(macEvent);
+ EXPECT_TRUE(webEvent.isSystemKey);
+ macEvent = BuildFakeKeyEvent(kVK_ANSI_I, 'I',
+ NSCommandKeyMask | NSControlKeyMask, NSKeyDown);
+ webEvent = WebKeyboardEventBuilder::Build(macEvent);
+ EXPECT_TRUE(webEvent.isSystemKey);
+
+ // Cmd + <any letter other then B and I> should be treated as system event.
+ macEvent = BuildFakeKeyEvent(kVK_ANSI_S, 'S', NSCommandKeyMask, NSKeyDown);
+ webEvent = WebKeyboardEventBuilder::Build(macEvent);
+ EXPECT_TRUE(webEvent.isSystemKey);
+
+ // Cmd + <some other modifier> + <any letter other then B and I> should be
+ // treated as system event.
+ macEvent = BuildFakeKeyEvent(kVK_ANSI_S, 'S',
+ NSCommandKeyMask | NSShiftKeyMask, NSKeyDown);
+ webEvent = WebKeyboardEventBuilder::Build(macEvent);
+ EXPECT_TRUE(webEvent.isSystemKey);
+}
« no previous file with comments | « content/browser/renderer_host/input/web_input_event_builders_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698