195 {
196 TextServicesManager fakeTextServicesManager = mock(TextServicesManager.class);
197 SpellCheckChannel fakeSpellCheckChannel = mock(SpellCheckChannel.class);
198 SpellCheckPlugin spellCheckPlugin =
199 spy(new SpellCheckPlugin(fakeTextServicesManager, fakeSpellCheckChannel));
200 MethodChannel.Result mockResult = mock(MethodChannel.Result.class);
201 spellCheckPlugin.pendingResult = mockResult;
202
203 spellCheckPlugin.onGetSentenceSuggestions(
204 new SentenceSuggestionsInfo[] {
205 new SentenceSuggestionsInfo(
206 (new SuggestionsInfo[] {
207 new SuggestionsInfo(
208 SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO,
209 new String[] {"world", "word", "old"})
210 }),
211 new int[] {7},
212 new int[] {5})
213 });
214
215 ArrayList<HashMap<String, Object>> expectedResults = new ArrayList<HashMap<String, Object>>();
216 HashMap<String, Object> expectedResult = new HashMap<String, Object>();
217
218 expectedResult.put(SpellCheckPlugin.START_INDEX_KEY, 7);
219 expectedResult.put(SpellCheckPlugin.END_INDEX_KEY, 12);
220 expectedResult.put(
221 SpellCheckPlugin.SUGGESTIONS_KEY,
222 new ArrayList<String>(Arrays.asList("world", "word", "old")));
223 expectedResults.add(expectedResult);
224
225 verify(mockResult).success(expectedResults);
226 }