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.common.CodePointUtils;
22 
23 import java.util.Random;
24 
25 @LargeTest
26 public class LatinImeStressTests extends InputTestsBase {
testSwitchLanguagesAndInputLatinRandomCodePoints()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[] codePointSet = CodePointUtils.LATIN_ALPHABETS_LOWER;
34         for (int i = 0; i < switchCount; ++i) {
35             changeLanguageWithoutWait(locales[random.nextInt(locales.length)],
36                     null /* combiningSpec */);
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     }
testSwitchLanguagesAndInputRandomCodePoints()44     public void testSwitchLanguagesAndInputRandomCodePoints() {
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                     null /* combiningSpec */);
55             final int wordCount = random.nextInt(maxWordCountToTypeInEachIteration);
56             for (int j = 0; j < wordCount; ++j) {
57                 final String word = CodePointUtils.generateWord(random, codePointSet);
58                 type(word);
59             }
60         }
61     }
62 }
63