1057 {
1058 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
1059 ::testing::NiceMock<flutter::testing::MockIMContext> context;
1060 ::testing::NiceMock<flutter::testing::MockTextInputViewDelegate> delegate;
1061
1062 g_autoptr(FlTextInputPlugin) plugin =
1064 EXPECT_NE(plugin, nullptr);
1065
1066
1068 .client_id = 1,
1069 .enable_delta_model = true,
1070 });
1073 FL_METHOD_CODEC(codec),
"TextInput.setClient",
args,
nullptr);
1074
1077 ::testing::Eq<FlBinaryMessenger*>(messenger),
1078 ::testing::A<FlBinaryMessengerResponseHandle*>(),
1079 SuccessResponse(null), ::testing::A<GError**>()))
1080 .WillOnce(::testing::Return(true));
1081
1082 messenger.ReceiveMessage(
"flutter/textinput",
set_client);
1083
1084
1088 "deltas",
1091 .old_text = "",
1092 .delta_text = "F",
1093 .delta_start = 0,
1094 .delta_end = 0,
1095 .selection_base = 1,
1096 .selection_extent = 1,
1097 .composing_base = -1,
1098 .composing_extent = -1,
1099 }),
1100 }),
1101 }}),
1102 });
1103
1104 EXPECT_CALL(messenger,
1106 ::testing::Eq<FlBinaryMessenger*>(messenger),
1107 ::testing::StrEq("flutter/textinput"),
1108 MethodCall(
"TextInputClient.updateEditingStateWithDeltas",
1109 FlValueEq(commit)),
1110 ::testing::_, ::testing::_, ::testing::_));
1111
1112 g_signal_emit_by_name(context, "commit", "F", nullptr);
1113
1114
1118 "deltas",
1121 .old_text = "F",
1122 .delta_text = "l",
1123 .delta_start = 1,
1124 .delta_end = 1,
1125 .selection_base = 2,
1126 .selection_extent = 2,
1127 .composing_base = -1,
1128 .composing_extent = -1,
1129 }),
1130 }),
1131 }}),
1132 });
1133
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::_));
1141
1142 g_signal_emit_by_name(context, "commit", "l", nullptr);
1143
1144
1148 "deltas",
1151 .old_text = "Fl",
1152 .delta_text = "u",
1153 .delta_start = 2,
1154 .delta_end = 2,
1155 .selection_base = 3,
1156 .selection_extent = 3,
1157 .composing_base = -1,
1158 .composing_extent = -1,
1159 }),
1160 }),
1161 }}),
1162 });
1163
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::_));
1171
1172 g_signal_emit_by_name(context, "commit", "u", nullptr);
1173
1174
1178 "deltas",
1181 .old_text = "Flu",
1182 .delta_text = "t",
1183 .delta_start = 3,
1184 .delta_end = 3,
1185 .selection_base = 4,
1186 .selection_extent = 4,
1187 .composing_base = -1,
1188 .composing_extent = -1,
1189 }),
1190 }),
1191 }}),
1192 });
1193
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::_));
1201
1202 g_signal_emit_by_name(context, "commit", "t", nullptr);
1203
1204
1208 "deltas",
1211 .old_text = "Flut",
1212 .delta_text = "t",
1213 .delta_start = 4,
1214 .delta_end = 4,
1215 .selection_base = 5,
1216 .selection_extent = 5,
1217 .composing_base = -1,
1218 .composing_extent = -1,
1219 }),
1220 }),
1221 }}),
1222 });
1223
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::_));
1231
1232 g_signal_emit_by_name(context, "commit", "t", nullptr);
1233
1234
1238 "deltas",
1241 .old_text = "Flutt",
1242 .delta_text = "e",
1243 .delta_start = 5,
1244 .delta_end = 5,
1245 .selection_base = 6,
1246 .selection_extent = 6,
1247 .composing_base = -1,
1248 .composing_extent = -1,
1249 }),
1250 }),
1251 }}),
1252 });
1253
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::_));
1261
1262 g_signal_emit_by_name(context, "commit", "e", nullptr);
1263
1264
1268 "deltas",
1271 .old_text = "Flutte",
1272 .delta_text = "r",
1273 .delta_start = 6,
1274 .delta_end = 6,
1275 .selection_base = 7,
1276 .selection_extent = 7,
1277 .composing_base = -1,
1278 .composing_extent = -1,
1279 }),
1280 }),
1281 }}),
1282 });
1283
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::_));
1291
1292 g_signal_emit_by_name(context, "commit", "r", nullptr);
1293}