diff options
Diffstat (limited to 'tests/src')
3 files changed, 43 insertions, 15 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index 6cc4befae..fe92be618 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -305,5 +305,33 @@ public class InputLogicTests extends InputTestsBase { assertEquals("resume suggestion on backspace", 8, BaseInputConnection.getComposingSpanEnd(mEditText.getText())); } + + private void helperTestComposing(final String wordToType, final boolean shouldBeComposing) { + mEditText.setText(""); + type(wordToType); + assertEquals("start composing inside text", shouldBeComposing ? 0 : -1, + BaseInputConnection.getComposingSpanStart(mEditText.getText())); + assertEquals("start composing inside text", shouldBeComposing ? wordToType.length() : -1, + BaseInputConnection.getComposingSpanEnd(mEditText.getText())); + } + + public void testStartComposing() { + // Should start composing on a letter + helperTestComposing("a", true); + type(" "); // To reset the composing state + // Should not start composing on quote + helperTestComposing("'", false); + type(" "); + helperTestComposing("'-", false); + type(" "); + // Should not start composing on dash + helperTestComposing("-", false); + type(" "); + helperTestComposing("-'", false); + type(" "); + helperTestComposing("a-", true); + type(" "); + helperTestComposing("a'", true); + } // TODO: Add some tests for non-BMP characters } diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java index f3ca2b147..d50d1ac96 100644 --- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java +++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java @@ -44,7 +44,7 @@ import java.util.Random; import java.util.Set; /** - * Unit tests for BinaryDictDecoderUtils and BinaryDictEncoder. + * Unit tests for BinaryDictDecoderUtils and BinaryDictEncoderUtils. */ @LargeTest public class BinaryDictDecoderEncoderTests extends AndroidTestCase { @@ -210,7 +210,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { // If you need to dump the dict to a textual file, uncomment the line below and the // function above // dumpToCombinedFileForDebug(file, "/tmp/foo"); - BinaryDictEncoder.writeDictionaryBinary(out, dict, formatOptions); + BinaryDictEncoderUtils.writeDictionaryBinary(out, dict, formatOptions); diff = System.currentTimeMillis() - now; out.flush(); @@ -512,7 +512,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase { return null; } if (fileHeader == null) return null; - return BinaryDictDecoderUtils.getWordAtAddress(dictBuffer, fileHeader.mHeaderSize, + return BinaryDictDecoderUtils.getWordAtAddress(dictDecoder, fileHeader.mHeaderSize, address - fileHeader.mHeaderSize, fileHeader.mFormatOptions).mWord; } diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java index 74c20a38c..878417084 100644 --- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java +++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java @@ -112,14 +112,15 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { Log.d(TAG, " end address = " + info.mEndAddress); } - private static void printNode(final DictBuffer dictBuffer, + private static void printNode(final Ver3DictDecoder dictDecoder, final FormatSpec.FormatOptions formatOptions) { + final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); Log.d(TAG, "Node at " + dictBuffer.position()); final int count = BinaryDictDecoderUtils.readCharGroupCount(dictBuffer); Log.d(TAG, " charGroupCount = " + count); for (int i = 0; i < count; ++i) { - final CharGroupInfo currentInfo = BinaryDictDecoderUtils.readCharGroup(dictBuffer, - dictBuffer.position(), formatOptions); + final CharGroupInfo currentInfo = dictDecoder.readPtNode(dictBuffer.position(), + formatOptions); printCharGroup(currentInfo); } if (formatOptions.mSupportsDynamicUpdate) { @@ -131,9 +132,9 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { private static void printBinaryFile(final Ver3DictDecoder dictDecoder) throws IOException, UnsupportedFormatException { final FileHeader fileHeader = dictDecoder.readHeader(); - final DictBuffer buffer = dictDecoder.getDictBuffer(); - while (buffer.position() < buffer.limit()) { - printNode(buffer, fileHeader.mFormatOptions); + final DictBuffer dictBuffer = dictDecoder.getDictBuffer(); + while (dictBuffer.position() < dictBuffer.limit()) { + printNode(dictDecoder, fileHeader.mFormatOptions); } } @@ -227,9 +228,8 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory()); final FileHeader fileHeader = dictDecoder.readHeader(); assertEquals(word, - BinaryDictDecoderUtils.getWordAtAddress(dictDecoder.getDictBuffer(), - fileHeader.mHeaderSize, position - fileHeader.mHeaderSize, - fileHeader.mFormatOptions).mWord); + BinaryDictDecoderUtils.getWordAtAddress(dictDecoder, fileHeader.mHeaderSize, + position - fileHeader.mHeaderSize, fileHeader.mFormatOptions).mWord); } catch (IOException e) { Log.e(TAG, "Raised an IOException while looking up a word", e); } catch (UnsupportedFormatException e) { @@ -253,7 +253,7 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { try { final FileOutputStream out = new FileOutputStream(file); - BinaryDictEncoder.writeDictionaryBinary(out, dict, FORMAT_OPTIONS); + BinaryDictEncoderUtils.writeDictionaryBinary(out, dict, FORMAT_OPTIONS); out.close(); } catch (IOException e) { fail("IOException while writing an initial dictionary : " + e); @@ -305,7 +305,7 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { try { final FileOutputStream out = new FileOutputStream(file); - BinaryDictEncoder.writeDictionaryBinary(out, dict, FORMAT_OPTIONS); + BinaryDictEncoderUtils.writeDictionaryBinary(out, dict, FORMAT_OPTIONS); out.close(); } catch (IOException e) { fail("IOException while writing an initial dictionary : " + e); @@ -343,7 +343,7 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase { try { final FileOutputStream out = new FileOutputStream(file); - BinaryDictEncoder.writeDictionaryBinary(out, dict, FORMAT_OPTIONS); + BinaryDictEncoderUtils.writeDictionaryBinary(out, dict, FORMAT_OPTIONS); out.close(); } catch (IOException e) { assertTrue(false); |