|
18 | 18 |
|
19 | 19 | import android.annotation.TargetApi; |
20 | 20 | import android.content.Context; |
21 | | -import android.content.pm.PackageInfo; |
22 | 21 | import android.content.res.AssetManager; |
23 | 22 | import android.graphics.Insets; |
24 | 23 | import android.graphics.Rect; |
|
67 | 66 | import org.mockito.Mock; |
68 | 67 | import org.robolectric.RobolectricTestRunner; |
69 | 68 | import org.robolectric.RuntimeEnvironment; |
70 | | -import org.robolectric.Shadows; |
71 | 69 | import org.robolectric.annotation.Config; |
72 | 70 | import org.robolectric.annotation.Implementation; |
73 | 71 | import org.robolectric.annotation.Implements; |
74 | 72 | import org.robolectric.shadow.api.Shadow; |
75 | 73 | import org.robolectric.shadows.ShadowAutofillManager; |
76 | 74 | import org.robolectric.shadows.ShadowBuild; |
77 | 75 | import org.robolectric.shadows.ShadowInputMethodManager; |
78 | | -import org.robolectric.shadows.ShadowPackageManager; |
79 | 76 |
|
80 | 77 | @Config( |
81 | 78 | manifest = Config.NONE, |
@@ -344,21 +341,14 @@ public void setTextInputEditingState_alwaysSetEditableWhenDifferent() { |
344 | 341 | assertTrue(textInputPlugin.getEditable().toString().equals("Shibuyawoo")); |
345 | 342 | } |
346 | 343 |
|
347 | | - // See also: https://github.com/flutter/flutter/issues/29341 and |
348 | | - // https://github.com/flutter/flutter/issues/31512. |
349 | | - // Some recent versions of Samsung keybords are affected including non-korean |
350 | | - // languages and thus needed the restart. |
| 344 | + // See https://github.com/flutter/flutter/issues/29341 and |
| 345 | + // https://github.com/flutter/flutter/issues/31512 |
| 346 | + // All modern Samsung keybords are affected including non-korean languages and thus |
| 347 | + // need the restart. |
351 | 348 | @Test |
352 | | - public void setTextInputEditingState_alwaysRestartsOnAffectedDevices() { |
353 | | - // Initialize a TextInputPlugin with a Samsung keypad. |
| 349 | + public void setTextInputEditingState_alwaysRestartsOnAffectedDevices2() { |
| 350 | + // Initialize a TextInputPlugin that needs to be always restarted. |
354 | 351 | ShadowBuild.setManufacturer("samsung"); |
355 | | - final ShadowPackageManager packageManager = |
356 | | - Shadows.shadowOf( |
357 | | - RuntimeEnvironment.application.getApplicationContext().getPackageManager()); |
358 | | - final PackageInfo info = new PackageInfo(); |
359 | | - info.packageName = "com.sec.android.inputmethod"; |
360 | | - info.versionCode = 200000000; |
361 | | - packageManager.addPackage(info); |
362 | 352 | InputMethodSubtype inputMethodSubtype = |
363 | 353 | new InputMethodSubtype(0, 0, /*locale=*/ "en", "", "", false, false); |
364 | 354 | Settings.Secure.putString( |
@@ -398,59 +388,6 @@ public void setTextInputEditingState_alwaysRestartsOnAffectedDevices() { |
398 | 388 | assertEquals(2, testImm.getRestartCount(testView)); |
399 | 389 | } |
400 | 390 |
|
401 | | - // Regression test for https://github.com/flutter/flutter/issues/73433. |
402 | | - // The restart workaround seems to have caused #73433 and it's no longer |
403 | | - // needed on newer versions of Samsung keyboard. |
404 | | - @Test |
405 | | - public void setTextInputEditingState_DontForceRestartOnNewSamsungKeyboard() { |
406 | | - // Initialize a TextInputPlugin with a Samsung keypad. |
407 | | - ShadowBuild.setManufacturer("samsung"); |
408 | | - final ShadowPackageManager packageManager = |
409 | | - Shadows.shadowOf( |
410 | | - RuntimeEnvironment.application.getApplicationContext().getPackageManager()); |
411 | | - final PackageInfo info = new PackageInfo(); |
412 | | - info.packageName = "com.sec.android.inputmethod"; |
413 | | - info.versionCode = 333183070; |
414 | | - packageManager.addPackage(info); |
415 | | - InputMethodSubtype inputMethodSubtype = |
416 | | - new InputMethodSubtype(0, 0, /*locale=*/ "en", "", "", false, false); |
417 | | - Settings.Secure.putString( |
418 | | - RuntimeEnvironment.application.getContentResolver(), |
419 | | - Settings.Secure.DEFAULT_INPUT_METHOD, |
420 | | - "com.sec.android.inputmethod/.SamsungKeypad"); |
421 | | - TestImm testImm = |
422 | | - Shadow.extract( |
423 | | - RuntimeEnvironment.application.getSystemService(Context.INPUT_METHOD_SERVICE)); |
424 | | - testImm.setCurrentInputMethodSubtype(inputMethodSubtype); |
425 | | - View testView = new View(RuntimeEnvironment.application); |
426 | | - TextInputChannel textInputChannel = new TextInputChannel(mock(DartExecutor.class)); |
427 | | - TextInputPlugin textInputPlugin = |
428 | | - new TextInputPlugin(testView, textInputChannel, mock(PlatformViewsController.class)); |
429 | | - textInputPlugin.setTextInputClient( |
430 | | - 0, |
431 | | - new TextInputChannel.Configuration( |
432 | | - false, |
433 | | - false, |
434 | | - true, |
435 | | - TextInputChannel.TextCapitalization.NONE, |
436 | | - null, |
437 | | - null, |
438 | | - null, |
439 | | - null, |
440 | | - null)); |
441 | | - // There's a pending restart since we initialized the text input client. Flush that now. |
442 | | - textInputPlugin.setTextInputEditingState( |
443 | | - testView, new TextInputChannel.TextEditState("", 0, 0, -1, -1)); |
444 | | - |
445 | | - // Move the cursor. |
446 | | - assertEquals(1, testImm.getRestartCount(testView)); |
447 | | - textInputPlugin.setTextInputEditingState( |
448 | | - testView, new TextInputChannel.TextEditState("", 0, 0, -1, -1)); |
449 | | - |
450 | | - // Verify that we've NOT restarted the input. |
451 | | - assertEquals(1, testImm.getRestartCount(testView)); |
452 | | - } |
453 | | - |
454 | 391 | @Test |
455 | 392 | public void setTextInputEditingState_doesNotRestartOnUnaffectedDevices() { |
456 | 393 | // Initialize a TextInputPlugin that needs to be always restarted. |
@@ -490,7 +427,7 @@ public void setTextInputEditingState_doesNotRestartOnUnaffectedDevices() { |
490 | 427 | textInputPlugin.setTextInputEditingState( |
491 | 428 | testView, new TextInputChannel.TextEditState("", 0, 0, -1, -1)); |
492 | 429 |
|
493 | | - // Verify that we've NOT restarted the input. |
| 430 | + // Verify that we've restarted the input. |
494 | 431 | assertEquals(1, testImm.getRestartCount(testView)); |
495 | 432 | } |
496 | 433 |
|
|
0 commit comments