Quit using currentTimeMillis() for user history unit tests.

Change-Id: I24bd81e6781148302d5679850ed0a9bda71a3d27
This commit is contained in:
Keisuke Kuroyanagi 2014-09-29 14:26:51 +09:00
parent a4a4e9d96b
commit 6c7a85cb35

View file

@ -159,11 +159,11 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
return new ArrayList<>(wordSet); return new ArrayList<>(wordSet);
} }
private static void addToDict(final UserHistoryDictionary dict, final List<String> words) { private static void addToDict(final UserHistoryDictionary dict, final List<String> words,
final int timestamp) {
NgramContext ngramContext = NgramContext.EMPTY_PREV_WORDS_INFO; NgramContext ngramContext = NgramContext.EMPTY_PREV_WORDS_INFO;
for (String word : words) { for (String word : words) {
UserHistoryDictionary.addToDictionary(dict, ngramContext, word, true, UserHistoryDictionary.addToDictionary(dict, ngramContext, word, true, timestamp,
(int)TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),
DistracterFilter.EMPTY_DISTRACTER_FILTER); DistracterFilter.EMPTY_DISTRACTER_FILTER);
ngramContext = ngramContext.getNextNgramContext(new WordInfo(word)); ngramContext = ngramContext.getNextNgramContext(new WordInfo(word));
} }
@ -177,7 +177,7 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
final int numberOfWords, final Random random, final boolean checkContents) { final int numberOfWords, final Random random, final boolean checkContents) {
final List<String> words = generateWords(numberOfWords, random); final List<String> words = generateWords(numberOfWords, random);
// Add random words to the user history dictionary. // Add random words to the user history dictionary.
addToDict(dict, words); addToDict(dict, words, mCurrentTime);
if (checkContents) { if (checkContents) {
dict.waitAllTasksForTests(); dict.waitAllTasksForTests();
for (int i = 0; i < numberOfWords; ++i) { for (int i = 0; i < numberOfWords; ++i) {
@ -308,6 +308,5 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
for (final String word : words) { for (final String word : words) {
assertFalse(dict.isInDictionary(word)); assertFalse(dict.isInDictionary(word));
} }
stopTestModeInNativeCode();
} }
} }