aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2014-01-16 17:25:28 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-01-16 17:25:29 +0000
commitf4bf620502198202b98882254d7a355e1f5a6e45 (patch)
tree4acf4342b298eb82fa1c1a5fa84be4b1d8d3ff17 /java/src
parent47f04e2e35832788a84d36a384570f60bbd7da9e (diff)
parentd78a447d107ae60d2bb8f16a1b9797f5ebad2277 (diff)
downloadlatinime-f4bf620502198202b98882254d7a355e1f5a6e45.tar.gz
latinime-f4bf620502198202b98882254d7a355e1f5a6e45.tar.xz
latinime-f4bf620502198202b98882254d7a355e1f5a6e45.zip
Merge "Add a dedicated method to control time in native code."
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionary.java17
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);
}