Home | History | Annotate | Download | only in latin
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of 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,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.inputmethod.latin;
     18 
     19 import android.test.suitebuilder.annotation.LargeTest;
     20 
     21 import com.android.inputmethod.latin.suggestions.SuggestionStripView;
     22 
     23 @LargeTest
     24 public class InputLogicTestsNonEnglish extends InputTestsBase {
     25     final String NEXT_WORD_PREDICTION_OPTION = "next_word_prediction";
     26 
     27     public void testAutoCorrectForFrench() {
     28         final String STRING_TO_TYPE = "irq ";
     29         final String EXPECTED_RESULT = "ira ";
     30         changeLanguage("fr");
     31         type(STRING_TO_TYPE);
     32         assertEquals("simple auto-correct for French", EXPECTED_RESULT,
     33                 mEditText.getText().toString());
     34     }
     35 
     36     public void testManualPickThenSeparatorForFrench() {
     37         final String WORD1_TO_TYPE = "test";
     38         final String WORD2_TO_TYPE = "!";
     39         final String EXPECTED_RESULT = "test !";
     40         changeLanguage("fr");
     41         type(WORD1_TO_TYPE);
     42         pickSuggestionManually(0, WORD1_TO_TYPE);
     43         type(WORD2_TO_TYPE);
     44         assertEquals("manual pick then separator for French", EXPECTED_RESULT,
     45                 mEditText.getText().toString());
     46     }
     47 
     48     public void testWordThenSpaceThenPunctuationFromStripTwiceForFrench() {
     49         final String WORD_TO_TYPE = "test ";
     50         final String PUNCTUATION_FROM_STRIP = "!";
     51         final String EXPECTED_RESULT = "test !!";
     52         final boolean defaultNextWordPredictionOption =
     53                 mLatinIME.getResources().getBoolean(R.bool.config_default_next_word_prediction);
     54         final boolean previousNextWordPredictionOption =
     55                 setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, false,
     56                         defaultNextWordPredictionOption);
     57         try {
     58             changeLanguage("fr");
     59             type(WORD_TO_TYPE);
     60             sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
     61             runMessages();
     62             assertTrue("type word then type space should display punctuation strip",
     63                     mLatinIME.isShowingPunctuationList());
     64             pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
     65             pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
     66             assertEquals("type word then type space then punctuation from strip twice for French",
     67                     EXPECTED_RESULT, mEditText.getText().toString());
     68         } finally {
     69             setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption,
     70                     defaultNextWordPredictionOption);
     71         }
     72     }
     73 
     74     public void testWordThenSpaceDisplaysPredictions() {
     75         final String WORD_TO_TYPE = "beaujolais ";
     76         final String EXPECTED_RESULT = "nouveau";
     77         final boolean defaultNextWordPredictionOption =
     78                 mLatinIME.getResources().getBoolean(R.bool.config_default_next_word_prediction);
     79         final boolean previousNextWordPredictionOption =
     80                 setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, true,
     81                         defaultNextWordPredictionOption);
     82         try {
     83             changeLanguage("fr");
     84             type(WORD_TO_TYPE);
     85             sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
     86             runMessages();
     87             assertEquals("type word then type space yields predictions for French",
     88                     EXPECTED_RESULT, mLatinIME.getFirstSuggestedWord());
     89         } finally {
     90             setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption,
     91                     defaultNextWordPredictionOption);
     92         }
     93     }
     94 
     95     public void testAutoCorrectForGerman() {
     96         final String STRING_TO_TYPE = "unf ";
     97         final String EXPECTED_RESULT = "und ";
     98         changeLanguage("de");
     99         type(STRING_TO_TYPE);
    100         assertEquals("simple auto-correct for German", EXPECTED_RESULT,
    101                 mEditText.getText().toString());
    102     }
    103 
    104     public void testAutoCorrectWithUmlautForGerman() {
    105         final String STRING_TO_TYPE = "ueber ";
    106         final String EXPECTED_RESULT = "ber ";
    107         changeLanguage("de");
    108         type(STRING_TO_TYPE);
    109         assertEquals("auto-correct with umlaut for German", EXPECTED_RESULT,
    110                 mEditText.getText().toString());
    111     }
    112 }
    113