Add VERSION4_DEV(402) in Java side and use it for tests.
Bug: 13406708 Change-Id: I7c9c53bf34d12dced7331a359a83f6444490783a
This commit is contained in:
parent
7116ea98f4
commit
04536f14b0
3 changed files with 99 additions and 38 deletions
|
@ -193,8 +193,9 @@ public final class FormatSpec {
|
|||
// Dictionary version used for testing.
|
||||
public static final int VERSION4_ONLY_FOR_TESTING = 399;
|
||||
public static final int VERSION4 = 401;
|
||||
public static final int VERSION4_DEV = 402;
|
||||
static final int MINIMUM_SUPPORTED_VERSION = VERSION2;
|
||||
static final int MAXIMUM_SUPPORTED_VERSION = VERSION4;
|
||||
static final int MAXIMUM_SUPPORTED_VERSION = VERSION4_DEV;
|
||||
|
||||
// TODO: Make this value adaptative to content data, store it in the header, and
|
||||
// use it in the reading code.
|
||||
|
|
|
@ -46,6 +46,8 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
private static final String TEST_DICT_FILE_EXTENSION = ".testDict";
|
||||
private static final String TEST_LOCALE = "test";
|
||||
private static final int DUMMY_PROBABILITY = 0;
|
||||
private static final int[] DICT_FORMAT_VERSIONS =
|
||||
new int[] { FormatSpec.VERSION4, FormatSpec.VERSION4_DEV };
|
||||
|
||||
private int mCurrentTime = 0;
|
||||
|
||||
|
@ -94,7 +96,8 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
private File createEmptyDictionaryAndGetFile(final String dictId,
|
||||
final int formatVersion) throws IOException {
|
||||
if (formatVersion == FormatSpec.VERSION4
|
||||
|| formatVersion == FormatSpec.VERSION4_ONLY_FOR_TESTING) {
|
||||
|| formatVersion == FormatSpec.VERSION4_ONLY_FOR_TESTING
|
||||
|| formatVersion == FormatSpec.VERSION4_DEV) {
|
||||
return createEmptyVer4DictionaryAndGetFile(dictId, formatVersion);
|
||||
} else {
|
||||
throw new IOException("Dictionary format version " + formatVersion
|
||||
|
@ -120,7 +123,7 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
return file;
|
||||
} else {
|
||||
throw new IOException("Empty dictionary " + file.getAbsolutePath()
|
||||
+ " cannot be created.");
|
||||
+ " cannot be created. Foramt version: " + formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +136,9 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testReadDictInJavaSide() {
|
||||
testReadDictInJavaSide(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testReadDictInJavaSide(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testReadDictInJavaSide(final int formatVersion) {
|
||||
|
@ -178,10 +183,6 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testControlCurrentTime() {
|
||||
testControlCurrentTime(FormatSpec.VERSION4);
|
||||
}
|
||||
|
||||
private void testControlCurrentTime(final int formatVersion) {
|
||||
final int TEST_COUNT = 1000;
|
||||
final long seed = System.currentTimeMillis();
|
||||
final Random random = new Random(seed);
|
||||
|
@ -197,7 +198,9 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testAddValidAndInvalidWords() {
|
||||
testAddValidAndInvalidWords(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testAddValidAndInvalidWords(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testAddValidAndInvalidWords(final int formatVersion) {
|
||||
|
@ -240,7 +243,9 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testDecayingProbability() {
|
||||
testDecayingProbability(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testDecayingProbability(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testDecayingProbability(final int formatVersion) {
|
||||
|
@ -295,7 +300,9 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testAddManyUnigramsToDecayingDict() {
|
||||
testAddManyUnigramsToDecayingDict(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testAddManyUnigramsToDecayingDict(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testAddManyUnigramsToDecayingDict(final int formatVersion) {
|
||||
|
@ -354,7 +361,9 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testOverflowUnigrams() {
|
||||
testOverflowUnigrams(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testOverflowUnigrams(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testOverflowUnigrams(final int formatVersion) {
|
||||
|
@ -413,7 +422,9 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testAddManyBigramsToDecayingDict() {
|
||||
testAddManyBigramsToDecayingDict(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testAddManyBigramsToDecayingDict(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testAddManyBigramsToDecayingDict(final int formatVersion) {
|
||||
|
@ -487,7 +498,9 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testOverflowBigrams() {
|
||||
testOverflowBigrams(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testOverflowBigrams(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testOverflowBigrams(final int formatVersion) {
|
||||
|
@ -566,7 +579,9 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testDictMigration() {
|
||||
testDictMigration(FormatSpec.VERSION4_ONLY_FOR_TESTING, FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testDictMigration(FormatSpec.VERSION4_ONLY_FOR_TESTING, formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testDictMigration(final int fromFormatVersion, final int toFormatVersion) {
|
||||
|
|
|
@ -43,11 +43,14 @@ import java.util.Random;
|
|||
public class BinaryDictionaryTests extends AndroidTestCase {
|
||||
private static final String TEST_DICT_FILE_EXTENSION = ".testDict";
|
||||
private static final String TEST_LOCALE = "test";
|
||||
private static final int[] DICT_FORMAT_VERSIONS =
|
||||
new int[] { FormatSpec.VERSION4, FormatSpec.VERSION4_DEV };
|
||||
|
||||
private File createEmptyDictionaryAndGetFile(final String dictId,
|
||||
final int formatVersion) throws IOException {
|
||||
if (formatVersion == FormatSpec.VERSION4
|
||||
|| formatVersion == FormatSpec.VERSION4_ONLY_FOR_TESTING) {
|
||||
|| formatVersion == FormatSpec.VERSION4_ONLY_FOR_TESTING
|
||||
|| formatVersion == FormatSpec.VERSION4_DEV) {
|
||||
return createEmptyVer4DictionaryAndGetFile(dictId, formatVersion);
|
||||
} else {
|
||||
throw new IOException("Dictionary format version " + formatVersion
|
||||
|
@ -67,12 +70,14 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
return file;
|
||||
} else {
|
||||
throw new IOException("Empty dictionary " + file.getAbsolutePath()
|
||||
+ " cannot be created.");
|
||||
+ " cannot be created. Format version: " + formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
public void testIsValidDictionary() {
|
||||
testIsValidDictionary(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testIsValidDictionary(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testIsValidDictionary(final int formatVersion) {
|
||||
|
@ -100,7 +105,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testConstructingDictionaryOnMemory() {
|
||||
testConstructingDictionaryOnMemory(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testConstructingDictionaryOnMemory(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testConstructingDictionaryOnMemory(final int formatVersion) {
|
||||
|
@ -131,7 +138,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testAddTooLongWord() {
|
||||
testAddTooLongWord(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testAddTooLongWord(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testAddTooLongWord(final int formatVersion) {
|
||||
|
@ -190,7 +199,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testAddUnigramWord() {
|
||||
testAddUnigramWord(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testAddUnigramWord(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testAddUnigramWord(final int formatVersion) {
|
||||
|
@ -232,7 +243,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testRandomlyAddUnigramWord() {
|
||||
testRandomlyAddUnigramWord(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testRandomlyAddUnigramWord(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testRandomlyAddUnigramWord(final int formatVersion) {
|
||||
|
@ -268,7 +281,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testAddBigramWords() {
|
||||
testAddBigramWords(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testAddBigramWords(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testAddBigramWords(final int formatVersion) {
|
||||
|
@ -336,7 +351,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testRandomlyAddBigramWords() {
|
||||
testRandomlyAddBigramWords(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testRandomlyAddBigramWords(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testRandomlyAddBigramWords(final int formatVersion) {
|
||||
|
@ -397,7 +414,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testRemoveBigramWords() {
|
||||
testRemoveBigramWords(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testRemoveBigramWords(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testRemoveBigramWords(final int formatVersion) {
|
||||
|
@ -447,7 +466,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testFlushDictionary() {
|
||||
testFlushDictionary(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testFlushDictionary(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testFlushDictionary(final int formatVersion) {
|
||||
|
@ -499,7 +520,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testFlushWithGCDictionary() {
|
||||
testFlushWithGCDictionary(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testFlushWithGCDictionary(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testFlushWithGCDictionary(final int formatVersion) {
|
||||
|
@ -547,7 +570,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testAddBigramWordsAndFlashWithGC() {
|
||||
testAddBigramWordsAndFlashWithGC(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testAddBigramWordsAndFlashWithGC(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Evaluate performance of GC
|
||||
|
@ -616,7 +641,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testRandomOperationsAndFlashWithGC() {
|
||||
testRandomOperationsAndFlashWithGC(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testRandomOperationsAndFlashWithGC(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testRandomOperationsAndFlashWithGC(final int formatVersion) {
|
||||
|
@ -727,7 +754,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testAddManyUnigramsAndFlushWithGC() {
|
||||
testAddManyUnigramsAndFlushWithGC(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testAddManyUnigramsAndFlushWithGC(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testAddManyUnigramsAndFlushWithGC(final int formatVersion) {
|
||||
|
@ -775,7 +804,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testUnigramAndBigramCount() {
|
||||
testUnigramAndBigramCount(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testUnigramAndBigramCount(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testUnigramAndBigramCount(final int formatVersion) {
|
||||
|
@ -834,7 +865,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testAddMultipleDictionaryEntries() {
|
||||
testAddMultipleDictionaryEntries(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testAddMultipleDictionaryEntries(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testAddMultipleDictionaryEntries(final int formatVersion) {
|
||||
|
@ -896,7 +929,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testGetWordProperties() {
|
||||
testGetWordProperties(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testGetWordProperties(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testGetWordProperties(final int formatVersion) {
|
||||
|
@ -995,7 +1030,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testIterateAllWords() {
|
||||
testIterateAllWords(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testIterateAllWords(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testIterateAllWords(final int formatVersion) {
|
||||
|
@ -1091,7 +1128,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testAddShortcuts() {
|
||||
testAddShortcuts(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testAddShortcuts(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testAddShortcuts(final int formatVersion) {
|
||||
|
@ -1151,7 +1190,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testAddManyShortcuts() {
|
||||
testAddManyShortcuts(FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testAddManyShortcuts(formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testAddManyShortcuts(final int formatVersion) {
|
||||
|
@ -1227,7 +1268,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testDictMigration() {
|
||||
testDictMigration(FormatSpec.VERSION4_ONLY_FOR_TESTING, FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testDictMigration(FormatSpec.VERSION4_ONLY_FOR_TESTING, formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testDictMigration(final int fromFormatVersion, final int toFormatVersion) {
|
||||
|
@ -1271,7 +1314,9 @@ public class BinaryDictionaryTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testLargeDictMigration() {
|
||||
testLargeDictMigration(FormatSpec.VERSION4_ONLY_FOR_TESTING, FormatSpec.VERSION4);
|
||||
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
|
||||
testLargeDictMigration(FormatSpec.VERSION4_ONLY_FOR_TESTING, formatVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void testLargeDictMigration(final int fromFormatVersion, final int toFormatVersion) {
|
||||
|
|
Loading…
Reference in a new issue