Handling key repeat by emulating key press and code input

This change also eliminates a reference of
AudioAndHapticFeedbackManager from KeyboardSwitcher and MainKeyboard.

Bug: 6522943
Change-Id: Iac42ec8ff00c66deb76a660ffc07477923a58959
main
Tadashi G. Takaoka 2013-07-02 18:07:35 +09:00
parent b6f5d3e39d
commit f87e8f7ec1
11 changed files with 206 additions and 115 deletions

View File

@ -20,7 +20,6 @@ import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.InputPointers; import com.android.inputmethod.latin.InputPointers;
public interface KeyboardActionListener { public interface KeyboardActionListener {
/** /**
* Called when the user presses a key. This is sent before the {@link #onCodeInput} is called. * Called when the user presses a key. This is sent before the {@link #onCodeInput} is called.
* For keys that repeat, this is only called once. * For keys that repeat, this is only called once.
@ -99,9 +98,9 @@ public interface KeyboardActionListener {
*/ */
public boolean onCustomRequest(int requestCode); public boolean onCustomRequest(int requestCode);
public static class Adapter implements KeyboardActionListener { public static final KeyboardActionListener EMPTY_LISTENER = new Adapter();
public static final Adapter EMPTY_LISTENER = new Adapter();
public static class Adapter implements KeyboardActionListener {
@Override @Override
public void onPressKey(int primaryCode, boolean isSinglePointer) {} public void onPressKey(int primaryCode, boolean isSinglePointer) {}
@Override @Override

View File

@ -31,7 +31,6 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetException; import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetException;
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy; import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
import com.android.inputmethod.keyboard.internal.KeyboardState; import com.android.inputmethod.keyboard.internal.KeyboardState;
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
import com.android.inputmethod.latin.InputView; import com.android.inputmethod.latin.InputView;
import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
@ -210,7 +209,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
} }
public void onPressKey(final int code, final boolean isSinglePointer) { public void onPressKey(final int code, final boolean isSinglePointer) {
hapticAndAudioFeedback(code);
mState.onPressKey(code, isSinglePointer, mLatinIME.getCurrentAutoCapsState()); mState.onPressKey(code, isSinglePointer, mLatinIME.getCurrentAutoCapsState());
} }
@ -299,13 +297,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
? keyboardView.getTimerProxy().isInDoubleTapShiftKeyTimeout() : false; ? keyboardView.getTimerProxy().isInDoubleTapShiftKeyTimeout() : false;
} }
private void hapticAndAudioFeedback(final int code) {
if (mKeyboardView == null || mKeyboardView.isInSlidingKeyInput()) {
return;
}
AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(code, mKeyboardView);
}
/** /**
* Updates state machine to figure out when to automatically switch back to the previous mode. * Updates state machine to figure out when to automatically switch back to the previous mode.
*/ */

View File

@ -57,10 +57,8 @@ import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
import com.android.inputmethod.keyboard.internal.PreviewPlacerView; import com.android.inputmethod.keyboard.internal.PreviewPlacerView;
import com.android.inputmethod.keyboard.internal.SlidingKeyInputPreview; import com.android.inputmethod.keyboard.internal.SlidingKeyInputPreview;
import com.android.inputmethod.keyboard.internal.TouchScreenRegulator; import com.android.inputmethod.keyboard.internal.TouchScreenRegulator;
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.DebugSettings; import com.android.inputmethod.latin.DebugSettings;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.Settings; import com.android.inputmethod.latin.Settings;
@ -240,11 +238,15 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
break; break;
case MSG_REPEAT_KEY: case MSG_REPEAT_KEY:
final Key currentKey = tracker.getKey(); final Key currentKey = tracker.getKey();
if (currentKey != null && currentKey.mCode == msg.arg1) { final int code = msg.arg1;
tracker.onRepeatKey(currentKey); if (currentKey != null && currentKey.mCode == code) {
AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(
currentKey.mCode, keyboardView);
startKeyRepeatTimer(tracker, mKeyRepeatInterval); startKeyRepeatTimer(tracker, mKeyRepeatInterval);
startTypingStateTimer(currentKey);
final KeyboardActionListener listener =
keyboardView.getKeyboardActionListener();
listener.onPressKey(code, true /* isSinglePointer */);
listener.onCodeInput(code,
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
} }
break; break;
case MSG_LONGPRESS_KEY: case MSG_LONGPRESS_KEY:
@ -564,6 +566,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
altCodeKeyWhileTypingFadeoutAnimatorResId, this); altCodeKeyWhileTypingFadeoutAnimatorResId, this);
mAltCodeKeyWhileTypingFadeinAnimator = loadObjectAnimator( mAltCodeKeyWhileTypingFadeinAnimator = loadObjectAnimator(
altCodeKeyWhileTypingFadeinAnimatorResId, this); altCodeKeyWhileTypingFadeinAnimatorResId, this);
mKeyboardActionListener = KeyboardActionListener.EMPTY_LISTENER;
} }
private ObjectAnimator loadObjectAnimator(final int resId, final Object target) { private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
@ -977,39 +981,28 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.mainKeyboardView_onLongPress(); ResearchLogger.mainKeyboardView_onLongPress();
} }
final int code = key.mCode; final KeyboardActionListener listener = mKeyboardActionListener;
if (key.hasNoPanelAutoMoreKey()) { if (key.hasNoPanelAutoMoreKey()) {
final int embeddedCode = key.mMoreKeys[0].mCode; final int moreKeyCode = key.mMoreKeys[0].mCode;
tracker.onLongPressed(); tracker.onLongPressed();
invokeCodeInput(embeddedCode); listener.onPressKey(moreKeyCode, true /* isSinglePointer */);
invokeReleaseKey(code); listener.onCodeInput(moreKeyCode,
AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(code, this); Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
listener.onReleaseKey(moreKeyCode, false /* withSliding */);
return; return;
} }
final int code = key.mCode;
if (code == Constants.CODE_SPACE || code == Constants.CODE_LANGUAGE_SWITCH) { if (code == Constants.CODE_SPACE || code == Constants.CODE_LANGUAGE_SWITCH) {
// Long pressing the space key invokes IME switcher dialog. // Long pressing the space key invokes IME switcher dialog.
if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) { if (listener.onCustomRequest(Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER)) {
tracker.onLongPressed(); tracker.onLongPressed();
invokeReleaseKey(code); listener.onReleaseKey(code, false /* withSliding */);
return; return;
} }
} }
openMoreKeysPanel(key, tracker); openMoreKeysPanel(key, tracker);
} }
private boolean invokeCustomRequest(final int requestCode) {
return mKeyboardActionListener.onCustomRequest(requestCode);
}
private void invokeCodeInput(final int code) {
mKeyboardActionListener.onCodeInput(
code, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
}
private void invokeReleaseKey(final int code) {
mKeyboardActionListener.onReleaseKey(code, false);
}
private void openMoreKeysPanel(final Key key, final PointerTracker tracker) { private void openMoreKeysPanel(final Key key, final PointerTracker tracker) {
final MoreKeysPanel moreKeysPanel = onCreateMoreKeysPanel(key, getContext()); final MoreKeysPanel moreKeysPanel = onCreateMoreKeysPanel(key, getContext());
if (moreKeysPanel == null) { if (moreKeysPanel == null) {

View File

@ -175,7 +175,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
private DrawingProxy mDrawingProxy; private DrawingProxy mDrawingProxy;
private TimerProxy mTimerProxy; private TimerProxy mTimerProxy;
private KeyDetector mKeyDetector; private KeyDetector mKeyDetector;
private KeyboardActionListener mListener = KeyboardActionListener.Adapter.EMPTY_LISTENER; private KeyboardActionListener mListener = KeyboardActionListener.EMPTY_LISTENER;
private Keyboard mKeyboard; private Keyboard mKeyboard;
private int mPhantonSuddenMoveThreshold; private int mPhantonSuddenMoveThreshold;
@ -1263,13 +1263,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
if (!key.isRepeatable()) return; if (!key.isRepeatable()) return;
// Don't start key repeat when we are in sliding input mode. // Don't start key repeat when we are in sliding input mode.
if (mIsInSlidingKeyInput) return; if (mIsInSlidingKeyInput) return;
onRepeatKey(key);
mTimerProxy.startKeyRepeatTimer(this);
}
public void onRepeatKey(final Key key) {
detectAndSendKey(key, key.mX, key.mY, SystemClock.uptimeMillis()); detectAndSendKey(key, key.mX, key.mY, SystemClock.uptimeMillis());
mTimerProxy.startTypingStateTimer(key); mTimerProxy.startKeyRepeatTimer(this);
} }
private boolean isMajorEnoughMoveToBeOnNewKey(final int x, final int y, final long eventTime, private boolean isMajorEnoughMoveToBeOnNewKey(final int x, final int y, final long eventTime,

View File

@ -81,9 +81,6 @@ public final class KeyboardState {
private boolean mPrevSymbolsKeyboardWasShifted; private boolean mPrevSymbolsKeyboardWasShifted;
private int mRecapitalizeMode; private int mRecapitalizeMode;
// For handling long press.
private boolean mLongPressShiftLockFired;
// For handling double tap. // For handling double tap.
private boolean mIsInAlphabetUnshiftedFromShifted; private boolean mIsInAlphabetUnshiftedFromShifted;
private boolean mIsInDoubleTapShiftKey; private boolean mIsInDoubleTapShiftKey;
@ -325,10 +322,11 @@ public final class KeyboardState {
} }
if (code == Constants.CODE_SHIFT) { if (code == Constants.CODE_SHIFT) {
onPressShift(); onPressShift();
} else if (code == Constants.CODE_CAPSLOCK) {
// Nothing to do here. See {@link #onReleaseKey(int,boolean)}.
} else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { } else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
onPressSymbol(); onPressSymbol();
} else { } else {
mLongPressShiftLockFired = false;
mShiftKeyState.onOtherKeyPressed(); mShiftKeyState.onOtherKeyPressed();
mSymbolKeyState.onOtherKeyPressed(); mSymbolKeyState.onOtherKeyPressed();
// It is required to reset the auto caps state when all of the following conditions // It is required to reset the auto caps state when all of the following conditions
@ -356,6 +354,8 @@ public final class KeyboardState {
} }
if (code == Constants.CODE_SHIFT) { if (code == Constants.CODE_SHIFT) {
onReleaseShift(withSliding); onReleaseShift(withSliding);
} else if (code == Constants.CODE_CAPSLOCK) {
setShiftLocked(!mAlphabetShiftState.isShiftLocked());
} else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) { } else if (code == Constants.CODE_SWITCH_ALPHA_SYMBOL) {
onReleaseSymbol(withSliding); onReleaseSymbol(withSliding);
} }
@ -437,7 +437,6 @@ public final class KeyboardState {
} }
private void onPressShift() { private void onPressShift() {
mLongPressShiftLockFired = false;
// If we are recapitalizing, we don't do any of the normal processing, including // If we are recapitalizing, we don't do any of the normal processing, including
// importantly the double tap timer. // importantly the double tap timer.
if (RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE != mRecapitalizeMode) { if (RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE != mRecapitalizeMode) {
@ -499,8 +498,6 @@ public final class KeyboardState {
// Double tap shift key has been handled in {@link #onPressShift}, so that just // Double tap shift key has been handled in {@link #onPressShift}, so that just
// ignore this release shift key here. // ignore this release shift key here.
mIsInDoubleTapShiftKey = false; mIsInDoubleTapShiftKey = false;
} else if (mLongPressShiftLockFired) {
setShiftLocked(!mAlphabetShiftState.isShiftLocked());
} else if (mShiftKeyState.isChording()) { } else if (mShiftKeyState.isChording()) {
if (mAlphabetShiftState.isShiftLockShifted()) { if (mAlphabetShiftState.isShiftLockShifted()) {
// After chording input while shift locked state. // After chording input while shift locked state.
@ -610,12 +607,6 @@ public final class KeyboardState {
break; break;
} }
if (code == Constants.CODE_CAPSLOCK) {
// Changing shift lock state will be handled at {@link #onPressShift()} when the shift
// key is released.
mLongPressShiftLockFired = true;
}
// If the code is a letter, update keyboard shift state. // If the code is a letter, update keyboard shift state.
if (Constants.isLetterCode(code)) { if (Constants.isLetterCode(code)) {
updateAlphabetShiftState(autoCaps, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE); updateAlphabetShiftState(autoCaps, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);

View File

@ -148,6 +148,13 @@ public final class Constants {
return coordinate >= 0; return coordinate >= 0;
} }
/**
* Custom request code used in
* {@link com.android.inputmethod.keyboard.KeyboardActionListener#onCustomRequest(int)}.
*/
// The code to show input method picker.
public static final int CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER = 1;
/** /**
* Some common keys code. Must be positive. * Some common keys code. Must be positive.
*/ */

View File

@ -1360,14 +1360,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
showSubtypeSelectorAndSettings(); showSubtypeSelectorAndSettings();
} }
// Virtual codes representing custom requests. These are used in onCustomRequest() below.
public static final int CODE_SHOW_INPUT_METHOD_PICKER = 1;
@Override @Override
public boolean onCustomRequest(final int requestCode) { public boolean onCustomRequest(final int requestCode) {
if (isShowingOptionDialog()) return false; if (isShowingOptionDialog()) return false;
switch (requestCode) { switch (requestCode) {
case CODE_SHOW_INPUT_METHOD_PICKER: case Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER:
if (mRichImm.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */)) { if (mRichImm.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */)) {
mRichImm.getInputMethodManager().showInputMethodPicker(); mRichImm.getInputMethodManager().showInputMethodPicker();
return true; return true;
@ -2678,15 +2675,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
} }
// Callback called by PointerTracker through the KeyboardActionListener. This is called when a // Callback of the {@link KeyboardActionListener}. This is called when a key is depressed;
// key is depressed; release matching call is onReleaseKey below. // release matching call is {@link #onReleaseKey(int,boolean)} below.
@Override @Override
public void onPressKey(final int primaryCode, final boolean isSinglePointer) { public void onPressKey(final int primaryCode, final boolean isSinglePointer) {
mKeyboardSwitcher.onPressKey(primaryCode, isSinglePointer); mKeyboardSwitcher.onPressKey(primaryCode, isSinglePointer);
final MainKeyboardView mKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
final boolean noFeedback = (mKeyboardView != null && mKeyboardView.isInSlidingKeyInput())
|| (primaryCode == Constants.CODE_DELETE && !mConnection.canDeleteCharacters());
if (!noFeedback) {
AudioAndHapticFeedbackManager.getInstance().hapticAndAudioFeedback(
primaryCode, mKeyboardView);
}
} }
// Callback by PointerTracker through the KeyboardActionListener. This is called when a key // Callback of the {@link KeyboardActionListener}. This is called when a key is released;
// is released; press matching call is onPressKey above. // press matching call is {@link #onPressKey(int,boolean)} above.
@Override @Override
public void onReleaseKey(final int primaryCode, final boolean withSliding) { public void onReleaseKey(final int primaryCode, final boolean withSliding) {
mKeyboardSwitcher.onReleaseKey(primaryCode, withSliding); mKeyboardSwitcher.onReleaseKey(primaryCode, withSliding);

View File

@ -191,6 +191,10 @@ public final class RichInputConnection {
return mIC.getSelectedText(flags); return mIC.getSelectedText(flags);
} }
public boolean canDeleteCharacters() {
return mCurrentCursorPosition > 0;
}
/** /**
* Gets the caps modes we should be in after this specific string. * Gets the caps modes we should be in after this specific string.
* *

View File

@ -60,7 +60,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
// Chording input in shift locked. // Chording input in shift locked.
public void testChordingShiftLocked() { public void testChordingShiftLocked() {
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press shift key and hold, enter into choring shift state. // Press shift key and hold, enter into choring shift state.
@ -119,7 +119,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -137,7 +137,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -196,7 +196,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -216,7 +216,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -397,29 +397,29 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
public void testLongPressShiftAndChording() { public void testLongPressShiftAndChording() {
// Long press shift key, enter maybe shift locked. // Long press shift key, enter maybe shift locked.
longPressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Press/release letter key, remain in manual shifted. // Press/release letter key, remain in manual shifted.
chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Release shift key, back to alphabet (not shift locked). // Release shift key, back to alphabet (not shift locked).
releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Long press shift key, enter maybe alphabet. // Long press shift key, enter maybe alphabet.
longPressKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED); longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED);
// Press/release letter key, remain in manual shifted. // Press/release letter key, remain in manual shifted.
chordingPressAndReleaseKey('A', ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED); chordingPressAndReleaseKey('A', ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED);
// Release shift key, back to shift locked (not alphabet). // Release shift key, back to shift locked (not alphabet).
releaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED); releaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED);
// Long press shift key, enter alphabet // Long press shift key, enter alphabet
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED,
ALPHABET_UNSHIFTED); ALPHABET_UNSHIFTED);
// Press/release shift key, enter alphabet shifted. // Press/release shift key, enter alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Long press shift key, enter maybe alphabet. // Long press shift key, enter maybe alphabet.
longPressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Press/release letter key, remain in manual shifted. // Press/release letter key, remain in manual shifted.
chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Release shift key, back to alphabet shifted (not alphabet). // Release shift key, back to alphabet shifted (not alphabet).
@ -430,7 +430,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
// Load keyboard, should be in automatic shifted. // Load keyboard, should be in automatic shifted.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
// Long press shift key, enter maybe shift locked. // Long press shift key, enter maybe shift locked.
longPressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Press/release letter key, remain in manual shifted. // Press/release letter key, remain in manual shifted.
chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Release shift key, back to alphabet (not shift locked). // Release shift key, back to alphabet (not shift locked).
@ -449,7 +449,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
// releaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); // releaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED);
// //
// // Long press shift key, enter alphabet shift locked. // // Long press shift key, enter alphabet shift locked.
// longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, // longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
// ALPHABET_SHIFT_LOCKED); // ALPHABET_SHIFT_LOCKED);
// // First shift key tap. // // First shift key tap.
// pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); // pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);

View File

@ -91,7 +91,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Switching between alphabet shift locked and symbols. // Switching between alphabet shift locked and symbols.
public void testAlphabetShiftLockedAndSymbols() { public void testAlphabetShiftLockedAndSymbols() {
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
@ -133,7 +133,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Automatic switch back to alphabet shift locked test by space key. // Automatic switch back to alphabet shift locked test by space key.
public void testSwitchBackBySpaceShiftLocked() { public void testSwitchBackBySpaceShiftLocked() {
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
@ -196,13 +196,13 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Load keyboard, should be in alphabet. // Load keyboard, should be in alphabet.
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release shift key, back to alphabet. // Press/release shift key, back to alphabet.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release letter key, remain in shift locked. // Press/release letter key, remain in shift locked.
pressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); pressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
@ -212,16 +212,16 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Long press shift key, back to alphabet. // Long press shift key, back to alphabet.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED,
ALPHABET_UNSHIFTED); ALPHABET_UNSHIFTED);
// Press/release shift key, enter alphabet shifted. // Press/release shift key, enter alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release shift key, back to alphabet. // Press/release shift key, back to alphabet.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED);
@ -231,7 +231,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Load keyboard, should be in automatic shifted. // Load keyboard, should be in automatic shifted.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release shift key, back to alphabet. // Press/release shift key, back to alphabet.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED);
@ -293,12 +293,12 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
updateShiftState(ALPHABET_UNSHIFTED); updateShiftState(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Update shift state, remained in alphabet shift locked. // Update shift state, remained in alphabet shift locked.
updateShiftState(ALPHABET_SHIFT_LOCKED); updateShiftState(ALPHABET_SHIFT_LOCKED);
// Long press shift key, back to alphabet. // Long press shift key, back to alphabet.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED,
ALPHABET_UNSHIFTED); ALPHABET_UNSHIFTED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
@ -326,12 +326,12 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED); updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Update shift state, remained in alphabet shift locked (not automatic shifted). // Update shift state, remained in alphabet shift locked (not automatic shifted).
updateShiftState(ALPHABET_SHIFT_LOCKED); updateShiftState(ALPHABET_SHIFT_LOCKED);
// Long press shift key, back to alphabet. // Long press shift key, back to alphabet.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED,
ALPHABET_UNSHIFTED); ALPHABET_UNSHIFTED);
// Load keyboard, should be in automatic shifted. // Load keyboard, should be in automatic shifted.
@ -383,7 +383,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Alphabet shift locked -> shift key + letter -> alphabet shift locked. // Alphabet shift locked -> shift key + letter -> alphabet shift locked.
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press and slide from "123?" key, enter symbols. // Press and slide from "123?" key, enter symbols.
pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -441,7 +441,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Alphabet shift locked -> shift key + letter -> cancel -> alphabet shift locked. // Alphabet shift locked -> shift key + letter -> cancel -> alphabet shift locked.
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press and slide from "123?" key, enter symbols. // Press and slide from "123?" key, enter symbols.
pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -500,7 +500,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -517,7 +517,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -574,7 +574,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -592,7 +592,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -651,7 +651,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -670,7 +670,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -733,7 +733,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -753,7 +753,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Load keyboard // Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
@ -777,7 +777,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Change focus to new text field. // Change focus to new text field.
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
@ -808,7 +808,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Change focus to new text field. // Change focus to new text field.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
@ -852,7 +852,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Alphabet shift locked -> rotate -> alphabet shift locked. // Alphabet shift locked -> rotate -> alphabet shift locked.
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Rotate device, remain in alphabet shift locked. // Rotate device, remain in alphabet shift locked.
rotateDevice(ALPHABET_SHIFT_LOCKED); rotateDevice(ALPHABET_SHIFT_LOCKED);
@ -936,7 +936,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
secondPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); secondPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Long press shift key to enter alphabet shift locked. // Long press shift key to enter alphabet shift locked.
longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED,
ALPHABET_SHIFT_LOCKED); ALPHABET_SHIFT_LOCKED);
// Press/release shift key // Press/release shift key
pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED);

View File

@ -34,6 +34,11 @@ public class KeyboardStateTestsBase extends AndroidTestCase
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
} }
/**
* Set auto caps mode.
*
* @param autoCaps the auto cap mode.
*/
public void setAutoCapsMode(final int autoCaps) { public void setAutoCapsMode(final int autoCaps) {
mSwitcher.setAutoCapsMode(autoCaps); mSwitcher.setAutoCapsMode(autoCaps);
} }
@ -44,17 +49,32 @@ public class KeyboardStateTestsBase extends AndroidTestCase
expected == actual); expected == actual);
} }
/**
* Emulate update keyboard shift state.
*
* @param afterUpdate the keyboard state after updating the keyboard shift state.
*/
public void updateShiftState(final int afterUpdate) { public void updateShiftState(final int afterUpdate) {
mSwitcher.updateShiftState(); mSwitcher.updateShiftState();
assertLayout("afterUpdate", afterUpdate, mSwitcher.getLayoutId()); assertLayout("afterUpdate", afterUpdate, mSwitcher.getLayoutId());
} }
/**
* Emulate load default keyboard.
*
* @param afterLoad the keyboard state after loading default keyboard.
*/
public void loadKeyboard(final int afterLoad) { public void loadKeyboard(final int afterLoad) {
mSwitcher.loadKeyboard(); mSwitcher.loadKeyboard();
mSwitcher.updateShiftState(); mSwitcher.updateShiftState();
assertLayout("afterLoad", afterLoad, mSwitcher.getLayoutId()); assertLayout("afterLoad", afterLoad, mSwitcher.getLayoutId());
} }
/**
* Emulate rotate device.
*
* @param afterRotate the keyboard state after rotating device.
*/
public void rotateDevice(final int afterRotate) { public void rotateDevice(final int afterRotate) {
mSwitcher.saveKeyboardState(); mSwitcher.saveKeyboardState();
mSwitcher.loadKeyboard(); mSwitcher.loadKeyboard();
@ -67,45 +87,97 @@ public class KeyboardStateTestsBase extends AndroidTestCase
assertLayout("afterPress", afterPress, mSwitcher.getLayoutId()); assertLayout("afterPress", afterPress, mSwitcher.getLayoutId());
} }
/**
* Emulate key press.
*
* @param code the key code to press.
* @param afterPress the keyboard state after pressing the key.
*/
public void pressKey(final int code, final int afterPress) { public void pressKey(final int code, final int afterPress) {
mSwitcher.expireDoubleTapTimeout(); mSwitcher.expireDoubleTapTimeout();
pressKeyWithoutTimerExpire(code, true, afterPress); pressKeyWithoutTimerExpire(code, true, afterPress);
} }
/**
* Emulate key release and register.
*
* @param code the key code to release and register
* @param afterRelease the keyboard state after releasing the key.
*/
public void releaseKey(final int code, final int afterRelease) { public void releaseKey(final int code, final int afterRelease) {
mSwitcher.onCodeInput(code); mSwitcher.onCodeInput(code);
mSwitcher.onReleaseKey(code, NOT_SLIDING); mSwitcher.onReleaseKey(code, NOT_SLIDING);
assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId()); assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId());
} }
/**
* Emulate key press and release.
*
* @param code the key code to press and release.
* @param afterPress the keyboard state after pressing the key.
* @param afterRelease the keyboard state after releasing the key.
*/
public void pressAndReleaseKey(final int code, final int afterPress, final int afterRelease) { public void pressAndReleaseKey(final int code, final int afterPress, final int afterRelease) {
pressKey(code, afterPress); pressKey(code, afterPress);
releaseKey(code, afterRelease); releaseKey(code, afterRelease);
} }
/**
* Emulate chording key press.
*
* @param code the chording key code.
* @param afterPress the keyboard state after pressing chording key.
*/
public void chordingPressKey(final int code, final int afterPress) { public void chordingPressKey(final int code, final int afterPress) {
mSwitcher.expireDoubleTapTimeout(); mSwitcher.expireDoubleTapTimeout();
pressKeyWithoutTimerExpire(code, false, afterPress); pressKeyWithoutTimerExpire(code, false, afterPress);
} }
/**
* Emulate chording key release.
*
* @param code the cording key code.
* @param afterRelease the keyboard state after releasing chording key.
*/
public void chordingReleaseKey(final int code, final int afterRelease) { public void chordingReleaseKey(final int code, final int afterRelease) {
mSwitcher.onCodeInput(code); mSwitcher.onCodeInput(code);
mSwitcher.onReleaseKey(code, NOT_SLIDING); mSwitcher.onReleaseKey(code, NOT_SLIDING);
assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId()); assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId());
} }
/**
* Emulate chording key press and release.
*
* @param code the chording key code.
* @param afterPress the keyboard state after pressing chording key.
* @param afterRelease the keyboard state after releasing chording key.
*/
public void chordingPressAndReleaseKey(final int code, final int afterPress, public void chordingPressAndReleaseKey(final int code, final int afterPress,
final int afterRelease) { final int afterRelease) {
chordingPressKey(code, afterPress); chordingPressKey(code, afterPress);
chordingReleaseKey(code, afterRelease); chordingReleaseKey(code, afterRelease);
} }
/**
* Emulate start of the sliding key input.
*
* @param code the key code to start sliding.
* @param afterPress the keyboard state after pressing the key.
* @param afterSlide the keyboard state after releasing the key with sliding input.
*/
public void pressAndSlideFromKey(final int code, final int afterPress, final int afterSlide) { public void pressAndSlideFromKey(final int code, final int afterPress, final int afterSlide) {
pressKey(code, afterPress); pressKey(code, afterPress);
mSwitcher.onReleaseKey(code, SLIDING); mSwitcher.onReleaseKey(code, SLIDING);
assertLayout("afterSlide", afterSlide, mSwitcher.getLayoutId()); assertLayout("afterSlide", afterSlide, mSwitcher.getLayoutId());
} }
/**
* Emulate end of the sliding key input.
*
* @param code the key code to stop sliding.
* @param afterPress the keyboard state after pressing the key.
* @param afterSlide the keyboard state after releasing the key and stop sliding.
*/
public void stopSlidingOnKey(final int code, final int afterPress, final int afterSlide) { public void stopSlidingOnKey(final int code, final int afterPress, final int afterSlide) {
pressKey(code, afterPress); pressKey(code, afterPress);
mSwitcher.onCodeInput(code); mSwitcher.onCodeInput(code);
@ -114,32 +186,67 @@ public class KeyboardStateTestsBase extends AndroidTestCase
assertLayout("afterSlide", afterSlide, mSwitcher.getLayoutId()); assertLayout("afterSlide", afterSlide, mSwitcher.getLayoutId());
} }
/**
* Emulate cancel the sliding key input.
*
* @param afterCancelSliding the keyboard state after canceling sliding input.
*/
public void stopSlidingAndCancel(final int afterCancelSliding) { public void stopSlidingAndCancel(final int afterCancelSliding) {
mSwitcher.onFinishSlidingInput(); mSwitcher.onFinishSlidingInput();
assertLayout("afterCancelSliding", afterCancelSliding, mSwitcher.getLayoutId()); assertLayout("afterCancelSliding", afterCancelSliding, mSwitcher.getLayoutId());
} }
public void longPressKey(final int code, final int afterPress, final int afterLongPress) { /**
pressKey(code, afterPress); * Emulate long press shift key.
*
* @param afterPress the keyboard state after pressing shift key.
* @param afterLongPress the keyboard state after long press fired.
*/
public void longPressShiftKey(final int afterPress, final int afterLongPress) {
// Long press shift key will register {@link Constants#CODE_CAPS_LOCK}. See // Long press shift key will register {@link Constants#CODE_CAPS_LOCK}. See
// {@link R.xml#key_styles_common} and its baseForShiftKeyStyle. We thus emulate the // {@link R.xml#key_styles_common} and its baseForShiftKeyStyle. We thus emulate the
// behavior here. // behavior that is implemented in {@link MainKeyboardView#onLongPress(PointerTracker)}.
final int longPressCode = code == CODE_SHIFT ? Constants.CODE_CAPSLOCK : code; pressKey(Constants.CODE_SHIFT, afterPress);
mSwitcher.onCodeInput(longPressCode); mSwitcher.onPressKey(Constants.CODE_CAPSLOCK, true /* isSinglePointer */);
mSwitcher.onCodeInput(Constants.CODE_CAPSLOCK);
assertLayout("afterLongPress", afterLongPress, mSwitcher.getLayoutId()); assertLayout("afterLongPress", afterLongPress, mSwitcher.getLayoutId());
} }
public void longPressAndReleaseKey(final int code, final int afterPress, /**
final int afterLongPress, final int afterRelease) { * Emulate long press shift key and release.
longPressKey(code, afterPress, afterLongPress); *
releaseKey(code, afterRelease); * @param afterPress the keyboard state after pressing shift key.
* @param afterLongPress the keyboard state after long press fired.
* @param afterRelease the keyboard state after shift key is released.
*/
public void longPressAndReleaseShiftKey(final int afterPress, final int afterLongPress,
final int afterRelease) {
// Long press shift key will register {@link Constants#CODE_CAPS_LOCK}. See
// {@link R.xml#key_styles_common} and its baseForShiftKeyStyle. We thus emulate the
// behavior that is implemented in {@link MainKeyboardView#onLongPress(PointerTracker)}.
longPressShiftKey(afterPress, afterLongPress);
releaseKey(Constants.CODE_CAPSLOCK, afterRelease);
} }
public void secondPressKey(int code, int afterPress) { /**
* Emulate the second press of the double tap.
*
* @param code the key code to double tap.
* @param afterPress the keyboard state after pressing the second tap.
*/
public void secondPressKey(final int code, final int afterPress) {
pressKeyWithoutTimerExpire(code, true, afterPress); pressKeyWithoutTimerExpire(code, true, afterPress);
} }
public void secondPressAndReleaseKey(int code, int afterPress, int afterRelease) { /**
* Emulate the second tap of the double tap.
*
* @param code the key code to double tap.
* @param afterPress the keyboard state after pressing the second tap.
* @param afterRelease the keyboard state after releasing the second tap.
*/
public void secondPressAndReleaseKey(final int code, final int afterPress,
final int afterRelease) {
secondPressKey(code, afterPress); secondPressKey(code, afterPress);
releaseKey(code, afterRelease); releaseKey(code, afterRelease);
} }