7 #include "flutter/shell/platform/embedder/test_utils/key_codes.g.h"
8 #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
12 #include "flutter/shell/platform/linux/testing/fl_mock_binary_messenger.h"
13 #include "flutter/shell/platform/linux/testing/mock_keymap.h"
15 #include "gmock/gmock.h"
16 #include "gtest/gtest.h"
21 using ::flutter::testing::keycodes::kLogicalKeyA;
22 using ::flutter::testing::keycodes::kPhysicalKeyA;
26 TEST(FlKeyboardHandlerTest, KeyboardChannelGetPressedState) {
27 ::testing::NiceMock<flutter::testing::MockKeymap> mock_keymap;
29 g_autoptr(FlMockBinaryMessenger) messenger = fl_mock_binary_messenger_new();
30 g_autoptr(FlEngine) engine =
36 g_autoptr(FlKeyboardHandler) handler =
38 EXPECT_NE(handler,
nullptr);
41 fl_mock_binary_messenger_set_json_message_channel(
42 messenger,
"flutter/keyevent",
43 [](FlMockBinaryMessenger* messenger, GTask* task,
FlValue* message,
51 SendKeyEvent, ([](
auto engine,
const FlutterKeyEvent* event,
52 FlutterKeyEventCallback callback,
void*
user_data) {
56 g_autoptr(GMainLoop) loop = g_main_loop_new(
nullptr, 0);
60 manager, event,
nullptr,
61 [](GObject*
object, GAsyncResult* result, gpointer
user_data) {
62 g_autoptr(FlKeyEvent) redispatched_event =
nullptr;
64 FL_KEYBOARD_MANAGER(
object), result, &redispatched_event,
nullptr));
65 g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
68 g_main_loop_run(loop);
70 gboolean called = FALSE;
71 fl_mock_binary_messenger_invoke_standard_method(
73 [](FlMockBinaryMessenger* messenger, FlMethodResponse* response,
75 gboolean* called =
static_cast<gboolean*
>(
user_data);
78 EXPECT_TRUE(FL_IS_METHOD_SUCCESS_RESPONSE(response));
84 FL_METHOD_SUCCESS_RESPONSE(response)),