AndroidSpellCheckerServiceTest.java revision b4598f7d05d6afd01ddc7ea0bed71dda837d1deb
1/* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17package com.android.inputmethod.latin.spellcheck; 18 19import android.test.suitebuilder.annotation.LargeTest; 20import android.text.style.SuggestionSpan; 21 22import com.android.inputmethod.latin.InputTestsBase; 23 24@LargeTest 25public class AndroidSpellCheckerServiceTest extends InputTestsBase { 26 public void testSpellchecker() { 27 mTextView.onAttachedToWindow(); 28 mTextView.setText("tgis"); 29 type(" "); 30 sleep(1000); 31 runMessages(); 32 sleep(1000); 33 34 final SpanGetter span = new SpanGetter(mTextView.getText(), SuggestionSpan.class); 35 // If no span, the following will crash 36 final String[] suggestions = span.getSuggestions(); 37 // For this test we consider "tgis" should yield at least 2 suggestions (at this moment 38 // it yields 5). 39 assertTrue(suggestions.length >= 2); 40 // We also assume the top suggestion should be "this". 41 assertEquals("", "this", suggestions[0]); 42 } 43 44 public void testRussianSpellchecker() { 45 changeLanguage("ru"); 46 mTextView.onAttachedToWindow(); 47 mTextView.setText("годп"); 48 type(" "); 49 sleep(1000); 50 runMessages(); 51 sleep(1000); 52 53 final SpanGetter span = new SpanGetter(mTextView.getText(), SuggestionSpan.class); 54 // If no span, the following will crash 55 final String[] suggestions = span.getSuggestions(); 56 // For this test we consider "годп" should yield at least 2 suggestions (at this moment 57 // it yields 5). 58 assertTrue(suggestions.length >= 2); 59 // We also assume the top suggestion should be "года", which is the top word in the 60 // Russian dictionary. 61 assertEquals("", "года", suggestions[0]); 62 } 63} 64