1003 {
1006 OCMStub(
1007 [engineMock binaryMessenger])
1008 .andReturn(binaryMessengerMock);
1009
1011 nibName:@""
1012 bundle:nil];
1013
1016
1017 NSDictionary* setClientConfig = @{
1018 @"inputAction" : @"action",
1019 @"enableDeltaModel" : @"true",
1020 @"inputType" : @{@"name" : @"inputName"},
1021 };
1025 }];
1026 [plugin setMarkedText:@"m" selectedRange:NSMakeRange(0, 1)];
1027
1028 NSDictionary* deltaToFramework = @{
1029 @"oldText" : @"",
1030 @"deltaText" : @"m",
1031 @"deltaStart" : @(0),
1032 @"deltaEnd" : @(0),
1033 @"selectionBase" : @(0),
1034 @"selectionExtent" : @(1),
1035 @"selectionAffinity" : @"TextAffinity.upstream",
1036 @"selectionIsDirectional" : @(false),
1037 @"composingBase" : @(0),
1038 @"composingExtent" : @(1),
1039 };
1040 NSDictionary* expectedState = @{
1041 @"deltas" : @[ deltaToFramework ],
1042 };
1043
1048
1049 @try {
1050 OCMVerify(
1051 [binaryMessengerMock sendOnChannel:
@"flutter/textinput" message:updateCall]);
1052 } @catch (...) {
1053 return false;
1054 }
1055
1056 [plugin setMarkedText:@"ma" selectedRange:NSMakeRange(0, 1)];
1057
1058 deltaToFramework = @{
1059 @"oldText" : @"m",
1060 @"deltaText" : @"ma",
1061 @"deltaStart" : @(0),
1062 @"deltaEnd" : @(1),
1063 @"selectionBase" : @(0),
1064 @"selectionExtent" : @(1),
1065 @"selectionAffinity" : @"TextAffinity.upstream",
1066 @"selectionIsDirectional" : @(false),
1067 @"composingBase" : @(0),
1068 @"composingExtent" : @(2),
1069 };
1070 expectedState = @{
1071 @"deltas" : @[ deltaToFramework ],
1072 };
1073
1078
1079 @try {
1080 OCMVerify(
1081 [binaryMessengerMock sendOnChannel:
@"flutter/textinput" message:updateCall]);
1082 } @catch (...) {
1083 return false;
1084 }
1085
1086 [plugin setMarkedText:@"mar" selectedRange:NSMakeRange(0, 1)];
1087
1088 deltaToFramework = @{
1089 @"oldText" : @"ma",
1090 @"deltaText" : @"mar",
1091 @"deltaStart" : @(0),
1092 @"deltaEnd" : @(2),
1093 @"selectionBase" : @(0),
1094 @"selectionExtent" : @(1),
1095 @"selectionAffinity" : @"TextAffinity.upstream",
1096 @"selectionIsDirectional" : @(false),
1097 @"composingBase" : @(0),
1098 @"composingExtent" : @(3),
1099 };
1100 expectedState = @{
1101 @"deltas" : @[ deltaToFramework ],
1102 };
1103
1108
1109 @try {
1110 OCMVerify(
1111 [binaryMessengerMock sendOnChannel:
@"flutter/textinput" message:updateCall]);
1112 } @catch (...) {
1113 return false;
1114 }
1115
1116 [plugin setMarkedText:@"mark" selectedRange:NSMakeRange(0, 1)];
1117
1118 deltaToFramework = @{
1119 @"oldText" : @"mar",
1120 @"deltaText" : @"mark",
1121 @"deltaStart" : @(0),
1122 @"deltaEnd" : @(3),
1123 @"selectionBase" : @(0),
1124 @"selectionExtent" : @(1),
1125 @"selectionAffinity" : @"TextAffinity.upstream",
1126 @"selectionIsDirectional" : @(false),
1127 @"composingBase" : @(0),
1128 @"composingExtent" : @(4),
1129 };
1130 expectedState = @{
1131 @"deltas" : @[ deltaToFramework ],
1132 };
1133
1138
1139 @try {
1140 OCMVerify(
1141 [binaryMessengerMock sendOnChannel:
@"flutter/textinput" message:updateCall]);
1142 } @catch (...) {
1143 return false;
1144 }
1145
1146 [plugin setMarkedText:@"marke" selectedRange:NSMakeRange(0, 1)];
1147
1148 deltaToFramework = @{
1149 @"oldText" : @"mark",
1150 @"deltaText" : @"marke",
1151 @"deltaStart" : @(0),
1152 @"deltaEnd" : @(4),
1153 @"selectionBase" : @(0),
1154 @"selectionExtent" : @(1),
1155 @"selectionAffinity" : @"TextAffinity.upstream",
1156 @"selectionIsDirectional" : @(false),
1157 @"composingBase" : @(0),
1158 @"composingExtent" : @(5),
1159 };
1160 expectedState = @{
1161 @"deltas" : @[ deltaToFramework ],
1162 };
1163
1168
1169 @try {
1170 OCMVerify(
1171 [binaryMessengerMock sendOnChannel:
@"flutter/textinput" message:updateCall]);
1172 } @catch (...) {
1173 return false;
1174 }
1175
1176 [plugin setMarkedText:@"marked" selectedRange:NSMakeRange(0, 1)];
1177
1178 deltaToFramework = @{
1179 @"oldText" : @"marke",
1180 @"deltaText" : @"marked",
1181 @"deltaStart" : @(0),
1182 @"deltaEnd" : @(5),
1183 @"selectionBase" : @(0),
1184 @"selectionExtent" : @(1),
1185 @"selectionAffinity" : @"TextAffinity.upstream",
1186 @"selectionIsDirectional" : @(false),
1187 @"composingBase" : @(0),
1188 @"composingExtent" : @(6),
1189 };
1190 expectedState = @{
1191 @"deltas" : @[ deltaToFramework ],
1192 };
1193
1198
1199 @try {
1200 OCMVerify(
1201 [binaryMessengerMock sendOnChannel:
@"flutter/textinput" message:updateCall]);
1202 } @catch (...) {
1203 return false;
1204 }
1205
1207
1208 deltaToFramework = @{
1209 @"oldText" : @"marked",
1210 @"deltaText" : @"",
1211 @"deltaStart" : @(-1),
1212 @"deltaEnd" : @(-1),
1213 @"selectionBase" : @(6),
1214 @"selectionExtent" : @(6),
1215 @"selectionAffinity" : @"TextAffinity.upstream",
1216 @"selectionIsDirectional" : @(
false),
1217 @"composingBase" : @(-1),
1218 @"composingExtent" : @(-1),
1219 };
1220 expectedState = @{
1221 @"deltas" : @[ deltaToFramework ],
1222 };
1223
1228
1229 @try {
1230 OCMVerify(
1231 [binaryMessengerMock sendOnChannel:
@"flutter/textinput" message:updateCall]);
1232 } @catch (...) {
1233 return false;
1234 }
1235 return true;
1236}
instancetype sharedInstance()