diff options
author | 2014-04-14 12:31:22 +0000 | |
---|---|---|
committer | 2014-04-14 12:31:22 +0000 | |
commit | 751dc070bf5cbf2534eb86f5dbc05ec38fcffbee (patch) | |
tree | 749b9414c8edc6c97a6a1b38d4257ffd8bafd467 /tests/src | |
parent | d4e54af0bad9cdee02756f4973fb48670005e31a (diff) | |
parent | 2282e8520a2c1984989a14fb09896536f5033b26 (diff) | |
download | latinime-751dc070bf5cbf2534eb86f5dbc05ec38fcffbee.tar.gz latinime-751dc070bf5cbf2534eb86f5dbc05ec38fcffbee.tar.xz latinime-751dc070bf5cbf2534eb86f5dbc05ec38fcffbee.zip |
Merge "Fix updating the shift state upon backspace"
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/InputTestsBase.java | 20 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/latin/ShiftModeTests.java | 25 |
2 files changed, 40 insertions, 5 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java index e5f111ab6..260e534ee 100644 --- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java @@ -254,7 +254,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { } // type(int) and type(String): helper methods to send a code point resp. a string to LatinIME. - protected void type(final int codePoint) { + protected void typeInternal(final int codePoint, final boolean isKeyRepeat) { // onPressKey and onReleaseKey are explicitly deactivated here, but they do happen in the // code (although multitouch/slide input and other factors make the sequencing complicated). // They are supposed to be entirely deconnected from the input logic from LatinIME point of @@ -263,16 +263,26 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { // but keep them in mind if something breaks. Commenting them out as is should work. //mLatinIME.onPressKey(codePoint, 0 /* repeatCount */, true /* isSinglePointer */); final Key key = mKeyboard.getKey(codePoint); - if (key != null) { + if (key == null) { + mLatinIME.onCodeInput(codePoint, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, + isKeyRepeat); + } else { final int x = key.getX() + key.getWidth() / 2; final int y = key.getY() + key.getHeight() / 2; - mLatinIME.onCodeInput(codePoint, x, y); - return; + mLatinIME.onCodeInput(codePoint, x, y, isKeyRepeat); } - mLatinIME.onCodeInput(codePoint, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); + // Also see the comment at the top of this function about onReleaseKey //mLatinIME.onReleaseKey(codePoint, false /* withSliding */); } + protected void type(final int codePoint) { + typeInternal(codePoint, false /* isKeyRepeat */); + } + + protected void repeatKey(final int codePoint) { + typeInternal(codePoint, true /* isKeyRepeat */); + } + protected void type(final String stringToType) { for (int i = 0; i < stringToType.length(); i = stringToType.offsetByCodePoints(i, 1)) { type(stringToType.codePointAt(i)); diff --git a/tests/src/com/android/inputmethod/latin/ShiftModeTests.java b/tests/src/com/android/inputmethod/latin/ShiftModeTests.java index 806fad060..6fc9df793 100644 --- a/tests/src/com/android/inputmethod/latin/ShiftModeTests.java +++ b/tests/src/com/android/inputmethod/latin/ShiftModeTests.java @@ -53,4 +53,29 @@ public class ShiftModeTests extends InputTestsBase { type(" "); assertTrue("Caps after period space", isCapsModeAutoShifted()); } + + public void testBackspace() { + assertTrue("Initial auto caps state", isCapsModeAutoShifted()); + type("A"); + assertFalse("Caps state after one letter", isCapsModeAutoShifted()); + type(Constants.CODE_DELETE); + assertTrue("Auto caps state at start after delete", isCapsModeAutoShifted()); + } + + public void testRepeatingBackspace() { + final String SENTENCE_TO_TYPE = "Test sentence. Another."; + final int BACKSPACE_COUNT = + SENTENCE_TO_TYPE.length() - SENTENCE_TO_TYPE.lastIndexOf(' ') - 1; + + type(SENTENCE_TO_TYPE); + assertFalse("Caps after typing \"" + SENTENCE_TO_TYPE + "\"", isCapsModeAutoShifted()); + type(Constants.CODE_DELETE); + for (int i = 1; i < BACKSPACE_COUNT; ++i) { + repeatKey(Constants.CODE_DELETE); + } + assertFalse("Caps immediately after repeating Backspace a lot", isCapsModeAutoShifted()); + sleep(DELAY_TO_WAIT_FOR_PREDICTIONS); + runMessages(); + assertTrue("Caps after a while after repeating Backspace a lot", isCapsModeAutoShifted()); + } } |