Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8aaae56c authored by Yuichiro Hanada's avatar Yuichiro Hanada
Browse files

Fix unit test.

Change-Id: Ib104d5de71c2ab1a07921b407c74c21b0409d9af
parent 606a056b
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -84,6 +84,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
    /** Controls access to the local binary dictionary for this instance. */
    private final DictionaryController mLocalDictionaryController = new DictionaryController();

    /* A extension for a binary dictionary file. */
    public static final String DICT_FILE_EXTENSION = ".dict";

    /**
     * Abstract method for loading the unigrams and bigrams of a given dictionary in a background
     * thread.
@@ -129,7 +132,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
    }

    protected static String getFilenameWithLocale(final String name, final String localeStr) {
        return name + "." + localeStr + ".dict";
        return name + "." + localeStr + DICT_FILE_EXTENSION;
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.inputmethod.latin.personalization;

import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.ExpandableBinaryDictionary;

import android.content.Context;
import android.content.SharedPreferences;
@@ -31,6 +32,6 @@ public class PersonalizationPredictionDictionary extends DynamicPredictionDictio

    @Override
    protected String getDictionaryFileName() {
        return NAME + "." + getLocale() + ".dict";
        return NAME + "." + getLocale() + ExpandableBinaryDictionary.DICT_FILE_EXTENSION;
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.inputmethod.latin.personalization;

import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.ExpandableBinaryDictionary;

import android.content.Context;
import android.content.SharedPreferences;
@@ -35,6 +36,6 @@ public class UserHistoryPredictionDictionary extends DynamicPredictionDictionary

    @Override
    protected String getDictionaryFileName() {
        return NAME + "." + getLocale() + ".dict";
        return NAME + "." + getLocale() + ExpandableBinaryDictionary.DICT_FILE_EXTENSION;
    }
}
+9 −4
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
    private static final FormatSpec.FormatOptions VERSION3_WITH_DYNAMIC_UPDATE =
            new FormatSpec.FormatOptions(3, true /* supportsDynamicUpdate */);

    private static final String TEST_DICT_FILE_EXTENSION = ".testDict";

    public BinaryDictDecoderEncoderTests() {
        this(System.currentTimeMillis(), DEFAULT_MAX_UNIGRAMS);
    }
@@ -293,7 +295,8 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
            final String message) {
        File file = null;
        try {
            file = File.createTempFile("runReadAndWrite", ".dict", getContext().getCacheDir());
            file = File.createTempFile("runReadAndWrite", TEST_DICT_FILE_EXTENSION,
                    getContext().getCacheDir());
        } catch (IOException e) {
            Log.e(TAG, "IOException", e);
        }
@@ -435,7 +438,8 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
            final FormatSpec.FormatOptions formatOptions, final String message) {
        File file = null;
        try {
            file = File.createTempFile("runReadUnigrams", ".dict", getContext().getCacheDir());
            file = File.createTempFile("runReadUnigrams", TEST_DICT_FILE_EXTENSION,
                    getContext().getCacheDir());
        } catch (IOException e) {
            Log.e(TAG, "IOException", e);
        }
@@ -533,7 +537,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
    public void testGetTerminalPosition() {
        File file = null;
        try {
            file = File.createTempFile("testGetTerminalPosition", ".dict",
            file = File.createTempFile("testGetTerminalPosition", TEST_DICT_FILE_EXTENSION,
                    getContext().getCacheDir());
        } catch (IOException e) {
            // do nothing
@@ -593,7 +597,8 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
    public void testDeleteWord() {
        File file = null;
        try {
            file = File.createTempFile("testDeleteWord", ".dict", getContext().getCacheDir());
            file = File.createTempFile("testDeleteWord", TEST_DICT_FILE_EXTENSION,
                    getContext().getCacheDir());
        } catch (IOException e) {
            // do nothing
        }
+7 −3
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
    public static final int DEFAULT_MAX_UNIGRAMS = 1500;
    private final int mMaxUnigrams;

    private static final String TEST_DICT_FILE_EXTENSION = ".testDict";

    private static final String[] CHARACTERS = {
        "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
        "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
@@ -234,7 +236,8 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
    public void testInsertWord() {
        File file = null;
        try {
            file = File.createTempFile("testInsertWord", ".dict", getContext().getCacheDir());
            file = File.createTempFile("testInsertWord", TEST_DICT_FILE_EXTENSION,
                    getContext().getCacheDir());
        } catch (IOException e) {
            fail("IOException while creating temporary file: " + e);
        }
@@ -284,7 +287,7 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
    public void testInsertWordWithBigrams() {
        File file = null;
        try {
            file = File.createTempFile("testInsertWordWithBigrams", ".dict",
            file = File.createTempFile("testInsertWordWithBigrams", TEST_DICT_FILE_EXTENSION,
                    getContext().getCacheDir());
        } catch (IOException e) {
            fail("IOException while creating temporary file: " + e);
@@ -322,7 +325,8 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
    public void testRandomWords() {
        File file = null;
        try {
            file = File.createTempFile("testRandomWord", ".dict", getContext().getCacheDir());
            file = File.createTempFile("testRandomWord", TEST_DICT_FILE_EXTENSION,
                    getContext().getCacheDir());
        } catch (IOException e) {
        }
        assertNotNull(file);
Loading