aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/UserHistoryDictionaryTests.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/UserHistoryDictionaryTests.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/UserHistoryDictionaryTests.java65
1 files changed, 38 insertions, 27 deletions
diff --git a/tests/src/com/android/inputmethod/latin/UserHistoryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/UserHistoryDictionaryTests.java
index f2a17d206..7536f64ac 100644
--- a/tests/src/com/android/inputmethod/latin/UserHistoryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/UserHistoryDictionaryTests.java
@@ -23,6 +23,8 @@ import android.preference.PreferenceManager;
import android.test.AndroidTestCase;
import android.util.Log;
+import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -76,34 +78,43 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
}
public void testRandomWords() {
- Log.d(TAG, "This test can be used for profiling.");
- Log.d(TAG, "Usage: please set UserHisotoryDictionary.PROFILE_SAVE_RESTORE to true.");
- final int numberOfWords = 1000;
- final Random random = new Random(123456);
- List<String> words = generateWords(numberOfWords, random);
-
- final String locale = "testRandomWords";
- final UserHistoryDictionary dict = UserHistoryDictionary.getInstance(getContext(),
- locale, mPrefs);
- dict.isTest = true;
-
- addToDict(dict, words);
-
- try {
- Log.d(TAG, "waiting for adding the word ...");
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- Log.d(TAG, "InterruptedException: " + e);
- }
-
- // write to file
- dict.close();
-
+ File dictFile = null;
try {
- Log.d(TAG, "waiting for writing ...");
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- Log.d(TAG, "InterruptedException: " + e);
+ Log.d(TAG, "This test can be used for profiling.");
+ Log.d(TAG, "Usage: please set UserHisotoryDictionary.PROFILE_SAVE_RESTORE to true.");
+ final int numberOfWords = 1000;
+ final Random random = new Random(123456);
+ List<String> words = generateWords(numberOfWords, random);
+
+ final String locale = "testRandomWords";
+ final String fileName = "UserHistoryDictionary." + locale + ".dict";
+ dictFile = new File(getContext().getFilesDir(), fileName);
+ final UserHistoryDictionary dict = UserHistoryDictionary.getInstance(getContext(),
+ locale, mPrefs);
+ dict.isTest = true;
+
+ addToDict(dict, words);
+
+ try {
+ Log.d(TAG, "waiting for adding the word ...");
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ Log.d(TAG, "InterruptedException: " + e);
+ }
+
+ // write to file
+ dict.close();
+
+ try {
+ Log.d(TAG, "waiting for writing ...");
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ Log.d(TAG, "InterruptedException: " + e);
+ }
+ } finally {
+ if (dictFile != null) {
+ dictFile.delete();
+ }
}
}
}