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

Unified Diff: Source/web/tests/WebInputEventFactoryTestMac.mm

Issue 1215633003: Fix false negatives in system key events recognition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test 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 | « Source/web/WebInputEventFactoryMac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebInputEventFactoryTestMac.mm
diff --git a/Source/web/tests/WebInputEventFactoryTestMac.mm b/Source/web/tests/WebInputEventFactoryTestMac.mm
index 90a01f43818df3120bb9c396f6926d9a3893aad5..3bb9a4adebc2e95a821fd119e923f314bc16e3e7 100644
--- a/Source/web/tests/WebInputEventFactoryTestMac.mm
+++ b/Source/web/tests/WebInputEventFactoryTestMac.mm
@@ -31,6 +31,7 @@
#include "config.h"
#import <Cocoa/Cocoa.h>
+#include <Carbon/Carbon.h>
#include <gtest/gtest.h>
#include "core/events/KeyboardEvent.h"
@@ -192,3 +193,35 @@ TEST(WebInputEventFactoryTestMac, MissingUndocumentedModifierFlags)
EXPECT_EQ(WebInputEvent::KeyUp, webEvent.type);
}
}
+
+// Test system key events recognition.
+TEST(WebInputEventFactoryTestMac, SystemKeyEvents)
+{
+ // Cmd + B should not be treated as system event.
+ NSEvent* macEvent = BuildFakeKeyEvent(kVK_ANSI_B, 'B', NSCommandKeyMask, NSKeyDown);
+ WebKeyboardEvent webEvent = WebInputEventFactory::keyboardEvent(macEvent);
+ EXPECT_FALSE(WebInputEventFactory::isSystemKeyEvent(webEvent));
+
+ // Cmd + I should not be treated as system event.
+ macEvent = BuildFakeKeyEvent(kVK_ANSI_I, 'I', NSCommandKeyMask, NSKeyDown);
+ webEvent = WebInputEventFactory::keyboardEvent(macEvent);
+ EXPECT_FALSE(WebInputEventFactory::isSystemKeyEvent(webEvent));
+
+ // Cmd + <some other modifier> + <B|I> should be treated as system event.
+ macEvent = BuildFakeKeyEvent(kVK_ANSI_B, 'B', NSCommandKeyMask | NSShiftKeyMask, NSKeyDown);
+ webEvent = WebInputEventFactory::keyboardEvent(macEvent);
+ EXPECT_TRUE(WebInputEventFactory::isSystemKeyEvent(webEvent));
+ macEvent = BuildFakeKeyEvent(kVK_ANSI_I, 'I', NSCommandKeyMask | NSControlKeyMask, NSKeyDown);
+ webEvent = WebInputEventFactory::keyboardEvent(macEvent);
+ EXPECT_TRUE(WebInputEventFactory::isSystemKeyEvent(webEvent));
+
+ // Cmd + <any letter other then B and I> should be treated as system event.
+ macEvent = BuildFakeKeyEvent(kVK_ANSI_S, 'S', NSCommandKeyMask, NSKeyDown);
+ webEvent = WebInputEventFactory::keyboardEvent(macEvent);
+ EXPECT_TRUE(WebInputEventFactory::isSystemKeyEvent(webEvent));
+
+ // 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 = WebInputEventFactory::keyboardEvent(macEvent);
+ EXPECT_TRUE(WebInputEventFactory::isSystemKeyEvent(webEvent));
+}
« no previous file with comments | « Source/web/WebInputEventFactoryMac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698