2525import android .view .View ;
2626import android .view .inputmethod .EditorInfo ;
2727import android .view .inputmethod .ExtractedText ;
28+ import io .flutter .embedding .android .AndroidKeyProcessor ;
2829import io .flutter .embedding .engine .FlutterJNI ;
2930import io .flutter .embedding .engine .dart .DartExecutor ;
3031import io .flutter .embedding .engine .systemchannels .TextInputChannel ;
@@ -68,14 +69,15 @@ public void inputConnectionAdaptor_ReceivesEnter() throws NullPointerException {
6869 DartExecutor dartExecutor = spy (new DartExecutor (mockFlutterJni , mock (AssetManager .class )));
6970 int inputTargetId = 0 ;
7071 TextInputChannel textInputChannel = new TextInputChannel (dartExecutor );
72+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
7173 Editable mEditable = Editable .Factory .getInstance ().newEditable ("" );
7274 Editable spyEditable = spy (mEditable );
7375 EditorInfo outAttrs = new EditorInfo ();
7476 outAttrs .inputType = InputType .TYPE_CLASS_TEXT | InputType .TYPE_TEXT_FLAG_MULTI_LINE ;
7577
7678 InputConnectionAdaptor inputConnectionAdaptor =
7779 new InputConnectionAdaptor (
78- testView , inputTargetId , textInputChannel , spyEditable , outAttrs );
80+ testView , inputTargetId , textInputChannel , mockKeyProcessor , spyEditable , outAttrs );
7981
8082 // Send an enter key and make sure the Editable received it.
8183 FakeKeyEvent keyEvent = new FakeKeyEvent (KeyEvent .ACTION_DOWN , KeyEvent .KEYCODE_ENTER );
@@ -156,10 +158,11 @@ public void testPerformPrivateCommand_dataIsNull() throws JSONException {
156158 FlutterJNI mockFlutterJNI = mock (FlutterJNI .class );
157159 DartExecutor dartExecutor = spy (new DartExecutor (mockFlutterJNI , mock (AssetManager .class )));
158160 TextInputChannel textInputChannel = new TextInputChannel (dartExecutor );
161+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
159162 Editable editable = sampleEditable (0 , 0 );
160163 InputConnectionAdaptor adaptor =
161164 new InputConnectionAdaptor (
162- testView , client , textInputChannel , editable , null , mockFlutterJNI );
165+ testView , client , textInputChannel , mockKeyProcessor , editable , null , mockFlutterJNI );
163166 adaptor .performPrivateCommand ("actionCommand" , null );
164167
165168 ArgumentCaptor <String > channelCaptor = ArgumentCaptor .forClass (String .class );
@@ -183,10 +186,11 @@ public void testPerformPrivateCommand_dataIsByteArray() throws JSONException {
183186 FlutterJNI mockFlutterJNI = mock (FlutterJNI .class );
184187 DartExecutor dartExecutor = spy (new DartExecutor (mockFlutterJNI , mock (AssetManager .class )));
185188 TextInputChannel textInputChannel = new TextInputChannel (dartExecutor );
189+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
186190 Editable editable = sampleEditable (0 , 0 );
187191 InputConnectionAdaptor adaptor =
188192 new InputConnectionAdaptor (
189- testView , client , textInputChannel , editable , null , mockFlutterJNI );
193+ testView , client , textInputChannel , mockKeyProcessor , editable , null , mockFlutterJNI );
190194
191195 Bundle bundle = new Bundle ();
192196 byte [] buffer = new byte [] {'a' , 'b' , 'c' , 'd' };
@@ -216,10 +220,11 @@ public void testPerformPrivateCommand_dataIsByte() throws JSONException {
216220 FlutterJNI mockFlutterJNI = mock (FlutterJNI .class );
217221 DartExecutor dartExecutor = spy (new DartExecutor (mockFlutterJNI , mock (AssetManager .class )));
218222 TextInputChannel textInputChannel = new TextInputChannel (dartExecutor );
223+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
219224 Editable editable = sampleEditable (0 , 0 );
220225 InputConnectionAdaptor adaptor =
221226 new InputConnectionAdaptor (
222- testView , client , textInputChannel , editable , null , mockFlutterJNI );
227+ testView , client , textInputChannel , mockKeyProcessor , editable , null , mockFlutterJNI );
223228
224229 Bundle bundle = new Bundle ();
225230 byte b = 3 ;
@@ -247,10 +252,11 @@ public void testPerformPrivateCommand_dataIsCharArray() throws JSONException {
247252 FlutterJNI mockFlutterJNI = mock (FlutterJNI .class );
248253 DartExecutor dartExecutor = spy (new DartExecutor (mockFlutterJNI , mock (AssetManager .class )));
249254 TextInputChannel textInputChannel = new TextInputChannel (dartExecutor );
255+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
250256 Editable editable = sampleEditable (0 , 0 );
251257 InputConnectionAdaptor adaptor =
252258 new InputConnectionAdaptor (
253- testView , client , textInputChannel , editable , null , mockFlutterJNI );
259+ testView , client , textInputChannel , mockKeyProcessor , editable , null , mockFlutterJNI );
254260
255261 Bundle bundle = new Bundle ();
256262 char [] buffer = new char [] {'a' , 'b' , 'c' , 'd' };
@@ -281,10 +287,11 @@ public void testPerformPrivateCommand_dataIsChar() throws JSONException {
281287 FlutterJNI mockFlutterJNI = mock (FlutterJNI .class );
282288 DartExecutor dartExecutor = spy (new DartExecutor (mockFlutterJNI , mock (AssetManager .class )));
283289 TextInputChannel textInputChannel = new TextInputChannel (dartExecutor );
290+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
284291 Editable editable = sampleEditable (0 , 0 );
285292 InputConnectionAdaptor adaptor =
286293 new InputConnectionAdaptor (
287- testView , client , textInputChannel , editable , null , mockFlutterJNI );
294+ testView , client , textInputChannel , mockKeyProcessor , editable , null , mockFlutterJNI );
288295
289296 Bundle bundle = new Bundle ();
290297 char b = 'a' ;
@@ -312,10 +319,11 @@ public void testPerformPrivateCommand_dataIsCharSequenceArray() throws JSONExcep
312319 FlutterJNI mockFlutterJNI = mock (FlutterJNI .class );
313320 DartExecutor dartExecutor = spy (new DartExecutor (mockFlutterJNI , mock (AssetManager .class )));
314321 TextInputChannel textInputChannel = new TextInputChannel (dartExecutor );
322+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
315323 Editable editable = sampleEditable (0 , 0 );
316324 InputConnectionAdaptor adaptor =
317325 new InputConnectionAdaptor (
318- testView , client , textInputChannel , editable , null , mockFlutterJNI );
326+ testView , client , textInputChannel , mockKeyProcessor , editable , null , mockFlutterJNI );
319327
320328 Bundle bundle = new Bundle ();
321329 CharSequence charSequence1 = new StringBuffer ("abc" );
@@ -347,10 +355,11 @@ public void testPerformPrivateCommand_dataIsCharSequence() throws JSONException
347355 FlutterJNI mockFlutterJNI = mock (FlutterJNI .class );
348356 DartExecutor dartExecutor = spy (new DartExecutor (mockFlutterJNI , mock (AssetManager .class )));
349357 TextInputChannel textInputChannel = new TextInputChannel (dartExecutor );
358+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
350359 Editable editable = sampleEditable (0 , 0 );
351360 InputConnectionAdaptor adaptor =
352361 new InputConnectionAdaptor (
353- testView , client , textInputChannel , editable , null , mockFlutterJNI );
362+ testView , client , textInputChannel , mockKeyProcessor , editable , null , mockFlutterJNI );
354363
355364 Bundle bundle = new Bundle ();
356365 CharSequence charSequence = new StringBuffer ("abc" );
@@ -380,10 +389,11 @@ public void testPerformPrivateCommand_dataIsFloat() throws JSONException {
380389 FlutterJNI mockFlutterJNI = mock (FlutterJNI .class );
381390 DartExecutor dartExecutor = spy (new DartExecutor (mockFlutterJNI , mock (AssetManager .class )));
382391 TextInputChannel textInputChannel = new TextInputChannel (dartExecutor );
392+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
383393 Editable editable = sampleEditable (0 , 0 );
384394 InputConnectionAdaptor adaptor =
385395 new InputConnectionAdaptor (
386- testView , client , textInputChannel , editable , null , mockFlutterJNI );
396+ testView , client , textInputChannel , mockKeyProcessor , editable , null , mockFlutterJNI );
387397
388398 Bundle bundle = new Bundle ();
389399 float value = 0.5f ;
@@ -411,10 +421,11 @@ public void testPerformPrivateCommand_dataIsFloatArray() throws JSONException {
411421 FlutterJNI mockFlutterJNI = mock (FlutterJNI .class );
412422 DartExecutor dartExecutor = spy (new DartExecutor (mockFlutterJNI , mock (AssetManager .class )));
413423 TextInputChannel textInputChannel = new TextInputChannel (dartExecutor );
424+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
414425 Editable editable = sampleEditable (0 , 0 );
415426 InputConnectionAdaptor adaptor =
416427 new InputConnectionAdaptor (
417- testView , client , textInputChannel , editable , null , mockFlutterJNI );
428+ testView , client , textInputChannel , mockKeyProcessor , editable , null , mockFlutterJNI );
418429
419430 Bundle bundle = new Bundle ();
420431 float [] value = {0.5f , 0.6f };
@@ -907,14 +918,15 @@ public void inputConnectionAdaptor_RepeatFilter() throws NullPointerException {
907918 DartExecutor dartExecutor = spy (new DartExecutor (mockFlutterJni , mock (AssetManager .class )));
908919 int inputTargetId = 0 ;
909920 TestTextInputChannel textInputChannel = new TestTextInputChannel (dartExecutor );
921+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
910922 Editable mEditable = Editable .Factory .getInstance ().newEditable ("" );
911923 Editable spyEditable = spy (mEditable );
912924 EditorInfo outAttrs = new EditorInfo ();
913925 outAttrs .inputType = InputType .TYPE_CLASS_TEXT | InputType .TYPE_TEXT_FLAG_MULTI_LINE ;
914926
915927 InputConnectionAdaptor inputConnectionAdaptor =
916928 new InputConnectionAdaptor (
917- testView , inputTargetId , textInputChannel , spyEditable , outAttrs );
929+ testView , inputTargetId , textInputChannel , mockKeyProcessor , spyEditable , outAttrs );
918930
919931 inputConnectionAdaptor .beginBatchEdit ();
920932 assertEquals (textInputChannel .updateEditingStateInvocations , 0 );
@@ -1159,6 +1171,7 @@ private static InputConnectionAdaptor sampleInputConnectionAdaptor(Editable edit
11591171 int client = 0 ;
11601172 TextInputChannel textInputChannel = mock (TextInputChannel .class );
11611173 FlutterJNI mockFlutterJNI = mock (FlutterJNI .class );
1174+ AndroidKeyProcessor mockKeyProcessor = mock (AndroidKeyProcessor .class );
11621175 when (mockFlutterJNI .nativeFlutterTextUtilsIsEmoji (anyInt ()))
11631176 .thenAnswer ((invocation ) -> Emoji .isEmoji ((int ) invocation .getArguments ()[0 ]));
11641177 when (mockFlutterJNI .nativeFlutterTextUtilsIsEmojiModifier (anyInt ()))
@@ -1175,7 +1188,7 @@ private static InputConnectionAdaptor sampleInputConnectionAdaptor(Editable edit
11751188 .thenAnswer (
11761189 (invocation ) -> Emoji .isRegionalIndicatorSymbol ((int ) invocation .getArguments ()[0 ]));
11771190 return new InputConnectionAdaptor (
1178- testView , client , textInputChannel , editable , null , mockFlutterJNI );
1191+ testView , client , textInputChannel , mockKeyProcessor , editable , null , mockFlutterJNI );
11791192 }
11801193
11811194 private class TestTextInputChannel extends TextInputChannel {
0 commit comments