diff options
Diffstat (limited to 'tests/src')
3 files changed, 31 insertions, 88 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java index a1ceb8e2e..74ff87977 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java @@ -150,59 +150,6 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_SHIFT_LOCKED); } - // Automatic switch back to alphabet by registered letters. - public void testSwitchBackChar() { - // Set switch back chars. - final String switchBackSymbols = "'"; - final int switchBackCode = switchBackSymbols.codePointAt(0); - setLayoutSwitchBackSymbols(switchBackSymbols); - loadKeyboard(ALPHABET_UNSHIFTED); - - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Enter symbol letter. - pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Enter switch back letter, switch back to alphabet. - pressAndReleaseKey(switchBackCode, SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED); - - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Enter symbol shift letter. - pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Enter switch abck letter, switch back to alphabet. - pressAndReleaseKey(switchBackCode, SYMBOLS_SHIFTED, ALPHABET_UNSHIFTED); - } - - // Automatic switch back to alphabet shift locked by registered letters. - public void testSwitchBackCharShiftLocked() { - // Set switch back chars. - final String switchBackSymbols = "'"; - final int switchBackCode = switchBackSymbols.codePointAt(0); - setLayoutSwitchBackSymbols(switchBackSymbols); - loadKeyboard(ALPHABET_UNSHIFTED); - // Long press shift key, enter alphabet shift locked. - longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, - ALPHABET_SHIFT_LOCKED); - - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Enter symbol letter. - pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Enter switch back letter, switch back to alphabet shift locked. - pressAndReleaseKey(switchBackCode, SYMBOLS_UNSHIFTED, ALPHABET_SHIFT_LOCKED); - - // Press/release "?123" key, enter into symbols. - pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); - // Press/release "=\<" key, enter into symbols shifted. - pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Enter symbol shift letter. - pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); - // Enter switch back letter, switch back to alphabet shift locked. - pressAndReleaseKey(switchBackCode, SYMBOLS_SHIFTED, ALPHABET_SHIFT_LOCKED); - } - // Automatic upper case test public void testAutomaticUpperCase() { // Set capitalize the first character of all words mode. diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTestsBase.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTestsBase.java index c75f8269a..08199a074 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTestsBase.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTestsBase.java @@ -22,8 +22,6 @@ public class KeyboardStateTestsBase extends AndroidTestCase implements MockKeyboardSwitcher.MockConstants { protected MockKeyboardSwitcher mSwitcher; - private String mLayoutSwitchBackSymbols = ""; - @Override protected void setUp() throws Exception { super.setUp(); @@ -34,88 +32,86 @@ public class KeyboardStateTestsBase extends AndroidTestCase loadKeyboard(ALPHABET_UNSHIFTED); } - public void setAutoCapsMode(int autoCaps) { + public void setAutoCapsMode(final int autoCaps) { mSwitcher.setAutoCapsMode(autoCaps); } - public void setLayoutSwitchBackSymbols(String switchBackSymbols) { - mLayoutSwitchBackSymbols = switchBackSymbols; - } - - private static void assertLayout(String message, int expected, int actual) { + private static void assertLayout(final String message, final int expected, final int actual) { assertTrue(message + ": expected=" + MockKeyboardSwitcher.getLayoutName(expected) + " actual=" + MockKeyboardSwitcher.getLayoutName(actual), expected == actual); } - public void updateShiftState(int afterUpdate) { + public void updateShiftState(final int afterUpdate) { mSwitcher.updateShiftState(); assertLayout("afterUpdate", afterUpdate, mSwitcher.getLayoutId()); } - public void loadKeyboard(int afterLoad) { - mSwitcher.loadKeyboard(mLayoutSwitchBackSymbols); + public void loadKeyboard(final int afterLoad) { + mSwitcher.loadKeyboard(); mSwitcher.updateShiftState(); assertLayout("afterLoad", afterLoad, mSwitcher.getLayoutId()); } - public void rotateDevice(int afterRotate) { + public void rotateDevice(final int afterRotate) { mSwitcher.saveKeyboardState(); - mSwitcher.loadKeyboard(mLayoutSwitchBackSymbols); + mSwitcher.loadKeyboard(); assertLayout("afterRotate", afterRotate, mSwitcher.getLayoutId()); } - private void pressKeyWithoutTimerExpire(int code, boolean isSinglePointer, int afterPress) { + private void pressKeyWithoutTimerExpire(final int code, final boolean isSinglePointer, + final int afterPress) { mSwitcher.onPressKey(code, isSinglePointer); assertLayout("afterPress", afterPress, mSwitcher.getLayoutId()); } - public void pressKey(int code, int afterPress) { + public void pressKey(final int code, final int afterPress) { mSwitcher.expireDoubleTapTimeout(); pressKeyWithoutTimerExpire(code, true, afterPress); } - public void releaseKey(int code, int afterRelease) { + public void releaseKey(final int code, final int afterRelease) { mSwitcher.onCodeInput(code, SINGLE); mSwitcher.onReleaseKey(code, NOT_SLIDING); assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId()); } - public void pressAndReleaseKey(int code, int afterPress, int afterRelease) { + public void pressAndReleaseKey(final int code, final int afterPress, final int afterRelease) { pressKey(code, afterPress); releaseKey(code, afterRelease); } - public void chordingPressKey(int code, int afterPress) { + public void chordingPressKey(final int code, final int afterPress) { mSwitcher.expireDoubleTapTimeout(); pressKeyWithoutTimerExpire(code, false, afterPress); } - public void chordingReleaseKey(int code, int afterRelease) { + public void chordingReleaseKey(final int code, final int afterRelease) { mSwitcher.onCodeInput(code, MULTI); mSwitcher.onReleaseKey(code, NOT_SLIDING); assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId()); } - public void chordingPressAndReleaseKey(int code, int afterPress, int afterRelease) { + public void chordingPressAndReleaseKey(final int code, final int afterPress, + final int afterRelease) { chordingPressKey(code, afterPress); chordingReleaseKey(code, afterRelease); } - public void pressAndSlideFromKey(int code, int afterPress, int afterSlide) { + public void pressAndSlideFromKey(final int code, final int afterPress, final int afterSlide) { pressKey(code, afterPress); mSwitcher.onReleaseKey(code, SLIDING); assertLayout("afterSlide", afterSlide, mSwitcher.getLayoutId()); } - public void longPressKey(int code, int afterPress, int afterLongPress) { + public void longPressKey(final int code, final int afterPress, final int afterLongPress) { pressKey(code, afterPress); mSwitcher.onLongPressTimeout(code); assertLayout("afterLongPress", afterLongPress, mSwitcher.getLayoutId()); } - public void longPressAndReleaseKey(int code, int afterPress, int afterLongPress, - int afterRelease) { + public void longPressAndReleaseKey(final int code, final int afterPress, + final int afterLongPress, final int afterRelease) { longPressKey(code, afterPress, afterLongPress); releaseKey(code, afterRelease); } diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java index 0213744fb..ac3558521 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java @@ -61,7 +61,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { return mLayout; } - public static String getLayoutName(int layoutId) { + public static String getLayoutName(final int layoutId) { switch (layoutId) { case MockConstants.ALPHABET_UNSHIFTED: return "ALPHABET_UNSHIFTED"; case MockConstants.ALPHABET_MANUAL_SHIFTED: return "ALPHABET_MANUAL_SHIFTED"; @@ -74,7 +74,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { } } - public void setAutoCapsMode(int autoCaps) { + public void setAutoCapsMode(final int autoCaps) { mAutoCapsMode = autoCaps; mAutoCapsState = autoCaps; } @@ -139,7 +139,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { } @Override - public void startLongPressTimer(int code) { + public void startLongPressTimer(final int code) { mLongPressTimeoutCode = code; } @@ -149,11 +149,11 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { } @Override - public void hapticAndAudioFeedback(int code) { + public void hapticAndAudioFeedback(final int code) { // Nothing to do. } - public void onLongPressTimeout(int code) { + public void onLongPressTimeout(final int code) { // TODO: Handle simultaneous long presses. if (mLongPressTimeoutCode == code) { mLongPressTimeoutCode = 0; @@ -165,26 +165,26 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { mState.onUpdateShiftState(mAutoCapsState); } - public void loadKeyboard(String layoutSwitchBackSymbols) { - mState.onLoadKeyboard(layoutSwitchBackSymbols); + public void loadKeyboard() { + mState.onLoadKeyboard(); } public void saveKeyboardState() { mState.onSaveKeyboardState(); } - public void onPressKey(int code, boolean isSinglePointer) { + public void onPressKey(final int code, final boolean isSinglePointer) { mState.onPressKey(code, isSinglePointer, mAutoCapsState); } - public void onReleaseKey(int code, boolean withSliding) { + public void onReleaseKey(final int code, final boolean withSliding) { mState.onReleaseKey(code, withSliding); if (mLongPressTimeoutCode == code) { mLongPressTimeoutCode = 0; } } - public void onCodeInput(int code, boolean isSinglePointer) { + public void onCodeInput(final int code, final boolean isSinglePointer) { if (mAutoCapsMode == MockConstants.CAP_MODE_WORDS) { if (Constants.isLetterCode(code)) { mAutoCapsState = (code == MockConstants.CODE_AUTO_CAPS_TRIGGER) @@ -196,7 +196,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { mState.onCodeInput(code, isSinglePointer, mAutoCapsState); } - public void onCancelInput(boolean isSinglePointer) { + public void onCancelInput(final boolean isSinglePointer) { mState.onCancelInput(isSinglePointer); } }
\ No newline at end of file |