7#include "flutter/shell/platform/linux/fl_method_codec_private.h"
8#include "flutter/shell/platform/linux/fl_text_input_plugin.h"
9#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"
10#include "flutter/shell/platform/linux/public/flutter_linux/fl_json_method_codec.h"
11#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h"
12#include "flutter/shell/platform/linux/testing/fl_test.h"
13#include "flutter/shell/platform/linux/testing/mock_binary_messenger.h"
14#include "flutter/shell/platform/linux/testing/mock_binary_messenger_response_handle.h"
15#include "flutter/shell/platform/linux/testing/mock_im_context.h"
16#include "flutter/shell/platform/linux/testing/mock_text_input_view_delegate.h"
17#include "flutter/testing/testing.h"
19#include "gmock/gmock.h"
20#include "gtest/gtest.h"
22void printTo(FlMethodResponse* response, ::std::ostream* os) {
29 g_autoptr(FlMethodResponse) response =
48 ::testing::Matcher<FlValue*>
args)
52 ::testing::MatchResultListener* result_listener)
const {
54 g_autoptr(GError)
error =
nullptr;
55 g_autofree gchar*
name =
nullptr;
63 if (!name_.MatchAndExplain(
name, result_listener)) {
64 *result_listener <<
" where the name doesn't match: \"" <<
name <<
"\"";
67 if (!args_.MatchAndExplain(
args, result_listener)) {
68 *result_listener <<
" where the args don't match: "
76 *os <<
"method name ";
83 *os <<
"method name ";
84 name_.DescribeNegationTo(os);
86 args_.DescribeNegationTo(os);
90 ::testing::Matcher<std::string> name_;
91 ::testing::Matcher<FlValue*> args_;
95 ::testing::Matcher<FlValue*>
args) {
101 for (
auto it =
args.begin(); it !=
args.end(); ++it) {
109 for (
auto it =
args.begin(); it !=
args.end(); ++it) {
184 GdkEvent* gdk_event = gdk_event_new(GDK_KEY_PRESS);
185 gdk_event->key.keyval = keyval;
186 gdk_event->key.state =
state;
193 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
194 ::testing::NiceMock<flutter::testing::MockIMContext> context;
195 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
197 g_autoptr(FlTextInputPlugin) plugin =
199 EXPECT_NE(plugin,
nullptr);
201 EXPECT_TRUE(messenger.HasMessageHandler(
"flutter/textinput"));
204TEST(FlTextInputPluginTest, SetClient) {
205 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
206 ::testing::NiceMock<flutter::testing::MockIMContext> context;
207 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
209 g_autoptr(FlTextInputPlugin) plugin =
211 EXPECT_NE(plugin,
nullptr);
216 FL_METHOD_CODEC(codec),
"TextInput.setClient",
args,
nullptr);
220 ::testing::Eq<FlBinaryMessenger*>(messenger),
221 ::testing::_, SuccessResponse(null), ::testing::_))
222 .WillOnce(::testing::Return(
true));
224 messenger.ReceiveMessage(
"flutter/textinput",
message);
227TEST(FlTextInputPluginTest, Show) {
228 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
229 ::testing::NiceMock<flutter::testing::MockIMContext> context;
230 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
232 g_autoptr(FlTextInputPlugin) plugin =
234 EXPECT_NE(plugin,
nullptr);
237 gtk_im_context_focus_in(::testing::Eq<GtkIMContext*>(context)));
241 ::testing::Eq<FlBinaryMessenger*>(messenger),
242 ::testing::_, SuccessResponse(null), ::testing::_))
243 .WillOnce(::testing::Return(
true));
247 FL_METHOD_CODEC(codec),
"TextInput.show",
nullptr,
nullptr);
249 messenger.ReceiveMessage(
"flutter/textinput",
message);
252TEST(FlTextInputPluginTest, Hide) {
253 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
254 ::testing::NiceMock<flutter::testing::MockIMContext> context;
255 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
257 g_autoptr(FlTextInputPlugin) plugin =
259 EXPECT_NE(plugin,
nullptr);
262 gtk_im_context_focus_out(::testing::Eq<GtkIMContext*>(context)));
266 ::testing::Eq<FlBinaryMessenger*>(messenger),
267 ::testing::_, SuccessResponse(null), ::testing::_))
268 .WillOnce(::testing::Return(
true));
272 FL_METHOD_CODEC(codec),
"TextInput.hide",
nullptr,
nullptr);
274 messenger.ReceiveMessage(
"flutter/textinput",
message);
277TEST(FlTextInputPluginTest, ClearClient) {
278 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
279 ::testing::NiceMock<flutter::testing::MockIMContext> context;
280 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
282 g_autoptr(FlTextInputPlugin) plugin =
284 EXPECT_NE(plugin,
nullptr);
288 ::testing::Eq<FlBinaryMessenger*>(messenger),
289 ::testing::_, SuccessResponse(null), ::testing::_))
290 .WillOnce(::testing::Return(
true));
294 FL_METHOD_CODEC(codec),
"TextInput.clearClient",
nullptr,
nullptr);
296 messenger.ReceiveMessage(
"flutter/textinput",
message);
299TEST(FlTextInputPluginTest, PerformAction) {
300 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
301 ::testing::NiceMock<flutter::testing::MockIMContext> context;
302 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
304 g_autoptr(FlTextInputPlugin) plugin =
306 EXPECT_NE(plugin,
nullptr);
311 .input_type =
"TextInputType.multiline",
312 .input_action =
"TextInputAction.newline",
316 FL_METHOD_CODEC(codec),
"TextInput.setClient", config,
nullptr);
320 ::testing::Eq<FlBinaryMessenger*>(messenger),
321 ::testing::_, SuccessResponse(null), ::testing::_))
322 .WillOnce(::testing::Return(
true));
324 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
330 .selection_extent = 7,
333 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
336 ::testing::Eq<FlBinaryMessenger*>(messenger),
337 ::testing::_, SuccessResponse(null), ::testing::_))
338 .WillOnce(::testing::Return(
true));
340 messenger.ReceiveMessage(
"flutter/textinput", set_state);
348 .selection_extent = 8,
353 ::testing::Eq<FlBinaryMessenger*>(messenger),
354 ::testing::StrEq(
"flutter/textinput"),
355 MethodCall(
"TextInputClient.updateEditingState",
356 FlValueEq(new_state)),
357 ::testing::_, ::testing::_, ::testing::_));
366 ::testing::Eq<FlBinaryMessenger*>(messenger),
367 ::testing::StrEq(
"flutter/textinput"),
370 ::testing::_, ::testing::_, ::testing::_));
376TEST(FlTextInputPluginTest, MultilineWithSendAction) {
377 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
378 ::testing::NiceMock<flutter::testing::MockIMContext> context;
379 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
381 g_autoptr(FlTextInputPlugin) plugin =
383 EXPECT_NE(plugin,
nullptr);
388 .input_type =
"TextInputType.multiline",
389 .input_action =
"TextInputAction.send",
393 FL_METHOD_CODEC(codec),
"TextInput.setClient", config,
nullptr);
397 ::testing::Eq<FlBinaryMessenger*>(messenger),
398 ::testing::_, SuccessResponse(null), ::testing::_))
399 .WillOnce(::testing::Return(
true));
401 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
407 .selection_extent = 7,
410 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
413 ::testing::Eq<FlBinaryMessenger*>(messenger),
414 ::testing::_, SuccessResponse(null), ::testing::_))
415 .WillOnce(::testing::Return(
true));
417 messenger.ReceiveMessage(
"flutter/textinput", set_state);
431 ::testing::Eq<FlBinaryMessenger*>(messenger),
432 ::testing::StrEq(
"flutter/textinput"),
435 ::testing::_, ::testing::_, ::testing::_));
440TEST(FlTextInputPluginTest, MoveCursor) {
441 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
442 ::testing::NiceMock<flutter::testing::MockIMContext> context;
443 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
445 g_autoptr(FlTextInputPlugin) plugin =
447 EXPECT_NE(plugin,
nullptr);
453 FL_METHOD_CODEC(codec),
"TextInput.setClient", config,
nullptr);
457 ::testing::Eq<FlBinaryMessenger*>(messenger),
458 ::testing::_, SuccessResponse(null), ::testing::_))
459 .WillOnce(::testing::Return(
true));
461 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
467 .selection_extent = 4,
470 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
473 ::testing::Eq<FlBinaryMessenger*>(messenger),
474 ::testing::_, SuccessResponse(null), ::testing::_))
475 .WillOnce(::testing::Return(
true));
477 messenger.ReceiveMessage(
"flutter/textinput", set_state);
485 .selection_extent = 0,
490 ::testing::Eq<FlBinaryMessenger*>(messenger),
491 ::testing::StrEq(
"flutter/textinput"),
492 MethodCall(
"TextInputClient.updateEditingState",
493 FlValueEq(beginning)),
494 ::testing::_, ::testing::_, ::testing::_));
504 .selection_extent = 7,
509 ::testing::Eq<FlBinaryMessenger*>(messenger),
510 ::testing::StrEq(
"flutter/textinput"),
511 MethodCall(
"TextInputClient.updateEditingState",
513 ::testing::_, ::testing::_, ::testing::_));
518TEST(FlTextInputPluginTest, Select) {
519 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
520 ::testing::NiceMock<flutter::testing::MockIMContext> context;
521 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
523 g_autoptr(FlTextInputPlugin) plugin =
525 EXPECT_NE(plugin,
nullptr);
531 FL_METHOD_CODEC(codec),
"TextInput.setClient", config,
nullptr);
535 ::testing::Eq<FlBinaryMessenger*>(messenger),
536 ::testing::_, SuccessResponse(null), ::testing::_))
537 .WillOnce(::testing::Return(
true));
539 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
545 .selection_extent = 4,
548 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
551 ::testing::Eq<FlBinaryMessenger*>(messenger),
552 ::testing::_, SuccessResponse(null), ::testing::_))
553 .WillOnce(::testing::Return(
true));
555 messenger.ReceiveMessage(
"flutter/textinput", set_state);
563 .selection_extent = 7,
568 ::testing::Eq<FlBinaryMessenger*>(messenger),
569 ::testing::StrEq(
"flutter/textinput"),
570 MethodCall(
"TextInputClient.updateEditingState",
571 FlValueEq(select_to_end)),
572 ::testing::_, ::testing::_, ::testing::_));
582 .selection_extent = 0,
587 ::testing::Eq<FlBinaryMessenger*>(messenger),
588 ::testing::StrEq(
"flutter/textinput"),
589 MethodCall(
"TextInputClient.updateEditingState",
590 FlValueEq(select_to_beginning)),
591 ::testing::_, ::testing::_, ::testing::_));
596TEST(FlTextInputPluginTest, Composing) {
597 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
598 ::testing::NiceMock<flutter::testing::MockIMContext> context;
599 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
601 g_autoptr(FlTextInputPlugin) plugin =
603 EXPECT_NE(plugin,
nullptr);
605 g_signal_emit_by_name(context,
"preedit-start",
nullptr);
609 gtk_im_context_get_preedit_string(
610 ::testing::Eq<GtkIMContext*>(context),
611 ::testing::A<gchar**>(), ::testing::_, ::testing::A<gint*>()))
613 ::testing::DoAll(::testing::SetArgPointee<1>(g_strdup(
"Flutter")),
614 ::testing::SetArgPointee<3>(0)));
621 .selection_extent = 0,
623 .composing_extent = 7,
628 ::testing::Eq<FlBinaryMessenger*>(messenger),
629 ::testing::StrEq(
"flutter/textinput"),
630 MethodCall(
"TextInputClient.updateEditingState",
632 ::testing::_, ::testing::_, ::testing::_));
634 g_signal_emit_by_name(context,
"preedit-changed",
nullptr);
642 .selection_extent = 6,
647 ::testing::Eq<FlBinaryMessenger*>(messenger),
648 ::testing::StrEq(
"flutter/textinput"),
649 MethodCall(
"TextInputClient.updateEditingState",
651 ::testing::_, ::testing::_, ::testing::_));
653 g_signal_emit_by_name(context,
"commit",
"engine",
nullptr);
657 ::testing::Eq<FlBinaryMessenger*>(messenger),
658 ::testing::StrEq(
"flutter/textinput"),
659 MethodCall(
"TextInputClient.updateEditingState",
661 ::testing::_, ::testing::_, ::testing::_));
663 g_signal_emit_by_name(context,
"preedit-end",
nullptr);
666TEST(FlTextInputPluginTest, SurroundingText) {
667 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
668 ::testing::NiceMock<flutter::testing::MockIMContext> context;
669 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
671 g_autoptr(FlTextInputPlugin) plugin =
673 EXPECT_NE(plugin,
nullptr);
679 FL_METHOD_CODEC(codec),
"TextInput.setClient", config,
nullptr);
683 ::testing::Eq<FlBinaryMessenger*>(messenger),
684 ::testing::_, SuccessResponse(null), ::testing::_))
685 .WillOnce(::testing::Return(
true));
687 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
693 .selection_extent = 3,
696 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
699 ::testing::Eq<FlBinaryMessenger*>(messenger),
700 ::testing::_, SuccessResponse(null), ::testing::_))
701 .WillOnce(::testing::Return(
true));
703 messenger.ReceiveMessage(
"flutter/textinput", set_state);
706 EXPECT_CALL(context, gtk_im_context_set_surrounding(
707 ::testing::Eq<GtkIMContext*>(context),
708 ::testing::StrEq(
"Flutter"), 7, 3));
710 gboolean retrieved =
false;
711 g_signal_emit_by_name(context,
"retrieve-surrounding", &retrieved,
nullptr);
720 .selection_extent = 3,
725 ::testing::Eq<FlBinaryMessenger*>(messenger),
726 ::testing::StrEq(
"flutter/textinput"),
727 MethodCall(
"TextInputClient.updateEditingState",
729 ::testing::_, ::testing::_, ::testing::_));
731 gboolean deleted =
false;
732 g_signal_emit_by_name(context,
"delete-surrounding", 1, 2, &deleted,
nullptr);
736TEST(FlTextInputPluginTest, SetMarkedTextRect) {
737 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
738 ::testing::NiceMock<flutter::testing::MockIMContext> context;
739 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
741 g_autoptr(FlTextInputPlugin) plugin =
743 EXPECT_NE(plugin,
nullptr);
745 g_signal_emit_by_name(context,
"preedit-start",
nullptr);
774 FL_METHOD_CODEC(codec),
"TextInput.setEditableSizeAndTransform",
775 size_and_transform,
nullptr);
779 ::testing::Eq<FlBinaryMessenger*>(messenger),
780 ::testing::_, SuccessResponse(null), ::testing::_))
781 .WillOnce(::testing::Return(
true));
783 messenger.ReceiveMessage(
"flutter/textinput",
794 FL_METHOD_CODEC(codec),
"TextInput.setMarkedTextRect",
rect,
nullptr);
797 ::testing::Eq<FlBinaryMessenger*>(messenger),
798 ::testing::_, SuccessResponse(null), ::testing::_))
799 .WillOnce(::testing::Return(
true));
802 ::testing::Eq<FlTextInputViewDelegate*>(delegate),
803 ::testing::Eq(27), ::testing::Eq(32), ::testing::_,
805 .WillOnce(::testing::DoAll(::testing::SetArgPointee<3>(123),
806 ::testing::SetArgPointee<4>(456)));
808 EXPECT_CALL(context, gtk_im_context_set_cursor_location(
809 ::testing::Eq<GtkIMContext*>(context),
810 ::testing::Pointee(::testing::AllOf(
819TEST(FlTextInputPluginTest, TextInputTypeNone) {
820 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
821 ::testing::NiceMock<flutter::testing::MockIMContext> context;
822 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
824 g_autoptr(FlTextInputPlugin) plugin =
826 EXPECT_NE(plugin,
nullptr);
830 .input_type =
"TextInputType.none",
834 FL_METHOD_CODEC(codec),
"TextInput.setClient",
args,
nullptr);
838 ::testing::Eq<FlBinaryMessenger*>(messenger),
839 ::testing::A<FlBinaryMessengerResponseHandle*>(),
840 SuccessResponse(null), ::testing::A<GError**>()))
841 .WillOnce(::testing::Return(
true));
843 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
846 gtk_im_context_focus_in(::testing::Eq<GtkIMContext*>(context)))
849 gtk_im_context_focus_out(::testing::Eq<GtkIMContext*>(context)));
852 ::testing::Eq<FlBinaryMessenger*>(messenger),
853 ::testing::_, SuccessResponse(null), ::testing::_))
854 .WillOnce(::testing::Return(
true));
857 FL_METHOD_CODEC(codec),
"TextInput.show",
nullptr,
nullptr);
859 messenger.ReceiveMessage(
"flutter/textinput",
show);
862TEST(FlTextInputPluginTest, TextEditingDelta) {
863 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
864 ::testing::NiceMock<flutter::testing::MockIMContext> context;
865 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
867 g_autoptr(FlTextInputPlugin) plugin =
869 EXPECT_NE(plugin,
nullptr);
874 .enable_delta_model =
true,
878 FL_METHOD_CODEC(codec),
"TextInput.setClient",
args,
nullptr);
882 ::testing::Eq<FlBinaryMessenger*>(messenger),
883 ::testing::A<FlBinaryMessengerResponseHandle*>(),
884 SuccessResponse(null), ::testing::A<GError**>()))
885 .WillOnce(::testing::Return(
true));
887 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
893 .selection_extent = 7,
896 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
899 ::testing::Eq<FlBinaryMessenger*>(messenger),
900 ::testing::_, SuccessResponse(null), ::testing::_))
901 .WillOnce(::testing::Return(
true));
903 messenger.ReceiveMessage(
"flutter/textinput", set_state);
912 .old_text =
"Flutter",
913 .delta_text =
"Flutter",
917 .selection_extent = 0,
923 EXPECT_CALL(messenger,
925 ::testing::Eq<FlBinaryMessenger*>(messenger),
926 ::testing::StrEq(
"flutter/textinput"),
927 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
929 ::testing::_, ::testing::_, ::testing::_));
934TEST(FlTextInputPluginTest, ComposingDelta) {
935 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
936 ::testing::NiceMock<flutter::testing::MockIMContext> context;
937 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
939 g_autoptr(FlTextInputPlugin) plugin =
941 EXPECT_NE(plugin,
nullptr);
946 .enable_delta_model =
true,
950 FL_METHOD_CODEC(codec),
"TextInput.setClient",
args,
nullptr);
954 ::testing::Eq<FlBinaryMessenger*>(messenger),
955 ::testing::A<FlBinaryMessengerResponseHandle*>(),
956 SuccessResponse(null), ::testing::A<GError**>()))
957 .WillOnce(::testing::Return(
true));
959 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
961 g_signal_emit_by_name(context,
"preedit-start",
nullptr);
965 gtk_im_context_get_preedit_string(
966 ::testing::Eq<GtkIMContext*>(context),
967 ::testing::A<gchar**>(), ::testing::_, ::testing::A<gint*>()))
969 ::testing::DoAll(::testing::SetArgPointee<1>(g_strdup(
"Flutter ")),
970 ::testing::SetArgPointee<3>(8)));
979 .delta_text =
"Flutter ",
983 .selection_extent = 8,
985 .composing_extent = 8,
991 EXPECT_CALL(messenger,
993 ::testing::Eq<FlBinaryMessenger*>(messenger),
994 ::testing::StrEq(
"flutter/textinput"),
995 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
997 ::testing::_, ::testing::_, ::testing::_));
999 g_signal_emit_by_name(context,
"preedit-changed",
nullptr);
1008 .old_text =
"Flutter ",
1009 .delta_text =
"Flutter engine",
1012 .selection_base = 14,
1013 .selection_extent = 14,
1014 .composing_base = -1,
1015 .composing_extent = -1,
1021 EXPECT_CALL(messenger,
1023 ::testing::Eq<FlBinaryMessenger*>(messenger),
1024 ::testing::StrEq(
"flutter/textinput"),
1025 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1027 ::testing::_, ::testing::_, ::testing::_));
1029 g_signal_emit_by_name(context,
"commit",
"Flutter engine",
nullptr);
1038 .old_text =
"Flutter engine",
1039 .selection_base = 14,
1040 .selection_extent = 14,
1046 EXPECT_CALL(messenger,
1048 ::testing::Eq<FlBinaryMessenger*>(messenger),
1049 ::testing::StrEq(
"flutter/textinput"),
1050 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1052 ::testing::_, ::testing::_, ::testing::_));
1054 g_signal_emit_by_name(context,
"preedit-end",
nullptr);
1057TEST(FlTextInputPluginTest, NonComposingDelta) {
1058 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
1059 ::testing::NiceMock<flutter::testing::MockIMContext> context;
1060 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
1062 g_autoptr(FlTextInputPlugin) plugin =
1064 EXPECT_NE(plugin,
nullptr);
1069 .enable_delta_model =
true,
1073 FL_METHOD_CODEC(codec),
"TextInput.setClient",
args,
nullptr);
1077 ::testing::Eq<FlBinaryMessenger*>(messenger),
1078 ::testing::A<FlBinaryMessengerResponseHandle*>(),
1079 SuccessResponse(null), ::testing::A<GError**>()))
1080 .WillOnce(::testing::Return(
true));
1082 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
1095 .selection_base = 1,
1096 .selection_extent = 1,
1097 .composing_base = -1,
1098 .composing_extent = -1,
1104 EXPECT_CALL(messenger,
1106 ::testing::Eq<FlBinaryMessenger*>(messenger),
1107 ::testing::StrEq(
"flutter/textinput"),
1108 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1110 ::testing::_, ::testing::_, ::testing::_));
1112 g_signal_emit_by_name(context,
"commit",
"F",
nullptr);
1125 .selection_base = 2,
1126 .selection_extent = 2,
1127 .composing_base = -1,
1128 .composing_extent = -1,
1134 EXPECT_CALL(messenger,
1136 ::testing::Eq<FlBinaryMessenger*>(messenger),
1137 ::testing::StrEq(
"flutter/textinput"),
1138 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1139 FlValueEq(commitL)),
1140 ::testing::_, ::testing::_, ::testing::_));
1142 g_signal_emit_by_name(context,
"commit",
"l",
nullptr);
1155 .selection_base = 3,
1156 .selection_extent = 3,
1157 .composing_base = -1,
1158 .composing_extent = -1,
1164 EXPECT_CALL(messenger,
1166 ::testing::Eq<FlBinaryMessenger*>(messenger),
1167 ::testing::StrEq(
"flutter/textinput"),
1168 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1169 FlValueEq(commitU)),
1170 ::testing::_, ::testing::_, ::testing::_));
1172 g_signal_emit_by_name(context,
"commit",
"u",
nullptr);
1185 .selection_base = 4,
1186 .selection_extent = 4,
1187 .composing_base = -1,
1188 .composing_extent = -1,
1194 EXPECT_CALL(messenger,
1196 ::testing::Eq<FlBinaryMessenger*>(messenger),
1197 ::testing::StrEq(
"flutter/textinput"),
1198 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1199 FlValueEq(commitTa)),
1200 ::testing::_, ::testing::_, ::testing::_));
1202 g_signal_emit_by_name(context,
"commit",
"t",
nullptr);
1215 .selection_base = 5,
1216 .selection_extent = 5,
1217 .composing_base = -1,
1218 .composing_extent = -1,
1224 EXPECT_CALL(messenger,
1226 ::testing::Eq<FlBinaryMessenger*>(messenger),
1227 ::testing::StrEq(
"flutter/textinput"),
1228 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1229 FlValueEq(commitTb)),
1230 ::testing::_, ::testing::_, ::testing::_));
1232 g_signal_emit_by_name(context,
"commit",
"t",
nullptr);
1241 .old_text =
"Flutt",
1245 .selection_base = 6,
1246 .selection_extent = 6,
1247 .composing_base = -1,
1248 .composing_extent = -1,
1254 EXPECT_CALL(messenger,
1256 ::testing::Eq<FlBinaryMessenger*>(messenger),
1257 ::testing::StrEq(
"flutter/textinput"),
1258 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1259 FlValueEq(commitE)),
1260 ::testing::_, ::testing::_, ::testing::_));
1262 g_signal_emit_by_name(context,
"commit",
"e",
nullptr);
1271 .old_text =
"Flutte",
1275 .selection_base = 7,
1276 .selection_extent = 7,
1277 .composing_base = -1,
1278 .composing_extent = -1,
1284 EXPECT_CALL(messenger,
1286 ::testing::Eq<FlBinaryMessenger*>(messenger),
1287 ::testing::StrEq(
"flutter/textinput"),
1288 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1289 FlValueEq(commitR)),
1290 ::testing::_, ::testing::_, ::testing::_));
1292 g_signal_emit_by_name(context,
"commit",
"r",
nullptr);
bool MatchAndExplain(GBytes *method_call, ::testing::MatchResultListener *result_listener) const
MethodCallMatcher(::testing::Matcher< std::string > name, ::testing::Matcher< FlValue * > args)
void DescribeTo(std::ostream *os) const
void DescribeNegationTo(std::ostream *os) const
G_MODULE_EXPORT void fl_binary_messenger_send_on_channel(FlBinaryMessenger *self, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
G_MODULE_EXPORT gboolean fl_binary_messenger_send_response(FlBinaryMessenger *self, FlBinaryMessengerResponseHandle *response_handle, GBytes *response, GError **error)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_MODULE_EXPORT FlJsonMethodCodec * fl_json_method_codec_new()
void fl_key_event_dispose(FlKeyEvent *event)
FlKeyEvent * fl_key_event_new_from_gdk_event(GdkEvent *event)
G_BEGIN_DECLS G_MODULE_EXPORT FlMethodCall * method_call
FlMethodResponse * fl_method_codec_decode_response(FlMethodCodec *self, GBytes *message, GError **error)
gboolean fl_method_codec_decode_method_call(FlMethodCodec *self, GBytes *message, gchar **name, FlValue **args, GError **error)
GBytes * fl_method_codec_encode_method_call(FlMethodCodec *self, const gchar *name, FlValue *args, GError **error)
G_MODULE_EXPORT FlValue * fl_method_response_get_result(FlMethodResponse *self, GError **error)
const uint8_t uint32_t uint32_t GError ** error
static FlMethodResponse * set_client(FlTextInputPlugin *self, FlValue *args)
static FlMethodResponse * show(FlTextInputPlugin *self)
static FlMethodResponse * set_marked_text_rect(FlTextInputPlugin *self, FlValue *args)
static FlMethodResponse * set_editable_size_and_transform(FlTextInputPlugin *self, FlValue *args)
gboolean fl_text_input_plugin_filter_keypress(FlTextInputPlugin *self, FlKeyEvent *event)
FlTextInputPlugin * fl_text_input_plugin_new(FlBinaryMessenger *messenger, GtkIMContext *im_context, FlTextInputViewDelegate *view_delegate)
MATCHER_P(SuccessResponse, result, "")
static FlValue * build_input_config(InputConfig config)
static FlValue * build_editing_state(EditingState state)
void printTo(FlMethodResponse *response, ::std::ostream *os)
static FlValue * build_map(std::map< const gchar *, FlValue * > args)
TEST(FlTextInputPluginTest, MessageHandler)
::testing::Matcher< GBytes * > MethodCall(const std::string &name, ::testing::Matcher< FlValue * > args)
static void send_key_event(FlTextInputPlugin *plugin, gint keyval, gint state=0)
static FlValue * build_list(std::vector< FlValue * > args)
static FlValue * build_editing_delta(EditingDelta delta)
void fl_text_input_view_delegate_translate_coordinates(FlTextInputViewDelegate *self, gint view_x, gint view_y, gint *window_x, gint *window_y)
G_MODULE_EXPORT FlValue * fl_value_new_map()
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
G_MODULE_EXPORT FlValue * fl_value_new_null()
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
G_MODULE_EXPORT FlValue * fl_value_new_list()
G_MODULE_EXPORT bool fl_value_equal(FlValue *a, FlValue *b)
typedefG_BEGIN_DECLS struct _FlValue FlValue
FlutterKeyEvent key_event
sk_sp< SkBlender > blender SkRect rect
static CStringUniquePtr PrintToString(const char *format,...)
std::function< void(const T &message, const MessageReply< T > &reply)> MessageHandler
DEF_SWITCHES_START aot vmservice shared library name
#define EXPECT_TRUE(handle)