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"
22 void printTo(FlMethodResponse* response, ::std::ostream* os) {
23 *os << ::testing::PrintToString(
29 g_autoptr(FlMethodResponse) response =
35 *result_listener << ::testing::PrintToString(response);
48 ::testing::Matcher<FlValue*>
args)
49 : name_(std::move(name)), args_(std::move(
args)) {}
52 ::testing::MatchResultListener* result_listener)
const {
54 g_autoptr(GError)
error =
nullptr;
55 g_autofree gchar* name =
nullptr;
60 *result_listener << ::testing::PrintToString(
error->message);
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: "
69 << ::testing::PrintToString(
args);
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_;
94 ::testing::Matcher<GBytes*>
MethodCall(
const std::string& name,
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;
192 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
193 ::testing::NiceMock<flutter::testing::MockIMContext> context;
194 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
196 g_autoptr(FlTextInputHandler) handler =
198 EXPECT_NE(handler,
nullptr);
200 EXPECT_TRUE(messenger.HasMessageHandler(
"flutter/textinput"));
203 TEST(FlTextInputHandlerTest, SetClient) {
204 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
205 ::testing::NiceMock<flutter::testing::MockIMContext> context;
206 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
208 g_autoptr(FlTextInputHandler) handler =
210 EXPECT_NE(handler,
nullptr);
215 FL_METHOD_CODEC(codec),
"TextInput.setClient",
args,
nullptr);
219 ::testing::Eq<FlBinaryMessenger*>(messenger),
220 ::testing::_, SuccessResponse(
null), ::testing::_))
221 .WillOnce(::testing::Return(
true));
223 messenger.ReceiveMessage(
"flutter/textinput", message);
226 TEST(FlTextInputHandlerTest, Show) {
227 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
228 ::testing::NiceMock<flutter::testing::MockIMContext> context;
229 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
231 g_autoptr(FlTextInputHandler) handler =
233 EXPECT_NE(handler,
nullptr);
236 gtk_im_context_focus_in(::testing::Eq<GtkIMContext*>(context)));
240 ::testing::Eq<FlBinaryMessenger*>(messenger),
241 ::testing::_, SuccessResponse(
null), ::testing::_))
242 .WillOnce(::testing::Return(
true));
246 FL_METHOD_CODEC(codec),
"TextInput.show",
nullptr,
nullptr);
248 messenger.ReceiveMessage(
"flutter/textinput", message);
251 TEST(FlTextInputHandlerTest, Hide) {
252 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
253 ::testing::NiceMock<flutter::testing::MockIMContext> context;
254 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
256 g_autoptr(FlTextInputHandler) handler =
258 EXPECT_NE(handler,
nullptr);
261 gtk_im_context_focus_out(::testing::Eq<GtkIMContext*>(context)));
265 ::testing::Eq<FlBinaryMessenger*>(messenger),
266 ::testing::_, SuccessResponse(
null), ::testing::_))
267 .WillOnce(::testing::Return(
true));
271 FL_METHOD_CODEC(codec),
"TextInput.hide",
nullptr,
nullptr);
273 messenger.ReceiveMessage(
"flutter/textinput", message);
276 TEST(FlTextInputHandlerTest, ClearClient) {
277 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
278 ::testing::NiceMock<flutter::testing::MockIMContext> context;
279 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
281 g_autoptr(FlTextInputHandler) handler =
283 EXPECT_NE(handler,
nullptr);
287 ::testing::Eq<FlBinaryMessenger*>(messenger),
288 ::testing::_, SuccessResponse(
null), ::testing::_))
289 .WillOnce(::testing::Return(
true));
293 FL_METHOD_CODEC(codec),
"TextInput.clearClient",
nullptr,
nullptr);
295 messenger.ReceiveMessage(
"flutter/textinput", message);
298 TEST(FlTextInputHandlerTest, PerformAction) {
299 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
300 ::testing::NiceMock<flutter::testing::MockIMContext> context;
301 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
303 g_autoptr(FlTextInputHandler) handler =
305 EXPECT_NE(handler,
nullptr);
310 .input_type =
"TextInputType.multiline",
311 .input_action =
"TextInputAction.newline",
315 FL_METHOD_CODEC(codec),
"TextInput.setClient", config,
nullptr);
319 ::testing::Eq<FlBinaryMessenger*>(messenger),
320 ::testing::_, SuccessResponse(
null), ::testing::_))
321 .WillOnce(::testing::Return(
true));
323 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
329 .selection_extent = 7,
332 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
335 ::testing::Eq<FlBinaryMessenger*>(messenger),
336 ::testing::_, SuccessResponse(
null), ::testing::_))
337 .WillOnce(::testing::Return(
true));
339 messenger.ReceiveMessage(
"flutter/textinput", set_state);
347 .selection_extent = 8,
352 ::testing::Eq<FlBinaryMessenger*>(messenger),
353 ::testing::StrEq(
"flutter/textinput"),
354 MethodCall(
"TextInputClient.updateEditingState",
355 FlValueEq(new_state)),
356 ::testing::_, ::testing::_, ::testing::_));
365 ::testing::Eq<FlBinaryMessenger*>(messenger),
366 ::testing::StrEq(
"flutter/textinput"),
369 ::testing::_, ::testing::_, ::testing::_));
375 TEST(FlTextInputHandlerTest, MultilineWithSendAction) {
376 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
377 ::testing::NiceMock<flutter::testing::MockIMContext> context;
378 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
380 g_autoptr(FlTextInputHandler) handler =
382 EXPECT_NE(handler,
nullptr);
387 .input_type =
"TextInputType.multiline",
388 .input_action =
"TextInputAction.send",
392 FL_METHOD_CODEC(codec),
"TextInput.setClient", config,
nullptr);
396 ::testing::Eq<FlBinaryMessenger*>(messenger),
397 ::testing::_, SuccessResponse(
null), ::testing::_))
398 .WillOnce(::testing::Return(
true));
400 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
406 .selection_extent = 7,
409 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
412 ::testing::Eq<FlBinaryMessenger*>(messenger),
413 ::testing::_, SuccessResponse(
null), ::testing::_))
414 .WillOnce(::testing::Return(
true));
416 messenger.ReceiveMessage(
"flutter/textinput", set_state);
430 ::testing::Eq<FlBinaryMessenger*>(messenger),
431 ::testing::StrEq(
"flutter/textinput"),
434 ::testing::_, ::testing::_, ::testing::_));
439 TEST(FlTextInputHandlerTest, MoveCursor) {
440 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
441 ::testing::NiceMock<flutter::testing::MockIMContext> context;
442 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
444 g_autoptr(FlTextInputHandler) handler =
446 EXPECT_NE(handler,
nullptr);
452 FL_METHOD_CODEC(codec),
"TextInput.setClient", config,
nullptr);
456 ::testing::Eq<FlBinaryMessenger*>(messenger),
457 ::testing::_, SuccessResponse(
null), ::testing::_))
458 .WillOnce(::testing::Return(
true));
460 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
466 .selection_extent = 4,
469 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
472 ::testing::Eq<FlBinaryMessenger*>(messenger),
473 ::testing::_, SuccessResponse(
null), ::testing::_))
474 .WillOnce(::testing::Return(
true));
476 messenger.ReceiveMessage(
"flutter/textinput", set_state);
484 .selection_extent = 0,
489 ::testing::Eq<FlBinaryMessenger*>(messenger),
490 ::testing::StrEq(
"flutter/textinput"),
491 MethodCall(
"TextInputClient.updateEditingState",
492 FlValueEq(beginning)),
493 ::testing::_, ::testing::_, ::testing::_));
503 .selection_extent = 7,
508 ::testing::Eq<FlBinaryMessenger*>(messenger),
509 ::testing::StrEq(
"flutter/textinput"),
510 MethodCall(
"TextInputClient.updateEditingState",
512 ::testing::_, ::testing::_, ::testing::_));
517 TEST(FlTextInputHandlerTest, Select) {
518 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
519 ::testing::NiceMock<flutter::testing::MockIMContext> context;
520 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
522 g_autoptr(FlTextInputHandler) handler =
524 EXPECT_NE(handler,
nullptr);
530 FL_METHOD_CODEC(codec),
"TextInput.setClient", config,
nullptr);
534 ::testing::Eq<FlBinaryMessenger*>(messenger),
535 ::testing::_, SuccessResponse(
null), ::testing::_))
536 .WillOnce(::testing::Return(
true));
538 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
544 .selection_extent = 4,
547 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
550 ::testing::Eq<FlBinaryMessenger*>(messenger),
551 ::testing::_, SuccessResponse(
null), ::testing::_))
552 .WillOnce(::testing::Return(
true));
554 messenger.ReceiveMessage(
"flutter/textinput", set_state);
562 .selection_extent = 7,
567 ::testing::Eq<FlBinaryMessenger*>(messenger),
568 ::testing::StrEq(
"flutter/textinput"),
569 MethodCall(
"TextInputClient.updateEditingState",
570 FlValueEq(select_to_end)),
571 ::testing::_, ::testing::_, ::testing::_));
581 .selection_extent = 0,
586 ::testing::Eq<FlBinaryMessenger*>(messenger),
587 ::testing::StrEq(
"flutter/textinput"),
588 MethodCall(
"TextInputClient.updateEditingState",
589 FlValueEq(select_to_beginning)),
590 ::testing::_, ::testing::_, ::testing::_));
595 TEST(FlTextInputHandlerTest, Composing) {
596 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
597 ::testing::NiceMock<flutter::testing::MockIMContext> context;
598 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
600 g_autoptr(FlTextInputHandler) handler =
602 EXPECT_NE(handler,
nullptr);
604 g_signal_emit_by_name(context,
"preedit-start",
nullptr);
608 gtk_im_context_get_preedit_string(
609 ::testing::Eq<GtkIMContext*>(context),
610 ::testing::A<gchar**>(), ::testing::_, ::testing::A<gint*>()))
612 ::testing::DoAll(::testing::SetArgPointee<1>(g_strdup(
"Flutter")),
613 ::testing::SetArgPointee<3>(0)));
620 .selection_extent = 0,
622 .composing_extent = 7,
627 ::testing::Eq<FlBinaryMessenger*>(messenger),
628 ::testing::StrEq(
"flutter/textinput"),
629 MethodCall(
"TextInputClient.updateEditingState",
631 ::testing::_, ::testing::_, ::testing::_));
633 g_signal_emit_by_name(context,
"preedit-changed",
nullptr);
641 .selection_extent = 6,
646 ::testing::Eq<FlBinaryMessenger*>(messenger),
647 ::testing::StrEq(
"flutter/textinput"),
648 MethodCall(
"TextInputClient.updateEditingState",
650 ::testing::_, ::testing::_, ::testing::_));
652 g_signal_emit_by_name(context,
"commit",
"engine",
nullptr);
656 ::testing::Eq<FlBinaryMessenger*>(messenger),
657 ::testing::StrEq(
"flutter/textinput"),
658 MethodCall(
"TextInputClient.updateEditingState",
660 ::testing::_, ::testing::_, ::testing::_));
662 g_signal_emit_by_name(context,
"preedit-end",
nullptr);
665 TEST(FlTextInputHandlerTest, SurroundingText) {
666 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
667 ::testing::NiceMock<flutter::testing::MockIMContext> context;
668 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
670 g_autoptr(FlTextInputHandler) handler =
672 EXPECT_NE(handler,
nullptr);
678 FL_METHOD_CODEC(codec),
"TextInput.setClient", config,
nullptr);
682 ::testing::Eq<FlBinaryMessenger*>(messenger),
683 ::testing::_, SuccessResponse(
null), ::testing::_))
684 .WillOnce(::testing::Return(
true));
686 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
692 .selection_extent = 3,
695 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
698 ::testing::Eq<FlBinaryMessenger*>(messenger),
699 ::testing::_, SuccessResponse(
null), ::testing::_))
700 .WillOnce(::testing::Return(
true));
702 messenger.ReceiveMessage(
"flutter/textinput", set_state);
705 EXPECT_CALL(context, gtk_im_context_set_surrounding(
706 ::testing::Eq<GtkIMContext*>(context),
707 ::testing::StrEq(
"Flutter"), 7, 3));
709 gboolean retrieved =
false;
710 g_signal_emit_by_name(context,
"retrieve-surrounding", &retrieved,
nullptr);
711 EXPECT_TRUE(retrieved);
719 .selection_extent = 3,
724 ::testing::Eq<FlBinaryMessenger*>(messenger),
725 ::testing::StrEq(
"flutter/textinput"),
726 MethodCall(
"TextInputClient.updateEditingState",
728 ::testing::_, ::testing::_, ::testing::_));
730 gboolean deleted =
false;
731 g_signal_emit_by_name(context,
"delete-surrounding", 1, 2, &deleted,
nullptr);
732 EXPECT_TRUE(deleted);
735 TEST(FlTextInputHandlerTest, SetMarkedTextRect) {
736 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
737 ::testing::NiceMock<flutter::testing::MockIMContext> context;
738 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
740 g_autoptr(FlTextInputHandler) handler =
742 EXPECT_NE(handler,
nullptr);
744 g_signal_emit_by_name(context,
"preedit-start",
nullptr);
773 FL_METHOD_CODEC(codec),
"TextInput.setEditableSizeAndTransform",
774 size_and_transform,
nullptr);
778 ::testing::Eq<FlBinaryMessenger*>(messenger),
779 ::testing::_, SuccessResponse(
null), ::testing::_))
780 .WillOnce(::testing::Return(
true));
782 messenger.ReceiveMessage(
"flutter/textinput",
793 FL_METHOD_CODEC(codec),
"TextInput.setMarkedTextRect", rect,
nullptr);
796 ::testing::Eq<FlBinaryMessenger*>(messenger),
797 ::testing::_, SuccessResponse(
null), ::testing::_))
798 .WillOnce(::testing::Return(
true));
801 ::testing::Eq<FlTextInputViewDelegate*>(delegate),
802 ::testing::Eq(27), ::testing::Eq(32), ::testing::_,
804 .WillOnce(::testing::DoAll(::testing::SetArgPointee<3>(123),
805 ::testing::SetArgPointee<4>(456)));
807 EXPECT_CALL(context, gtk_im_context_set_cursor_location(
808 ::testing::Eq<GtkIMContext*>(context),
809 ::testing::Pointee(::testing::AllOf(
810 ::testing::Field(&GdkRectangle::x, 123),
811 ::testing::Field(&GdkRectangle::y, 456),
818 TEST(FlTextInputHandlerTest, TextInputTypeNone) {
819 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
820 ::testing::NiceMock<flutter::testing::MockIMContext> context;
821 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
823 g_autoptr(FlTextInputHandler) handler =
825 EXPECT_NE(handler,
nullptr);
829 .input_type =
"TextInputType.none",
833 FL_METHOD_CODEC(codec),
"TextInput.setClient",
args,
nullptr);
837 ::testing::Eq<FlBinaryMessenger*>(messenger),
838 ::testing::A<FlBinaryMessengerResponseHandle*>(),
839 SuccessResponse(
null), ::testing::A<GError**>()))
840 .WillOnce(::testing::Return(
true));
842 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
845 gtk_im_context_focus_in(::testing::Eq<GtkIMContext*>(context)))
848 gtk_im_context_focus_out(::testing::Eq<GtkIMContext*>(context)));
851 ::testing::Eq<FlBinaryMessenger*>(messenger),
852 ::testing::_, SuccessResponse(
null), ::testing::_))
853 .WillOnce(::testing::Return(
true));
856 FL_METHOD_CODEC(codec),
"TextInput.show",
nullptr,
nullptr);
858 messenger.ReceiveMessage(
"flutter/textinput",
show);
861 TEST(FlTextInputHandlerTest, TextEditingDelta) {
862 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
863 ::testing::NiceMock<flutter::testing::MockIMContext> context;
864 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
866 g_autoptr(FlTextInputHandler) handler =
868 EXPECT_NE(handler,
nullptr);
873 .enable_delta_model =
true,
877 FL_METHOD_CODEC(codec),
"TextInput.setClient",
args,
nullptr);
881 ::testing::Eq<FlBinaryMessenger*>(messenger),
882 ::testing::A<FlBinaryMessengerResponseHandle*>(),
883 SuccessResponse(
null), ::testing::A<GError**>()))
884 .WillOnce(::testing::Return(
true));
886 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
892 .selection_extent = 7,
895 FL_METHOD_CODEC(codec),
"TextInput.setEditingState",
state,
nullptr);
898 ::testing::Eq<FlBinaryMessenger*>(messenger),
899 ::testing::_, SuccessResponse(
null), ::testing::_))
900 .WillOnce(::testing::Return(
true));
902 messenger.ReceiveMessage(
"flutter/textinput", set_state);
911 .old_text =
"Flutter",
912 .delta_text =
"Flutter",
916 .selection_extent = 0,
922 EXPECT_CALL(messenger,
924 ::testing::Eq<FlBinaryMessenger*>(messenger),
925 ::testing::StrEq(
"flutter/textinput"),
926 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
928 ::testing::_, ::testing::_, ::testing::_));
933 TEST(FlTextInputHandlerTest, ComposingDelta) {
934 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
935 ::testing::NiceMock<flutter::testing::MockIMContext> context;
936 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
938 g_autoptr(FlTextInputHandler) handler =
940 EXPECT_NE(handler,
nullptr);
945 .enable_delta_model =
true,
949 FL_METHOD_CODEC(codec),
"TextInput.setClient",
args,
nullptr);
953 ::testing::Eq<FlBinaryMessenger*>(messenger),
954 ::testing::A<FlBinaryMessengerResponseHandle*>(),
955 SuccessResponse(
null), ::testing::A<GError**>()))
956 .WillOnce(::testing::Return(
true));
958 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
960 g_signal_emit_by_name(context,
"preedit-start",
nullptr);
964 gtk_im_context_get_preedit_string(
965 ::testing::Eq<GtkIMContext*>(context),
966 ::testing::A<gchar**>(), ::testing::_, ::testing::A<gint*>()))
968 ::testing::DoAll(::testing::SetArgPointee<1>(g_strdup(
"Flutter ")),
969 ::testing::SetArgPointee<3>(8)));
978 .delta_text =
"Flutter ",
982 .selection_extent = 8,
984 .composing_extent = 8,
990 EXPECT_CALL(messenger,
992 ::testing::Eq<FlBinaryMessenger*>(messenger),
993 ::testing::StrEq(
"flutter/textinput"),
994 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
996 ::testing::_, ::testing::_, ::testing::_));
998 g_signal_emit_by_name(context,
"preedit-changed",
nullptr);
1007 .old_text =
"Flutter ",
1008 .delta_text =
"Flutter engine",
1011 .selection_base = 14,
1012 .selection_extent = 14,
1013 .composing_base = -1,
1014 .composing_extent = -1,
1020 EXPECT_CALL(messenger,
1022 ::testing::Eq<FlBinaryMessenger*>(messenger),
1023 ::testing::StrEq(
"flutter/textinput"),
1024 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1026 ::testing::_, ::testing::_, ::testing::_));
1028 g_signal_emit_by_name(context,
"commit",
"Flutter engine",
nullptr);
1037 .old_text =
"Flutter engine",
1038 .selection_base = 14,
1039 .selection_extent = 14,
1045 EXPECT_CALL(messenger,
1047 ::testing::Eq<FlBinaryMessenger*>(messenger),
1048 ::testing::StrEq(
"flutter/textinput"),
1049 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1051 ::testing::_, ::testing::_, ::testing::_));
1053 g_signal_emit_by_name(context,
"preedit-end",
nullptr);
1056 TEST(FlTextInputHandlerTest, NonComposingDelta) {
1057 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
1058 ::testing::NiceMock<flutter::testing::MockIMContext> context;
1059 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
1061 g_autoptr(FlTextInputHandler) handler =
1063 EXPECT_NE(handler,
nullptr);
1068 .enable_delta_model =
true,
1072 FL_METHOD_CODEC(codec),
"TextInput.setClient",
args,
nullptr);
1076 ::testing::Eq<FlBinaryMessenger*>(messenger),
1077 ::testing::A<FlBinaryMessengerResponseHandle*>(),
1078 SuccessResponse(
null), ::testing::A<GError**>()))
1079 .WillOnce(::testing::Return(
true));
1081 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
1094 .selection_base = 1,
1095 .selection_extent = 1,
1096 .composing_base = -1,
1097 .composing_extent = -1,
1103 EXPECT_CALL(messenger,
1105 ::testing::Eq<FlBinaryMessenger*>(messenger),
1106 ::testing::StrEq(
"flutter/textinput"),
1107 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1109 ::testing::_, ::testing::_, ::testing::_));
1111 g_signal_emit_by_name(context,
"commit",
"F",
nullptr);
1124 .selection_base = 2,
1125 .selection_extent = 2,
1126 .composing_base = -1,
1127 .composing_extent = -1,
1133 EXPECT_CALL(messenger,
1135 ::testing::Eq<FlBinaryMessenger*>(messenger),
1136 ::testing::StrEq(
"flutter/textinput"),
1137 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1138 FlValueEq(commitL)),
1139 ::testing::_, ::testing::_, ::testing::_));
1141 g_signal_emit_by_name(context,
"commit",
"l",
nullptr);
1154 .selection_base = 3,
1155 .selection_extent = 3,
1156 .composing_base = -1,
1157 .composing_extent = -1,
1163 EXPECT_CALL(messenger,
1165 ::testing::Eq<FlBinaryMessenger*>(messenger),
1166 ::testing::StrEq(
"flutter/textinput"),
1167 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1168 FlValueEq(commitU)),
1169 ::testing::_, ::testing::_, ::testing::_));
1171 g_signal_emit_by_name(context,
"commit",
"u",
nullptr);
1184 .selection_base = 4,
1185 .selection_extent = 4,
1186 .composing_base = -1,
1187 .composing_extent = -1,
1193 EXPECT_CALL(messenger,
1195 ::testing::Eq<FlBinaryMessenger*>(messenger),
1196 ::testing::StrEq(
"flutter/textinput"),
1197 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1198 FlValueEq(commitTa)),
1199 ::testing::_, ::testing::_, ::testing::_));
1201 g_signal_emit_by_name(context,
"commit",
"t",
nullptr);
1214 .selection_base = 5,
1215 .selection_extent = 5,
1216 .composing_base = -1,
1217 .composing_extent = -1,
1223 EXPECT_CALL(messenger,
1225 ::testing::Eq<FlBinaryMessenger*>(messenger),
1226 ::testing::StrEq(
"flutter/textinput"),
1227 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1228 FlValueEq(commitTb)),
1229 ::testing::_, ::testing::_, ::testing::_));
1231 g_signal_emit_by_name(context,
"commit",
"t",
nullptr);
1240 .old_text =
"Flutt",
1244 .selection_base = 6,
1245 .selection_extent = 6,
1246 .composing_base = -1,
1247 .composing_extent = -1,
1253 EXPECT_CALL(messenger,
1255 ::testing::Eq<FlBinaryMessenger*>(messenger),
1256 ::testing::StrEq(
"flutter/textinput"),
1257 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1258 FlValueEq(commitE)),
1259 ::testing::_, ::testing::_, ::testing::_));
1261 g_signal_emit_by_name(context,
"commit",
"e",
nullptr);
1270 .old_text =
"Flutte",
1274 .selection_base = 7,
1275 .selection_extent = 7,
1276 .composing_base = -1,
1277 .composing_extent = -1,
1283 EXPECT_CALL(messenger,
1285 ::testing::Eq<FlBinaryMessenger*>(messenger),
1286 ::testing::StrEq(
"flutter/textinput"),
1287 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1288 FlValueEq(commitR)),
1289 ::testing::_, ::testing::_, ::testing::_));
1291 g_signal_emit_by_name(context,
"commit",
"r",
nullptr);