diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java index d84bf6b65ff..bfe87a7e0fd 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java @@ -189,7 +189,7 @@ public class TextInputPluginTest { textInputPlugin.setTextInputEditingState( testView, new TextInputChannel.TextEditState("initial input from framework", 0, 0, -1, -1)); - assertTrue(textInputPlugin.getEditable().toString().equals("initial input from framework")); + assertEquals("initial input from framework", textInputPlugin.getEditable().toString()); verify(textInputChannel, times(0)) .updateEditingState(anyInt(), any(), anyInt(), anyInt(), anyInt(), anyInt()); @@ -198,7 +198,7 @@ public class TextInputPluginTest { testView, new TextInputChannel.TextEditState("more update from the framework", 1, 2, -1, -1)); - assertTrue(textInputPlugin.getEditable().toString().equals("more update from the framework")); + assertEquals("more update from the framework", textInputPlugin.getEditable().toString()); verify(textInputChannel, times(0)) .updateEditingState(anyInt(), any(), anyInt(), anyInt(), anyInt(), anyInt()); } @@ -223,7 +223,7 @@ public class TextInputPluginTest { // Here's no textInputPlugin.setTextInputClient() textInputPlugin.setTextInputEditingState( testView, new TextInputChannel.TextEditState("initial input from framework", 0, 0, -1, -1)); - assertTrue(textInputPlugin.getEditable().toString().equals("initial input from framework")); + assertEquals("initial input from framework", textInputPlugin.getEditable().toString()); } @Test @@ -262,8 +262,8 @@ public class TextInputPluginTest { textInputPlugin.setTextInputEditingState( testView, new TextInputChannel.TextEditState("receiving initial input from framework", 0, 0, -1, -1)); - assertTrue( - textInputPlugin.getEditable().toString().equals("receiving initial input from framework")); + assertEquals( + "receiving initial input from framework", textInputPlugin.getEditable().toString()); verify(textInputChannel, times(0)).updateEditingStateWithDeltas(anyInt(), any()); @@ -272,11 +272,8 @@ public class TextInputPluginTest { new TextInputChannel.TextEditState( "receiving more updates from the framework", 1, 2, -1, -1)); - assertTrue( - textInputPlugin - .getEditable() - .toString() - .equals("receiving more updates from the framework")); + assertEquals( + "receiving more updates from the framework", textInputPlugin.getEditable().toString()); verify(textInputChannel, times(0)).updateEditingStateWithDeltas(anyInt(), any()); } @@ -382,8 +379,8 @@ public class TextInputPluginTest { // updateEditingStateWithDeltas after the batch edit has completed and notified all listeners // of the editing state. inputConnection.setSelection(3, 4); - assertEquals(Selection.getSelectionStart(textInputPlugin.getEditable()), 3); - assertEquals(Selection.getSelectionEnd(textInputPlugin.getEditable()), 4); + assertEquals(3, Selection.getSelectionStart(textInputPlugin.getEditable())); + assertEquals(4, Selection.getSelectionEnd(textInputPlugin.getEditable())); verify(textInputChannel, times(0)).updateEditingStateWithDeltas(anyInt(), any()); verify(textInputChannel, times(1)) @@ -518,8 +515,8 @@ public class TextInputPluginTest { // updateEditingStateWithDeltas after the batch edit has completed and notified all listeners // of the editing state. inputConnection.setSelection(3, 4); - assertEquals(Selection.getSelectionStart(textInputPlugin.getEditable()), 3); - assertEquals(Selection.getSelectionEnd(textInputPlugin.getEditable()), 4); + assertEquals(3, Selection.getSelectionStart(textInputPlugin.getEditable())); + assertEquals(4, Selection.getSelectionEnd(textInputPlugin.getEditable())); verify(textInputChannel, times(1)).updateEditingStateWithDeltas(anyInt(), any()); verify(textInputChannel, times(0)) @@ -640,8 +637,8 @@ public class TextInputPluginTest { // updateEditingStateWithDeltas after the batch edit has completed and notified all listeners // of the editing state. inputConnection.setSelection(3, 4); - assertEquals(Selection.getSelectionStart(textInputPlugin.getEditable()), 3); - assertEquals(Selection.getSelectionEnd(textInputPlugin.getEditable()), 4); + assertEquals(3, Selection.getSelectionStart(textInputPlugin.getEditable())); + assertEquals(4, Selection.getSelectionEnd(textInputPlugin.getEditable())); verify(textInputChannel, times(1)).updateEditingStateWithDeltas(anyInt(), any()); @@ -757,8 +754,8 @@ public class TextInputPluginTest { // updateEditingStateWithDeltas after the batch edit has completed and notified all listeners // of the editing state. inputConnection.setSelection(3, 4); - assertEquals(Selection.getSelectionStart(textInputPlugin.getEditable()), 3); - assertEquals(Selection.getSelectionEnd(textInputPlugin.getEditable()), 4); + assertEquals(3, Selection.getSelectionStart(textInputPlugin.getEditable())); + assertEquals(4, Selection.getSelectionEnd(textInputPlugin.getEditable())); verify(textInputChannel, times(1)).updateEditingStateWithDeltas(anyInt(), any()); @@ -872,8 +869,8 @@ public class TextInputPluginTest { // updateEditingStateWithDeltas after the batch edit has completed and notified all listeners // of the editing state. inputConnection.setSelection(3, 4); - assertEquals(Selection.getSelectionStart(textInputPlugin.getEditable()), 3); - assertEquals(Selection.getSelectionEnd(textInputPlugin.getEditable()), 4); + assertEquals(3, Selection.getSelectionStart(textInputPlugin.getEditable())); + assertEquals(4, Selection.getSelectionEnd(textInputPlugin.getEditable())); verify(textInputChannel, times(1)).updateEditingStateWithDeltas(anyInt(), any()); @@ -963,8 +960,8 @@ public class TextInputPluginTest { .updateEditingState(anyInt(), any(), anyInt(), anyInt(), anyInt(), anyInt()); inputConnectionAdaptor.setSelection(3, 4); - assertEquals(Selection.getSelectionStart(textInputPlugin.getEditable()), 3); - assertEquals(Selection.getSelectionEnd(textInputPlugin.getEditable()), 4); + assertEquals(3, Selection.getSelectionStart(textInputPlugin.getEditable())); + assertEquals(4, Selection.getSelectionEnd(textInputPlugin.getEditable())); verify(textInputChannel, times(1)) .updateEditingState(anyInt(), any(), anyInt(), anyInt(), anyInt(), anyInt()); @@ -1067,18 +1064,18 @@ public class TextInputPluginTest { textInputPlugin.setTextInputEditingState( testView, new TextInputChannel.TextEditState("hello", 0, 0, -1, -1)); assertEquals(1, testImm.getRestartCount(testView)); - assertTrue(textInputPlugin.getEditable().toString().equals("hello")); + assertEquals("hello", textInputPlugin.getEditable().toString()); // No pending restart, set Editable contents anyways. textInputPlugin.setTextInputEditingState( testView, new TextInputChannel.TextEditState("Shibuyawoo", 0, 0, -1, -1)); assertEquals(1, testImm.getRestartCount(testView)); - assertTrue(textInputPlugin.getEditable().toString().equals("Shibuyawoo")); + assertEquals("Shibuyawoo", textInputPlugin.getEditable().toString()); } // See https://github.com/flutter/flutter/issues/29341 and // https://github.com/flutter/flutter/issues/31512 - // All modern Samsung keybords are affected including non-korean languages and thus + // All modern Samsung keyboards are affected including non-korean languages and thus // need the restart. // Update: many other keyboards need this too: // https://github.com/flutter/flutter/issues/78827 @@ -1561,7 +1558,7 @@ public class TextInputPluginTest { null)); textInputPlugin.showTextInput(testView); - assertEquals(testImm.isSoftInputVisible(), false); + assertFalse(testImm.isSoftInputVisible()); } @Test @@ -1600,7 +1597,7 @@ public class TextInputPluginTest { textInputPlugin.createInputConnection(testView, mock(KeyboardManager.class), editorInfo); assertEquals( - editorInfo.inputType, InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); + InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI, editorInfo.inputType); } @Test @@ -1639,8 +1636,8 @@ public class TextInputPluginTest { textInputPlugin.createInputConnection(testView, mock(KeyboardManager.class), editorInfo); assertEquals( - editorInfo.inputType, - InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); + InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS, + editorInfo.inputType); } @Test @@ -1679,11 +1676,11 @@ public class TextInputPluginTest { textInputPlugin.createInputConnection(testView, mock(KeyboardManager.class), editorInfo); assertEquals( - editorInfo.inputType, InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS - | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD, + editorInfo.inputType); } @Config(minSdk = API_LEVELS.API_34) @@ -1728,7 +1725,7 @@ public class TextInputPluginTest { @Config(sdk = API_LEVELS.API_32) @TargetApi(API_LEVELS.API_32) @Test - public void inputConnection_doesNotcallSetsStylusHandwritingAvailableWhenAPILevelUnsupported() { + public void inputConnection_doesNotCallSetsStylusHandwritingAvailableWhenAPILevelUnsupported() { View testView = new View(ctx); DartExecutor dartExecutor = mock(DartExecutor.class); TextInputChannel textInputChannel = new TextInputChannel(dartExecutor); @@ -2343,7 +2340,7 @@ public class TextInputPluginTest { textInputPlugin.autofill(autofillValues); // Verify the Editable has been updated. - assertTrue(textInputPlugin.getEditable().toString().equals("focused field")); + assertEquals("focused field", textInputPlugin.getEditable().toString()); // The autofill value of the focused field is sent via updateEditingState. verify(textInputChannel, times(1)) @@ -2355,7 +2352,7 @@ public class TextInputPluginTest { .updateEditingStateWithTag(anyInt(), mapCaptor.capture()); final TextInputChannel.TextEditState editState = (TextInputChannel.TextEditState) mapCaptor.getValue().get("2"); - assertEquals(editState.text, "unfocused field"); + assertEquals("unfocused field", editState.text); }); } } @@ -2418,7 +2415,7 @@ public class TextInputPluginTest { @Config(minSdk = API_LEVELS.API_26) @Test - public void autofill_testSetTextIpnutClientUpdatesSideFields() { + public void autofill_testSetTextInputClientUpdatesSideFields() { if (Build.VERSION.SDK_INT < API_LEVELS.API_26) { return; }