aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-10-20 14:48:56 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-10-21 19:28:37 +0900
commit5f00fe09e9a611b647592188316e5999465df4d3 (patch)
tree954a429256171897c7b9ed56a732e386eec76b2b /tests/src/com
parentfa1e65cb3a5dcce6299a6dd067cee95720107307 (diff)
downloadlatinime-5f00fe09e9a611b647592188316e5999465df4d3.tar.gz
latinime-5f00fe09e9a611b647592188316e5999465df4d3.tar.xz
latinime-5f00fe09e9a611b647592188316e5999465df4d3.zip
Fix some compiler warnings
This CL fixes the following compiler warnings. - Indirect access to static member - Access to a non-accessible member of an enclosing type - Parameter assignment - Method can be static - Local variable declaration hides another field or variable - Value of local variable is not used - Unused import - Unused private member - Unnecessary 'else' statement - Unnecessary declaration of throw exception - Redundant type arguments - Missing '@Override' annotation - Unused '@SuppressWarning' annotations Bug: 18003991 Change-Id: Icfebe753e53a2cc621848f769d6a3d7ce501ebc7
Diffstat (limited to 'tests/src/com')
-rw-r--r--tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java67
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java4
-rw-r--r--tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java9
-rw-r--r--tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java16
-rw-r--r--tests/src/com/android/inputmethod/latin/BlueUnderlineTests.java1
-rw-r--r--tests/src/com/android/inputmethod/latin/DictionaryFacilitatorLruCacheTests.java4
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTestsDeadKeys.java2
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java14
-rw-r--r--tests/src/com/android/inputmethod/latin/InputTestsBase.java10
-rw-r--r--tests/src/com/android/inputmethod/latin/NgramContextTests.java15
-rw-r--r--tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java3
-rw-r--r--tests/src/com/android/inputmethod/latin/ShiftModeTests.java4
-rw-r--r--tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java2
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java28
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java17
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java25
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java6
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/FusionDictionary.java23
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java12
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoderTests.java4
-rw-r--r--tests/src/com/android/inputmethod/latin/network/BlockingHttpClientTests.java2
-rw-r--r--tests/src/com/android/inputmethod/latin/personalization/ContextualDictionaryTests.java2
-rw-r--r--tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java6
-rw-r--r--tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java46
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/AsyncResultHolderTests.java4
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/BinaryDictionaryUtilsTests.java8
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/CollectionUtilsTests.java2
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/ResizableIntArrayTests.java6
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/SpannableStringUtilsTests.java7
29 files changed, 171 insertions, 178 deletions
diff --git a/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java b/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java
index 319302c71..67e76464b 100644
--- a/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java
+++ b/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java
@@ -20,7 +20,6 @@ import android.graphics.Typeface;
import android.os.Build;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
-import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.StyleSpan;
@@ -72,141 +71,141 @@ public class LocaleSpanCompatUtilsTests extends AndroidTestCase {
final SpannableString text = new SpannableString("0123456789");
LocaleSpanCompatUtils.updateLocaleSpan(text, 1, 5, Locale.JAPANESE);
assertSpanCount(1, text);
- assertLocaleSpan(text, 0, 1, 5, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 0, 1, 5, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
// Test if only LocaleSpans are updated.
{
final SpannableString text = new SpannableString("0123456789");
final StyleSpan styleSpan = new StyleSpan(Typeface.BOLD);
- text.setSpan(styleSpan, 0, 7, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ text.setSpan(styleSpan, 0, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 1, 5, Locale.JAPANESE);
assertSpanCount(2, text);
assertSpanEquals(styleSpan, text, 0);
- assertLocaleSpan(text, 1, 1, 5, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 1, 1, 5, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
// Test if two jointed spans are merged into one span.
{
final SpannableString text = new SpannableString("0123456789");
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.JAPANESE), 1, 3,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 3, 5, Locale.JAPANESE);
assertSpanCount(1, text);
- assertLocaleSpan(text, 0, 1, 5, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 0, 1, 5, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
// Test if two overlapped spans are merged into one span.
{
final SpannableString text = new SpannableString("0123456789");
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.JAPANESE), 1, 4,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 3, 5, Locale.JAPANESE);
assertSpanCount(1, text);
- assertLocaleSpan(text, 0, 1, 5, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 0, 1, 5, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
// Test if three overlapped spans are merged into one span.
{
final SpannableString text = new SpannableString("0123456789");
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.JAPANESE), 1, 4,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.JAPANESE), 5, 6,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 2, 8, Locale.JAPANESE);
assertSpanCount(1, text);
- assertLocaleSpan(text, 0, 1, 8, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 0, 1, 8, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
// Test if disjoint spans remain disjoint.
{
final SpannableString text = new SpannableString("0123456789");
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.JAPANESE), 1, 3,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.JAPANESE), 5, 6,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 8, 9, Locale.JAPANESE);
assertSpanCount(3, text);
- assertLocaleSpan(text, 0, 1, 3, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- assertLocaleSpan(text, 1, 5, 6, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- assertLocaleSpan(text, 2, 8, 9, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 0, 1, 3, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 1, 5, 6, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 2, 8, 9, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
// Test if existing span flags are preserved during merge.
{
final SpannableString text = new SpannableString("0123456789");
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.JAPANESE), 1, 5,
- Spannable.SPAN_INCLUSIVE_INCLUSIVE | Spannable.SPAN_INTERMEDIATE);
+ Spanned.SPAN_INCLUSIVE_INCLUSIVE | Spanned.SPAN_INTERMEDIATE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 3, 4, Locale.JAPANESE);
assertSpanCount(1, text);
assertLocaleSpan(text, 0, 1, 5, Locale.JAPANESE,
- Spannable.SPAN_INCLUSIVE_INCLUSIVE | Spannable.SPAN_INTERMEDIATE);
+ Spanned.SPAN_INCLUSIVE_INCLUSIVE | Spanned.SPAN_INTERMEDIATE);
}
// Test if existing span flags are preserved even when partially overlapped (leading edge).
{
final SpannableString text = new SpannableString("0123456789");
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.JAPANESE), 1, 5,
- Spannable.SPAN_INCLUSIVE_INCLUSIVE | Spannable.SPAN_INTERMEDIATE);
+ Spanned.SPAN_INCLUSIVE_INCLUSIVE | Spanned.SPAN_INTERMEDIATE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 3, 7, Locale.JAPANESE);
assertSpanCount(1, text);
assertLocaleSpan(text, 0, 1, 7, Locale.JAPANESE,
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE | Spannable.SPAN_INTERMEDIATE);
+ Spanned.SPAN_INCLUSIVE_EXCLUSIVE | Spanned.SPAN_INTERMEDIATE);
}
// Test if existing span flags are preserved even when partially overlapped (trailing edge).
{
final SpannableString text = new SpannableString("0123456789");
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.JAPANESE), 3, 7,
- Spannable.SPAN_INCLUSIVE_INCLUSIVE | Spannable.SPAN_INTERMEDIATE);
+ Spanned.SPAN_INCLUSIVE_INCLUSIVE | Spanned.SPAN_INTERMEDIATE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 1, 5, Locale.JAPANESE);
assertSpanCount(1, text);
assertLocaleSpan(text, 0, 1, 7, Locale.JAPANESE,
- Spannable.SPAN_EXCLUSIVE_INCLUSIVE | Spannable.SPAN_INTERMEDIATE);
+ Spanned.SPAN_EXCLUSIVE_INCLUSIVE | Spanned.SPAN_INTERMEDIATE);
}
// Test if existing locale span will be removed when the locale doesn't match.
{
final SpannableString text = new SpannableString("0123456789");
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.ENGLISH), 3, 5,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 1, 7, Locale.JAPANESE);
assertSpanCount(1, text);
- assertLocaleSpan(text, 0, 1, 7, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 0, 1, 7, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
// Test if existing locale span will be removed when the locale doesn't match. (case 2)
{
final SpannableString text = new SpannableString("0123456789");
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.ENGLISH), 3, 7,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 5, 6, Locale.JAPANESE);
assertSpanCount(3, text);
- assertLocaleSpan(text, 0, 3, 5, Locale.ENGLISH, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- assertLocaleSpan(text, 1, 6, 7, Locale.ENGLISH, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- assertLocaleSpan(text, 2, 5, 6, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 0, 3, 5, Locale.ENGLISH, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 1, 6, 7, Locale.ENGLISH, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 2, 5, 6, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
// Test if existing locale span will be removed when the locale doesn't match. (case 3)
{
final SpannableString text = new SpannableString("0123456789");
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.ENGLISH), 3, 7,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 2, 5, Locale.JAPANESE);
assertSpanCount(2, text);
- assertLocaleSpan(text, 0, 5, 7, Locale.ENGLISH, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- assertLocaleSpan(text, 1, 2, 5, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 0, 5, 7, Locale.ENGLISH, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 1, 2, 5, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
// Test if existing locale span will be removed when the locale doesn't match. (case 3)
{
final SpannableString text = new SpannableString("0123456789");
text.setSpan(LocaleSpanCompatUtils.newLocaleSpan(Locale.ENGLISH), 3, 7,
- Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
LocaleSpanCompatUtils.updateLocaleSpan(text, 5, 8, Locale.JAPANESE);
assertSpanCount(2, text);
- assertLocaleSpan(text, 0, 3, 5, Locale.ENGLISH, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- assertLocaleSpan(text, 1, 5, 8, Locale.JAPANESE, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 0, 3, 5, Locale.ENGLISH, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ assertLocaleSpan(text, 1, 5, 8, Locale.JAPANESE, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
}
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java b/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java
index 6c0d74941..ffef91181 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java
@@ -78,6 +78,7 @@ public final class MoreKeySpecTests extends KeySpecParserTestsBase {
assertArrayEquals(message, expected, actual);
}
+ @SuppressWarnings("static-method")
public void testEmptyEntry() {
assertInsertAdditionalMoreKeys("null more keys and null additons",
null,
@@ -106,6 +107,7 @@ public final class MoreKeySpecTests extends KeySpecParserTestsBase {
new String[] { "a", "A", "b", "B", "c", "d" });
}
+ @SuppressWarnings("static-method")
public void testInsertAdditionalMoreKeys() {
// Escaped marker.
assertInsertAdditionalMoreKeys("escaped marker",
@@ -306,6 +308,7 @@ public final class MoreKeySpecTests extends KeySpecParserTestsBase {
assertArrayEquals(message, expected, actual);
}
+ @SuppressWarnings("static-method")
public void testGetBooleanValue() {
assertGetBooleanValue("Has label", HAS_LABEL,
new String[] { HAS_LABEL, "a", "b", "c" },
@@ -345,6 +348,7 @@ public final class MoreKeySpecTests extends KeySpecParserTestsBase {
assertArrayEquals(message, expected, actual);
}
+ @SuppressWarnings("static-method")
public void testGetIntValue() {
assertGetIntValue("Fixed column order 3", FIXED_COLUMN_ORDER, -1,
new String[] { FIXED_COLUMN_ORDER + "3", "a", "b", "c" },
diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java
index 83e523c3c..07622c1f3 100644
--- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java
+++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java
@@ -174,13 +174,12 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
if (BinaryDictionaryUtils.createEmptyDictFile(file.getAbsolutePath(), formatVersion,
LocaleUtils.constructLocaleFromString(TEST_LOCALE), attributeMap)) {
return file;
- } else {
- throw new IOException("Empty dictionary " + file.getAbsolutePath()
- + " cannot be created. Foramt version: " + formatVersion);
}
+ throw new IOException("Empty dictionary " + file.getAbsolutePath()
+ + " cannot be created. Foramt version: " + formatVersion);
}
- private BinaryDictionary getBinaryDictionary(final File dictFile) {
+ private static BinaryDictionary getBinaryDictionary(final File dictFile) {
return new BinaryDictionary(dictFile.getAbsolutePath(),
0 /* offset */, dictFile.length(), true /* useFullEditDistance */,
Locale.getDefault(), TEST_LOCALE, true /* isUpdatable */);
@@ -683,7 +682,7 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
final BinaryDictionary binaryDictionary = getBinaryDictionary(dictFile);
binaryDictionary.addUnigramEntry("", DUMMY_PROBABILITY, "" /* shortcutTarget */,
- BinaryDictionary.NOT_A_PROBABILITY /* shortcutProbability */,
+ Dictionary.NOT_A_PROBABILITY /* shortcutProbability */,
true /* isBeginningOfSentence */, true /* isNotAWord */,
false /* isPossiblyOffensive */, mCurrentTime);
final NgramContext beginningOfSentenceContext = NgramContext.BEGINNING_OF_SENTENCE;
diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
index 0a1f5a326..5d6378937 100644
--- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
@@ -111,13 +111,12 @@ public class BinaryDictionaryTests extends AndroidTestCase {
if (BinaryDictionaryUtils.createEmptyDictFile(file.getAbsolutePath(), formatVersion,
Locale.ENGLISH, attributeMap)) {
return file;
- } else {
- throw new IOException("Empty dictionary " + file.getAbsolutePath()
- + " cannot be created. Format version: " + formatVersion);
}
+ throw new IOException("Empty dictionary " + file.getAbsolutePath()
+ + " cannot be created. Format version: " + formatVersion);
}
- private BinaryDictionary getBinaryDictionary(final File dictFile) {
+ private static BinaryDictionary getBinaryDictionary(final File dictFile) {
return new BinaryDictionary(dictFile.getAbsolutePath(),
0 /* offset */, dictFile.length(), true /* useFullEditDistance */,
Locale.getDefault(), TEST_LOCALE, true /* isUpdatable */);
@@ -211,15 +210,14 @@ public class BinaryDictionaryTests extends AndroidTestCase {
assertEquals(probability, binaryDictionary.getFrequency("aaa"));
assertEquals(updatedProbability, binaryDictionary.getFrequency(validLongWord));
- assertEquals(BinaryDictionary.NOT_A_PROBABILITY,
- binaryDictionary.getFrequency(invalidLongWord));
+ assertEquals(Dictionary.NOT_A_PROBABILITY, binaryDictionary.getFrequency(invalidLongWord));
assertEquals(updatedProbability, binaryDictionary.getFrequency("abc"));
}
private static void addUnigramWord(final BinaryDictionary binaryDictionary, final String word,
final int probability) {
binaryDictionary.addUnigramEntry(word, probability, "" /* shortcutTarget */,
- BinaryDictionary.NOT_A_PROBABILITY /* shortcutProbability */,
+ Dictionary.NOT_A_PROBABILITY /* shortcutProbability */,
false /* isBeginningOfSentence */, false /* isNotAWord */,
false /* isPossiblyOffensive */,
BinaryDictionary.NOT_A_VALID_TIMESTAMP /* timestamp */);
@@ -975,7 +973,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
final boolean isPossiblyOffensive = random.nextBoolean();
// TODO: Add tests for historical info.
binaryDictionary.addUnigramEntry(word, unigramProbability,
- null /* shortcutTarget */, BinaryDictionary.NOT_A_PROBABILITY,
+ null /* shortcutTarget */, Dictionary.NOT_A_PROBABILITY,
false /* isBeginningOfSentence */, isNotAWord, isPossiblyOffensive,
BinaryDictionary.NOT_A_VALID_TIMESTAMP);
if (binaryDictionary.needsToRunGC(false /* mindsBlockByGC */)) {
@@ -1264,7 +1262,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
WordProperty wordProperty = binaryDictionary.getWordProperty("ddd", false);
assertEquals(true, wordProperty.mIsPossiblyOffensive);
}
-
+
public void testDictMigration() {
for (final int formatVersion : DICT_FORMAT_VERSIONS) {
testDictMigration(FormatSpec.VERSION4_ONLY_FOR_TESTING, formatVersion);
diff --git a/tests/src/com/android/inputmethod/latin/BlueUnderlineTests.java b/tests/src/com/android/inputmethod/latin/BlueUnderlineTests.java
index ae5cc5c73..5146ea873 100644
--- a/tests/src/com/android/inputmethod/latin/BlueUnderlineTests.java
+++ b/tests/src/com/android/inputmethod/latin/BlueUnderlineTests.java
@@ -61,7 +61,6 @@ public class BlueUnderlineTests extends InputTestsBase {
public void testBlueUnderlineOnBackspace() {
final String STRING_TO_TYPE = "tgis";
final int typedLength = STRING_TO_TYPE.length();
- final int EXPECTED_SUGGESTION_SPAN_START = -1;
final int EXPECTED_UNDERLINE_SPAN_START = 0;
final int EXPECTED_UNDERLINE_SPAN_END = 3;
type(STRING_TO_TYPE);
diff --git a/tests/src/com/android/inputmethod/latin/DictionaryFacilitatorLruCacheTests.java b/tests/src/com/android/inputmethod/latin/DictionaryFacilitatorLruCacheTests.java
index ed3929dc7..3ad659a99 100644
--- a/tests/src/com/android/inputmethod/latin/DictionaryFacilitatorLruCacheTests.java
+++ b/tests/src/com/android/inputmethod/latin/DictionaryFacilitatorLruCacheTests.java
@@ -47,7 +47,7 @@ public class DictionaryFacilitatorLruCacheTests extends AndroidTestCase {
getContext(), MAX_CACHE_SIZE_LARGE, ""));
}
- private void testGetFacilitator(final DictionaryFacilitatorLruCache cache) {
+ private static void testGetFacilitator(final DictionaryFacilitatorLruCache cache) {
final DictionaryFacilitator dictionaryFacilitatorEnUs = cache.get(Locale.US);
assertNotNull(dictionaryFacilitatorEnUs);
assertTrue(dictionaryFacilitatorEnUs.isForLocales(new Locale[] { Locale.US }));
@@ -68,7 +68,7 @@ public class DictionaryFacilitatorLruCacheTests extends AndroidTestCase {
getContext(), MAX_CACHE_SIZE_LARGE, ""));
}
- private void testSetUseContactsDictionary(final DictionaryFacilitatorLruCache cache) {
+ private static void testSetUseContactsDictionary(final DictionaryFacilitatorLruCache cache) {
assertNull(cache.get(Locale.US).getSubDictForTesting(Dictionary.TYPE_CONTACTS));
cache.setUseContactsDictionary(true /* useContactsDictionary */);
assertNotNull(cache.get(Locale.US).getSubDictForTesting(Dictionary.TYPE_CONTACTS));
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTestsDeadKeys.java b/tests/src/com/android/inputmethod/latin/InputLogicTestsDeadKeys.java
index afe7dbe70..f9ab1acf8 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTestsDeadKeys.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTestsDeadKeys.java
@@ -25,7 +25,7 @@ import java.util.ArrayList;
@LargeTest
public class InputLogicTestsDeadKeys extends InputTestsBase {
// A helper class for readability
- private static class EventList extends ArrayList<Event> {
+ static class EventList extends ArrayList<Event> {
public EventList addCodePoint(final int codePoint, final boolean isDead) {
final Event event;
if (isDead) {
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java b/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java
index ab69c8592..1372514da 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java
@@ -80,7 +80,6 @@ import android.util.Pair;
@LargeTest
// These tests are inactive until the combining code for Myanmar Reordering is sorted out.
@Suppress
-@SuppressWarnings("rawtypes")
public class InputLogicTestsReorderingMyanmar extends InputTestsBase {
// The tests are formatted as follows.
// Each test is an entry in the array of Pair arrays.
@@ -90,7 +89,7 @@ public class InputLogicTestsReorderingMyanmar extends InputTestsBase {
// member is stored the string that should be in the text view after this
// key press.
- private static final Pair[][] TESTS = {
+ private static final Pair<?, ?>[][] TESTS = {
// Tests for U+1031 MYANMAR VOWEL SIGN E : ေ
new Pair[] { // Type : U+1031 U+1000 U+101F ေ က ဟ
@@ -206,13 +205,12 @@ public class InputLogicTestsReorderingMyanmar extends InputTestsBase {
*/
};
- @SuppressWarnings("unchecked")
- private void doMyanmarTest(final int testNumber, final Pair[] test) {
+ private void doMyanmarTest(final int testNumber, final Pair<?, ?>[] test) {
int stepNumber = 0;
- for (final Pair<int[], String> step : test) {
+ for (final Pair<?, ?> step : test) {
++stepNumber;
- final int[] input = step.first;
- final String expectedResult = step.second;
+ final int[] input = (int[]) step.first;
+ final String expectedResult = (String) step.second;
if (input.length > 1) {
mLatinIME.onTextInput(new String(input, 0, input.length));
} else {
@@ -226,7 +224,7 @@ public class InputLogicTestsReorderingMyanmar extends InputTestsBase {
public void testMyanmarReordering() {
int testNumber = 0;
changeLanguage("my_MM", "CombiningRules=MyanmarReordering");
- for (final Pair[] test : TESTS) {
+ for (final Pair<?, ?>[] test : TESTS) {
// Small trick to reset LatinIME : setText("") and send updateSelection with values
// LatinIME has never seen, and cursor pos 0,0.
mEditText.setText("");
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
index dd900a22c..f58dad9e6 100644
--- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
@@ -40,7 +40,6 @@ import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
import com.android.inputmethod.event.Event;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
-import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.Dictionary.PhonyDictionary;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.settings.DebugSettings;
@@ -250,7 +249,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
// Now, Looper#loop() never exits in normal operation unless the Looper#quit() method
// is called, which has a lot of bad side effects. We can however just throw an exception
// in the runnable which will unwind the stack and allow us to exit.
- private final class InterruptRunMessagesException extends RuntimeException {
+ final class InterruptRunMessagesException extends RuntimeException {
// Empty class
}
protected void runMessages() {
@@ -284,7 +283,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
} else {
final int x = key.getX() + key.getWidth() / 2;
final int y = key.getY() + key.getHeight() / 2;
- event = mLatinIME.createSoftwareKeypressEvent(codePoint, x, y, isKeyRepeat);
+ event = LatinIME.createSoftwareKeypressEvent(codePoint, x, y, isKeyRepeat);
}
mLatinIME.onEvent(event);
// Also see the comment at the top of this function about onReleaseKey
@@ -309,9 +308,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
final Key key = mKeyboard.getKey(codePoint);
if (key == null) {
throw new RuntimeException("Code point not on the keyboard");
- } else {
- return new Point(key.getX() + key.getWidth() / 2, key.getY() + key.getHeight() / 2);
}
+ return new Point(key.getX() + key.getWidth() / 2, key.getY() + key.getHeight() / 2);
}
protected void gesture(final String stringToGesture) {
@@ -386,7 +384,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
false /* isAuxiliary */,
false /* overridesImplicitlyEnabledSubtype */,
0 /* id */);
- SubtypeSwitcher.getInstance().forceSubtype(subtype);
+ SubtypeSwitcher.forceSubtype(subtype);
mLatinIME.onCurrentInputMethodSubtypeChanged(subtype);
runMessages();
mKeyboard = mLatinIME.mKeyboardSwitcher.getKeyboard();
diff --git a/tests/src/com/android/inputmethod/latin/NgramContextTests.java b/tests/src/com/android/inputmethod/latin/NgramContextTests.java
index ecc2c634d..ab1819d0b 100644
--- a/tests/src/com/android/inputmethod/latin/NgramContextTests.java
+++ b/tests/src/com/android/inputmethod/latin/NgramContextTests.java
@@ -25,8 +25,8 @@ import android.test.suitebuilder.annotation.SmallTest;
public class NgramContextTests extends AndroidTestCase {
public void testConstruct() {
assertEquals(new NgramContext(new WordInfo("a")), new NgramContext(new WordInfo("a")));
- assertEquals(new NgramContext(WordInfo.BEGINNING_OF_SENTENCE),
- new NgramContext(WordInfo.BEGINNING_OF_SENTENCE));
+ assertEquals(new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO),
+ new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO));
assertEquals(new NgramContext(WordInfo.EMPTY_WORD_INFO),
new NgramContext(WordInfo.EMPTY_WORD_INFO));
assertEquals(new NgramContext(WordInfo.EMPTY_WORD_INFO),
@@ -35,17 +35,18 @@ public class NgramContextTests extends AndroidTestCase {
public void testIsBeginningOfSentenceContext() {
assertFalse(new NgramContext().isBeginningOfSentenceContext());
- assertTrue(new NgramContext(WordInfo.BEGINNING_OF_SENTENCE)
+ assertTrue(new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO)
.isBeginningOfSentenceContext());
assertTrue(NgramContext.BEGINNING_OF_SENTENCE.isBeginningOfSentenceContext());
assertFalse(new NgramContext(new WordInfo("a")).isBeginningOfSentenceContext());
assertFalse(new NgramContext(new WordInfo("")).isBeginningOfSentenceContext());
assertFalse(new NgramContext(WordInfo.EMPTY_WORD_INFO).isBeginningOfSentenceContext());
- assertTrue(new NgramContext(WordInfo.BEGINNING_OF_SENTENCE, new WordInfo("a"))
+ assertTrue(new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO, new WordInfo("a"))
.isBeginningOfSentenceContext());
- assertFalse(new NgramContext(new WordInfo("a"), WordInfo.BEGINNING_OF_SENTENCE)
+ assertFalse(new NgramContext(new WordInfo("a"), WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO)
.isBeginningOfSentenceContext());
- assertFalse(new NgramContext(WordInfo.EMPTY_WORD_INFO, WordInfo.BEGINNING_OF_SENTENCE)
+ assertFalse(new NgramContext(
+ WordInfo.EMPTY_WORD_INFO, WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO)
.isBeginningOfSentenceContext());
}
@@ -56,7 +57,7 @@ public class NgramContextTests extends AndroidTestCase {
assertEquals("b", ngramContext_b_a.getNthPrevWord(1));
assertEquals("a", ngramContext_b_a.getNthPrevWord(2));
final NgramContext ngramContext_bos_b =
- ngramContext_b_a.getNextNgramContext(WordInfo.BEGINNING_OF_SENTENCE);
+ ngramContext_b_a.getNextNgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO);
assertTrue(ngramContext_bos_b.isBeginningOfSentenceContext());
assertEquals("b", ngramContext_bos_b.getNthPrevWord(2));
final NgramContext ngramContext_c_bos =
diff --git a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java
index 7a3233625..28c41f23f 100644
--- a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java
+++ b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java
@@ -136,7 +136,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
}
}
- private class MockInputMethodService extends InputMethodService {
+ static class MockInputMethodService extends InputMethodService {
private MockConnection mMockConnection;
public void setInputConnection(final MockConnection mockConnection) {
mMockConnection = mockConnection;
@@ -221,7 +221,6 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
mSpacingAndPunctuations, new int[] { Constants.CODE_SPACE });
final SpacingAndPunctuations TAB = new SpacingAndPunctuations(
mSpacingAndPunctuations, new int[] { Constants.CODE_TAB });
- final int[] SPACE_TAB = StringUtils.toSortedCodePointArray(" \t");
// A character that needs surrogate pair to represent its code point (U+2008A).
final String SUPPLEMENTARY_CHAR_STRING = "\uD840\uDC8A";
final SpacingAndPunctuations SUPPLEMENTARY_CHAR = new SpacingAndPunctuations(
diff --git a/tests/src/com/android/inputmethod/latin/ShiftModeTests.java b/tests/src/com/android/inputmethod/latin/ShiftModeTests.java
index 8ba0174b5..a445f61b2 100644
--- a/tests/src/com/android/inputmethod/latin/ShiftModeTests.java
+++ b/tests/src/com/android/inputmethod/latin/ShiftModeTests.java
@@ -16,14 +16,10 @@
package com.android.inputmethod.latin;
-import android.os.Build;
import android.test.suitebuilder.annotation.LargeTest;
import android.text.TextUtils;
import android.view.inputmethod.EditorInfo;
-import com.android.inputmethod.latin.Constants;
-import com.android.inputmethod.latin.WordComposer;
-
@LargeTest
public class ShiftModeTests extends InputTestsBase {
diff --git a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
index 221541e4a..90db75e39 100644
--- a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
+++ b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
@@ -60,7 +60,7 @@ public class SuggestedWordsTests extends AndroidTestCase {
}
// Helper for testGetTransformedWordInfo
- private SuggestedWordInfo transformWordInfo(final String info,
+ private static SuggestedWordInfo transformWordInfo(final String info,
final int trailingSingleQuotesCount) {
final SuggestedWordInfo suggestedWordInfo = createTypedWordInfo(info);
final SuggestedWordInfo returnedWordInfo =
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java
index 05616d888..d1cb14196 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java
@@ -117,7 +117,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
super.tearDown();
}
- private void generateWords(final int number, final Random random) {
+ private static void generateWords(final int number, final Random random) {
final int[] codePointSet = CodePointUtils.generateCodePointSet(DEFAULT_CODE_POINT_SET_SIZE,
random);
final Set<String> wordSet = new HashSet<>();
@@ -138,7 +138,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
/**
* Adds unigrams to the dictionary.
*/
- private void addUnigrams(final int number, final FusionDictionary dict,
+ private static void addUnigrams(final int number, final FusionDictionary dict,
final List<String> words, final HashMap<String, List<String>> shortcutMap) {
for (int i = 0; i < number; ++i) {
final String word = words.get(i);
@@ -154,7 +154,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
}
}
- private void addBigrams(final FusionDictionary dict,
+ private static void addBigrams(final FusionDictionary dict,
final List<String> words,
final SparseArray<List<Integer>> bigrams) {
for (int i = 0; i < bigrams.size(); ++i) {
@@ -173,7 +173,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
// new java.io.FileWriter(new File(filename)), dict);
// }
- private long timeWritingDictToFile(final File file, final FusionDictionary dict,
+ private static long timeWritingDictToFile(final File file, final FusionDictionary dict,
final FormatSpec.FormatOptions formatOptions) {
long now = -1, diff = -1;
@@ -196,7 +196,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
return diff;
}
- private void checkDictionary(final FusionDictionary dict, final List<String> words,
+ private static void checkDictionary(final FusionDictionary dict, final List<String> words,
final SparseArray<List<Integer>> bigrams,
final HashMap<String, List<String>> shortcutMap) {
assertNotNull(dict);
@@ -231,16 +231,16 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
}
}
- private String outputOptions(final int bufferType,
+ private static String outputOptions(final int bufferType,
final FormatSpec.FormatOptions formatOptions) {
- String result = " : buffer type = "
+ final String result = " : buffer type = "
+ ((bufferType == BinaryDictUtils.USE_BYTE_BUFFER) ? "byte buffer" : "byte array");
return result + " : version = " + formatOptions.mVersion;
}
// Tests for readDictionaryBinary and writeDictionaryBinary
- private long timeReadingAndCheckDict(final File file, final List<String> words,
+ private static long timeReadingAndCheckDict(final File file, final List<String> words,
final SparseArray<List<Integer>> bigrams,
final HashMap<String, List<String>> shortcutMap, final int bufferType) {
long now, diff = -1;
@@ -385,7 +385,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
// Tests for readUnigramsAndBigramsBinary
- private void checkWordMap(final List<String> expectedWords,
+ private static void checkWordMap(final List<String> expectedWords,
final SparseArray<List<Integer>> expectedBigrams,
final TreeMap<Integer, String> resultWords,
final TreeMap<Integer, Integer> resultFrequencies,
@@ -434,9 +434,9 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
assertEquals(actBigrams, expBigrams);
}
- private long timeAndCheckReadUnigramsAndBigramsBinary(final File file, final List<String> words,
- final SparseArray<List<Integer>> bigrams, final int bufferType,
- final boolean checkProbability) {
+ private static long timeAndCheckReadUnigramsAndBigramsBinary(final File file,
+ final List<String> words, final SparseArray<List<Integer>> bigrams,
+ final int bufferType, final boolean checkProbability) {
final TreeMap<Integer, String> resultWords = new TreeMap<>();
final TreeMap<Integer, ArrayList<PendingAttribute>> resultBigrams = new TreeMap<>();
final TreeMap<Integer, Integer> resultFreqs = new TreeMap<>();
@@ -519,7 +519,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
}
// Tests for getTerminalPosition
- private String getWordFromBinary(final DictDecoder dictDecoder, final int address) {
+ private static String getWordFromBinary(final DictDecoder dictDecoder, final int address) {
if (dictDecoder.getPosition() != 0) dictDecoder.setPosition(0);
DictionaryHeader fileHeader = null;
@@ -535,7 +535,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
address).mWord;
}
- private long checkGetTerminalPosition(final DictDecoder dictDecoder, final String word,
+ private static long checkGetTerminalPosition(final DictDecoder dictDecoder, final String word,
final boolean contained) {
long diff = -1;
int position = -1;
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java
index 1f3ee19af..21411f24c 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java
@@ -113,15 +113,16 @@ public final class BinaryDictDecoderUtils {
/**
* Helper method to find out whether this code fits on one byte
*/
- private static boolean fitsOnOneByte(int character,
+ private static boolean fitsOnOneByte(final int character,
final HashMap<Integer, Integer> codePointToOneByteCodeMap) {
+ int codePoint = character;
if (codePointToOneByteCodeMap != null) {
if (codePointToOneByteCodeMap.containsKey(character)) {
- character = codePointToOneByteCodeMap.get(character);
+ codePoint = codePointToOneByteCodeMap.get(character);
}
}
- return character >= FormatSpec.MINIMAL_ONE_BYTE_CHARACTER_VALUE
- && character <= FormatSpec.MAXIMAL_ONE_BYTE_CHARACTER_VALUE;
+ return codePoint >= FormatSpec.MINIMAL_ONE_BYTE_CHARACTER_VALUE
+ && codePoint <= FormatSpec.MAXIMAL_ONE_BYTE_CHARACTER_VALUE;
}
/**
@@ -168,8 +169,9 @@ public final class BinaryDictDecoderUtils {
* @param codePointToOneByteCodeMap the map to convert the code point.
* @return the index after the last character.
*/
- static int writeCharArray(final int[] codePoints, final byte[] buffer, int index,
+ static int writeCharArray(final int[] codePoints, final byte[] buffer, final int fromIndex,
final HashMap<Integer, Integer> codePointToOneByteCodeMap) {
+ int index = fromIndex;
for (int codePoint : codePoints) {
if (codePointToOneByteCodeMap != null) {
if (codePointToOneByteCodeMap.containsKey(codePoint)) {
@@ -293,10 +295,9 @@ public final class BinaryDictDecoderUtils {
final int msb = dictBuffer.readUnsignedByte();
if (FormatSpec.MAX_PTNODES_FOR_ONE_BYTE_PTNODE_COUNT >= msb) {
return msb;
- } else {
- return ((FormatSpec.MAX_PTNODES_FOR_ONE_BYTE_PTNODE_COUNT & msb) << 8)
- + dictBuffer.readUnsignedByte();
}
+ return ((FormatSpec.MAX_PTNODES_FOR_ONE_BYTE_PTNODE_COUNT & msb) << 8)
+ + dictBuffer.readUnsignedByte();
}
/**
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java
index 09bf22117..a3a71a45e 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java
@@ -199,8 +199,9 @@ public class BinaryDictEncoderUtils {
}
}
- static int writeUIntToBuffer(final byte[] buffer, int position, final int value,
+ static int writeUIntToBuffer(final byte[] buffer, final int fromPosition, final int value,
final int size) {
+ int position = fromPosition;
switch(size) {
case 4:
buffer[position++] = (byte) ((value >> 24) & 0xFF);
@@ -324,11 +325,9 @@ public class BinaryDictEncoderUtils {
return targetNodeArray.mCachedAddressAfterUpdate
- (currentNodeArray.mCachedAddressAfterUpdate
+ offsetFromStartOfCurrentNodeArray);
- } else {
- return targetNodeArray.mCachedAddressBeforeUpdate
- - (currentNodeArray.mCachedAddressBeforeUpdate
- + offsetFromStartOfCurrentNodeArray);
}
+ return targetNodeArray.mCachedAddressBeforeUpdate
+ - (currentNodeArray.mCachedAddressBeforeUpdate + offsetFromStartOfCurrentNodeArray);
}
/**
@@ -356,9 +355,8 @@ public class BinaryDictEncoderUtils {
final int newOffsetBasePoint = currentNodeArray.mCachedAddressAfterUpdate
+ offsetFromStartOfCurrentNodeArray;
return targetPtNode.mCachedAddressAfterUpdate - newOffsetBasePoint;
- } else {
- return targetPtNode.mCachedAddressBeforeUpdate - oldOffsetBasePoint;
}
+ return targetPtNode.mCachedAddressBeforeUpdate - oldOffsetBasePoint;
}
/**
@@ -541,8 +539,9 @@ public class BinaryDictEncoderUtils {
* @param position the position to write.
* @return the size in bytes the address actually took.
*/
- /* package */ static int writeChildrenPosition(final byte[] buffer, int index,
+ /* package */ static int writeChildrenPosition(final byte[] buffer, final int fromIndex,
final int position) {
+ int index = fromIndex;
switch (getByteSize(position)) {
case 1:
buffer[index++] = (byte)position;
@@ -623,7 +622,7 @@ public class BinaryDictEncoderUtils {
* @return the flags
*/
/* package */ static final int makeBigramFlags(final boolean more, final int offset,
- int bigramFrequency, final int unigramFrequency, final String word) {
+ final int bigramFrequency, final int unigramFrequency, final String word) {
int bigramFlags = (more ? FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_HAS_NEXT : 0)
+ (offset < 0 ? FormatSpec.FLAG_BIGRAM_ATTR_OFFSET_NEGATIVE : 0);
switch (getByteSize(offset)) {
@@ -639,13 +638,16 @@ public class BinaryDictEncoderUtils {
default:
throw new RuntimeException("Strange offset size");
}
+ final int frequency;
if (unigramFrequency > bigramFrequency) {
MakedictLog.e("Unigram freq is superior to bigram freq for \"" + word
+ "\". Bigram freq is " + bigramFrequency + ", unigram freq for "
+ word + " is " + unigramFrequency);
- bigramFrequency = unigramFrequency;
+ frequency = unigramFrequency;
+ } else {
+ frequency = bigramFrequency;
}
- bigramFlags += getBigramFrequencyDiff(unigramFrequency, bigramFrequency)
+ bigramFlags += getBigramFrequencyDiff(unigramFrequency, frequency)
& FormatSpec.FLAG_BIGRAM_SHORTCUT_ATTR_FREQUENCY;
return bigramFlags;
}
@@ -722,7 +724,6 @@ public class BinaryDictEncoderUtils {
* @param ptNodeArray the node array to write.
* @param codePointToOneByteCodeMap the map to convert the code points.
*/
- @SuppressWarnings("unused")
/* package */ static void writePlacedPtNodeArray(final FusionDictionary dict,
final DictEncoder dictEncoder, final PtNodeArray ptNodeArray,
final HashMap<Integer, Integer> codePointToOneByteCodeMap) {
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java
index 9c3b37387..5e90387f7 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java
@@ -206,11 +206,7 @@ public final class BinaryDictIOUtils {
if (same) {
// found the PtNode matches the word.
if (wordPos + currentInfo.mCharacters.length == wordLen) {
- if (!currentInfo.isTerminal()) {
- return FormatSpec.NOT_VALID_WORD;
- } else {
- return ptNodePos;
- }
+ return currentInfo.isTerminal() ? ptNodePos : FormatSpec.NOT_VALID_WORD;
}
wordPos += currentInfo.mCharacters.length;
if (currentInfo.mChildrenAddress == FormatSpec.NO_CHILDREN_ADDRESS) {
diff --git a/tests/src/com/android/inputmethod/latin/makedict/FusionDictionary.java b/tests/src/com/android/inputmethod/latin/makedict/FusionDictionary.java
index ea5bc5640..5581d68b8 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/FusionDictionary.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/FusionDictionary.java
@@ -142,11 +142,7 @@ public final class FusionDictionary implements Iterable<WordProperty> {
}
public int getProbability() {
- if (isTerminal()) {
- return mProbabilityInfo.mProbability;
- } else {
- return NOT_A_TERMINAL;
- }
+ return isTerminal() ? mProbabilityInfo.mProbability : NOT_A_TERMINAL;
}
public boolean getIsNotAWord() {
@@ -235,7 +231,7 @@ public final class FusionDictionary implements Iterable<WordProperty> {
* the existing ones if any. Note: unigram, bigram, and shortcut frequencies are only
* updated if they are higher than the existing ones.
*/
- private void update(final ProbabilityInfo probabilityInfo,
+ void update(final ProbabilityInfo probabilityInfo,
final ArrayList<WeightedString> shortcutTargets,
final ArrayList<WeightedString> bigrams,
final boolean isNotAWord, final boolean isPossiblyOffensive) {
@@ -337,15 +333,15 @@ public final class FusionDictionary implements Iterable<WordProperty> {
* This method checks that all PtNodes in a node array are ordered as expected.
* If they are, nothing happens. If they aren't, an exception is thrown.
*/
- private void checkStack(PtNodeArray ptNodeArray) {
+ private static void checkStack(PtNodeArray ptNodeArray) {
ArrayList<PtNode> stack = ptNodeArray.mData;
int lastValue = -1;
for (int i = 0; i < stack.size(); ++i) {
int currentValue = stack.get(i).mChars[0];
- if (currentValue <= lastValue)
+ if (currentValue <= lastValue) {
throw new RuntimeException("Invalid stack");
- else
- lastValue = currentValue;
+ }
+ lastValue = currentValue;
}
}
@@ -521,14 +517,14 @@ public final class FusionDictionary implements Iterable<WordProperty> {
* is ignored.
* This comparator imposes orderings that are inconsistent with equals.
*/
- static private final class PtNodeComparator implements java.util.Comparator<PtNode> {
+ static final class PtNodeComparator implements java.util.Comparator<PtNode> {
@Override
public int compare(PtNode p1, PtNode p2) {
if (p1.mChars[0] == p2.mChars[0]) return 0;
return p1.mChars[0] < p2.mChars[0] ? -1 : 1;
}
}
- final static private PtNodeComparator PTNODE_COMPARATOR = new PtNodeComparator();
+ final static PtNodeComparator PTNODE_COMPARATOR = new PtNodeComparator();
/**
* Finds the insertion index of a character within a node array.
@@ -559,7 +555,8 @@ public final class FusionDictionary implements Iterable<WordProperty> {
/**
* Helper method to find a word in a given branch.
*/
- public static PtNode findWordInTree(PtNodeArray nodeArray, final String string) {
+ public static PtNode findWordInTree(final PtNodeArray rootNodeArray, final String string) {
+ PtNodeArray nodeArray = rootNodeArray;
int index = 0;
final StringBuilder checker = DBG ? new StringBuilder() : null;
final int[] codePoints = getCodePoints(string);
diff --git a/tests/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java b/tests/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java
index 7894f0b1d..457e7af8e 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java
@@ -36,17 +36,17 @@ public class Ver2DictDecoder extends AbstractDictDecoder {
/**
* A utility class for reading a PtNode.
*/
- protected static class PtNodeReader {
- private static ProbabilityInfo readProbabilityInfo(final DictBuffer dictBuffer) {
+ static class PtNodeReader {
+ static ProbabilityInfo readProbabilityInfo(final DictBuffer dictBuffer) {
// Ver2 dicts don't contain historical information.
return new ProbabilityInfo(dictBuffer.readUnsignedByte());
}
- protected static int readPtNodeOptionFlags(final DictBuffer dictBuffer) {
+ static int readPtNodeOptionFlags(final DictBuffer dictBuffer) {
return dictBuffer.readUnsignedByte();
}
- protected static int readChildrenAddress(final DictBuffer dictBuffer,
+ static int readChildrenAddress(final DictBuffer dictBuffer,
final int ptNodeFlags) {
switch (ptNodeFlags & FormatSpec.MASK_CHILDREN_ADDRESS_TYPE) {
case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_ONEBYTE:
@@ -62,7 +62,7 @@ public class Ver2DictDecoder extends AbstractDictDecoder {
}
// Reads shortcuts and returns the read length.
- protected static int readShortcut(final DictBuffer dictBuffer,
+ static int readShortcut(final DictBuffer dictBuffer,
final ArrayList<WeightedString> shortcutTargets) {
final int pointerBefore = dictBuffer.position();
dictBuffer.readUnsignedShort(); // skip the size
@@ -76,7 +76,7 @@ public class Ver2DictDecoder extends AbstractDictDecoder {
return dictBuffer.position() - pointerBefore;
}
- protected static int readBigramAddresses(final DictBuffer dictBuffer,
+ static int readBigramAddresses(final DictBuffer dictBuffer,
final ArrayList<PendingAttribute> bigrams, final int baseAddress) {
int readLength = 0;
int bigramCount = 0;
diff --git a/tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoderTests.java b/tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoderTests.java
index 988cd3748..7d858760e 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoderTests.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoderTests.java
@@ -27,14 +27,12 @@ import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
/**
* Unit tests for Ver2DictEncoder
*/
@LargeTest
public class Ver2DictEncoderTests extends AndroidTestCase {
- private static final String TAG = Ver2DictEncoderTests.class.getSimpleName();
private static final int UNIGRAM_FREQ = 10;
public void testCodePointTable() {
@@ -75,7 +73,7 @@ public class Ver2DictEncoderTests extends AndroidTestCase {
/**
* Adds unigrams to the dictionary.
*/
- private void addUnigrams(final FusionDictionary dict, final List<String> words,
+ private static void addUnigrams(final FusionDictionary dict, final List<String> words,
final HashMap<String, List<String>> shortcutMap) {
for (final String word : words) {
final ArrayList<WeightedString> shortcuts = new ArrayList<>();
diff --git a/tests/src/com/android/inputmethod/latin/network/BlockingHttpClientTests.java b/tests/src/com/android/inputmethod/latin/network/BlockingHttpClientTests.java
index fed8be920..8f24cdb44 100644
--- a/tests/src/com/android/inputmethod/latin/network/BlockingHttpClientTests.java
+++ b/tests/src/com/android/inputmethod/latin/network/BlockingHttpClientTests.java
@@ -128,7 +128,7 @@ public class BlockingHttpClientTests extends AndroidTestCase {
assertTrue("ResponseProcessor was not invoked", processor.mInvoked);
}
- private static class FakeErrorResponseProcessor implements ResponseProcessor<Void> {
+ static class FakeErrorResponseProcessor implements ResponseProcessor<Void> {
@Override
public Void onSuccess(InputStream response) {
fail("Expected an error but received success");
diff --git a/tests/src/com/android/inputmethod/latin/personalization/ContextualDictionaryTests.java b/tests/src/com/android/inputmethod/latin/personalization/ContextualDictionaryTests.java
index 011309942..f07dac7c0 100644
--- a/tests/src/com/android/inputmethod/latin/personalization/ContextualDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/personalization/ContextualDictionaryTests.java
@@ -34,8 +34,6 @@ import android.test.suitebuilder.annotation.LargeTest;
*/
@LargeTest
public class ContextualDictionaryTests extends AndroidTestCase {
- private static final String TAG = ContextualDictionaryTests.class.getSimpleName();
-
private static final Locale LOCALE_EN_US = new Locale("en", "US");
private DictionaryFacilitator getDictionaryFacilitator() {
diff --git a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
index 766627334..778f6e800 100644
--- a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
@@ -67,14 +67,14 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
FileUtils.deleteFilteredFiles(dictFile.getParentFile(), filenameFilter);
}
- private void printAllFiles(final File dir) {
+ private static void printAllFiles(final File dir) {
Log.d(TAG, dir.getAbsolutePath());
for (final File file : dir.listFiles()) {
Log.d(TAG, " " + file.getName());
}
}
- private void checkExistenceAndRemoveDictFile(final UserHistoryDictionary dict,
+ private static void checkExistenceAndRemoveDictFile(final UserHistoryDictionary dict,
final File dictFile) {
Log.d(TAG, "waiting for writing ...");
dict.waitAllTasksForTests();
@@ -193,7 +193,7 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
* Clear all entries in the user history dictionary.
* @param dict the user history dictionary.
*/
- private void clearHistory(final UserHistoryDictionary dict) {
+ private static void clearHistory(final UserHistoryDictionary dict) {
dict.waitAllTasksForTests();
dict.clear();
dict.close();
diff --git a/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java b/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java
index 2ef8b548f..36e967275 100644
--- a/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java
+++ b/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java
@@ -17,7 +17,7 @@
package com.android.inputmethod.latin.settings;
import android.app.AlertDialog;
-import android.app.Dialog;
+import android.content.DialogInterface;
import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.MediumTest;
@@ -33,8 +33,6 @@ public class AccountsSettingsFragmentTests
private static final String FRAG_NAME = AccountsSettingsFragment.class.getName();
private static final long TEST_TIMEOUT_MILLIS = 5000;
- private AlertDialog mDialog;
-
public AccountsSettingsFragmentTests() {
super(TestFragmentActivity.class);
}
@@ -58,21 +56,29 @@ public class AccountsSettingsFragmentTests
}
}
+ private static class DialogHolder {
+ AlertDialog mDialog;
+ DialogHolder() {}
+ }
+
public void testMultipleAccounts_noCurrentAccount() {
final AccountsSettingsFragment fragment =
(AccountsSettingsFragment) getActivity().mFragment;
+ final DialogHolder dialogHolder = new DialogHolder();
final CountDownLatch latch = new CountDownLatch(1);
+
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
- mDialog = fragment.createAccountPicker(
+ final AlertDialog dialog = fragment.createAccountPicker(
new String[] {
"1@example.com",
"2@example.com",
"3@example.com",
"4@example.com"},
null);
- mDialog.show();
+ dialog.show();
+ dialogHolder.mDialog = dialog;
latch.countDown();
}
});
@@ -83,32 +89,38 @@ public class AccountsSettingsFragmentTests
fail();
}
getInstrumentation().waitForIdleSync();
- final ListView lv = mDialog.getListView();
+ final AlertDialog dialog = dialogHolder.mDialog;
+ final ListView lv = dialog.getListView();
// The 1st account should be checked by default.
assertEquals("checked-item", 0, lv.getCheckedItemPosition());
// There should be 4 accounts in the list.
assertEquals("count", 4, lv.getCount());
// The sign-out button shouldn't exist
- assertEquals(View.GONE, mDialog.getButton(Dialog.BUTTON_NEUTRAL).getVisibility());
- assertEquals(View.VISIBLE, mDialog.getButton(Dialog.BUTTON_NEGATIVE).getVisibility());
- assertEquals(View.VISIBLE, mDialog.getButton(Dialog.BUTTON_POSITIVE).getVisibility());
+ assertEquals(View.GONE,
+ dialog.getButton(DialogInterface.BUTTON_NEUTRAL).getVisibility());
+ assertEquals(View.VISIBLE,
+ dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getVisibility());
+ assertEquals(View.VISIBLE,
+ dialog.getButton(DialogInterface.BUTTON_POSITIVE).getVisibility());
}
public void testMultipleAccounts_currentAccount() {
final AccountsSettingsFragment fragment =
(AccountsSettingsFragment) getActivity().mFragment;
+ final DialogHolder dialogHolder = new DialogHolder();
final CountDownLatch latch = new CountDownLatch(1);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
- mDialog = fragment.createAccountPicker(
+ final AlertDialog dialog = fragment.createAccountPicker(
new String[] {
"1@example.com",
"2@example.com",
"3@example.com",
"4@example.com"},
"3@example.com");
- mDialog.show();
+ dialog.show();
+ dialogHolder.mDialog = dialog;
latch.countDown();
}
});
@@ -119,14 +131,18 @@ public class AccountsSettingsFragmentTests
fail();
}
getInstrumentation().waitForIdleSync();
- final ListView lv = mDialog.getListView();
+ final AlertDialog dialog = dialogHolder.mDialog;
+ final ListView lv = dialog.getListView();
// The 3rd account should be checked by default.
assertEquals("checked-item", 2, lv.getCheckedItemPosition());
// There should be 4 accounts in the list.
assertEquals("count", 4, lv.getCount());
// The sign-out button should be shown
- assertEquals(View.VISIBLE, mDialog.getButton(Dialog.BUTTON_NEUTRAL).getVisibility());
- assertEquals(View.VISIBLE, mDialog.getButton(Dialog.BUTTON_NEGATIVE).getVisibility());
- assertEquals(View.VISIBLE, mDialog.getButton(Dialog.BUTTON_POSITIVE).getVisibility());
+ assertEquals(View.VISIBLE,
+ dialog.getButton(DialogInterface.BUTTON_NEUTRAL).getVisibility());
+ assertEquals(View.VISIBLE,
+ dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getVisibility());
+ assertEquals(View.VISIBLE,
+ dialog.getButton(DialogInterface.BUTTON_POSITIVE).getVisibility());
}
}
diff --git a/tests/src/com/android/inputmethod/latin/utils/AsyncResultHolderTests.java b/tests/src/com/android/inputmethod/latin/utils/AsyncResultHolderTests.java
index 1501e942a..170d64383 100644
--- a/tests/src/com/android/inputmethod/latin/utils/AsyncResultHolderTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/AsyncResultHolderTests.java
@@ -22,14 +22,14 @@ import android.util.Log;
@MediumTest
public class AsyncResultHolderTests extends AndroidTestCase {
- private static final String TAG = AsyncResultHolderTests.class.getSimpleName();
+ static final String TAG = AsyncResultHolderTests.class.getSimpleName();
private static final int TIMEOUT_IN_MILLISECONDS = 500;
private static final int MARGIN_IN_MILLISECONDS = 250;
private static final int DEFAULT_VALUE = 2;
private static final int SET_VALUE = 1;
- private <T> void setAfterGivenTime(final AsyncResultHolder<T> holder, final T value,
+ private static <T> void setAfterGivenTime(final AsyncResultHolder<T> holder, final T value,
final long time) {
new Thread(new Runnable() {
@Override
diff --git a/tests/src/com/android/inputmethod/latin/utils/BinaryDictionaryUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/BinaryDictionaryUtilsTests.java
index a333ee9bc..131865ab2 100644
--- a/tests/src/com/android/inputmethod/latin/utils/BinaryDictionaryUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/BinaryDictionaryUtilsTests.java
@@ -39,10 +39,8 @@ public class BinaryDictionaryUtilsTests extends AndroidTestCase {
final int formatVersion) throws IOException {
if (formatVersion == FormatSpec.VERSION4) {
return createEmptyVer4DictionaryAndGetFile(dictId);
- } else {
- throw new IOException("Dictionary format version " + formatVersion
- + " is not supported.");
}
+ throw new IOException("Dictionary format version " + formatVersion + " is not supported.");
}
private File createEmptyVer4DictionaryAndGetFile(final String dictId) throws IOException {
@@ -59,10 +57,8 @@ public class BinaryDictionaryUtilsTests extends AndroidTestCase {
if (BinaryDictionaryUtils.createEmptyDictFile(file.getAbsolutePath(), FormatSpec.VERSION4,
LocaleUtils.constructLocaleFromString(TEST_LOCALE), attributeMap)) {
return file;
- } else {
- throw new IOException("Empty dictionary " + file.getAbsolutePath()
- + " cannot be created.");
}
+ throw new IOException("Empty dictionary " + file.getAbsolutePath() + " cannot be created.");
}
private File getDictFile(final String dictId) {
diff --git a/tests/src/com/android/inputmethod/latin/utils/CollectionUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/CollectionUtilsTests.java
index 76e28288f..8bda6726e 100644
--- a/tests/src/com/android/inputmethod/latin/utils/CollectionUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/CollectionUtilsTests.java
@@ -47,7 +47,7 @@ public class CollectionUtilsTests extends AndroidTestCase {
*/
public void testIsNullOrEmpty() {
assertTrue(CollectionUtils.isNullOrEmpty(null));
- assertTrue(CollectionUtils.isNullOrEmpty(new ArrayList()));
+ assertTrue(CollectionUtils.isNullOrEmpty(new ArrayList<>()));
assertTrue(CollectionUtils.isNullOrEmpty(Collections.EMPTY_SET));
assertFalse(CollectionUtils.isNullOrEmpty(Collections.singleton("Not empty")));
}
diff --git a/tests/src/com/android/inputmethod/latin/utils/ResizableIntArrayTests.java b/tests/src/com/android/inputmethod/latin/utils/ResizableIntArrayTests.java
index 8f58e6873..7519becbc 100644
--- a/tests/src/com/android/inputmethod/latin/utils/ResizableIntArrayTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/ResizableIntArrayTests.java
@@ -79,13 +79,13 @@ public class ResizableIntArrayTests extends AndroidTestCase {
public void testGet() {
final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
try {
- final int value = src.get(0);
+ src.get(0);
fail("get(0) shouldn't succeed");
} catch (ArrayIndexOutOfBoundsException e) {
// success
}
try {
- final int value = src.get(DEFAULT_CAPACITY);
+ src.get(DEFAULT_CAPACITY);
fail("get(DEFAULT_CAPACITY) shouldn't succeed");
} catch (ArrayIndexOutOfBoundsException e) {
// success
@@ -98,7 +98,7 @@ public class ResizableIntArrayTests extends AndroidTestCase {
assertEquals("value after add at " + index, valueAddAt, src.get(index));
assertEquals("value after add at 0", 0, src.get(0));
try {
- final int value = src.get(src.getLength());
+ src.get(src.getLength());
fail("get(length) shouldn't succeed");
} catch (ArrayIndexOutOfBoundsException e) {
// success
diff --git a/tests/src/com/android/inputmethod/latin/utils/SpannableStringUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/SpannableStringUtilsTests.java
index fa6ad16c1..11d10aa2f 100644
--- a/tests/src/com/android/inputmethod/latin/utils/SpannableStringUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/SpannableStringUtilsTests.java
@@ -21,7 +21,6 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.text.style.SuggestionSpan;
import android.text.style.URLSpan;
import android.text.SpannableStringBuilder;
-import android.text.Spannable;
import android.text.Spanned;
@SmallTest
@@ -34,8 +33,8 @@ public class SpannableStringUtilsTests extends AndroidTestCase {
for (int i = 0; i < N; ++i) {
// Put a PARAGRAPH-flagged span that should not be found in the result.
s.setSpan(new SuggestionSpan(getContext(),
- new String[] {"" + i}, Spannable.SPAN_PARAGRAPH),
- i * 12, i * 12 + 12, Spannable.SPAN_PARAGRAPH);
+ new String[] {"" + i}, Spanned.SPAN_PARAGRAPH),
+ i * 12, i * 12 + 12, Spanned.SPAN_PARAGRAPH);
// Put a normal suggestion span that should be found in the result.
s.setSpan(new SuggestionSpan(getContext(), new String[] {"" + i}, 0), i, i * 2, 0);
// Put a URL span than should not be found in the result.
@@ -51,7 +50,7 @@ public class SpannableStringUtilsTests extends AndroidTestCase {
for (int i = 0; i < spans.length; i++) {
final int flags = result.getSpanFlags(spans[i]);
assertEquals("Should not find a span with PARAGRAPH flag",
- flags & Spannable.SPAN_PARAGRAPH, 0);
+ flags & Spanned.SPAN_PARAGRAPH, 0);
assertTrue("Should be a SuggestionSpan", spans[i] instanceof SuggestionSpan);
}
}