am a04fbce4: Merge "[TestPrep17] Allow fake dictionary for testing"

* commit 'a04fbce41273b0b7d464e4d823de5f0d54549673':
  [TestPrep17] Allow fake dictionary for testing
main
Kurt Partridge 2013-02-27 16:00:23 -08:00 committed by Android Git Automerger
commit b06798c599
1 changed files with 13 additions and 0 deletions

View File

@ -18,6 +18,7 @@ package com.android.inputmethod.research;
import android.util.Log; import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.Dictionary; import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.Suggest; import com.android.inputmethod.latin.Suggest;
import com.android.inputmethod.latin.define.ProductionFlag; 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. // 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; 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; private Suggest mSuggest;
@UsedForTesting
private Dictionary mDictionaryForTesting;
private boolean mIsStopping = false; private boolean mIsStopping = false;
/* package for test */ int mNumWordsBetweenNGrams; /* package for test */ int mNumWordsBetweenNGrams;
@ -83,7 +88,15 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
mSuggest = suggest; mSuggest = suggest;
} }
@UsedForTesting
/* package for test */ void setDictionaryForTesting(final Dictionary dictionary) {
mDictionaryForTesting = dictionary;
}
private Dictionary getDictionary() { private Dictionary getDictionary() {
if (mDictionaryForTesting != null) {
return mDictionaryForTesting;
}
if (mSuggest == null || !mSuggest.hasMainDictionary()) return null; if (mSuggest == null || !mSuggest.hasMainDictionary()) return null;
return mSuggest.getMainDictionary(); return mSuggest.getMainDictionary();
} }