aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/latin/ExpandableDictionaryTests.java58
-rw-r--r--tests/src/com/android/inputmethod/latin/InputTestsBase.java4
-rw-r--r--tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java4
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/StringUtilsTests.java27
4 files changed, 27 insertions, 66 deletions
diff --git a/tests/src/com/android/inputmethod/latin/ExpandableDictionaryTests.java b/tests/src/com/android/inputmethod/latin/ExpandableDictionaryTests.java
deleted file mode 100644
index 6aae1044e..000000000
--- a/tests/src/com/android/inputmethod/latin/ExpandableDictionaryTests.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.latin;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Unit test for ExpandableDictionary
- */
-@SmallTest
-public class ExpandableDictionaryTests extends AndroidTestCase {
-
- private final static int UNIGRAM_FREQ = 50;
- // See UserBinaryDictionary for more information about this variable.
- // For tests, its actual value does not matter.
- private final static int SHORTCUT_FREQ = 14;
-
- public void testAddWordAndGetWordFrequency() {
- final ExpandableDictionary dict = new ExpandableDictionary(Dictionary.TYPE_USER);
-
- // Add words
- dict.addWord("abcde", "abcde", UNIGRAM_FREQ, SHORTCUT_FREQ);
- dict.addWord("abcef", null, UNIGRAM_FREQ + 1, 0);
-
- // Check words
- assertFalse(dict.isValidWord("abcde"));
- assertEquals(UNIGRAM_FREQ, dict.getWordFrequency("abcde"));
- assertTrue(dict.isValidWord("abcef"));
- assertEquals(UNIGRAM_FREQ+1, dict.getWordFrequency("abcef"));
-
- dict.addWord("abc", null, UNIGRAM_FREQ + 2, 0);
- assertTrue(dict.isValidWord("abc"));
- assertEquals(UNIGRAM_FREQ + 2, dict.getWordFrequency("abc"));
-
- // Add existing word with lower frequency
- dict.addWord("abc", null, UNIGRAM_FREQ, 0);
- assertEquals(UNIGRAM_FREQ + 2, dict.getWordFrequency("abc"));
-
- // Add existing word with higher frequency
- dict.addWord("abc", null, UNIGRAM_FREQ + 3, 0);
- assertEquals(UNIGRAM_FREQ + 3, dict.getWordFrequency("abc"));
- }
-}
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
index b9b52a6f3..3cb980cb0 100644
--- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
@@ -44,8 +44,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
private static final String PREF_DEBUG_MODE = "debug_mode";
- // The message that sets the underline is posted with a 200 ms delay
- protected static final int DELAY_TO_WAIT_FOR_UNDERLINE = 200;
+ // The message that sets the underline is posted with a 500 ms delay
+ protected static final int DELAY_TO_WAIT_FOR_UNDERLINE = 500;
// The message that sets predictions is posted with a 200 ms delay
protected static final int DELAY_TO_WAIT_FOR_PREDICTIONS = 200;
diff --git a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
index 7c1decb71..c3e062b65 100644
--- a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
@@ -214,9 +214,7 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
public void testAddManyWords() {
final String testFilenameSuffix = "testRandomWords" + System.currentTimeMillis();
- final int numberOfWords =
- ExpandableBinaryDictionary.ENABLE_BINARY_DICTIONARY_DYNAMIC_UPDATE ?
- 10000 : 1000;
+ final int numberOfWords = 10000;
final Random random = new Random(123456);
clearHistory(testFilenameSuffix);
try {
diff --git a/tests/src/com/android/inputmethod/latin/utils/StringUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/StringUtilsTests.java
index 4e396a1cf..21fcf1117 100644
--- a/tests/src/com/android/inputmethod/latin/utils/StringUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/StringUtilsTests.java
@@ -44,7 +44,7 @@ public class StringUtilsTests extends AndroidTestCase {
}));
}
- public void testContainsInExtraValues() {
+ public void testContainsInCommaSplittableText() {
assertFalse("null", StringUtils.containsInCommaSplittableText("key", null));
assertFalse("empty", StringUtils.containsInCommaSplittableText("key", ""));
assertFalse("not in 1 element",
@@ -56,7 +56,28 @@ public class StringUtilsTests extends AndroidTestCase {
assertTrue("in 2 elements", StringUtils.containsInCommaSplittableText("key", "key1,key"));
}
- public void testAppendToExtraValuesIfNotExists() {
+ public void testJoinCommaSplittableText() {
+ assertEquals("2 nulls", "",
+ StringUtils.joinCommaSplittableText(null, null));
+ assertEquals("null and empty", "",
+ StringUtils.joinCommaSplittableText(null, ""));
+ assertEquals("empty and null", "",
+ StringUtils.joinCommaSplittableText("", null));
+ assertEquals("2 empties", "",
+ StringUtils.joinCommaSplittableText("", ""));
+ assertEquals("text and null", "text",
+ StringUtils.joinCommaSplittableText("text", null));
+ assertEquals("text and empty", "text",
+ StringUtils.joinCommaSplittableText("text", ""));
+ assertEquals("null and text", "text",
+ StringUtils.joinCommaSplittableText(null, "text"));
+ assertEquals("empty and text", "text",
+ StringUtils.joinCommaSplittableText("", "text"));
+ assertEquals("2 texts", "text1,text2",
+ StringUtils.joinCommaSplittableText("text1", "text2"));
+ }
+
+ public void testAppendToCommaSplittableTextIfNotExists() {
assertEquals("null", "key",
StringUtils.appendToCommaSplittableTextIfNotExists("key", null));
assertEquals("empty", "key",
@@ -77,7 +98,7 @@ public class StringUtilsTests extends AndroidTestCase {
StringUtils.appendToCommaSplittableTextIfNotExists("key", "key1,key,key3"));
}
- public void testRemoveFromExtraValuesIfExists() {
+ public void testRemoveFromCommaSplittableTextIfExists() {
assertEquals("null", "", StringUtils.removeFromCommaSplittableTextIfExists("key", null));
assertEquals("empty", "", StringUtils.removeFromCommaSplittableTextIfExists("key", ""));