diff options
author | 2013-02-19 15:36:40 -0800 | |
---|---|---|
committer | 2013-02-26 19:22:55 -0800 | |
commit | 5ee261a99012c0ac0c230093060e8f538b1ec646 (patch) | |
tree | b74c543ba3a9a2a616cdf4403c5c0d617fbb41e0 /java/src | |
parent | 64c34122f26f58a621ca9e2f9258ab47d99a1178 (diff) | |
download | latinime-5ee261a99012c0ac0c230093060e8f538b1ec646.tar.gz latinime-5ee261a99012c0ac0c230093060e8f538b1ec646.tar.xz latinime-5ee261a99012c0ac0c230093060e8f538b1ec646.zip |
[TestPrep17] Allow fake dictionary for testing
Currently ResearchLog requires a full dictionary to perform privacy-related checks.
This makes testing difficult. This change allows a fake dictionary to be used instead.
Change-Id: Ifca5bd8647475a6b84e4324117e0faa0a35479ee
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/research/MainLogBuffer.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/research/MainLogBuffer.java b/java/src/com/android/inputmethod/research/MainLogBuffer.java index 45b83dd76..9e77a1a38 100644 --- a/java/src/com/android/inputmethod/research/MainLogBuffer.java +++ b/java/src/com/android/inputmethod/research/MainLogBuffer.java @@ -18,6 +18,7 @@ package com.android.inputmethod.research; import android.util.Log; +import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.latin.Dictionary; import com.android.inputmethod.latin.Suggest; import com.android.inputmethod.latin.define.ProductionFlag; @@ -64,7 +65,11 @@ public abstract class MainLogBuffer extends FixedLogBuffer { // The size of the n-grams logged. E.g. N_GRAM_SIZE = 2 means to sample bigrams. public static final int N_GRAM_SIZE = 2; + // TODO: Remove dependence on Suggest, and pass in Dictionary as a parameter to an appropriate + // method. private Suggest mSuggest; + @UsedForTesting + private Dictionary mDictionaryForTesting; private boolean mIsStopping = false; /* package for test */ int mNumWordsBetweenNGrams; @@ -83,7 +88,15 @@ public abstract class MainLogBuffer extends FixedLogBuffer { mSuggest = suggest; } + @UsedForTesting + /* package for test */ void setDictionaryForTesting(final Dictionary dictionary) { + mDictionaryForTesting = dictionary; + } + private Dictionary getDictionary() { + if (mDictionaryForTesting != null) { + return mDictionaryForTesting; + } if (mSuggest == null || !mSuggest.hasMainDictionary()) return null; return mSuggest.getMainDictionary(); } |