aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/ImeLoggerTests.java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2010-08-19 22:46:06 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-08-19 22:46:06 -0700
commitd56f8f5c10d6a959c23fda6ba0a588198fe7412b (patch)
tree9c26f81aa39c45fc0f22ecb2d5337e622b6a4438 /tests/src/com/android/inputmethod/latin/ImeLoggerTests.java
parentb608a93c0f3087b191c88cd75665886b7c52015e (diff)
parent979f8690967ff5409fe18f5085858ccdb8e0ccf1 (diff)
downloadlatinime-d56f8f5c10d6a959c23fda6ba0a588198fe7412b.tar.gz
latinime-d56f8f5c10d6a959c23fda6ba0a588198fe7412b.tar.xz
latinime-d56f8f5c10d6a959c23fda6ba0a588198fe7412b.zip
am 979f8690: DO NOT MERGE. Backport LatinIME from master to Gingerbread
Merge commit '979f8690967ff5409fe18f5085858ccdb8e0ccf1' into gingerbread-plus-aosp * commit '979f8690967ff5409fe18f5085858ccdb8e0ccf1': DO NOT MERGE. Backport LatinIME from master to Gingerbread
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/ImeLoggerTests.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/ImeLoggerTests.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/src/com/android/inputmethod/latin/ImeLoggerTests.java b/tests/src/com/android/inputmethod/latin/ImeLoggerTests.java
new file mode 100644
index 000000000..234559bb7
--- /dev/null
+++ b/tests/src/com/android/inputmethod/latin/ImeLoggerTests.java
@@ -0,0 +1,59 @@
+package com.android.inputmethod.latin;
+
+import android.test.ServiceTestCase;
+
+public class ImeLoggerTests extends ServiceTestCase<LatinIME> {
+
+ private static final String WORD_SEPARATORS
+ = ".\u0009\u0020,;:!?\n()[]*&@{}<>;_+=|\\u0022";
+
+ public ImeLoggerTests() {
+ super(LatinIME.class);
+ }
+ static LatinImeLogger sLogger;
+ @Override
+ protected void setUp() {
+ try {
+ super.setUp();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ setupService();
+ // startService(null); // can't be started because VoiceInput can't be found.
+ final LatinIME context = getService();
+ context.mWordSeparators = WORD_SEPARATORS;
+ LatinImeLogger.init(context);
+ sLogger = LatinImeLogger.sLatinImeLogger;
+ }
+ /*********************** Tests *********************/
+ public void testRingBuffer() {
+ for (int i = 0; i < sLogger.mRingCharBuffer.BUFSIZE * 2; ++i) {
+ LatinImeLogger.logOnDelete();
+ }
+ assertEquals("", sLogger.mRingCharBuffer.getLastString());
+ LatinImeLogger.logOnInputChar('t');
+ LatinImeLogger.logOnInputChar('g');
+ LatinImeLogger.logOnInputChar('i');
+ LatinImeLogger.logOnInputChar('s');
+ LatinImeLogger.logOnInputChar(' ');
+ LatinImeLogger.logOnAutoSuggestion("tgis", "this");
+ LatinImeLogger.logOnInputChar(' ');
+ LatinImeLogger.logOnDelete();
+ assertEquals("", sLogger.mRingCharBuffer.getLastString());
+ LatinImeLogger.logOnDelete();
+ assertEquals("tgis", sLogger.mRingCharBuffer.getLastString());
+ assertEquals("tgis", LatinImeLogger.sLastAutoSuggestBefore);
+ LatinImeLogger.logOnAutoSuggestionCanceled();
+ assertEquals("", LatinImeLogger.sLastAutoSuggestBefore);
+ LatinImeLogger.logOnDelete();
+ assertEquals("tgi", sLogger.mRingCharBuffer.getLastString());
+ for (int i = 0; i < sLogger.mRingCharBuffer.BUFSIZE * 2; ++i) {
+ LatinImeLogger.logOnDelete();
+ }
+ assertEquals("", sLogger.mRingCharBuffer.getLastString());
+ for (int i = 0; i < sLogger.mRingCharBuffer.BUFSIZE * 2; ++i) {
+ LatinImeLogger.logOnInputChar('a');
+ }
+ assertEquals(sLogger.mRingCharBuffer.BUFSIZE, sLogger.mRingCharBuffer.length);
+ }
+}