Home | History | Annotate | Download | only in latin
      1 /*
      2  * Copyright (C) 2013 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.makedict.CodePointUtils;
     22 
     23 import java.util.Random;
     24 
     25 @LargeTest
     26 public class LatinImeStressTests extends InputTestsBase {
     27     public void testSwitchLanguagesAndInputLatinRandomCodePoints() {
     28         final String[] locales = {"en_US", "de", "el", "es", "fi", "it", "nl", "pt", "ru"};
     29         final int switchCount = 50;
     30         final int maxWordCountToTypeInEachIteration = 20;
     31         final long seed = System.currentTimeMillis();
     32         final Random random = new Random(seed);
     33         final int codePointSetSize = 30;
     34         final int[] codePointSet = CodePointUtils.LATIN_ALPHABETS_LOWER;
     35         for (int i = 0; i < switchCount; ++i) {
     36             changeLanguageWithoutWait(locales[random.nextInt(locales.length)]);
     37             final int wordCount = random.nextInt(maxWordCountToTypeInEachIteration);
     38             for (int j = 0; j < wordCount; ++j) {
     39                 final String word = CodePointUtils.generateWord(random, codePointSet);
     40                 type(word);
     41             }
     42         }
     43     }
     44     public void testSwitchLanguagesAndInputRandamCodePoints() {
     45         final String[] locales = {"en_US", "de", "el", "es", "fi", "it", "nl", "pt", "ru"};
     46         final int switchCount = 50;
     47         final int maxWordCountToTypeInEachIteration = 20;
     48         final long seed = System.currentTimeMillis();
     49         final Random random = new Random(seed);
     50         final int codePointSetSize = 30;
     51         final int[] codePointSet = CodePointUtils.generateCodePointSet(codePointSetSize, random);
     52         for (int i = 0; i < switchCount; ++i) {
     53             changeLanguageWithoutWait(locales[random.nextInt(locales.length)]);
     54             final int wordCount = random.nextInt(maxWordCountToTypeInEachIteration);
     55             for (int j = 0; j < wordCount; ++j) {
     56                 final String word = CodePointUtils.generateWord(random, codePointSet);
     57                 type(word);
     58             }
     59         }
     60     }
     61 }
     62