diff --git a/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java b/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java index 7b81e8be1..a2c3ed44d 100644 --- a/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtils.java @@ -73,8 +73,8 @@ public final class UserHistoryDictIOUtils { @UsedForTesting public static void writeDictionary(final DictEncoder dictEncoder, final BigramDictionaryInterface dict, final UserHistoryDictionaryBigramList bigrams, - final FormatOptions formatOptions) { - final FusionDictionary fusionDict = constructFusionDictionary(dict, bigrams); + final FormatOptions formatOptions, final HashMap options) { + final FusionDictionary fusionDict = constructFusionDictionary(dict, bigrams, options); fusionDict.addOptionAttribute(USES_FORGETTING_CURVE_KEY, USES_FORGETTING_CURVE_VALUE); fusionDict.addOptionAttribute(LAST_UPDATED_TIME_KEY, String.valueOf(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()))); @@ -92,10 +92,10 @@ public final class UserHistoryDictIOUtils { * Constructs a new FusionDictionary from BigramDictionaryInterface. */ @UsedForTesting - static FusionDictionary constructFusionDictionary( - final BigramDictionaryInterface dict, final UserHistoryDictionaryBigramList bigrams) { + static FusionDictionary constructFusionDictionary(final BigramDictionaryInterface dict, + final UserHistoryDictionaryBigramList bigrams, final HashMap options) { final FusionDictionary fusionDict = new FusionDictionary(new PtNodeArray(), - new FusionDictionary.DictionaryOptions(new HashMap(), false, + new FusionDictionary.DictionaryOptions(options, false, false)); int profTotal = 0; for (final String word1 : bigrams.keySet()) { diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java index 6affe233d..dac0dba1e 100644 --- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java +++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java @@ -558,12 +558,12 @@ public class BinaryDictionaryTests extends AndroidTestCase { dictFile.delete(); } - public void testRandomOperetionsAndFlashWithGC() { - testRandomOperetionsAndFlashWithGC(3 /* formatVersion */); - testRandomOperetionsAndFlashWithGC(4 /* formatVersion */); + public void testRandomOperationsAndFlashWithGC() { + testRandomOperationsAndFlashWithGC(3 /* formatVersion */); + testRandomOperationsAndFlashWithGC(4 /* formatVersion */); } - private void testRandomOperetionsAndFlashWithGC(final int formatVersion) { + private void testRandomOperationsAndFlashWithGC(final int formatVersion) { final int flashWithGCIterationCount = 50; final int operationCountInEachIteration = 200; final int initialUnigramCount = 100; diff --git a/tests/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtilsTests.java index 660e53e60..fc921b4fd 100644 --- a/tests/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtilsTests.java +++ b/tests/src/com/android/inputmethod/latin/utils/UserHistoryDictIOUtilsTests.java @@ -24,6 +24,7 @@ import android.util.Log; import com.android.inputmethod.latin.makedict.DictDecoder; import com.android.inputmethod.latin.makedict.DictEncoder; import com.android.inputmethod.latin.makedict.FormatSpec; +import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode; import com.android.inputmethod.latin.makedict.UnsupportedFormatException; @@ -53,6 +54,12 @@ public class UserHistoryDictIOUtilsTests extends AndroidTestCase private static final ArrayList NOT_HAVE_BIGRAM = new ArrayList(); private static final FormatSpec.FormatOptions FORMAT_OPTIONS = new FormatSpec.FormatOptions(2); private static final String TEST_DICT_FILE_EXTENSION = ".testDict"; + private static final HashMap HEADER_OPTIONS = new HashMap(); + static { + HEADER_OPTIONS.put(FileHeader.DICTIONARY_LOCALE_ATTRIBUTE, "en_US"); + HEADER_OPTIONS.put(FileHeader.DICTIONARY_ID_ATTRIBUTE, "test"); + HEADER_OPTIONS.put(FileHeader.DICTIONARY_VERSION_ATTRIBUTE, "1000"); + } /** * Return same frequency for all words and bigrams @@ -140,7 +147,8 @@ public class UserHistoryDictIOUtilsTests extends AndroidTestCase private void writeDictToFile(final File file, final UserHistoryDictionaryBigramList bigramList) { final DictEncoder dictEncoder = new Ver3DictEncoder(file); - UserHistoryDictIOUtils.writeDictionary(dictEncoder, this, bigramList, FORMAT_OPTIONS); + UserHistoryDictIOUtils.writeDictionary(dictEncoder, this, bigramList, FORMAT_OPTIONS, + HEADER_OPTIONS); } private void readDictFromFile(final File file, final OnAddWordListener listener) @@ -159,8 +167,8 @@ public class UserHistoryDictIOUtilsTests extends AndroidTestCase addBigramToBigramList("this", "was", addedWords, originalList); addBigramToBigramList("hello", "world", addedWords, originalList); - final FusionDictionary fusionDict = - UserHistoryDictIOUtils.constructFusionDictionary(this, originalList); + final FusionDictionary fusionDict = UserHistoryDictIOUtils.constructFusionDictionary( + this, originalList, HEADER_OPTIONS); checkWordsInFusionDict(fusionDict, addedWords); }