Simplify/fix ordering of asserts in TextInputPluginTest (#175784)

<img width="477" height="60" alt="04"
src="https://github.com/user-attachments/assets/25569784-aec9-472d-9d3c-93e8dee6e57d"
/>

<img width="367" height="49" alt="05"
src="https://github.com/user-attachments/assets/087f9f1b-da45-457e-82df-b5716b8f133d"
/>
and some small typos
## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

Co-authored-by: Reid Baker <1063596+reidbaker@users.noreply.github.com>
This commit is contained in:
Mohellebi abdessalem 2025-09-24 16:54:05 +01:00 committed by GitHub
parent 8dd9ff1b59
commit 439a80965a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
}