aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/InputLogicTests.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-03-08 15:40:31 +0900
committerJean Chalard <jchalard@google.com>2012-03-08 16:39:29 +0900
commit274a0643b100173ec505f2701afd51e10eeda3ff (patch)
treecf98e3b30bcfb934fa9c583edfd61d50ab6a8b30 /tests/src/com/android/inputmethod/latin/InputLogicTests.java
parent77541fc92e1d244bb21827715f159e6197c92133 (diff)
downloadlatinime-274a0643b100173ec505f2701afd51e10eeda3ff.tar.gz
latinime-274a0643b100173ec505f2701afd51e10eeda3ff.tar.xz
latinime-274a0643b100173ec505f2701afd51e10eeda3ff.zip
Give InputLogicTests the ability to change language
Also fix a typo, and increase the time allowed to load the main dictionary to 2 secs instead of 1. Bug: 6114326 Change-Id: I5f70b34fc4277c55977b18466253152aa98a2507
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 !!";