7 #include "gtest/gtest.h" 
    9 #include "flutter/shell/platform/embedder/test_utils/key_codes.g.h" 
   10 #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h" 
   12 #include "flutter/shell/platform/linux/testing/fl_test.h" 
   15 constexpr gboolean kRelease = FALSE;
 
   16 constexpr gboolean kPress = 
TRUE;
 
   18 constexpr guint16 kKeyCodeDigit1 = 0x0au;
 
   20 constexpr guint16 kKeyCodeShiftLeft = 0x32u;
 
   21 constexpr guint16 kKeyCodeShiftRight = 0x3Eu;
 
   22 constexpr guint16 kKeyCodeAltLeft = 0x40u;
 
   23 constexpr guint16 kKeyCodeAltRight = 0x6Cu;
 
   24 constexpr guint16 kKeyCodeNumpad1 = 0x57u;
 
   25 constexpr guint16 kKeyCodeNumLock = 0x4Du;
 
   26 constexpr guint16 kKeyCodeCapsLock = 0x42u;
 
   27 constexpr guint16 kKeyCodeControlLeft = 0x25u;
 
   28 constexpr guint16 kKeyCodeControlRight = 0x69u;
 
   30 using namespace ::flutter::testing::keycodes;
 
   34   g_ptr_array_remove_range(array, 0, array->len);
 
   38                      fl_key_embedder_call_record,
 
   40                      KEY_EMBEDDER_CALL_RECORD,
 
   52               fl_key_embedder_call_record,
 
   55 static void fl_key_embedder_call_record_init(FlKeyEmbedderCallRecord* 
self) {}
 
   59   g_return_if_fail(FL_IS_KEY_EMBEDDER_CALL_RECORD(
object));
 
   61   FlKeyEmbedderCallRecord* 
self = FL_KEY_EMBEDDER_CALL_RECORD(
object);
 
   62   if (self->event != 
nullptr) {
 
   63     g_free(
const_cast<char*
>(self->event->character));
 
   66   G_OBJECT_CLASS(fl_key_embedder_call_record_parent_class)->dispose(
object);
 
   71     FlKeyEmbedderCallRecordClass* klass) {
 
   76     const FlutterKeyEvent* event,
 
   77     FlutterKeyEventCallback callback,
 
   79   g_return_val_if_fail(event != 
nullptr, 
nullptr);
 
   81   FlKeyEmbedderCallRecord* 
self = FL_KEY_EMBEDDER_CALL_RECORD(
 
   82       g_object_new(fl_key_embedder_call_record_get_type(), 
nullptr));
 
   84   FlutterKeyEvent* clone_event = g_new(FlutterKeyEvent, 1);
 
   85   *clone_event = *event;
 
   86   if (event->character != 
nullptr) {
 
   87     size_t character_length = strlen(event->character);
 
   88     char* clone_character = g_new(
char, character_length + 1);
 
   89     strncpy(clone_character, event->character, character_length + 1);
 
   90     clone_event->character = clone_character;
 
   92   self->event = clone_event;
 
   93   self->callback = callback;
 
  100                                    bool expected_handled) {
 
  101   g_return_if_fail(record->callback != 
nullptr);
 
  102   record->callback(expected_handled, record->user_data);
 
  106 TEST(FlKeyEmbedderResponderTest, SendKeyEvent) {
 
  111   g_autoptr(FlKeyEmbedderResponder) responder =
 
  114   g_autoptr(GPtrArray) call_records =
 
  115       g_ptr_array_new_with_free_func(g_object_unref);
 
  118       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
  119                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
  127   g_autoptr(FlKeyEvent) event1 =
 
  129                        static_cast<GdkModifierType
>(0), 0);
 
  130   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
  132       responder, event1, 0, 
nullptr,
 
  133       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  136             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  137         EXPECT_EQ(handled, 
TRUE);
 
  139         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  143   EXPECT_EQ(call_records->len, 1u);
 
  144   FlKeyEmbedderCallRecord* record =
 
  145       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  146   EXPECT_EQ(record->event->struct_size, 
sizeof(FlutterKeyEvent));
 
  147   EXPECT_EQ(record->event->timestamp, 12345000);
 
  148   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  149   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
  150   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
  151   EXPECT_STREQ(record->event->character, 
"a");
 
  152   EXPECT_EQ(record->event->synthesized, 
false);
 
  155   g_main_loop_run(loop1);
 
  159   g_autoptr(FlKeyEvent) event2 =
 
  161                        static_cast<GdkModifierType
>(0), 0);
 
  162   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
  164       responder, event2, 0, 
nullptr,
 
  165       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  168             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  169         EXPECT_EQ(handled, FALSE);
 
  171         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  175   EXPECT_EQ(call_records->len, 1u);
 
  176   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  177   EXPECT_EQ(record->event->struct_size, 
sizeof(FlutterKeyEvent));
 
  178   EXPECT_EQ(record->event->timestamp, 12346000);
 
  179   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  180   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
  181   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
  182   EXPECT_STREQ(record->event->character, 
nullptr);
 
  183   EXPECT_EQ(record->event->synthesized, 
false);
 
  186   g_main_loop_run(loop2);
 
  191   g_autoptr(FlKeyEvent) event3 =
 
  193                        static_cast<GdkModifierType
>(0), 0);
 
  194   g_autoptr(GMainLoop) loop3 = g_main_loop_new(
nullptr, 0);
 
  196       responder, event3, 0, 
nullptr,
 
  197       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  200             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  201         EXPECT_EQ(handled, 
TRUE);
 
  203         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  207   EXPECT_EQ(call_records->len, 1u);
 
  208   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  209   EXPECT_EQ(record->event->struct_size, 
sizeof(FlutterKeyEvent));
 
  210   EXPECT_EQ(record->event->timestamp, 12347000);
 
  211   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  212   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
  213   EXPECT_EQ(record->event->logical, kLogicalKeyQ);
 
  214   EXPECT_STREQ(record->event->character, 
"q");
 
  215   EXPECT_EQ(record->event->synthesized, 
false);
 
  218   g_main_loop_run(loop3);
 
  222   g_autoptr(FlKeyEvent) event4 =
 
  224                        static_cast<GdkModifierType
>(0), 0);
 
  225   g_autoptr(GMainLoop) loop4 = g_main_loop_new(
nullptr, 0);
 
  227       responder, event4, 0, 
nullptr,
 
  228       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  231             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  232         EXPECT_EQ(handled, FALSE);
 
  234         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  238   EXPECT_EQ(call_records->len, 1u);
 
  239   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  240   EXPECT_EQ(record->event->struct_size, 
sizeof(FlutterKeyEvent));
 
  241   EXPECT_EQ(record->event->timestamp, 12348000);
 
  242   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  243   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
  244   EXPECT_EQ(record->event->logical, kLogicalKeyQ);
 
  245   EXPECT_STREQ(record->event->character, 
nullptr);
 
  246   EXPECT_EQ(record->event->synthesized, 
false);
 
  249   g_main_loop_run(loop4);
 
  253 TEST(FlKeyEmbedderResponderTest, UsesSpecifiedLogicalKey) {
 
  258   g_autoptr(FlKeyEmbedderResponder) responder =
 
  261   g_autoptr(GPtrArray) call_records =
 
  262       g_ptr_array_new_with_free_func(g_object_unref);
 
  265       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
  266                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
  274   g_autoptr(FlKeyEvent) 
event =
 
  276                        static_cast<GdkModifierType
>(0), 0);
 
  277   g_autoptr(GMainLoop) loop = g_main_loop_new(
nullptr, 0);
 
  279       responder, event, kLogicalDigit1, 
nullptr,
 
  280       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  283             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  284         EXPECT_EQ(handled, 
TRUE);
 
  286         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  290   EXPECT_EQ(call_records->len, 1u);
 
  291   FlKeyEmbedderCallRecord* record =
 
  292       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  293   EXPECT_EQ(record->event->struct_size, 
sizeof(FlutterKeyEvent));
 
  294   EXPECT_EQ(record->event->timestamp, 12345000);
 
  295   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  296   EXPECT_EQ(record->event->physical, kPhysicalDigit1);
 
  297   EXPECT_EQ(record->event->logical, kLogicalDigit1);
 
  298   EXPECT_STREQ(record->event->character, 
"&");
 
  299   EXPECT_EQ(record->event->synthesized, 
false);
 
  302   g_main_loop_run(loop);
 
  306 TEST(FlKeyEmbedderResponderTest, PressShiftDuringLetterKeyTap) {
 
  311   g_autoptr(FlKeyEmbedderResponder) responder =
 
  314   g_autoptr(GPtrArray) call_records =
 
  315       g_ptr_array_new_with_free_func(g_object_unref);
 
  318       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
  319                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
  326   g_autoptr(FlKeyEvent) event1 =
 
  328                        static_cast<GdkModifierType
>(0), 0);
 
  329   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
  331       responder, event1, 0, 
nullptr,
 
  332       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  335             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  336         EXPECT_EQ(handled, 
TRUE);
 
  338         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  342   EXPECT_EQ(call_records->len, 1u);
 
  343   FlKeyEmbedderCallRecord* record =
 
  344       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  345   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  346   EXPECT_EQ(record->event->physical, kPhysicalShiftRight);
 
  347   EXPECT_EQ(record->event->logical, kLogicalShiftRight);
 
  348   EXPECT_STREQ(record->event->character, 
nullptr);
 
  349   EXPECT_EQ(record->event->synthesized, 
false);
 
  352   g_main_loop_run(loop1);
 
  356   g_autoptr(FlKeyEvent) event2 =
 
  358   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
  360       responder, event2, 0, 
nullptr,
 
  361       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  364             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  365         EXPECT_EQ(handled, 
TRUE);
 
  367         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  371   EXPECT_EQ(call_records->len, 1u);
 
  372   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  373   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  374   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
  375   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
  376   EXPECT_STREQ(record->event->character, 
"A");
 
  377   EXPECT_EQ(record->event->synthesized, 
false);
 
  380   g_main_loop_run(loop2);
 
  385       103, kRelease, kKeyCodeShiftRight, GDK_KEY_Shift_R, GDK_SHIFT_MASK, 0);
 
  386   g_autoptr(GMainLoop) loop3 = g_main_loop_new(
nullptr, 0);
 
  388       responder, event3, 0, 
nullptr,
 
  389       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  392             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  393         EXPECT_EQ(handled, 
TRUE);
 
  395         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  399   EXPECT_EQ(call_records->len, 1u);
 
  400   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  401   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  402   EXPECT_EQ(record->event->physical, kPhysicalShiftRight);
 
  403   EXPECT_EQ(record->event->logical, kLogicalShiftRight);
 
  404   EXPECT_STREQ(record->event->character, 
nullptr);
 
  405   EXPECT_EQ(record->event->synthesized, 
false);
 
  408   g_main_loop_run(loop3);
 
  412   g_autoptr(FlKeyEvent) event4 =
 
  414                        static_cast<GdkModifierType
>(0), 0);
 
  415   g_autoptr(GMainLoop) loop4 = g_main_loop_new(
nullptr, 0);
 
  417       responder, event4, 0, 
nullptr,
 
  418       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  421             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  422         EXPECT_EQ(handled, 
TRUE);
 
  424         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  428   EXPECT_EQ(call_records->len, 1u);
 
  429   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  430   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  431   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
  432   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
  433   EXPECT_STREQ(record->event->character, 
nullptr);
 
  434   EXPECT_EQ(record->event->synthesized, 
false);
 
  437   g_main_loop_run(loop4);
 
  448 TEST(FlKeyEmbedderResponderTest, TapNumPadKeysBetweenNumLockEvents) {
 
  453   g_autoptr(FlKeyEmbedderResponder) responder =
 
  456   g_autoptr(GPtrArray) call_records =
 
  457       g_ptr_array_new_with_free_func(g_object_unref);
 
  460       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
  461                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
  468   g_autoptr(FlKeyEvent) event1 =
 
  470                        static_cast<GdkModifierType
>(0), 0);
 
  471   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
  473       responder, event1, 0, 
nullptr,
 
  474       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  477             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  478         EXPECT_EQ(handled, 
TRUE);
 
  480         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  484   EXPECT_EQ(call_records->len, 1u);
 
  485   FlKeyEmbedderCallRecord* record =
 
  486       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  487   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  488   EXPECT_EQ(record->event->physical, kPhysicalNumpad1);
 
  489   EXPECT_EQ(record->event->logical, kLogicalNumpad1);
 
  490   EXPECT_STREQ(record->event->character, 
nullptr);  
 
  491   EXPECT_EQ(record->event->synthesized, 
false);
 
  494   g_main_loop_run(loop1);
 
  498   g_autoptr(FlKeyEvent) event2 =
 
  500                        static_cast<GdkModifierType
>(0), 0);
 
  501   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
  503       responder, event2, 0, 
nullptr,
 
  504       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  507             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  508         EXPECT_EQ(handled, 
TRUE);
 
  510         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  514   EXPECT_EQ(call_records->len, 1u);
 
  515   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  516   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  517   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
  518   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
  519   EXPECT_STREQ(record->event->character, 
nullptr);
 
  520   EXPECT_EQ(record->event->synthesized, 
false);
 
  523   g_main_loop_run(loop2);
 
  528       104, kRelease, kKeyCodeNumpad1, GDK_KEY_KP_1, GDK_MOD2_MASK, 0);
 
  529   g_autoptr(GMainLoop) loop3 = g_main_loop_new(
nullptr, 0);
 
  531       responder, event3, 0, 
nullptr,
 
  532       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  535             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  536         EXPECT_EQ(handled, 
TRUE);
 
  538         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  542   EXPECT_EQ(call_records->len, 1u);
 
  543   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  544   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  545   EXPECT_EQ(record->event->physical, kPhysicalNumpad1);
 
  546   EXPECT_EQ(record->event->logical, kLogicalNumpad1);
 
  547   EXPECT_STREQ(record->event->character, 
nullptr);
 
  548   EXPECT_EQ(record->event->synthesized, 
false);
 
  551   g_main_loop_run(loop3);
 
  556       103, kRelease, kKeyCodeNumLock, GDK_KEY_Num_Lock, GDK_MOD2_MASK, 0);
 
  557   g_autoptr(GMainLoop) loop4 = g_main_loop_new(
nullptr, 0);
 
  559       responder, event4, 0, 
nullptr,
 
  560       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  563             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  564         EXPECT_EQ(handled, 
TRUE);
 
  566         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  570   EXPECT_EQ(call_records->len, 1u);
 
  571   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  572   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  573   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
  574   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
  575   EXPECT_STREQ(record->event->character, 
nullptr);
 
  576   EXPECT_EQ(record->event->synthesized, 
false);
 
  579   g_main_loop_run(loop4);
 
  584       101, kPress, kKeyCodeNumpad1, GDK_KEY_KP_End, GDK_MOD2_MASK, 0);
 
  585   g_autoptr(GMainLoop) loop5 = g_main_loop_new(
nullptr, 0);
 
  587       responder, event5, 0, 
nullptr,
 
  588       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  591             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  592         EXPECT_EQ(handled, 
TRUE);
 
  594         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  598   EXPECT_EQ(call_records->len, 1u);
 
  599   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  600   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  601   EXPECT_EQ(record->event->physical, kPhysicalNumpad1);
 
  602   EXPECT_EQ(record->event->logical, kLogicalNumpad1);
 
  603   EXPECT_STREQ(record->event->character, 
nullptr);  
 
  604   EXPECT_EQ(record->event->synthesized, 
false);
 
  607   g_main_loop_run(loop5);
 
  612       102, kPress, kKeyCodeNumLock, GDK_KEY_Num_Lock, GDK_MOD2_MASK, 0);
 
  613   g_autoptr(GMainLoop) loop6 = g_main_loop_new(
nullptr, 0);
 
  615       responder, event6, 0, 
nullptr,
 
  616       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  619             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  620         EXPECT_EQ(handled, 
TRUE);
 
  622         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  626   EXPECT_EQ(call_records->len, 1u);
 
  627   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  628   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  629   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
  630   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
  631   EXPECT_STREQ(record->event->character, 
nullptr);
 
  632   EXPECT_EQ(record->event->synthesized, 
false);
 
  635   g_main_loop_run(loop6);
 
  640       104, kRelease, kKeyCodeNumpad1, GDK_KEY_KP_1, GDK_MOD2_MASK, 0);
 
  641   g_autoptr(GMainLoop) loop7 = g_main_loop_new(
nullptr, 0);
 
  643       responder, event7, 0, 
nullptr,
 
  644       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  647             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  648         EXPECT_EQ(handled, 
TRUE);
 
  650         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  654   EXPECT_EQ(call_records->len, 1u);
 
  655   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  656   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  657   EXPECT_EQ(record->event->physical, kPhysicalNumpad1);
 
  658   EXPECT_EQ(record->event->logical, kLogicalNumpad1);
 
  659   EXPECT_STREQ(record->event->character, 
nullptr);
 
  660   EXPECT_EQ(record->event->synthesized, 
false);
 
  663   g_main_loop_run(loop7);
 
  668       103, kRelease, kKeyCodeNumLock, GDK_KEY_Num_Lock, GDK_MOD2_MASK, 0);
 
  669   g_autoptr(GMainLoop) loop8 = g_main_loop_new(
nullptr, 0);
 
  671       responder, event8, 0, 
nullptr,
 
  672       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  675             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  676         EXPECT_EQ(handled, 
TRUE);
 
  678         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  682   EXPECT_EQ(call_records->len, 1u);
 
  683   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  684   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  685   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
  686   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
  687   EXPECT_STREQ(record->event->character, 
nullptr);
 
  688   EXPECT_EQ(record->event->synthesized, 
false);
 
  691   g_main_loop_run(loop8);
 
  698 TEST(FlKeyEmbedderResponderTest, ReleaseShiftKeyBetweenDigitKeyEvents) {
 
  703   g_autoptr(FlKeyEmbedderResponder) responder =
 
  706   g_autoptr(GPtrArray) call_records =
 
  707       g_ptr_array_new_with_free_func(g_object_unref);
 
  710       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
  711                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
  717   GdkModifierType 
state = 
static_cast<GdkModifierType
>(0);
 
  721       101, kPress, kKeyCodeShiftLeft, GDK_KEY_Shift_L, 
state, 0);
 
  722   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
  724       responder, event1, 0, 
nullptr,
 
  725       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  728             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  729         EXPECT_EQ(handled, 
TRUE);
 
  731         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  735   EXPECT_EQ(call_records->len, 1u);
 
  736   FlKeyEmbedderCallRecord* record =
 
  737       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  738   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  739   EXPECT_EQ(record->event->physical, kPhysicalShiftLeft);
 
  740   EXPECT_EQ(record->event->logical, kLogicalShiftLeft);
 
  741   EXPECT_STREQ(record->event->character, 
nullptr);
 
  742   EXPECT_EQ(record->event->synthesized, 
false);
 
  745   g_main_loop_run(loop1);
 
  748   state = GDK_SHIFT_MASK;
 
  751   g_autoptr(FlKeyEvent) event2 =
 
  753   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
  755       responder, event2, 0, 
nullptr,
 
  756       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  759             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  760         EXPECT_EQ(handled, 
TRUE);
 
  762         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  766   EXPECT_EQ(call_records->len, 1u);
 
  767   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  768   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  769   EXPECT_EQ(record->event->physical, kPhysicalDigit1);
 
  770   EXPECT_EQ(record->event->logical, kLogicalExclamation);
 
  771   EXPECT_STREQ(record->event->character, 
"!");
 
  772   EXPECT_EQ(record->event->synthesized, 
false);
 
  775   g_main_loop_run(loop2);
 
  780       103, kRelease, kKeyCodeShiftLeft, GDK_KEY_Shift_L, 
state, 0);
 
  781   g_autoptr(GMainLoop) loop3 = g_main_loop_new(
nullptr, 0);
 
  783       responder, event3, 0, 
nullptr,
 
  784       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  787             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  788         EXPECT_EQ(handled, 
TRUE);
 
  790         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  794   EXPECT_EQ(call_records->len, 1u);
 
  795   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  796   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  797   EXPECT_EQ(record->event->physical, kPhysicalShiftLeft);
 
  798   EXPECT_EQ(record->event->logical, kLogicalShiftLeft);
 
  799   EXPECT_STREQ(record->event->character, 
nullptr);
 
  800   EXPECT_EQ(record->event->synthesized, 
false);
 
  803   g_main_loop_run(loop3);
 
  806   state = 
static_cast<GdkModifierType
>(0);
 
  809   g_autoptr(FlKeyEvent) event4 =
 
  811   g_autoptr(GMainLoop) loop4 = g_main_loop_new(
nullptr, 0);
 
  813       responder, event4, 0, 
nullptr,
 
  814       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  817             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  818         EXPECT_EQ(handled, 
TRUE);
 
  820         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  824   EXPECT_EQ(call_records->len, 1u);
 
  825   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  826   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  827   EXPECT_EQ(record->event->physical, kPhysicalDigit1);
 
  828   EXPECT_EQ(record->event->logical, kLogicalExclamation);  
 
  829   EXPECT_STREQ(record->event->character, 
nullptr);
 
  830   EXPECT_EQ(record->event->synthesized, 
false);
 
  833   g_main_loop_run(loop4);
 
  840 TEST(FlKeyEmbedderResponderTest, TapLetterKeysBetweenCapsLockEvents) {
 
  845   g_autoptr(FlKeyEmbedderResponder) responder =
 
  848   g_autoptr(GPtrArray) call_records =
 
  849       g_ptr_array_new_with_free_func(g_object_unref);
 
  852       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
  853                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
  860   g_autoptr(FlKeyEvent) event1 =
 
  862                        static_cast<GdkModifierType
>(0), 0);
 
  863   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
  865       responder, event1, 0, 
nullptr,
 
  866       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  869             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  870         EXPECT_EQ(handled, 
TRUE);
 
  872         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  876   EXPECT_EQ(call_records->len, 1u);
 
  877   FlKeyEmbedderCallRecord* record =
 
  878       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  879   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  880   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
  881   EXPECT_EQ(record->event->logical, kLogicalCapsLock);
 
  882   EXPECT_STREQ(record->event->character, 
nullptr);
 
  883   EXPECT_EQ(record->event->synthesized, 
false);
 
  886   g_main_loop_run(loop1);
 
  890   g_autoptr(FlKeyEvent) event2 =
 
  892   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
  894       responder, event2, 0, 
nullptr,
 
  895       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  898             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  899         EXPECT_EQ(handled, 
TRUE);
 
  901         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  905   EXPECT_EQ(call_records->len, 1u);
 
  906   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  907   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  908   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
  909   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
  910   EXPECT_STREQ(record->event->character, 
"A");
 
  911   EXPECT_EQ(record->event->synthesized, 
false);
 
  914   g_main_loop_run(loop2);
 
  919       103, kRelease, kKeyCodeCapsLock, GDK_KEY_Caps_Lock, GDK_LOCK_MASK, 0);
 
  920   g_autoptr(GMainLoop) loop3 = g_main_loop_new(
nullptr, 0);
 
  922       responder, event3, 0, 
nullptr,
 
  923       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  926             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  927         EXPECT_EQ(handled, 
TRUE);
 
  929         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  933   EXPECT_EQ(call_records->len, 1u);
 
  934   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  935   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  936   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
  937   EXPECT_EQ(record->event->logical, kLogicalCapsLock);
 
  938   EXPECT_STREQ(record->event->character, 
nullptr);
 
  939   EXPECT_EQ(record->event->synthesized, 
false);
 
  942   g_main_loop_run(loop3);
 
  947                                                   GDK_KEY_A, GDK_LOCK_MASK, 0);
 
  948   g_autoptr(GMainLoop) loop4 = g_main_loop_new(
nullptr, 0);
 
  950       responder, event4, 0, 
nullptr,
 
  951       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  954             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  955         EXPECT_EQ(handled, 
TRUE);
 
  957         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  961   EXPECT_EQ(call_records->len, 1u);
 
  962   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  963   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
  964   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
  965   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
  966   EXPECT_STREQ(record->event->character, 
nullptr);
 
  967   EXPECT_EQ(record->event->synthesized, 
false);
 
  970   g_main_loop_run(loop4);
 
  975       105, kPress, kKeyCodeCapsLock, GDK_KEY_Caps_Lock, GDK_LOCK_MASK, 0);
 
  976   g_autoptr(GMainLoop) loop5 = g_main_loop_new(
nullptr, 0);
 
  978       responder, event5, 0, 
nullptr,
 
  979       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
  982             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
  983         EXPECT_EQ(handled, 
TRUE);
 
  985         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
  989   EXPECT_EQ(call_records->len, 1u);
 
  990   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
  991   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
  992   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
  993   EXPECT_EQ(record->event->logical, kLogicalCapsLock);
 
  994   EXPECT_STREQ(record->event->character, 
nullptr);
 
  995   EXPECT_EQ(record->event->synthesized, 
false);
 
  998   g_main_loop_run(loop5);
 
 1002   g_autoptr(FlKeyEvent) event6 =
 
 1004   g_autoptr(GMainLoop) loop6 = g_main_loop_new(
nullptr, 0);
 
 1006       responder, event6, 0, 
nullptr,
 
 1007       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1010             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1011         EXPECT_EQ(handled, 
TRUE);
 
 1013         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1017   EXPECT_EQ(call_records->len, 1u);
 
 1018   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1019   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1020   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1021   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1022   EXPECT_STREQ(record->event->character, 
"A");
 
 1023   EXPECT_EQ(record->event->synthesized, 
false);
 
 1026   g_main_loop_run(loop6);
 
 1031       107, kRelease, kKeyCodeCapsLock, GDK_KEY_Caps_Lock, GDK_LOCK_MASK, 0);
 
 1032   g_autoptr(GMainLoop) loop7 = g_main_loop_new(
nullptr, 0);
 
 1034       responder, event7, 0, 
nullptr,
 
 1035       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1038             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1039         EXPECT_EQ(handled, 
TRUE);
 
 1041         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1045   EXPECT_EQ(call_records->len, 1u);
 
 1046   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1047   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1048   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
 1049   EXPECT_EQ(record->event->logical, kLogicalCapsLock);
 
 1050   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1051   EXPECT_EQ(record->event->synthesized, 
false);
 
 1054   g_main_loop_run(loop7);
 
 1058   g_autoptr(FlKeyEvent) event8 =
 
 1060                        static_cast<GdkModifierType
>(0), 0);
 
 1061   g_autoptr(GMainLoop) loop8 = g_main_loop_new(
nullptr, 0);
 
 1063       responder, event8, 0, 
nullptr,
 
 1064       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1067             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1068         EXPECT_EQ(handled, 
TRUE);
 
 1070         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1074   EXPECT_EQ(call_records->len, 1u);
 
 1075   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1076   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1077   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1078   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1079   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1080   EXPECT_EQ(record->event->synthesized, 
false);
 
 1083   g_main_loop_run(loop8);
 
 1090 TEST(FlKeyEmbedderResponderTest, TapLetterKeysBetweenCapsLockEventsReversed) {
 
 1095   g_autoptr(FlKeyEmbedderResponder) responder =
 
 1098   g_autoptr(GPtrArray) call_records =
 
 1099       g_ptr_array_new_with_free_func(g_object_unref);
 
 1102       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
 1103                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
 1111       101, kPress, 
kKeyCodeKeyA, GDK_KEY_a, 
static_cast<GdkModifierType
>(0), 0);
 
 1112   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
 1114       responder, event1, 0, 
nullptr,
 
 1115       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1118             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1119         EXPECT_EQ(handled, 
TRUE);
 
 1121         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1125   EXPECT_EQ(call_records->len, 1u);
 
 1126   FlKeyEmbedderCallRecord* record =
 
 1127       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1128   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1129   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1130   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1131   EXPECT_STREQ(record->event->character, 
"a");
 
 1132   EXPECT_EQ(record->event->synthesized, 
false);
 
 1135   g_main_loop_run(loop1);
 
 1140       102, kPress, kKeyCodeCapsLock, GDK_KEY_Caps_Lock, GDK_LOCK_MASK, 0);
 
 1141   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
 1143       responder, event2, 0, 
nullptr,
 
 1144       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1147             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1148         EXPECT_EQ(handled, 
TRUE);
 
 1150         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1154   EXPECT_EQ(call_records->len, 1u);
 
 1155   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1156   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1157   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
 1158   EXPECT_EQ(record->event->logical, kLogicalCapsLock);
 
 1159   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1160   EXPECT_EQ(record->event->synthesized, 
false);
 
 1163   g_main_loop_run(loop2);
 
 1168       103, kRelease, kKeyCodeCapsLock, GDK_KEY_Caps_Lock, GDK_LOCK_MASK, 0);
 
 1169   g_autoptr(GMainLoop) loop3 = g_main_loop_new(
nullptr, 0);
 
 1171       responder, event3, 0, 
nullptr,
 
 1172       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1175             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1176         EXPECT_EQ(handled, 
TRUE);
 
 1178         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1182   EXPECT_EQ(call_records->len, 1u);
 
 1183   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1184   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1185   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
 1186   EXPECT_EQ(record->event->logical, kLogicalCapsLock);
 
 1187   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1188   EXPECT_EQ(record->event->synthesized, 
false);
 
 1191   g_main_loop_run(loop3);
 
 1196                                                   GDK_KEY_A, GDK_LOCK_MASK, 0);
 
 1197   g_autoptr(GMainLoop) loop4 = g_main_loop_new(
nullptr, 0);
 
 1199       responder, event4, 0, 
nullptr,
 
 1200       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1203             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1204         EXPECT_EQ(handled, 
TRUE);
 
 1206         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1210   EXPECT_EQ(call_records->len, 1u);
 
 1211   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1212   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1213   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1214   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1215   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1216   EXPECT_EQ(record->event->synthesized, 
false);
 
 1219   g_main_loop_run(loop4);
 
 1223   g_autoptr(FlKeyEvent) event5 =
 
 1225   g_autoptr(GMainLoop) loop5 = g_main_loop_new(
nullptr, 0);
 
 1227       responder, event5, 0, 
nullptr,
 
 1228       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1231             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1232         EXPECT_EQ(handled, 
TRUE);
 
 1234         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1238   EXPECT_EQ(call_records->len, 1u);
 
 1239   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1240   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1241   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1242   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1243   EXPECT_STREQ(record->event->character, 
"A");
 
 1244   EXPECT_EQ(record->event->synthesized, 
false);
 
 1247   g_main_loop_run(loop5);
 
 1251   g_autoptr(FlKeyEvent) event6 =
 
 1253                        static_cast<GdkModifierType
>(0), 0);
 
 1254   g_autoptr(GMainLoop) loop6 = g_main_loop_new(
nullptr, 0);
 
 1256       responder, event6, 0, 
nullptr,
 
 1257       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1260             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1261         EXPECT_EQ(handled, 
TRUE);
 
 1263         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1267   EXPECT_EQ(call_records->len, 1u);
 
 1268   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1269   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1270   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
 1271   EXPECT_EQ(record->event->logical, kLogicalCapsLock);
 
 1272   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1273   EXPECT_EQ(record->event->synthesized, 
false);
 
 1276   g_main_loop_run(loop6);
 
 1281       107, kRelease, kKeyCodeCapsLock, GDK_KEY_Caps_Lock, GDK_LOCK_MASK, 0);
 
 1282   g_autoptr(GMainLoop) loop7 = g_main_loop_new(
nullptr, 0);
 
 1284       responder, event7, 0, 
nullptr,
 
 1285       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1288             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1289         EXPECT_EQ(handled, 
TRUE);
 
 1291         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1295   EXPECT_EQ(call_records->len, 1u);
 
 1296   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1297   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1298   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
 1299   EXPECT_EQ(record->event->logical, kLogicalCapsLock);
 
 1300   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1301   EXPECT_EQ(record->event->synthesized, 
false);
 
 1304   g_main_loop_run(loop7);
 
 1308   g_autoptr(FlKeyEvent) event8 =
 
 1310                        static_cast<GdkModifierType
>(0), 0);
 
 1311   g_autoptr(GMainLoop) loop8 = g_main_loop_new(
nullptr, 0);
 
 1313       responder, event8, 0, 
nullptr,
 
 1314       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1317             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1318         EXPECT_EQ(handled, 
TRUE);
 
 1320         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1324   EXPECT_EQ(call_records->len, 1u);
 
 1325   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1326   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1327   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1328   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1329   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1330   EXPECT_EQ(record->event->synthesized, 
false);
 
 1333   g_main_loop_run(loop8);
 
 1336 TEST(FlKeyEmbedderResponderTest, TurnDuplicateDownEventsToRepeats) {
 
 1341   g_autoptr(FlKeyEmbedderResponder) responder =
 
 1344   g_autoptr(GPtrArray) call_records =
 
 1345       g_ptr_array_new_with_free_func(g_object_unref);
 
 1348       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
 1349                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
 1357       101, kPress, 
kKeyCodeKeyA, GDK_KEY_a, 
static_cast<GdkModifierType
>(0), 0);
 
 1358   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
 1360       responder, event1, 0, 
nullptr,
 
 1361       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1364             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1365         EXPECT_EQ(handled, 
TRUE);
 
 1367         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1371   EXPECT_EQ(call_records->len, 1u);
 
 1373   FlKeyEmbedderCallRecord* record =
 
 1374       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1376   g_main_loop_run(loop1);
 
 1381       102, kPress, 
kKeyCodeKeyA, GDK_KEY_a, 
static_cast<GdkModifierType
>(0), 0);
 
 1382   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
 1384       responder, event2, 0, 
nullptr,
 
 1385       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1388             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1389         EXPECT_EQ(handled, 
TRUE);
 
 1391         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1395   EXPECT_EQ(call_records->len, 1u);
 
 1397   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1398   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeRepeat);
 
 1399   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1400   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1401   EXPECT_STREQ(record->event->character, 
"a");
 
 1402   EXPECT_EQ(record->event->synthesized, 
false);
 
 1403   EXPECT_NE(record->callback, 
nullptr);
 
 1406   g_main_loop_run(loop2);
 
 1410   g_autoptr(FlKeyEvent) event3 =
 
 1412                        static_cast<GdkModifierType
>(0), 0);
 
 1413   g_autoptr(GMainLoop) loop3 = g_main_loop_new(
nullptr, 0);
 
 1415       responder, event3, 0, 
nullptr,
 
 1416       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1419             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1420         EXPECT_EQ(handled, 
TRUE);
 
 1422         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1426   EXPECT_EQ(call_records->len, 1u);
 
 1427   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1429   g_main_loop_run(loop3);
 
 1432 TEST(FlKeyEmbedderResponderTest, IgnoreAbruptUpEvent) {
 
 1437   g_autoptr(FlKeyEmbedderResponder) responder =
 
 1440   g_autoptr(GPtrArray) call_records =
 
 1441       g_ptr_array_new_with_free_func(g_object_unref);
 
 1444       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
 1445                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
 1452   g_autoptr(FlKeyEvent) 
event =
 
 1454                        static_cast<GdkModifierType
>(0), 0);
 
 1455   g_autoptr(GMainLoop) loop = g_main_loop_new(
nullptr, 0);
 
 1457       responder, event, 0, 
nullptr,
 
 1458       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1461             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1462         EXPECT_EQ(handled, 
TRUE);
 
 1464         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1468   EXPECT_EQ(call_records->len, 1u);
 
 1470   FlKeyEmbedderCallRecord* record =
 
 1471       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1472   EXPECT_EQ(record->event->physical, 0ull);
 
 1473   EXPECT_EQ(record->event->logical, 0ull);
 
 1474   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1475   EXPECT_EQ(record->event->synthesized, 
false);
 
 1478   g_main_loop_run(loop);
 
 1483 TEST(FlKeyEmbedderResponderTest, SynthesizeForDesyncPressingStateOnSelfEvents) {
 
 1488   g_autoptr(FlKeyEmbedderResponder) responder =
 
 1491   g_autoptr(GPtrArray) call_records =
 
 1492       g_ptr_array_new_with_free_func(g_object_unref);
 
 1495       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
 1496                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
 1505   GdkModifierType 
state = GDK_CONTROL_MASK;
 
 1509       101, kRelease, kKeyCodeControlLeft, GDK_KEY_Control_L, 
state, 0);
 
 1510   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
 1512       responder, event1, 0, 
nullptr,
 
 1513       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1516             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1517         EXPECT_EQ(handled, 
TRUE);
 
 1519         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1523   EXPECT_EQ(call_records->len, 2u);
 
 1524   FlKeyEmbedderCallRecord* record =
 
 1525       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1526   EXPECT_EQ(record->event->timestamp, 101000);
 
 1527   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1528   EXPECT_EQ(record->event->physical, kPhysicalControlLeft);
 
 1529   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 1530   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1531   EXPECT_EQ(record->event->synthesized, 
true);
 
 1533   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 1534   EXPECT_EQ(record->event->timestamp, 101000);
 
 1535   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1536   EXPECT_EQ(record->event->physical, kPhysicalControlLeft);
 
 1537   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 1538   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1539   EXPECT_EQ(record->event->synthesized, 
false);
 
 1542   g_main_loop_run(loop1);
 
 1548   state = 
static_cast<GdkModifierType
>(0);
 
 1550       102, kPress, kKeyCodeControlLeft, GDK_KEY_Control_L, 
state, 0);
 
 1551   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
 1553       responder, event2, 0, 
nullptr,
 
 1554       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1557             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1558         EXPECT_EQ(handled, 
TRUE);
 
 1560         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1563   EXPECT_EQ(call_records->len, 1u);
 
 1564   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1566   g_main_loop_run(loop2);
 
 1570   state = 
static_cast<GdkModifierType
>(0);
 
 1574       103, kPress, kKeyCodeControlLeft, GDK_KEY_Control_L, 
state, 0);
 
 1575   g_autoptr(GMainLoop) loop3 = g_main_loop_new(
nullptr, 0);
 
 1577       responder, event3, 0, 
nullptr,
 
 1578       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1581             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1582         EXPECT_EQ(handled, 
TRUE);
 
 1584         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1588   EXPECT_EQ(call_records->len, 2u);
 
 1589   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1590   EXPECT_EQ(record->event->timestamp, 103000);
 
 1591   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1592   EXPECT_EQ(record->event->physical, kPhysicalControlLeft);
 
 1593   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 1594   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1595   EXPECT_EQ(record->event->synthesized, 
true);
 
 1597   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 1598   EXPECT_EQ(record->event->timestamp, 103000);
 
 1599   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1600   EXPECT_EQ(record->event->physical, kPhysicalControlLeft);
 
 1601   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 1602   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1603   EXPECT_EQ(record->event->synthesized, 
false);
 
 1606   g_main_loop_run(loop3);
 
 1610   state = GDK_CONTROL_MASK;
 
 1612       104, kRelease, kKeyCodeControlLeft, GDK_KEY_Control_L, 
state, 0);
 
 1613   g_autoptr(GMainLoop) loop4 = g_main_loop_new(
nullptr, 0);
 
 1615       responder, event4, 0, 
nullptr,
 
 1616       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1619             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1620         EXPECT_EQ(handled, 
TRUE);
 
 1622         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1625   EXPECT_EQ(call_records->len, 1u);
 
 1626   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1628   g_main_loop_run(loop4);
 
 1634   state = GDK_CONTROL_MASK;
 
 1638       105, kRelease, kKeyCodeControlRight, GDK_KEY_Control_R, 
state, 0);
 
 1639   g_autoptr(GMainLoop) loop5 = g_main_loop_new(
nullptr, 0);
 
 1641       responder, event5, 0, 
nullptr,
 
 1642       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1645             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1646         EXPECT_EQ(handled, 
TRUE);
 
 1648         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1656   EXPECT_EQ(call_records->len, 1u);
 
 1657   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1658   EXPECT_EQ(record->event->timestamp, 105000);
 
 1659   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1660   EXPECT_EQ(record->event->physical, kPhysicalControlLeft);
 
 1661   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 1662   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1663   EXPECT_EQ(record->event->synthesized, 
true);
 
 1666   g_main_loop_run(loop5);
 
 1672      SynthesizeForDesyncPressingStateOnNonSelfEvents) {
 
 1677   g_autoptr(FlKeyEmbedderResponder) responder =
 
 1680   g_autoptr(GPtrArray) call_records =
 
 1681       g_ptr_array_new_with_free_func(g_object_unref);
 
 1684       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
 1685                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
 1692   GdkModifierType 
state = GDK_CONTROL_MASK;
 
 1695   g_autoptr(FlKeyEvent) event1 =
 
 1697   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
 1699       responder, event1, 0, 
nullptr,
 
 1700       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1703             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1704         EXPECT_EQ(handled, 
TRUE);
 
 1706         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1710   EXPECT_EQ(call_records->len, 2u);
 
 1711   FlKeyEmbedderCallRecord* record =
 
 1712       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1713   EXPECT_EQ(record->event->timestamp, 101000);
 
 1714   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1715   EXPECT_EQ(record->event->physical, kPhysicalControlLeft);
 
 1716   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 1717   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1718   EXPECT_EQ(record->event->synthesized, 
true);
 
 1720   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 1721   EXPECT_EQ(record->event->timestamp, 101000);
 
 1722   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1723   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1724   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1725   EXPECT_STREQ(record->event->character, 
"a");
 
 1726   EXPECT_EQ(record->event->synthesized, 
false);
 
 1729   g_main_loop_run(loop1);
 
 1733   state = 
static_cast<GdkModifierType
>(0);
 
 1736   g_autoptr(FlKeyEvent) event2 =
 
 1738   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
 1740       responder, event2, 0, 
nullptr,
 
 1741       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1744             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1745         EXPECT_EQ(handled, 
TRUE);
 
 1747         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1751   EXPECT_EQ(call_records->len, 2u);
 
 1752   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1753   EXPECT_EQ(record->event->timestamp, 102000);
 
 1754   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1755   EXPECT_EQ(record->event->physical, kPhysicalControlLeft);
 
 1756   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 1757   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1758   EXPECT_EQ(record->event->synthesized, 
true);
 
 1760   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 1761   EXPECT_EQ(record->event->timestamp, 102000);
 
 1762   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1763   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1764   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1765   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1766   EXPECT_EQ(record->event->synthesized, 
false);
 
 1769   g_main_loop_run(loop2);
 
 1775   state = 
static_cast<GdkModifierType
>(0);
 
 1777   g_autoptr(FlKeyEvent) event3 = 
fl_key_event_new(101, kPress, kKeyCodeCapsLock,
 
 1778                                                   GDK_KEY_Control_L, 
state, 0);
 
 1779   g_autoptr(GMainLoop) loop3 = g_main_loop_new(
nullptr, 0);
 
 1781       responder, event3, 0, 
nullptr,
 
 1782       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1785             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1786         EXPECT_EQ(handled, 
TRUE);
 
 1788         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1792   EXPECT_EQ(call_records->len, 1u);
 
 1793   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1794   EXPECT_EQ(record->event->timestamp, 101000);
 
 1795   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1796   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
 1797   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 1798   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1799   EXPECT_EQ(record->event->synthesized, 
false);
 
 1802   g_main_loop_run(loop3);
 
 1806   state = 
static_cast<GdkModifierType
>(0);
 
 1809   g_autoptr(FlKeyEvent) event4 =
 
 1811   g_autoptr(GMainLoop) loop4 = g_main_loop_new(
nullptr, 0);
 
 1813       responder, event4, 0, 
nullptr,
 
 1814       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1817             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1818         EXPECT_EQ(handled, 
TRUE);
 
 1820         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1826   EXPECT_EQ(call_records->len, 2u);
 
 1827   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1828   EXPECT_EQ(record->event->timestamp, 102000);
 
 1829   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1830   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
 1831   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 1832   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1833   EXPECT_EQ(record->event->synthesized, 
true);
 
 1835   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 1836   EXPECT_EQ(record->event->timestamp, 102000);
 
 1837   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1838   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1839   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1840   EXPECT_STREQ(record->event->character, 
"A");
 
 1841   EXPECT_EQ(record->event->synthesized, 
false);
 
 1844   g_main_loop_run(loop4);
 
 1850      SynthesizeForDesyncPressingStateOnRemappedEvents) {
 
 1855   g_autoptr(FlKeyEmbedderResponder) responder =
 
 1858   g_autoptr(GPtrArray) call_records =
 
 1859       g_ptr_array_new_with_free_func(g_object_unref);
 
 1862       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
 1863                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
 1870   GdkModifierType 
state = 
static_cast<GdkModifierType
>(0);
 
 1872   g_autoptr(FlKeyEvent) event1 = 
fl_key_event_new(101, kPress, kKeyCodeCapsLock,
 
 1873                                                   GDK_KEY_Control_L, 
state, 0);
 
 1874   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
 1876       responder, event1, 0, 
nullptr,
 
 1877       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1880             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1881         EXPECT_EQ(handled, 
TRUE);
 
 1883         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1887   EXPECT_EQ(call_records->len, 1u);
 
 1888   FlKeyEmbedderCallRecord* record =
 
 1889       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1890   EXPECT_EQ(record->event->timestamp, 101000);
 
 1891   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1892   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
 1893   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 1894   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1895   EXPECT_EQ(record->event->synthesized, 
false);
 
 1898   g_main_loop_run(loop1);
 
 1902   state = 
static_cast<GdkModifierType
>(0);
 
 1905   g_autoptr(FlKeyEvent) event2 =
 
 1907   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
 1909       responder, event2, 0, 
nullptr,
 
 1910       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1913             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1914         EXPECT_EQ(handled, 
TRUE);
 
 1916         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1922   EXPECT_EQ(call_records->len, 2u);
 
 1923   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1924   EXPECT_EQ(record->event->timestamp, 102000);
 
 1925   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 1926   EXPECT_EQ(record->event->physical, kPhysicalCapsLock);
 
 1927   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 1928   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1929   EXPECT_EQ(record->event->synthesized, 
true);
 
 1931   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 1932   EXPECT_EQ(record->event->timestamp, 102000);
 
 1933   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1934   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1935   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1936   EXPECT_STREQ(record->event->character, 
"A");
 
 1937   EXPECT_EQ(record->event->synthesized, 
false);
 
 1940   g_main_loop_run(loop2);
 
 1945 TEST(FlKeyEmbedderResponderTest, SynthesizeForDesyncLockModeOnNonSelfEvents) {
 
 1950   g_autoptr(FlKeyEmbedderResponder) responder =
 
 1953   g_autoptr(GPtrArray) call_records =
 
 1954       g_ptr_array_new_with_free_func(g_object_unref);
 
 1957       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
 1958                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
 1965   GdkModifierType 
state = GDK_MOD2_MASK;
 
 1968   g_autoptr(FlKeyEvent) event1 =
 
 1970   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
 1972       responder, event1, 0, 
nullptr,
 
 1973       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 1976             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 1977         EXPECT_EQ(handled, 
TRUE);
 
 1979         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 1983   EXPECT_EQ(call_records->len, 2u);
 
 1984   FlKeyEmbedderCallRecord* record =
 
 1985       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 1986   EXPECT_EQ(record->event->timestamp, 101000);
 
 1987   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1988   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 1989   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 1990   EXPECT_STREQ(record->event->character, 
nullptr);
 
 1991   EXPECT_EQ(record->event->synthesized, 
true);
 
 1993   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 1994   EXPECT_EQ(record->event->timestamp, 101000);
 
 1995   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 1996   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 1997   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 1998   EXPECT_STREQ(record->event->character, 
"a");
 
 1999   EXPECT_EQ(record->event->synthesized, 
false);
 
 2002   g_main_loop_run(loop1);
 
 2006   state = 
static_cast<GdkModifierType
>(0);
 
 2009   g_autoptr(FlKeyEvent) event2 =
 
 2011   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
 2013       responder, event2, 0, 
nullptr,
 
 2014       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 2017             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 2018         EXPECT_EQ(handled, 
TRUE);
 
 2020         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 2024   EXPECT_EQ(call_records->len, 4u);
 
 2025   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 2026   EXPECT_EQ(record->event->timestamp, 102000);
 
 2027   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 2028   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 2029   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 2030   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2031   EXPECT_EQ(record->event->synthesized, 
true);
 
 2033   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 2034   EXPECT_EQ(record->event->timestamp, 102000);
 
 2035   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2036   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 2037   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 2038   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2039   EXPECT_EQ(record->event->synthesized, 
true);
 
 2041   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 2));
 
 2042   EXPECT_EQ(record->event->timestamp, 102000);
 
 2043   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 2044   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 2045   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 2046   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2047   EXPECT_EQ(record->event->synthesized, 
true);
 
 2049   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 3));
 
 2050   EXPECT_EQ(record->event->timestamp, 102000);
 
 2051   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 2052   EXPECT_EQ(record->event->physical, kPhysicalKeyA);
 
 2053   EXPECT_EQ(record->event->logical, kLogicalKeyA);
 
 2054   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2055   EXPECT_EQ(record->event->synthesized, 
false);
 
 2058   g_main_loop_run(loop2);
 
 2064       103, kRelease, kKeyCodeNumLock, GDK_KEY_Num_Lock, 
state, 0);
 
 2065   g_autoptr(GMainLoop) loop3 = g_main_loop_new(
nullptr, 0);
 
 2067       responder, event3, 0, 
nullptr,
 
 2068       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 2071             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 2072         EXPECT_EQ(handled, 
TRUE);
 
 2074         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 2078   EXPECT_EQ(call_records->len, 1u);
 
 2079   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 2080   EXPECT_EQ(record->event->physical, 0ull);
 
 2081   EXPECT_EQ(record->event->logical, 0ull);
 
 2082   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2083   EXPECT_EQ(record->event->synthesized, 
false);
 
 2086   g_main_loop_run(loop3);
 
 2091 TEST(FlKeyEmbedderResponderTest, SynthesizeForDesyncLockModeOnSelfEvents) {
 
 2096   g_autoptr(FlKeyEmbedderResponder) responder =
 
 2099   g_autoptr(GPtrArray) call_records =
 
 2100       g_ptr_array_new_with_free_func(g_object_unref);
 
 2103       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
 2104                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
 2111   GdkModifierType 
state = GDK_MOD2_MASK;
 
 2114   g_autoptr(FlKeyEvent) event1 = 
fl_key_event_new(101, kPress, kKeyCodeNumLock,
 
 2115                                                   GDK_KEY_Num_Lock, 
state, 0);
 
 2116   g_autoptr(GMainLoop) loop1 = g_main_loop_new(
nullptr, 0);
 
 2118       responder, event1, 0, 
nullptr,
 
 2119       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 2122             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 2123         EXPECT_EQ(handled, 
TRUE);
 
 2125         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 2129   EXPECT_EQ(call_records->len, 3u);
 
 2130   FlKeyEmbedderCallRecord* record =
 
 2131       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 2132   EXPECT_EQ(record->event->timestamp, 101000);
 
 2133   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2134   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 2135   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 2136   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2137   EXPECT_EQ(record->event->synthesized, 
true);
 
 2139   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 2140   EXPECT_EQ(record->event->timestamp, 101000);
 
 2141   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 2142   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 2143   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 2144   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2145   EXPECT_EQ(record->event->synthesized, 
true);
 
 2147   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 2));
 
 2148   EXPECT_EQ(record->event->timestamp, 101000);
 
 2149   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2150   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 2151   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 2152   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2153   EXPECT_EQ(record->event->synthesized, 
false);
 
 2156   g_main_loop_run(loop1);
 
 2160   state = GDK_MOD2_MASK;
 
 2163   g_autoptr(FlKeyEvent) event2 = 
fl_key_event_new(102, kPress, kKeyCodeNumLock,
 
 2164                                                   GDK_KEY_Num_Lock, 
state, 0);
 
 2165   g_autoptr(GMainLoop) loop2 = g_main_loop_new(
nullptr, 0);
 
 2167       responder, event2, 0, 
nullptr,
 
 2168       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 2171             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 2172         EXPECT_EQ(handled, 
TRUE);
 
 2174         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 2178   EXPECT_EQ(call_records->len, 4u);
 
 2179   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 2180   EXPECT_EQ(record->event->timestamp, 102000);
 
 2181   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 2182   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 2183   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 2184   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2185   EXPECT_EQ(record->event->synthesized, 
true);
 
 2187   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 2188   EXPECT_EQ(record->event->timestamp, 102000);
 
 2189   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2190   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 2191   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 2192   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2193   EXPECT_EQ(record->event->synthesized, 
true);
 
 2195   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 2));
 
 2196   EXPECT_EQ(record->event->timestamp, 102000);
 
 2197   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 2198   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 2199   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 2200   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2201   EXPECT_EQ(record->event->synthesized, 
true);
 
 2203   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 3));
 
 2204   EXPECT_EQ(record->event->timestamp, 102000);
 
 2205   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2206   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 2207   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 2208   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2209   EXPECT_EQ(record->event->synthesized, 
false);
 
 2212   g_main_loop_run(loop2);
 
 2217 TEST(FlKeyEmbedderResponderTest, SynthesizationOccursOnIgnoredEvents) {
 
 2222   g_autoptr(FlKeyEmbedderResponder) responder =
 
 2225   g_autoptr(GPtrArray) call_records =
 
 2226       g_ptr_array_new_with_free_func(g_object_unref);
 
 2229       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
 2230                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
 2237   GdkModifierType 
state =
 
 2238       static_cast<GdkModifierType
>(GDK_MOD2_MASK | GDK_CONTROL_MASK);
 
 2241   g_autoptr(FlKeyEvent) 
event =
 
 2243   g_autoptr(GMainLoop) loop = g_main_loop_new(
nullptr, 0);
 
 2245       responder, event, 0, 
nullptr,
 
 2246       [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 2249             FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 2250         EXPECT_EQ(handled, 
TRUE);
 
 2252         g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 2255   g_main_loop_run(loop);
 
 2257   EXPECT_EQ(call_records->len, 2u);
 
 2258   FlKeyEmbedderCallRecord* record =
 
 2259       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 2260   EXPECT_EQ(record->event->timestamp, 101000);
 
 2261   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2262   EXPECT_EQ(record->event->physical, kPhysicalNumLock);
 
 2263   EXPECT_EQ(record->event->logical, kLogicalNumLock);
 
 2264   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2265   EXPECT_EQ(record->event->synthesized, 
true);
 
 2267   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 2268   EXPECT_EQ(record->event->timestamp, 101000);
 
 2269   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2270   EXPECT_EQ(record->event->physical, kPhysicalControlLeft);
 
 2271   EXPECT_EQ(record->event->logical, kLogicalControlLeft);
 
 2272   EXPECT_STREQ(record->event->character, 
nullptr);
 
 2273   EXPECT_EQ(record->event->synthesized, 
true);
 
 2286 TEST(FlKeyEmbedderResponderTest, HandlesShiftAltVersusGroupNext) {
 
 2291   g_autoptr(FlKeyEmbedderResponder) responder =
 
 2294   g_autoptr(GPtrArray) call_records =
 
 2295       g_ptr_array_new_with_free_func(g_object_unref);
 
 2298       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
 2299                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
 2306   guint32 now_time = 1;
 
 2308   auto send_key_event = [responder, &now_time](
bool is_press, guint keyval,
 
 2310                                                GdkModifierType 
state) {
 
 2312     g_autoptr(FlKeyEvent) 
event =
 
 2314     g_autoptr(GMainLoop) loop = g_main_loop_new(
nullptr, 0);
 
 2316         responder, event, 0, 
nullptr,
 
 2317         [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 2320               FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 2321           EXPECT_EQ(handled, 
TRUE);
 
 2323           g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 2326     g_main_loop_run(loop);
 
 2330                  GDK_MODIFIER_RESERVED_25_MASK);
 
 2331   EXPECT_EQ(call_records->len, 1u);
 
 2332   FlKeyEmbedderCallRecord* record =
 
 2333       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 2334   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2335   EXPECT_EQ(record->event->physical, kPhysicalShiftLeft);
 
 2336   EXPECT_EQ(record->event->logical, kLogicalShiftLeft);
 
 2337   EXPECT_EQ(record->event->synthesized, 
false);
 
 2340                  static_cast<GdkModifierType
>(GDK_SHIFT_MASK |
 
 2341                                               GDK_MODIFIER_RESERVED_25_MASK));
 
 2342   EXPECT_EQ(call_records->len, 2u);
 
 2343   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 2344   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2345   EXPECT_EQ(record->event->physical, kPhysicalAltRight);
 
 2346   EXPECT_EQ(record->event->logical, kLogicalMetaRight);
 
 2347   EXPECT_EQ(record->event->synthesized, 
false);
 
 2349   send_key_event(kRelease, GDK_KEY_ISO_Next_Group, kKeyCodeShiftLeft,
 
 2350                  static_cast<GdkModifierType
>(GDK_SHIFT_MASK | GDK_MOD1_MASK |
 
 2351                                               GDK_MODIFIER_RESERVED_25_MASK));
 
 2352   EXPECT_EQ(call_records->len, 5u);
 
 2353   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 2));
 
 2354   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2355   EXPECT_EQ(record->event->physical, kPhysicalAltLeft);
 
 2356   EXPECT_EQ(record->event->logical, kLogicalAltLeft);
 
 2357   EXPECT_EQ(record->event->synthesized, 
true);
 
 2359   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 3));
 
 2360   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 2361   EXPECT_EQ(record->event->physical, kPhysicalAltRight);
 
 2362   EXPECT_EQ(record->event->logical, kLogicalMetaRight);
 
 2363   EXPECT_EQ(record->event->synthesized, 
true);
 
 2365   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 4));
 
 2366   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 2367   EXPECT_EQ(record->event->physical, kPhysicalShiftLeft);
 
 2368   EXPECT_EQ(record->event->logical, kLogicalShiftLeft);
 
 2369   EXPECT_EQ(record->event->synthesized, 
false);
 
 2371   send_key_event(kPress, GDK_KEY_ISO_Next_Group, kKeyCodeShiftLeft,
 
 2372                  static_cast<GdkModifierType
>(GDK_MOD1_MASK |
 
 2373                                               GDK_MODIFIER_RESERVED_25_MASK));
 
 2374   EXPECT_EQ(call_records->len, 6u);
 
 2375   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 5));
 
 2376   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2377   EXPECT_EQ(record->event->physical, kPhysicalShiftLeft);
 
 2378   EXPECT_EQ(record->event->logical, kLogicalGroupNext);
 
 2379   EXPECT_EQ(record->event->synthesized, 
false);
 
 2381   send_key_event(kRelease, GDK_KEY_ISO_Level3_Shift, kKeyCodeAltRight,
 
 2382                  static_cast<GdkModifierType
>(GDK_MOD1_MASK |
 
 2383                                               GDK_MODIFIER_RESERVED_13_MASK |
 
 2384                                               GDK_MODIFIER_RESERVED_25_MASK));
 
 2385   EXPECT_EQ(call_records->len, 7u);
 
 2386   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 6));
 
 2387   EXPECT_EQ(record->event->physical, 0u);
 
 2388   EXPECT_EQ(record->event->logical, 0u);
 
 2391                  static_cast<GdkModifierType
>(GDK_MODIFIER_RESERVED_13_MASK |
 
 2392                                               GDK_MODIFIER_RESERVED_25_MASK));
 
 2393   EXPECT_EQ(call_records->len, 9u);
 
 2394   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 7));
 
 2395   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 2396   EXPECT_EQ(record->event->physical, kPhysicalAltLeft);
 
 2397   EXPECT_EQ(record->event->logical, kLogicalAltLeft);
 
 2398   EXPECT_EQ(record->event->synthesized, 
true);
 
 2400   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 8));
 
 2401   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeUp);
 
 2402   EXPECT_EQ(record->event->physical, kPhysicalShiftLeft);
 
 2403   EXPECT_EQ(record->event->logical, kLogicalGroupNext);
 
 2404   EXPECT_EQ(record->event->synthesized, 
false);
 
 2413 TEST(FlKeyEmbedderResponderTest, HandlesShiftAltLeftIsMetaLeft) {
 
 2418   g_autoptr(FlKeyEmbedderResponder) responder =
 
 2421   g_autoptr(GPtrArray) call_records =
 
 2422       g_ptr_array_new_with_free_func(g_object_unref);
 
 2425       ([&call_records](
auto engine, 
const FlutterKeyEvent* event,
 
 2426                        FlutterKeyEventCallback callback, 
void* 
user_data) {
 
 2433   guint32 now_time = 1;
 
 2435   auto send_key_event = [responder, &now_time](
bool is_press, guint keyval,
 
 2437                                                GdkModifierType 
state) {
 
 2439     g_autoptr(FlKeyEvent) 
event =
 
 2441     g_autoptr(GMainLoop) loop = g_main_loop_new(
nullptr, 0);
 
 2443         responder, event, 0, 
nullptr,
 
 2444         [](GObject* 
object, GAsyncResult* result, gpointer 
user_data) {
 
 2447               FL_KEY_EMBEDDER_RESPONDER(
object), result, &handled, 
nullptr));
 
 2448           EXPECT_EQ(handled, 
TRUE);
 
 2450           g_main_loop_quit(
static_cast<GMainLoop*
>(
user_data));
 
 2453     g_main_loop_run(loop);
 
 2458                  GDK_MODIFIER_RESERVED_25_MASK);
 
 2459   EXPECT_EQ(call_records->len, 1u);
 
 2460   FlKeyEmbedderCallRecord* record =
 
 2461       FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 2462   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2463   EXPECT_EQ(record->event->physical, kPhysicalShiftLeft);
 
 2464   EXPECT_EQ(record->event->logical, kLogicalShiftLeft);
 
 2465   EXPECT_EQ(record->event->synthesized, 
false);
 
 2468                  static_cast<GdkModifierType
>(GDK_SHIFT_MASK |
 
 2469                                               GDK_MODIFIER_RESERVED_25_MASK));
 
 2470   EXPECT_EQ(call_records->len, 2u);
 
 2471   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 2472   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2473   EXPECT_EQ(record->event->physical, kPhysicalMetaLeft);
 
 2474   EXPECT_EQ(record->event->logical, kLogicalMetaLeft);
 
 2475   EXPECT_EQ(record->event->synthesized, 
false);
 
 2478                  static_cast<GdkModifierType
>(GDK_MODIFIER_RESERVED_13_MASK |
 
 2479                                               GDK_MODIFIER_RESERVED_25_MASK));
 
 2481                  GDK_MODIFIER_RESERVED_25_MASK);
 
 2486                  GDK_MODIFIER_RESERVED_25_MASK);
 
 2487   EXPECT_EQ(call_records->len, 1u);
 
 2488   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 0));
 
 2489   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2490   EXPECT_EQ(record->event->physical, kPhysicalShiftRight);
 
 2491   EXPECT_EQ(record->event->logical, kLogicalShiftRight);
 
 2492   EXPECT_EQ(record->event->synthesized, 
false);
 
 2495                  static_cast<GdkModifierType
>(GDK_SHIFT_MASK |
 
 2496                                               GDK_MODIFIER_RESERVED_25_MASK));
 
 2497   EXPECT_EQ(call_records->len, 2u);
 
 2498   record = FL_KEY_EMBEDDER_CALL_RECORD(g_ptr_array_index(call_records, 1));
 
 2499   EXPECT_EQ(record->event->type, kFlutterKeyEventTypeDown);
 
 2500   EXPECT_EQ(record->event->physical, kPhysicalMetaLeft);
 
 2501   EXPECT_EQ(record->event->logical, kLogicalMetaLeft);
 
 2502   EXPECT_EQ(record->event->synthesized, 
false);