aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/InputLogicTests.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-03-07 23:51:29 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-03-07 23:51:29 -0800
commitbedb1d33f30936e9b16a2ee9ad6b94fda0d6193f (patch)
tree9ba5359457b55690c0b990f8ddbd01ad04d19892 /tests/src/com/android/inputmethod/latin/InputLogicTests.java
parentf0d5a78388d763a6c19d88ebe2741da2c3cff9a9 (diff)
parent274a0643b100173ec505f2701afd51e10eeda3ff (diff)
downloadlatinime-bedb1d33f30936e9b16a2ee9ad6b94fda0d6193f.tar.gz
latinime-bedb1d33f30936e9b16a2ee9ad6b94fda0d6193f.tar.xz
latinime-bedb1d33f30936e9b16a2ee9ad6b94fda0d6193f.zip
Merge "Give InputLogicTests the ability to change language"
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/InputLogicTests.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTests.java75
1 files changed, 61 insertions, 14 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index 50aba7b94..a6a4d9343 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -95,20 +95,7 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
mLatinIME.onStartInputView(ei, false);
mLatinIME.onCreateInputMethodInterface().startInput(ic, ei);
mInputConnection = ic;
- // Wait for the main dictionary to be loaded (we need it for auto-correction tests)
- int remainingAttempts = 10;
- while (remainingAttempts > 0 && !mLatinIME.mSuggest.hasMainDictionary()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- // Don't do much
- } finally {
- --remainingAttempts;
- }
- }
- if (!mLatinIME.mSuggest.hasMainDictionary()) {
- throw new RuntimeException("Can't initialize the main dictionary");
- }
+ changeLanguage("en_US");
}
// We need to run the messages added to the handler from LatinIME. The only way to do
@@ -177,6 +164,29 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
}
}
+ private void waitForDictionaryToBeLoaded() {
+ int remainingAttempts = 10;
+ while (remainingAttempts > 0 && !mLatinIME.mSuggest.hasMainDictionary()) {
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ // Don't do much
+ } finally {
+ --remainingAttempts;
+ }
+ }
+ if (!mLatinIME.mSuggest.hasMainDictionary()) {
+ throw new RuntimeException("Can't initialize the main dictionary");
+ }
+ }
+
+ private void changeLanguage(final String locale) {
+ SubtypeSwitcher.getInstance().updateSubtype(
+ new ArbitrarySubtype(locale, LatinIME.SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE));
+ waitForDictionaryToBeLoaded();
+ }
+
+
// Helper to avoid writing the try{}catch block each time
private static void sleep(final int milliseconds) {
try {
@@ -273,6 +283,15 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
assertEquals("simple auto-correct", EXPECTED_RESULT, mTextView.getText().toString());
}
+ public void testAutoCorrectForFrench() {
+ final String STRING_TO_TYPE = "irq ";
+ final String EXPECTED_RESULT = "ira ";
+ changeLanguage("fr");
+ type(STRING_TO_TYPE);
+ assertEquals("simple auto-correct for French", EXPECTED_RESULT,
+ mTextView.getText().toString());
+ }
+
public void testAutoCorrectWithPeriod() {
final String STRING_TO_TYPE = "tgis.";
final String EXPECTED_RESULT = "this.";
@@ -375,6 +394,34 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
mTextView.getText().toString());
}
+ public void testManualPickThenSeparatorForFrench() {
+ final String WORD1_TO_TYPE = "test";
+ final String WORD2_TO_TYPE = "!";
+ final String EXPECTED_RESULT = "test !";
+ changeLanguage("fr");
+ type(WORD1_TO_TYPE);
+ mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE);
+ type(WORD2_TO_TYPE);
+ assertEquals("manual pick then separator for French", EXPECTED_RESULT,
+ mTextView.getText().toString());
+ }
+
+ public void testWordThenSpaceThenPunctuationFromStripTwiceForFrench() {
+ final String WORD_TO_TYPE = "test ";
+ final String PUNCTUATION_FROM_STRIP = "!";
+ final String EXPECTED_RESULT = "test !!";
+ changeLanguage("fr");
+ type(WORD_TO_TYPE);
+ sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
+ runMessages();
+ assertTrue("type word then type space should display punctuation strip",
+ mLatinIME.isShowingPunctuationList());
+ mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
+ mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
+ assertEquals("type word then type space then punctuation from strip twice for French",
+ EXPECTED_RESULT, mTextView.getText().toString());
+ }
+
public void testWordThenSpaceThenPunctuationFromKeyboardTwice() {
final String WORD_TO_TYPE = "this !!";
final String EXPECTED_RESULT = "this !!";