This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
io/flutter/plugin/editing
test/io/flutter/plugin/editing Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,11 @@ public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
132132 ArrayList <HashMap <String , Object >> spellCheckerSuggestionSpans =
133133 new ArrayList <HashMap <String , Object >>();
134134 SentenceSuggestionsInfo spellCheckResults = results [0 ];
135+ if (spellCheckResults == null ) {
136+ pendingResult .success (new ArrayList <HashMap <String , Object >>());
137+ pendingResult = null ;
138+ return ;
139+ }
135140
136141 for (int i = 0 ; i < spellCheckResults .getSuggestionsCount (); i ++) {
137142 SuggestionsInfo suggestionsInfo = spellCheckResults .getSuggestionsInfoAt (i );
Original file line number Diff line number Diff line change @@ -247,4 +247,22 @@ public void onGetSentenceSuggestionsResultsWithSuccessAndNoResultsWhenSuggestion
247247
248248 verify (mockResult ).success (new ArrayList <HashMap <String , Object >>());
249249 }
250+
251+ @ Test
252+ public void onGetSentenceSuggestionsResultsWithSuccessAndNoResultsWhenSuggestionsAreInvalid2 () {
253+ TextServicesManager fakeTextServicesManager = mock (TextServicesManager .class );
254+ SpellCheckChannel fakeSpellCheckChannel = mock (SpellCheckChannel .class );
255+ SpellCheckPlugin spellCheckPlugin =
256+ spy (new SpellCheckPlugin (fakeTextServicesManager , fakeSpellCheckChannel ));
257+ MethodChannel .Result mockResult = mock (MethodChannel .Result .class );
258+ spellCheckPlugin .pendingResult = mockResult ;
259+
260+ spellCheckPlugin .onGetSentenceSuggestions (
261+ new SentenceSuggestionsInfo [] {
262+ // This "suggestion" may be provided by the Samsung spell checker:
263+ null
264+ });
265+
266+ verify (mockResult ).success (new ArrayList <HashMap <String , Object >>());
267+ }
250268}
You can’t perform that action at this time.
0 commit comments