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)); |
+} |