diff options
author | 2014-01-15 14:55:57 -0800 | |
---|---|---|
committer | 2014-01-15 14:55:57 -0800 | |
commit | d78a447d107ae60d2bb8f16a1b9797f5ebad2277 (patch) | |
tree | 1d421bd74157c9598d2b19d57315434b3c8ec4e4 /java/src/com/android/inputmethod/latin/BinaryDictionary.java | |
parent | 118a4fc2b7fc4f0ba1de78eb0ef72b473a6ecfd5 (diff) | |
download | latinime-d78a447d107ae60d2bb8f16a1b9797f5ebad2277.tar.gz latinime-d78a447d107ae60d2bb8f16a1b9797f5ebad2277.tar.xz latinime-d78a447d107ae60d2bb8f16a1b9797f5ebad2277.zip |
Add a dedicated method to control time in native code.
Bug: 12443085
Change-Id: I41a5cf6c895cb59e54af98b40efded36afcd3247
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionary.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 2c7998688..e66cfca49 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -165,6 +165,7 @@ public final class BinaryDictionary extends Dictionary { LanguageModelParam[] languageModelParams, int startIndex); private static native int calculateProbabilityNative(long dict, int unigramProbability, int bigramProbability); + private static native int setCurrentTimeForTestNative(int currentTime); private static native String getPropertyNative(long dict, String query); @UsedForTesting @@ -420,8 +421,22 @@ public final class BinaryDictionary extends Dictionary { return calculateProbabilityNative(mNativeDict, unigramProbability, bigramProbability); } + /** + * Control the current time to be used in the native code. If currentTime >= 0, this method sets + * the current time and gets into test mode. + * In test mode, set timestamp is used as the current time in the native code. + * If currentTime < 0, quit the test mode and returns to using time() to get the current time. + * + * @param currentTime seconds since the unix epoch + * @return current time got in the native code. + */ + @UsedForTesting + public static int setCurrentTimeForTest(final int currentTime) { + return setCurrentTimeForTestNative(currentTime); + } + @UsedForTesting - public String getPropertyForTests(String query) { + public String getPropertyForTest(final String query) { if (!isValidDictionary()) return ""; return getPropertyNative(mNativeDict, query); } |