diff options
author | 2014-01-16 09:27:14 -0800 | |
---|---|---|
committer | 2014-01-16 09:27:14 -0800 | |
commit | b775b3c96ba670d575479d8b8b0ee32d35e17cb2 (patch) | |
tree | 4acf4342b298eb82fa1c1a5fa84be4b1d8d3ff17 /java/src/com/android/inputmethod | |
parent | acb16d34e7aa2447889d3b6adee4f745c3cd3c19 (diff) | |
parent | f4bf620502198202b98882254d7a355e1f5a6e45 (diff) | |
download | latinime-b775b3c96ba670d575479d8b8b0ee32d35e17cb2.tar.gz latinime-b775b3c96ba670d575479d8b8b0ee32d35e17cb2.tar.xz latinime-b775b3c96ba670d575479d8b8b0ee32d35e17cb2.zip |
am f4bf6205: Merge "Add a dedicated method to control time in native code."
* commit 'f4bf620502198202b98882254d7a355e1f5a6e45':
Add a dedicated method to control time in native code.
Diffstat (limited to 'java/src/com/android/inputmethod')
-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); } |