aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java2
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/Sinhala.java185
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindiCompact.java4
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMarathiIN.java4
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMyanmarMM.java4
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSinhalaLK.java37
-rw-r--r--tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java5
-rw-r--r--tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java9
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTests.java16
-rw-r--r--tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java18
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java3
-rw-r--r--tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java7
12 files changed, 264 insertions, 30 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
index bf19a8b46..59fe61110 100644
--- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
@@ -25,7 +25,7 @@ import java.util.ArrayList;
@SmallTest
public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase {
- private static final int NUMBER_OF_SUBTYPES = 68;
+ private static final int NUMBER_OF_SUBTYPES = 72;
private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 45;
private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2;
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Sinhala.java b/tests/src/com/android/inputmethod/keyboard/layout/Sinhala.java
new file mode 100644
index 000000000..bfd94d5fc
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/layout/Sinhala.java
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2014 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.keyboard.layout;
+
+import com.android.inputmethod.keyboard.KeyboardId;
+import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
+import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
+import com.android.inputmethod.latin.Constants;
+
+import java.util.Locale;
+
+/**
+ * The Sinhala keyboard.
+ */
+public final class Sinhala extends LayoutBase {
+ private static final String LAYOUT_NAME = "sinhala";
+
+ public Sinhala(final LayoutCustomizer customizer) {
+ super(customizer, Symbols.class, SymbolsShifted.class);
+ }
+
+ @Override
+ public String getName() { return LAYOUT_NAME; }
+
+ public static class SinhalaCustomizer extends LayoutCustomizer {
+ public SinhalaCustomizer(final Locale locale) { super(locale); }
+
+ @Override
+ public ExpectedKey getAlphabetKey() { return SINHALA_ALPHABET_KEY; }
+
+ @Override
+ public ExpectedKey[] getRightShiftKeys(final boolean isPhone) {
+ return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS;
+ }
+
+ // U+0D85: "අ" SINHALA LETTER AYANNA
+ // U+0D86: "ආ" SINHALA LETTER AAYANNA
+ private static final ExpectedKey SINHALA_ALPHABET_KEY = key(
+ "\u0D85,\u0D86", Constants.CODE_SWITCH_ALPHA_SYMBOL);
+ }
+
+ @Override
+ ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; }
+
+ @Override
+ ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) {
+ if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) {
+ return ALPHABET_COMMON;
+ }
+ return ALPHABET_SHIFTED_COMMON;
+ }
+
+ private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
+ .setKeysOfRow(1,
+ // U+0DD4: "ු" SINHALA VOWEL SIGN KETTI PAA-PILLA
+ key("\u0DD4", moreKey("1")),
+ // U+0D85: "අ" SINHALA LETTER AYANNA
+ key("\u0D85", moreKey("2")),
+ // U+0DD0: "ැ" SINHALA VOWEL SIGN KETTI AEDA-PILLA
+ key("\u0DD0", moreKey("3")),
+ // U+0DBB: "ර" SINHALA LETTER RAYANNA
+ key("\u0DBB", moreKey("4")),
+ // U+0D91: "එ" SINHALA LETTER EYANNA
+ key("\u0D91", moreKey("5")),
+ // U+0DC4: "හ" SINHALA LETTER HAYANNA
+ key("\u0DC4", moreKey("6")),
+ // U+0DB8: "ම" SINHALA LETTER MAYANNA
+ key("\u0DB8", moreKey("7")),
+ // U+0DC3: "ස" SINHALA LETTER DANTAJA SAYANNA
+ key("\u0DC3", moreKey("8")),
+ // U+0DAF: "ද" SINHALA LETTER ALPAPRAANA DAYANNA
+ // U+0DB3: "ඳ" SINHALA LETTER SANYAKA DAYANNA
+ key("\u0DAF", joinMoreKeys("9", "\u0DB3")),
+ // U+0DA0: "ච" SINHALA LETTER ALPAPRAANA CAYANNA
+ key("\u0DA0", moreKey("0")),
+ // U+0DA4: "ඤ" SINHALA LETTER TAALUJA NAASIKYAYA
+ // U+0DF4: "෴" SINHALA PUNCTUATION KUNDDALIYA
+ key("\u0DA4", moreKey("\u0DF4")))
+ .setKeysOfRow(2,
+ // U+0DCA: "්" SINHALA SIGN AL-LAKUNA
+ // U+0DD2: "ි" SINHALA VOWEL SIGN KETTI IS-PILLA
+ // U+0DCF: "ා" SINHALA VOWEL SIGN AELA-PILLA
+ // U+0DD9: "ෙ" SINHALA VOWEL SIGN KOMBUVA
+ // U+0DA7: "ට" SINHALA LETTER ALPAPRAANA TTAYANNA
+ // U+0DBA: "ය" SINHALA LETTER YAYANNA
+ // U+0DC0: "ව" SINHALA LETTER VAYANNA
+ // U+0DB1: "න" SINHALA LETTER DANTAJA NAYANNA
+ // U+0D9A: "ක" SINHALA LETTER ALPAPRAANA KAYANNA
+ // U+0DAD: "ත" SINHALA LETTER ALPAPRAANA TAYANNA
+ // U+0D8F: "ඏ" SINHALA LETTER ILUYANNA
+ "\u0DCA", "\u0DD2", "\u0DCF", "\u0DD9", "\u0DA7", "\u0DBA", "\u0DC0", "\u0DB1",
+ "\u0D9A", "\u0DAD", "\u0D8F")
+ .setKeysOfRow(3,
+ // U+0D82: "ං" SINHALA SIGN ANUSVARAYA
+ // U+0D83: "ඃ" SINHALA SIGN VISARGAYA
+ key("\u0D82", moreKey("\u0D83")),
+ // U+0DA2: "ජ" SINHALA LETTER ALPAPRAANA JAYANNA
+ // U+0DA6: "ඦ" SINHALA LETTER SANYAKA JAYANNA
+ key("\u0DA2", moreKey("\u0DA6")),
+ // U+0DA9: "ඩ" SINHALA LETTER ALPAPRAANA DDAYANNA
+ // U+0DAC: "ඬ" SINHALA LETTER SANYAKA DDAYANNA
+ key("\u0DA9", moreKey("\u0DAC")),
+ // U+0D89: "ඉ" SINHALA LETTER IYANNA
+ // U+0DB6: "බ" SINHALA LETTER ALPAPRAANA BAYANNA
+ // U+0DB4: "ප" SINHALA LETTER ALPAPRAANA PAYANNA
+ // U+0DBD: "ල" SINHALA LETTER DANTAJA LAYANNA
+ "\u0D89", "\u0DB6", "\u0DB4", "\u0DBD",
+ // U+0D9C: "ග" SINHALA LETTER ALPAPRAANA GAYANNA
+ // U+0D9F: "ඟ" SINHALA LETTER SANYAKA GAYANNA
+ key("\u0D9C", moreKey("\u0D9F")),
+ // U+0DF3: "ෳ" SINHALA VOWEL SIGN DIGA GAYANUKITTA
+ "\u0DF3")
+ .build();
+
+ private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder()
+ .setKeysOfRow(1,
+ // U+0DD6: "ූ" SINHALA VOWEL SIGN DIGA PAA-PILLA
+ key("\u0DD6", moreKey("1")),
+ // U+0D8B: "උ" SINHALA LETTER UYANNA
+ key("\u0D8B", moreKey("2")),
+ // U+0DD1: "ෑ" SINHALA VOWEL SIGN DIGA AEDA-PILLA
+ key("\u0DD1", moreKey("3")),
+ // U+0D8D: "ඍ" SINHALA LETTER IRUYANNA
+ key("\u0D8D", moreKey("4")),
+ // U+0D94: "ඔ" SINHALA LETTER OYANNA
+ key("\u0D94", moreKey("5")),
+ // U+0DC1: "ශ" SINHALA LETTER TAALUJA SAYANNA
+ key("\u0DC1", moreKey("6")),
+ // U+0DB9: "ඹ" SINHALA LETTER AMBA BAYANNA
+ key("\u0DB9", moreKey("7")),
+ // U+0DC2: "ෂ" SINHALA LETTER MUURDHAJA SAYANNA
+ key("\u0DC2", moreKey("8")),
+ // U+0DB0: "ධ" SINHALA LETTER MAHAAPRAANA DAYANNA
+ key("\u0DB0", moreKey("9")),
+ // U+0DA1: "ඡ" SINHALA LETTER MAHAAPRAANA CAYANNA
+ key("\u0DA1", moreKey("0")),
+ // U+0DA5: "ඥ" SINHALA LETTER TAALUJA SANYOOGA NAAKSIKYAYA
+ // U+0DF4: "෴" SINHALA PUNCTUATION KUNDDALIYA
+ key("\u0DA5", moreKey("\u0DF4")))
+ .setKeysOfRow(2,
+ // U+0DDF: "ෟ" SINHALA VOWEL SIGN GAYANUKITTA
+ // U+0DD3: "ී" SINHALA VOWEL SIGN DIGA IS-PILLA
+ // U+0DD8: "ෘ" SINHALA VOWEL SIGN GAETTA-PILLA
+ // U+0DC6: "ෆ" SINHALA LETTER FAYANNA
+ // U+0DA8: "ඨ" SINHALA LETTER MAHAAPRAANA TTAYANNA
+ // U+0DCA/U+200D/U+0DBA:
+ // "්‍ය" SINHALA SIGN AL-LAKUNA/ZERO WIDTH JOINER/SINHALA LETTER YAYANNA
+ // U+0DC5/U+0DD4:
+ // "ළු" SINHALA LETTER MUURDHAJA LAYANNA/SINHALA VOWEL SIGN KETTI PAA-PILLA
+ // U+0DAB: "ණ" SINHALA LETTER MUURDHAJA NAYANNA
+ // U+0D9B: "ඛ" SINHALA LETTER MAHAAPRAANA KAYANNA
+ // U+0DAE: "ථ" SINHALA LETTER MAHAAPRAANA TAYANNA
+ // U+0DCA/U+200D/U+0DBB:
+ // "්‍ර" SINHALA SIGN AL-LAKUNA/ZERO WIDTH JOINER/SINHALA LETTER RAYANNA
+ "\u0DDF", "\u0DD3", "\u0DD8", "\u0DC6", "\u0DA8", "\u0DCA\u200D\u0DBA",
+ "\u0DC5\u0DD4", "\u0DAB", "\u0D9B", "\u0DAE", "\u0DCA\u200D\u0DBB")
+ .setKeysOfRow(3,
+ // U+0D9E: "ඞ" SINHALA LETTER KANTAJA NAASIKYAYA
+ // U+0DA3: "ඣ" SINHALA LETTER MAHAAPRAANA JAYANNA
+ // U+0DAA: "ඪ" SINHALA LETTER MAHAAPRAANA DDAYANNA
+ // U+0D8A: "ඊ" SINHALA LETTER IIYANNA
+ // U+0DB7: "භ" SINHALA LETTER MAHAAPRAANA BAYANNA
+ // U+0DB5: "ඵ" SINHALA LETTER MAHAAPRAANA PAYANNA
+ // U+0DC5: "ළ" SINHALA LETTER MUURDHAJA LAYANNA
+ // U+0D9D: "ඝ" SINHALA LETTER MAHAAPRAANA GAYANNA
+ // U+0DBB/U+0DCA/U+200D:
+ // "ර්‍" SINHALA LETTER RAYANNA/SINHALA SIGN AL-LAKUNA/ZERO WIDTH JOINER
+ "\u0d9E", "\u0DA3", "\u0DAA", "\u0D8A", "\u0DB7", "\u0DB5", "\u0DC5", "\u0D9D",
+ "\u0DBB\u0DCA\u200D")
+ .build();
+}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindiCompact.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindiCompact.java
index 6380da524..2e676df26 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindiCompact.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindiCompact.java
@@ -16,7 +16,7 @@
package com.android.inputmethod.keyboard.layout.tests;
-import android.test.suitebuilder.annotation.Suppress;
+import android.test.suitebuilder.annotation.SmallTest;
import com.android.inputmethod.keyboard.layout.HindiCompact;
import com.android.inputmethod.keyboard.layout.HindiCompact.HindiCompactCustomizer;
@@ -27,7 +27,7 @@ import java.util.Locale;
/**
* hi: Hindi/hindi_compact
*/
-@Suppress
+@SmallTest
public final class TestsHindiCompact extends LayoutTestsBase {
private static final Locale LOCALE = new Locale("hi");
private static final LayoutBase LAYOUT = new HindiCompact(new HindiCompactCustomizer(LOCALE));
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMarathiIN.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMarathiIN.java
index d45d99d10..b937629b0 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMarathiIN.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMarathiIN.java
@@ -16,7 +16,7 @@
package com.android.inputmethod.keyboard.layout.tests;
-import android.test.suitebuilder.annotation.Suppress;
+import android.test.suitebuilder.annotation.SmallTest;
import com.android.inputmethod.keyboard.layout.LayoutBase;
import com.android.inputmethod.keyboard.layout.Marathi;
@@ -27,7 +27,7 @@ import java.util.Locale;
/**
* mr_IN: Marathi (India)/marathi
*/
-@Suppress
+@SmallTest
public final class TestsMarathiIN extends LayoutTestsBase {
private static final Locale LOCALE = new Locale("mr", "IN");
private static final LayoutBase LAYOUT = new Marathi(new MarathiCustomizer(LOCALE));
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMyanmarMM.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMyanmarMM.java
index a0bd50c9a..e6d3b3b92 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMyanmarMM.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMyanmarMM.java
@@ -16,7 +16,7 @@
package com.android.inputmethod.keyboard.layout.tests;
-import android.test.suitebuilder.annotation.Suppress;
+import android.test.suitebuilder.annotation.SmallTest;
import com.android.inputmethod.keyboard.layout.LayoutBase;
import com.android.inputmethod.keyboard.layout.Myanmar;
@@ -27,7 +27,7 @@ import java.util.Locale;
/**
* my_MM: Myanmar (Myanmar)/myanmar
*/
-@Suppress
+@SmallTest
public final class TestsMyanmarMM extends LayoutTestsBase {
private static final Locale LOCALE = new Locale("my", "MM");
private static final LayoutBase LAYOUT = new Myanmar(new MyanmarCustomizer(LOCALE));
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSinhalaLK.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSinhalaLK.java
new file mode 100644
index 000000000..1cea49760
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSinhalaLK.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 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.keyboard.layout.tests;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import com.android.inputmethod.keyboard.layout.LayoutBase;
+import com.android.inputmethod.keyboard.layout.Sinhala;
+import com.android.inputmethod.keyboard.layout.Sinhala.SinhalaCustomizer;
+
+import java.util.Locale;
+
+/**
+ * si_LK: Sinhala (Sri Lanka)/sinhala
+ */
+@SmallTest
+public final class TestsSinhalaLK extends LayoutTestsBase {
+ private static final Locale LOCALE = new Locale("si", "LK");
+ private static final LayoutBase LAYOUT = new Sinhala(new SinhalaCustomizer(LOCALE));
+
+ @Override
+ LayoutBase getLayout() { return LAYOUT; }
+}
diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java
index 28cce834c..ae184268c 100644
--- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java
+++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java
@@ -20,6 +20,7 @@ import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import android.util.Pair;
+import com.android.inputmethod.latin.PrevWordsInfo.WordInfo;
import com.android.inputmethod.latin.makedict.BinaryDictIOUtils;
import com.android.inputmethod.latin.makedict.CodePointUtils;
import com.android.inputmethod.latin.makedict.DictDecoder;
@@ -77,13 +78,13 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase {
private void addBigramWords(final BinaryDictionary binaryDictionary, final String word0,
final String word1, final int probability) {
- binaryDictionary.addNgramEntry(new PrevWordsInfo(word0), word1, probability,
+ binaryDictionary.addNgramEntry(new PrevWordsInfo(new WordInfo(word0)), word1, probability,
mCurrentTime /* timestamp */);
}
private static boolean isValidBigram(final BinaryDictionary binaryDictionary,
final String word0, final String word1) {
- return binaryDictionary.isValidNgram(new PrevWordsInfo(word0), word1);
+ return binaryDictionary.isValidNgram(new PrevWordsInfo(new WordInfo(word0)), word1);
}
private void forcePassingShortTime(final BinaryDictionary binaryDictionary) {
diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
index 83ea19399..6ba18d665 100644
--- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
@@ -21,6 +21,7 @@ import android.test.suitebuilder.annotation.LargeTest;
import android.text.TextUtils;
import android.util.Pair;
+import com.android.inputmethod.latin.PrevWordsInfo.WordInfo;
import com.android.inputmethod.latin.makedict.CodePointUtils;
import com.android.inputmethod.latin.makedict.FormatSpec;
import com.android.inputmethod.latin.makedict.WeightedString;
@@ -203,23 +204,23 @@ public class BinaryDictionaryTests extends AndroidTestCase {
private static void addBigramWords(final BinaryDictionary binaryDictionary, final String word0,
final String word1, final int probability) {
- binaryDictionary.addNgramEntry(new PrevWordsInfo(word0), word1, probability,
+ binaryDictionary.addNgramEntry(new PrevWordsInfo(new WordInfo(word0)), word1, probability,
BinaryDictionary.NOT_A_VALID_TIMESTAMP /* timestamp */);
}
private static boolean isValidBigram(final BinaryDictionary binaryDictionary,
final String word0, final String word1) {
- return binaryDictionary.isValidNgram(new PrevWordsInfo(word0), word1);
+ return binaryDictionary.isValidNgram(new PrevWordsInfo(new WordInfo(word0)), word1);
}
private static void removeBigramEntry(final BinaryDictionary binaryDictionary,
final String word0, final String word1) {
- binaryDictionary.removeNgramEntry(new PrevWordsInfo(word0), word1);
+ binaryDictionary.removeNgramEntry(new PrevWordsInfo(new WordInfo(word0)), word1);
}
private static int getBigramProbability(final BinaryDictionary binaryDictionary,
final String word0, final String word1) {
- return binaryDictionary.getNgramProbability(new PrevWordsInfo(word0), word1);
+ return binaryDictionary.getNgramProbability(new PrevWordsInfo(new WordInfo(word0)), word1);
}
public void testAddUnigramWord() {
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index 460f600ac..0552c221e 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -482,6 +482,7 @@ public class InputLogicTests extends InputTestsBase {
}
public void testPredictionsWithDoubleSpaceToPeriod() {
+ mLatinIME.clearPersonalizedDictionariesForTest();
final String WORD_TO_TYPE = "Barack ";
type(WORD_TO_TYPE);
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
@@ -516,14 +517,21 @@ public class InputLogicTests extends InputTestsBase {
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
}
- public void testNoPredictionsAfterPeriod() {
+ public void testPredictionsAfterPeriod() {
+ mLatinIME.clearPersonalizedDictionariesForTest();
final String WORD_TO_TYPE = "Barack. ";
type(WORD_TO_TYPE);
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
runMessages();
- // Test the first prediction is not displayed
- final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
- assertEquals("no prediction after period", 0, suggestedWords.size());
+ SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
+ assertEquals("No prediction after period after inputting once.", 0, suggestedWords.size());
+
+ type(WORD_TO_TYPE);
+ sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
+ runMessages();
+ suggestedWords = mLatinIME.getSuggestedWordsForTest();
+ assertEquals("Beginning-of-Sentence prediction after inputting 2 times.", "Barack",
+ suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
}
public void testPredictionsAfterRecorrection() {
diff --git a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java
index 2c92bb3d6..5a5ec6d2b 100644
--- a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java
+++ b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java
@@ -156,16 +156,16 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
public void testGetPreviousWord() {
// If one of the following cases breaks, the bigram suggestions won't work.
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
- "abc def", mSpacingAndPunctuations, 2).mPrevWord, "abc");
+ "abc def", mSpacingAndPunctuations, 2).mPrevWordsInfo[0].mWord, "abc");
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
"abc", mSpacingAndPunctuations, 2), PrevWordsInfo.BEGINNING_OF_SENTENCE);
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
"abc. def", mSpacingAndPunctuations, 2), PrevWordsInfo.BEGINNING_OF_SENTENCE);
assertFalse(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
- "abc def", mSpacingAndPunctuations, 2).mIsBeginningOfSentence);
+ "abc def", mSpacingAndPunctuations, 2).mPrevWordsInfo[0].mIsBeginningOfSentence);
assertTrue(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
- "abc", mSpacingAndPunctuations, 2).mIsBeginningOfSentence);
+ "abc", mSpacingAndPunctuations, 2).mPrevWordsInfo[0].mIsBeginningOfSentence);
// The following tests reflect the current behavior of the function
// RichInputConnection#getNthPreviousWord.
// TODO: However at this time, the code does never go
@@ -174,20 +174,20 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
// logical. These tests are just there to catch any unintentional
// changes in the behavior of the RichInputConnection#getPreviousWord method.
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
- "abc def ", mSpacingAndPunctuations, 2).mPrevWord, "abc");
+ "abc def ", mSpacingAndPunctuations, 2).mPrevWordsInfo[0].mWord, "abc");
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
- "abc def.", mSpacingAndPunctuations, 2).mPrevWord, "abc");
+ "abc def.", mSpacingAndPunctuations, 2).mPrevWordsInfo[0].mWord, "abc");
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
- "abc def .", mSpacingAndPunctuations, 2).mPrevWord, "def");
+ "abc def .", mSpacingAndPunctuations, 2).mPrevWordsInfo[0].mWord, "def");
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
"abc ", mSpacingAndPunctuations, 2), PrevWordsInfo.BEGINNING_OF_SENTENCE);
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
- "abc def", mSpacingAndPunctuations, 1).mPrevWord, "def");
+ "abc def", mSpacingAndPunctuations, 1).mPrevWordsInfo[0].mWord, "def");
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
- "abc def ", mSpacingAndPunctuations, 1).mPrevWord, "def");
+ "abc def ", mSpacingAndPunctuations, 1).mPrevWordsInfo[0].mWord, "def");
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
- "abc 'def", mSpacingAndPunctuations, 1).mPrevWord, "'def");
+ "abc 'def", mSpacingAndPunctuations, 1).mPrevWordsInfo[0].mWord, "'def");
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
"abc def.", mSpacingAndPunctuations, 1), PrevWordsInfo.BEGINNING_OF_SENTENCE);
assertEquals(RichInputConnection.getPrevWordsInfoFromNthPreviousWord(
diff --git a/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java b/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java
index 8f32e5336..76eaef431 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java
@@ -104,7 +104,8 @@ public class Ver4DictEncoder implements DictEncoder {
for (final WordProperty word0Property : dict) {
if (null == word0Property.mBigrams) continue;
for (final WeightedString word1 : word0Property.mBigrams) {
- final PrevWordsInfo prevWordsInfo = new PrevWordsInfo(word0Property.mWord);
+ final PrevWordsInfo prevWordsInfo =
+ new PrevWordsInfo(new PrevWordsInfo.WordInfo(word0Property.mWord));
if (!binaryDict.addNgramEntry(prevWordsInfo, word1.mWord,
word1.getProbability(), 0 /* timestamp */)) {
MakedictLog.e("Cannot add n-gram entry for "
diff --git a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
index 48d3a1cad..f87f3b494 100644
--- a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
@@ -22,6 +22,7 @@ import android.util.Log;
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
import com.android.inputmethod.latin.PrevWordsInfo;
+import com.android.inputmethod.latin.PrevWordsInfo.WordInfo;
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
import com.android.inputmethod.latin.utils.DistracterFilter;
import com.android.inputmethod.latin.utils.FileUtils;
@@ -115,7 +116,7 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
UserHistoryDictionary.addToDictionary(dict, prevWordsInfo, word, true,
(int)TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),
DistracterFilter.EMPTY_DISTRACTER_FILTER);
- prevWordsInfo = new PrevWordsInfo(word);
+ prevWordsInfo = prevWordsInfo.getNextPrevWordsInfo(new WordInfo(word));
}
}
@@ -262,11 +263,11 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
final UserHistoryDictionary dict =
PersonalizationHelper.getUserHistoryDictionary(getContext(), dummyLocale);
dict.waitAllTasksForTests();
- PrevWordsInfo prevWordsInfo = new PrevWordsInfo(null);
+ PrevWordsInfo prevWordsInfo = PrevWordsInfo.EMPTY_PREV_WORDS_INFO;
for (final String word : words) {
UserHistoryDictionary.addToDictionary(dict, prevWordsInfo, word, true, mCurrentTime,
DistracterFilter.EMPTY_DISTRACTER_FILTER);
- prevWordsInfo = new PrevWordsInfo(word);
+ prevWordsInfo = prevWordsInfo.getNextPrevWordsInfo(new WordInfo(word));
dict.waitAllTasksForTests();
assertTrue(dict.isInDictionary(word));
}