aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java21
-rw-r--r--tests/src/com/android/inputmethod/latin/InputTestsBase.java20
-rw-r--r--tests/src/com/android/inputmethod/latin/ShiftModeTests.java25
3 files changed, 54 insertions, 12 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
index 6e3e37add..a353e5a35 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
@@ -125,8 +125,9 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
}
@Override
- public void requestUpdatingShiftState() {
- mState.onUpdateShiftState(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
+ public void requestUpdatingShiftState(final int currentAutoCapsState,
+ final int currentRecapitalizeState) {
+ mState.onUpdateShiftState(currentAutoCapsState, currentRecapitalizeState);
}
@Override
@@ -149,7 +150,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
}
public void loadKeyboard() {
- mState.onLoadKeyboard();
+ mState.onLoadKeyboard(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
}
public void saveKeyboardState() {
@@ -157,11 +158,17 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
}
public void onPressKey(final int code, final boolean isSinglePointer) {
- mState.onPressKey(code, isSinglePointer, mAutoCapsState);
+ mState.onPressKey(code, isSinglePointer, mAutoCapsState,
+ RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
}
public void onReleaseKey(final int code, final boolean withSliding) {
- mState.onReleaseKey(code, withSliding);
+ onReleaseKey(code, withSliding, mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
+ }
+
+ public void onReleaseKey(final int code, final boolean withSliding,
+ final int currentAutoCapsState, final int currentRecapitalizeState) {
+ mState.onReleaseKey(code, withSliding, currentAutoCapsState, currentRecapitalizeState);
if (mLongPressTimeoutCode == code) {
mLongPressTimeoutCode = 0;
}
@@ -176,10 +183,10 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
} else {
mAutoCapsState = mAutoCapsMode;
}
- mState.onCodeInput(code, mAutoCapsState);
+ mState.onCodeInput(code, mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
}
public void onFinishSlidingInput() {
- mState.onFinishSlidingInput();
+ mState.onFinishSlidingInput(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
}
}
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());
+ }
}