aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/src/com/android/inputmethod/latin/common/CollectionUtils.java3
-rw-r--r--common/src/com/android/inputmethod/latin/common/InputPointers.java1
-rw-r--r--common/src/com/android/inputmethod/latin/common/ResizableIntArray.java3
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionary.java10
-rw-r--r--tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java2
5 files changed, 14 insertions, 5 deletions
diff --git a/common/src/com/android/inputmethod/latin/common/CollectionUtils.java b/common/src/com/android/inputmethod/latin/common/CollectionUtils.java
index f7ba693af..48df413fd 100644
--- a/common/src/com/android/inputmethod/latin/common/CollectionUtils.java
+++ b/common/src/com/android/inputmethod/latin/common/CollectionUtils.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.latin.common;
+import com.android.inputmethod.annotations.UsedForTesting;
+
import java.util.ArrayList;
import java.util.Collection;
@@ -57,6 +59,7 @@ public final class CollectionUtils {
* @param c Collection to test.
* @return Whether c contains no elements.
*/
+ @UsedForTesting
public static boolean isNullOrEmpty(@Nullable final Collection<?> c) {
return c == null || c.isEmpty();
}
diff --git a/common/src/com/android/inputmethod/latin/common/InputPointers.java b/common/src/com/android/inputmethod/latin/common/InputPointers.java
index 7beee1536..4b2ae7e76 100644
--- a/common/src/com/android/inputmethod/latin/common/InputPointers.java
+++ b/common/src/com/android/inputmethod/latin/common/InputPointers.java
@@ -112,6 +112,7 @@ public final class InputPointers {
* Shift to the left by elementCount, discarding elementCount pointers at the start.
* @param elementCount how many elements to shift.
*/
+ @UsedForTesting
public void shift(final int elementCount) {
mXCoordinates.shift(elementCount);
mYCoordinates.shift(elementCount);
diff --git a/common/src/com/android/inputmethod/latin/common/ResizableIntArray.java b/common/src/com/android/inputmethod/latin/common/ResizableIntArray.java
index 340abb23e..77f5c4cd5 100644
--- a/common/src/com/android/inputmethod/latin/common/ResizableIntArray.java
+++ b/common/src/com/android/inputmethod/latin/common/ResizableIntArray.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.latin.common;
+import com.android.inputmethod.annotations.UsedForTesting;
+
import java.util.Arrays;
import javax.annotation.Nonnull;
@@ -140,6 +142,7 @@ public final class ResizableIntArray {
* Shift to the left by elementCount, discarding elementCount pointers at the start.
* @param elementCount how many elements to shift.
*/
+ @UsedForTesting
public void shift(final int elementCount) {
System.arraycopy(mArray, elementCount, mArray, 0, mLength - elementCount);
mLength -= elementCount;
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index c1015511b..daac5b521 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -58,6 +58,8 @@ public final class BinaryDictionary extends Dictionary {
// Must be equal to CONFIDENCE_TO_AUTO_COMMIT in native/jni/src/defines.h
private static final int CONFIDENCE_TO_AUTO_COMMIT = 1000000;
+ static final int DICTIONARY_MAX_WORD_LENGTH = 48;
+
@UsedForTesting
public static final String UNIGRAM_COUNT_QUERY = "UNIGRAM_COUNT";
@UsedForTesting
@@ -318,9 +320,9 @@ public final class BinaryDictionary extends Dictionary {
final int count = session.mOutputSuggestionCount[0];
final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
for (int j = 0; j < count; ++j) {
- final int start = j * DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH;
+ final int start = j * DICTIONARY_MAX_WORD_LENGTH;
int len = 0;
- while (len < DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH
+ while (len < DICTIONARY_MAX_WORD_LENGTH
&& session.mOutputCodePoints[start + len] != 0) {
++len;
}
@@ -389,7 +391,7 @@ public final class BinaryDictionary extends Dictionary {
return null;
}
final int[] codePoints = StringUtils.toCodePointArray(word);
- final int[] outCodePoints = new int[DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH];
+ final int[] outCodePoints = new int[DICTIONARY_MAX_WORD_LENGTH];
final boolean[] outFlags = new boolean[FORMAT_WORD_PROPERTY_OUTPUT_FLAG_COUNT];
final int[] outProbabilityInfo =
new int[FORMAT_WORD_PROPERTY_OUTPUT_PROBABILITY_INFO_COUNT];
@@ -428,7 +430,7 @@ public final class BinaryDictionary extends Dictionary {
* If token is 0, this method newly starts iterating the dictionary.
*/
public GetNextWordPropertyResult getNextWordProperty(final int token) {
- final int[] codePoints = new int[DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH];
+ final int[] codePoints = new int[DICTIONARY_MAX_WORD_LENGTH];
final boolean[] isBeginningOfSentence = new boolean[1];
final int nextToken = getNextWordNative(mNativeDict, token, codePoints,
isBeginningOfSentence);
diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
index 9da1e9470..752051775 100644
--- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
@@ -170,7 +170,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
private void testAddTooLongWord(final int formatVersion) {
final BinaryDictionary binaryDictionary = getEmptyBinaryDictionary(formatVersion);
final StringBuffer stringBuilder = new StringBuffer();
- for (int i = 0; i < DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH; i++) {
+ for (int i = 0; i < BinaryDictionary.DICTIONARY_MAX_WORD_LENGTH; i++) {
stringBuilder.append('a');
}
final String validLongWord = stringBuilder.toString();