7 #include "gtest/gtest.h"
11 #include "flutter/shell/platform/linux/testing/fl_test.h"
29 g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
33 TEST(FlKeyChannelResponderTest, SendKeyEvent) {
34 g_autoptr(GMainLoop) loop = g_main_loop_new(
nullptr, 0);
40 .channel_name =
"test/echo",
42 g_autoptr(FlKeyResponder) responder =
46 12345,
TRUE, 0x04, GDK_KEY_A,
static_cast<GdkModifierType
>(0), 0);
49 "{type: keydown, keymap: linux, scanCode: 4, toolkit: gtk, keyCode: 65, "
50 "modifiers: 0, unicodeScalarValues: 65}";
54 g_main_loop_run(loop);
57 23456, FALSE, 0x04, GDK_KEY_A,
static_cast<GdkModifierType
>(0), 0);
60 "{type: keyup, keymap: linux, scanCode: 4, toolkit: gtk, keyCode: 65, "
61 "modifiers: 0, unicodeScalarValues: 65}";
65 g_main_loop_run(loop);
69 const char* down_expected,
70 const char* up_expected) {
71 g_autoptr(GMainLoop) loop = g_main_loop_new(
nullptr, 0);
77 .channel_name =
"test/echo",
79 g_autoptr(FlKeyResponder) responder =
83 12345,
TRUE, 0x04, key_code,
static_cast<GdkModifierType
>(0), 0);
89 g_main_loop_run(loop);
94 12346, FALSE, 0x04, key_code,
static_cast<GdkModifierType
>(0), 0);
98 g_main_loop_run(loop);
102 TEST(FlKeyChannelResponderTest, SendNumLockKeyEvent) {
104 "{type: keydown, keymap: linux, scanCode: 4, toolkit: gtk, "
105 "keyCode: 65407, modifiers: 16}",
106 "{type: keyup, keymap: linux, scanCode: 4, toolkit: gtk, "
107 "keyCode: 65407, modifiers: 0}");
111 TEST(FlKeyChannelResponderTest, SendCapsLockKeyEvent) {
113 "{type: keydown, keymap: linux, scanCode: 4, toolkit: gtk, "
114 "keyCode: 65509, modifiers: 2}",
115 "{type: keyup, keymap: linux, scanCode: 4, toolkit: gtk, "
116 "keyCode: 65509, modifiers: 0}");
120 TEST(FlKeyChannelResponderTest, SendShiftLockKeyEvent) {
122 "{type: keydown, keymap: linux, scanCode: 4, toolkit: gtk, "
123 "keyCode: 65510, modifiers: 2}",
124 "{type: keyup, keymap: linux, scanCode: 4, toolkit: gtk, "
125 "keyCode: 65510, modifiers: 0}");
128 TEST(FlKeyChannelResponderTest, TestKeyEventHandledByFramework) {
129 g_autoptr(GMainLoop) loop = g_main_loop_new(
nullptr, 0);
135 .channel_name =
"test/echo",
137 g_autoptr(FlKeyResponder) responder =
141 12345,
TRUE, 0x04, GDK_KEY_A,
static_cast<GdkModifierType
>(0), 0);
145 "{type: keydown, keymap: linux, scanCode: 4, toolkit: gtk, "
146 "keyCode: 65, modifiers: 0, unicodeScalarValues: 65}";
149 g_main_loop_run(loop);
152 TEST(FlKeyChannelResponderTest, UseSpecifiedLogicalKey) {
153 g_autoptr(GMainLoop) loop = g_main_loop_new(
nullptr, 0);
159 .channel_name =
"test/echo",
161 g_autoptr(FlKeyResponder) responder =
165 12345,
TRUE, 0x04, GDK_KEY_A,
static_cast<GdkModifierType
>(0), 0);
170 "{type: keydown, keymap: linux, scanCode: 4, toolkit: gtk, "
171 "keyCode: 65, modifiers: 0, unicodeScalarValues: 65, "
172 "specifiedLogicalKey: 888}";
175 g_main_loop_run(loop);