@@ -1130,150 +1130,6 @@ public void setTextInputEditingState_nullInputMethodSubtype() {
11301130 assertEquals (1 , testImm .getRestartCount (testView ));
11311131 }
11321132
1133- @ Test
1134- public void clearTextInputClient_restartsImmWhenInputActionIsNull () {
1135- // Initialize a general TextInputPlugin.
1136- InputMethodSubtype inputMethodSubtype = mock (InputMethodSubtype .class );
1137- TestImm testImm = Shadow .extract (ctx .getSystemService (Context .INPUT_METHOD_SERVICE ));
1138- testImm .setCurrentInputMethodSubtype (inputMethodSubtype );
1139- View testView = new View (ctx );
1140- TextInputChannel textInputChannel = new TextInputChannel (mock (DartExecutor .class ));
1141- TextInputPlugin textInputPlugin =
1142- new TextInputPlugin (testView , textInputChannel , mock (PlatformViewsController .class ));
1143- textInputPlugin .setTextInputClient (
1144- 0 ,
1145- new TextInputChannel .Configuration (
1146- false ,
1147- false ,
1148- true ,
1149- true ,
1150- false ,
1151- TextInputChannel .TextCapitalization .NONE ,
1152- null ,
1153- null ,
1154- null ,
1155- null ,
1156- null ,
1157- null ));
1158- // There's a pending restart since we initialized the text input client. Flush that now.
1159- textInputPlugin .setTextInputEditingState (
1160- testView , new TextInputChannel .TextEditState ("" , 0 , 0 , -1 , -1 ));
1161- assertEquals (1 , testImm .getRestartCount (testView ));
1162-
1163- // A restart is always forced when calling clearTextInputClient().
1164- textInputPlugin .clearTextInputClient ();
1165- assertEquals (2 , testImm .getRestartCount (testView ));
1166- }
1167-
1168- @ Test
1169- public void clearTextInputClient_restartsImmWhenInputActionIsDone () {
1170- // Initialize a general TextInputPlugin.
1171- InputMethodSubtype inputMethodSubtype = mock (InputMethodSubtype .class );
1172- TestImm testImm = Shadow .extract (ctx .getSystemService (Context .INPUT_METHOD_SERVICE ));
1173- testImm .setCurrentInputMethodSubtype (inputMethodSubtype );
1174- View testView = new View (ctx );
1175- TextInputChannel textInputChannel = new TextInputChannel (mock (DartExecutor .class ));
1176- TextInputPlugin textInputPlugin =
1177- new TextInputPlugin (testView , textInputChannel , mock (PlatformViewsController .class ));
1178- textInputPlugin .setTextInputClient (
1179- 0 ,
1180- new TextInputChannel .Configuration (
1181- false ,
1182- false ,
1183- true ,
1184- true ,
1185- false ,
1186- TextInputChannel .TextCapitalization .NONE ,
1187- null ,
1188- EditorInfo .IME_ACTION_DONE ,
1189- null ,
1190- null ,
1191- null ,
1192- null ));
1193- // There's a pending restart since we initialized the text input client. Flush that now.
1194- textInputPlugin .setTextInputEditingState (
1195- testView , new TextInputChannel .TextEditState ("" , 0 , 0 , -1 , -1 ));
1196- assertEquals (1 , testImm .getRestartCount (testView ));
1197-
1198- // A restart should be forced when calling clearTextInputClient() and input action is
1199- // EditorInfo.IME_ACTION_DONE.
1200- textInputPlugin .clearTextInputClient ();
1201- assertEquals (2 , testImm .getRestartCount (testView ));
1202- }
1203-
1204- @ Test
1205- public void clearTextInputClient_restartsImmWhenInputActionIsNone () {
1206- // Initialize a general TextInputPlugin.
1207- InputMethodSubtype inputMethodSubtype = mock (InputMethodSubtype .class );
1208- TestImm testImm = Shadow .extract (ctx .getSystemService (Context .INPUT_METHOD_SERVICE ));
1209- testImm .setCurrentInputMethodSubtype (inputMethodSubtype );
1210- View testView = new View (ctx );
1211- TextInputChannel textInputChannel = new TextInputChannel (mock (DartExecutor .class ));
1212- TextInputPlugin textInputPlugin =
1213- new TextInputPlugin (testView , textInputChannel , mock (PlatformViewsController .class ));
1214- textInputPlugin .setTextInputClient (
1215- 0 ,
1216- new TextInputChannel .Configuration (
1217- false ,
1218- false ,
1219- true ,
1220- true ,
1221- false ,
1222- TextInputChannel .TextCapitalization .NONE ,
1223- null ,
1224- EditorInfo .IME_ACTION_NONE ,
1225- null ,
1226- null ,
1227- null ,
1228- null ));
1229- // There's a pending restart since we initialized the text input client. Flush that now.
1230- textInputPlugin .setTextInputEditingState (
1231- testView , new TextInputChannel .TextEditState ("" , 0 , 0 , -1 , -1 ));
1232- assertEquals (1 , testImm .getRestartCount (testView ));
1233-
1234- // A restart should be forced when calling clearTextInputClient() and input action is
1235- // EditorInfo.IME_ACTION_NONE.
1236- textInputPlugin .clearTextInputClient ();
1237- assertEquals (2 , testImm .getRestartCount (testView ));
1238- }
1239-
1240- @ Test
1241- public void clearTextInputClient_doesNotRestartImmWhenInputActionIsNext () {
1242- // Regression test for https://github.com/flutter/flutter/issues/148673.
1243- // Initialize a general TextInputPlugin.
1244- InputMethodSubtype inputMethodSubtype = mock (InputMethodSubtype .class );
1245- TestImm testImm = Shadow .extract (ctx .getSystemService (Context .INPUT_METHOD_SERVICE ));
1246- testImm .setCurrentInputMethodSubtype (inputMethodSubtype );
1247- View testView = new View (ctx );
1248- TextInputChannel textInputChannel = new TextInputChannel (mock (DartExecutor .class ));
1249- TextInputPlugin textInputPlugin =
1250- new TextInputPlugin (testView , textInputChannel , mock (PlatformViewsController .class ));
1251- textInputPlugin .setTextInputClient (
1252- 0 ,
1253- new TextInputChannel .Configuration (
1254- false ,
1255- false ,
1256- true ,
1257- true ,
1258- false ,
1259- TextInputChannel .TextCapitalization .NONE ,
1260- null ,
1261- EditorInfo .IME_ACTION_NEXT ,
1262- null ,
1263- null ,
1264- null ,
1265- null ));
1266- // There's a pending restart since we initialized the text input client. Flush that now.
1267- textInputPlugin .setTextInputEditingState (
1268- testView , new TextInputChannel .TextEditState ("" , 0 , 0 , -1 , -1 ));
1269- assertEquals (1 , testImm .getRestartCount (testView ));
1270-
1271- // No restart is forced when calling clearTextInputClient() and input action is
1272- // EditorInfo.IME_ACTION_NEXT.
1273- textInputPlugin .clearTextInputClient ();
1274- assertEquals (1 , testImm .getRestartCount (testView ));
1275- }
1276-
12771133 @ Test
12781134 public void destroy_clearTextInputMethodHandler () {
12791135 View testView = new View (ctx );
0 commit comments