am c9fade6b: Merge "Remove toggleShift and toggleAlphabetAndSymbols from KeyboardSwitcher"
* commit 'c9fade6b87b77251f90ef7d7c03bf70c3b97d889': Remove toggleShift and toggleAlphabetAndSymbols from KeyboardSwitchermain
commit
41701fc1f5
|
@ -148,7 +148,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
// have separate layouts with unique KeyboardIds for alphabet and alphabet-shifted
|
// have separate layouts with unique KeyboardIds for alphabet and alphabet-shifted
|
||||||
// respectively.
|
// respectively.
|
||||||
if (mainKeyboardId.isPhoneKeyboard()) {
|
if (mainKeyboardId.isPhoneKeyboard()) {
|
||||||
mState.onToggleAlphabetAndSymbols();
|
mState.setSymbolsKeyboard();
|
||||||
}
|
}
|
||||||
updateShiftState();
|
updateShiftState();
|
||||||
}
|
}
|
||||||
|
@ -256,13 +256,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggle keyboard shift state triggered by user touch event.
|
|
||||||
*/
|
|
||||||
public void toggleShift() {
|
|
||||||
mState.onToggleShift();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle caps lock state triggered by user touch event.
|
* Toggle caps lock state triggered by user touch event.
|
||||||
*/
|
*/
|
||||||
|
@ -270,13 +263,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
mState.onToggleCapsLock();
|
mState.onToggleCapsLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggle between alphabet and symbols modes triggered by user touch event.
|
|
||||||
*/
|
|
||||||
public void toggleAlphabetAndSymbols() {
|
|
||||||
mState.onToggleAlphabetAndSymbols();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update keyboard shift state triggered by connected EditText status change.
|
* Update keyboard shift state triggered by connected EditText status change.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,8 +31,7 @@ import com.android.inputmethod.keyboard.Keyboard;
|
||||||
* {@link #onPressShift(boolean)}, {@link #onReleaseShift(boolean)}, {@link #onPressSymbol()},
|
* {@link #onPressShift(boolean)}, {@link #onReleaseShift(boolean)}, {@link #onPressSymbol()},
|
||||||
* {@link #onReleaseSymbol()}, {@link #onOtherKeyPressed()},
|
* {@link #onReleaseSymbol()}, {@link #onOtherKeyPressed()},
|
||||||
* {@link #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)},
|
* {@link #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)},
|
||||||
* {@link #onUpdateShiftState(boolean)}, {@link #onToggleShift()}, {@link #onToggleCapsLock()},
|
* {@link #onUpdateShiftState(boolean)}, and {@link #onToggleCapsLock()}.
|
||||||
* and {@link #onToggleAlphabetAndSymbols()}.
|
|
||||||
*
|
*
|
||||||
* The actions are {@link SwitchActions}'s methods.
|
* The actions are {@link SwitchActions}'s methods.
|
||||||
*/
|
*/
|
||||||
|
@ -219,7 +218,8 @@ public class KeyboardState {
|
||||||
mSwitchActions.requestUpdatingShiftState();
|
mSwitchActions.requestUpdatingShiftState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSymbolsKeyboard() {
|
// TODO: Make this method private
|
||||||
|
public void setSymbolsKeyboard() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "setSymbolsKeyboard");
|
Log.d(TAG, "setSymbolsKeyboard");
|
||||||
}
|
}
|
||||||
|
@ -464,18 +464,6 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onToggleShift() {
|
|
||||||
if (DEBUG_STATE) {
|
|
||||||
Log.d(TAG, "onToggleShift: " + this);
|
|
||||||
}
|
|
||||||
if (mIsAlphabetMode) {
|
|
||||||
setShifted(mKeyboardShiftState.isShiftedOrShiftLocked()
|
|
||||||
? SwitchActions.UNSHIFT : SwitchActions.MANUAL_SHIFT);
|
|
||||||
} else {
|
|
||||||
toggleShiftInSymbols();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onToggleCapsLock() {
|
public void onToggleCapsLock() {
|
||||||
if (DEBUG_STATE) {
|
if (DEBUG_STATE) {
|
||||||
Log.d(TAG, "onToggleCapsLock: " + this);
|
Log.d(TAG, "onToggleCapsLock: " + this);
|
||||||
|
@ -492,13 +480,6 @@ public class KeyboardState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onToggleAlphabetAndSymbols() {
|
|
||||||
if (DEBUG_STATE) {
|
|
||||||
Log.d(TAG, "onToggleAlphabetAndSymbols: " + this);
|
|
||||||
}
|
|
||||||
toggleAlphabetAndSymbols();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String shiftModeToString(int shiftMode) {
|
private static String shiftModeToString(int shiftMode) {
|
||||||
switch (shiftMode) {
|
switch (shiftMode) {
|
||||||
case SwitchActions.UNSHIFT: return "UNSHIFT";
|
case SwitchActions.UNSHIFT: return "UNSHIFT";
|
||||||
|
|
|
@ -1261,16 +1261,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
LatinImeLogger.logOnDelete();
|
LatinImeLogger.logOnDelete();
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_SHIFT:
|
case Keyboard.CODE_SHIFT:
|
||||||
// Shift key is handled in onPress() when device has distinct multi-touch panel.
|
|
||||||
if (!distinctMultiTouch) {
|
|
||||||
switcher.toggleShift();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
|
case Keyboard.CODE_SWITCH_ALPHA_SYMBOL:
|
||||||
// Symbol key is handled in onPress() when device has distinct multi-touch panel.
|
// Shift and symbol key is handled in onPress() and onRelease().
|
||||||
if (!distinctMultiTouch) {
|
|
||||||
switcher.toggleAlphabetAndSymbols();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Keyboard.CODE_SETTINGS:
|
case Keyboard.CODE_SETTINGS:
|
||||||
onSettingsKeyPressed();
|
onSettingsKeyPressed();
|
||||||
|
@ -2271,10 +2263,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
if (switcher.isVibrateAndSoundFeedbackRequired()) {
|
if (switcher.isVibrateAndSoundFeedbackRequired()) {
|
||||||
hapticAndAudioFeedback(primaryCode);
|
hapticAndAudioFeedback(primaryCode);
|
||||||
}
|
}
|
||||||
final boolean distinctMultiTouch = switcher.hasDistinctMultitouch();
|
if (primaryCode == Keyboard.CODE_SHIFT) {
|
||||||
if (distinctMultiTouch && primaryCode == Keyboard.CODE_SHIFT) {
|
|
||||||
switcher.onPressShift(withSliding);
|
switcher.onPressShift(withSliding);
|
||||||
} else if (distinctMultiTouch && primaryCode == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
} else if (primaryCode == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||||
switcher.onPressSymbol();
|
switcher.onPressSymbol();
|
||||||
} else {
|
} else {
|
||||||
switcher.onOtherKeyPressed();
|
switcher.onOtherKeyPressed();
|
||||||
|
@ -2284,11 +2275,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
@Override
|
@Override
|
||||||
public void onRelease(int primaryCode, boolean withSliding) {
|
public void onRelease(int primaryCode, boolean withSliding) {
|
||||||
KeyboardSwitcher switcher = mKeyboardSwitcher;
|
KeyboardSwitcher switcher = mKeyboardSwitcher;
|
||||||
// Reset any drag flags in the keyboard
|
if (primaryCode == Keyboard.CODE_SHIFT) {
|
||||||
final boolean distinctMultiTouch = switcher.hasDistinctMultitouch();
|
|
||||||
if (distinctMultiTouch && primaryCode == Keyboard.CODE_SHIFT) {
|
|
||||||
switcher.onReleaseShift(withSliding);
|
switcher.onReleaseShift(withSliding);
|
||||||
} else if (distinctMultiTouch && primaryCode == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
} else if (primaryCode == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||||
switcher.onReleaseSymbol();
|
switcher.onReleaseSymbol();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,11 @@ import android.test.AndroidTestCase;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
|
|
||||||
public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
private MockKeyboardSwitcher mSwitcher;
|
protected MockKeyboardSwitcher mSwitcher;
|
||||||
|
|
||||||
|
public boolean hasDistinctMultitouch() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
|
@ -30,40 +34,39 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
mSwitcher = new MockKeyboardSwitcher();
|
mSwitcher = new MockKeyboardSwitcher();
|
||||||
|
|
||||||
final String layoutSwitchBackSymbols = "";
|
final String layoutSwitchBackSymbols = "";
|
||||||
final boolean hasDistinctMultitouch = false;
|
mSwitcher.loadKeyboard(layoutSwitchBackSymbols, hasDistinctMultitouch());
|
||||||
mSwitcher.loadKeyboard(layoutSwitchBackSymbols, hasDistinctMultitouch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Argument for KeyboardState.onPressShift and onReleaseShift.
|
// Argument for KeyboardState.onPressShift and onReleaseShift.
|
||||||
private static final boolean NOT_SLIDING = false;
|
public static final boolean NOT_SLIDING = false;
|
||||||
private static final boolean SLIDING = true;
|
public static final boolean SLIDING = true;
|
||||||
// Argument for KeyboardState.onCodeInput.
|
// Argument for KeyboardState.onCodeInput.
|
||||||
private static final boolean SINGLE = true;
|
public static final boolean SINGLE = true;
|
||||||
private static final boolean MULTI = false;
|
public static final boolean MULTI = false;
|
||||||
static final boolean NO_AUTO_CAPS = false;
|
public static final boolean NO_AUTO_CAPS = false;
|
||||||
private static final boolean AUTO_CAPS = true;
|
public static final boolean AUTO_CAPS = true;
|
||||||
|
|
||||||
private void assertAlphabetNormal() {
|
public void assertAlphabetNormal() {
|
||||||
assertTrue(mSwitcher.assertAlphabetNormal());
|
assertTrue(mSwitcher.assertAlphabetNormal());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertAlphabetManualShifted() {
|
public void assertAlphabetManualShifted() {
|
||||||
assertTrue(mSwitcher.assertAlphabetManualShifted());
|
assertTrue(mSwitcher.assertAlphabetManualShifted());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertAlphabetAutomaticShifted() {
|
public void assertAlphabetAutomaticShifted() {
|
||||||
assertTrue(mSwitcher.assertAlphabetAutomaticShifted());
|
assertTrue(mSwitcher.assertAlphabetAutomaticShifted());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertAlphabetShiftLocked() {
|
public void assertAlphabetShiftLocked() {
|
||||||
assertTrue(mSwitcher.assertAlphabetShiftLocked());
|
assertTrue(mSwitcher.assertAlphabetShiftLocked());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSymbolsNormal() {
|
public void assertSymbolsNormal() {
|
||||||
assertTrue(mSwitcher.assertSymbolsNormal());
|
assertTrue(mSwitcher.assertSymbolsNormal());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSymbolsShifted() {
|
public void assertSymbolsShifted() {
|
||||||
assertTrue(mSwitcher.assertSymbolsShifted());
|
assertTrue(mSwitcher.assertSymbolsShifted());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,23 +78,20 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
// Shift key in alphabet mode.
|
// Shift key in alphabet mode.
|
||||||
public void testShift() {
|
public void testShift() {
|
||||||
// Press/release shift key, enter into shift state.
|
// Press/release shift key, enter into shift state.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
assertAlphabetNormal();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.toggleShift();
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Press/release shift key, back to normal state.
|
// Press/release shift key, back to normal state.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.toggleShift();
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
|
|
||||||
// Press/release shift key, enter into shift state.
|
// Press/release shift key, enter into shift state.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
assertAlphabetNormal();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.toggleShift();
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
// Press/release letter key, snap back to normal state.
|
// Press/release letter key, snap back to normal state.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onOtherKeyPressed();
|
||||||
|
@ -99,20 +99,36 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterSymbolsMode() {
|
// Shift key sliding input.
|
||||||
// Press/release "?123" key.
|
public void testShiftSliding() {
|
||||||
|
// Press shift key.
|
||||||
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
|
assertAlphabetManualShifted();
|
||||||
|
// Slide out shift key.
|
||||||
|
mSwitcher.onReleaseShift(SLIDING);
|
||||||
|
assertAlphabetManualShifted();
|
||||||
|
|
||||||
|
// Enter into letter key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onOtherKeyPressed();
|
||||||
|
assertAlphabetManualShifted();
|
||||||
|
// Release letter key, snap back to alphabet.
|
||||||
|
mSwitcher.onCodeInput('Z', SINGLE);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
mSwitcher.toggleAlphabetAndSymbols();
|
}
|
||||||
|
|
||||||
|
public void enterSymbolsMode() {
|
||||||
|
// Press/release "?123" key.
|
||||||
|
mSwitcher.onPressSymbol();
|
||||||
|
assertSymbolsNormal();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
||||||
|
mSwitcher.onReleaseSymbol();
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void leaveSymbolsMode() {
|
public void leaveSymbolsMode() {
|
||||||
// Press/release "ABC" key.
|
// Press/release "ABC" key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressSymbol();
|
||||||
assertSymbolsNormal();
|
assertAlphabetNormal();
|
||||||
mSwitcher.toggleAlphabetAndSymbols();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
@ -126,20 +142,31 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
// Switching between alphabet shift locked and symbols.
|
// Switching between alphabet shift locked and symbols.
|
||||||
public void testAlphabetShiftLockedAndSymbols() {
|
public void testAlphabetShiftLockedAndSymbols() {
|
||||||
enterShiftLockWithLongPressShift();
|
enterShiftLockWithLongPressShift();
|
||||||
|
enterSymbolsMode();
|
||||||
// Press/release "?123" key.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
assertAlphabetShiftLocked();
|
|
||||||
mSwitcher.toggleAlphabetAndSymbols();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
|
||||||
assertSymbolsNormal();
|
|
||||||
|
|
||||||
// Press/release "ABC" key, switch back to shift locked mode.
|
// Press/release "ABC" key, switch back to shift locked mode.
|
||||||
|
mSwitcher.onPressSymbol();
|
||||||
|
assertAlphabetShiftLocked();
|
||||||
|
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
||||||
|
mSwitcher.onReleaseSymbol();
|
||||||
|
assertAlphabetShiftLocked();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Symbols key sliding input.
|
||||||
|
public void testSymbolsSliding() {
|
||||||
|
// Press "123?" key.
|
||||||
|
mSwitcher.onPressSymbol();
|
||||||
|
assertSymbolsNormal();
|
||||||
|
// Slide out from "123?" key.
|
||||||
|
mSwitcher.onReleaseSymbol();
|
||||||
|
assertSymbolsNormal();
|
||||||
|
|
||||||
|
// Enter into letter key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onOtherKeyPressed();
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
mSwitcher.toggleAlphabetAndSymbols();
|
// Release letter key, snap back to alphabet.
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
mSwitcher.onCodeInput('z', SINGLE);
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switching between symbols and symbols shifted.
|
// Switching between symbols and symbols shifted.
|
||||||
|
@ -147,23 +174,64 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
enterSymbolsMode();
|
enterSymbolsMode();
|
||||||
|
|
||||||
// Press/release "=\<" key.
|
// Press/release "=\<" key.
|
||||||
// Press/release shift key, enter into shift state.
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
mSwitcher.onOtherKeyPressed();
|
assertSymbolsShifted();
|
||||||
assertSymbolsNormal();
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
mSwitcher.toggleShift();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
|
||||||
assertSymbolsShifted();
|
assertSymbolsShifted();
|
||||||
|
|
||||||
// Press/release "?123" key.
|
// Press/release "?123" key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
assertSymbolsShifted();
|
assertSymbolsNormal();
|
||||||
mSwitcher.toggleShift();
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
|
|
||||||
leaveSymbolsMode();
|
leaveSymbolsMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Symbols shift sliding input
|
||||||
|
public void testSymbolsShiftSliding() {
|
||||||
|
enterSymbolsMode();
|
||||||
|
|
||||||
|
// Press "=\<" key.
|
||||||
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
|
assertSymbolsShifted();
|
||||||
|
// Slide out "=\<" key.
|
||||||
|
mSwitcher.onReleaseShift(SLIDING);
|
||||||
|
assertSymbolsShifted();
|
||||||
|
|
||||||
|
// Enter into symbol shifted letter key.
|
||||||
|
mSwitcher.onOtherKeyPressed();
|
||||||
|
assertSymbolsShifted();
|
||||||
|
// Release symbol shifted letter key, snap back to symbols.
|
||||||
|
mSwitcher.onCodeInput('~', SINGLE);
|
||||||
|
assertSymbolsNormal();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Symbols shift sliding input from symbols shifted.
|
||||||
|
public void testSymbolsShiftSliding2() {
|
||||||
|
enterSymbolsMode();
|
||||||
|
|
||||||
|
// Press/release "=\<" key.
|
||||||
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
|
assertSymbolsShifted();
|
||||||
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
|
assertSymbolsShifted();
|
||||||
|
|
||||||
|
// Press "123?" key.
|
||||||
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
|
assertSymbolsNormal();
|
||||||
|
// Slide out "123?" key.
|
||||||
|
mSwitcher.onReleaseShift(SLIDING);
|
||||||
|
assertSymbolsNormal();
|
||||||
|
|
||||||
|
// Enter into symbol letter key.
|
||||||
|
mSwitcher.onOtherKeyPressed();
|
||||||
|
assertSymbolsNormal();
|
||||||
|
// Release symbol letter key, snap back to symbols shift.
|
||||||
|
mSwitcher.onCodeInput('1', SINGLE);
|
||||||
|
assertSymbolsShifted();
|
||||||
|
}
|
||||||
|
|
||||||
// Automatic snap back to alphabet from symbols by space key.
|
// Automatic snap back to alphabet from symbols by space key.
|
||||||
public void testSnapBackBySpace() {
|
public void testSnapBackBySpace() {
|
||||||
enterSymbolsMode();
|
enterSymbolsMode();
|
||||||
|
@ -178,9 +246,9 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
assertSymbolsNormal();
|
assertSymbolsNormal();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SPACE, SINGLE);
|
mSwitcher.onCodeInput(Keyboard.CODE_SPACE, SINGLE);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Add automatic snap back to shift locked test.
|
// TODO: Add automatic snap back to shift locked test.
|
||||||
}
|
|
||||||
|
|
||||||
// Automatic snap back to alphabet from symbols by registered letters.
|
// Automatic snap back to alphabet from symbols by registered letters.
|
||||||
public void testSnapBack() {
|
public void testSnapBack() {
|
||||||
|
@ -211,31 +279,79 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
assertAlphabetAutomaticShifted();
|
assertAlphabetAutomaticShifted();
|
||||||
|
|
||||||
// Press shift key.
|
// Press shift key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
assertAlphabetAutomaticShifted();
|
assertAlphabetManualShifted();
|
||||||
// Release shift key.
|
// Release shift key.
|
||||||
mSwitcher.toggleShift();
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterShiftLockWithLongPressShift() {
|
// Sliding from shift key in automatic upper case.
|
||||||
|
public void testAutomaticUpperCaseSliding() {
|
||||||
|
mSwitcher.setAutoCapsMode(AUTO_CAPS);
|
||||||
|
// Update shift state with auto caps enabled.
|
||||||
|
mSwitcher.updateShiftState();
|
||||||
|
assertAlphabetAutomaticShifted();
|
||||||
|
|
||||||
// Press shift key.
|
// Press shift key.
|
||||||
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
|
assertAlphabetManualShifted();
|
||||||
|
// Slide out shift key.
|
||||||
|
mSwitcher.onReleaseShift(SLIDING);
|
||||||
|
assertAlphabetManualShifted();
|
||||||
|
// Enter into letter key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onOtherKeyPressed();
|
||||||
|
assertAlphabetManualShifted();
|
||||||
|
// Release letter key, snap back to alphabet.
|
||||||
|
mSwitcher.onCodeInput('Z', SINGLE);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sliding from symbol key in automatic upper case.
|
||||||
|
public void testAutomaticUpperCaseSliding2() {
|
||||||
|
mSwitcher.setAutoCapsMode(AUTO_CAPS);
|
||||||
|
// Update shift state with auto caps enabled.
|
||||||
|
mSwitcher.updateShiftState();
|
||||||
|
assertAlphabetAutomaticShifted();
|
||||||
|
|
||||||
|
// Press "123?" key.
|
||||||
|
mSwitcher.onPressSymbol();
|
||||||
|
assertSymbolsNormal();
|
||||||
|
// Slide out "123?" key.
|
||||||
|
mSwitcher.onReleaseSymbol();
|
||||||
|
assertSymbolsNormal();
|
||||||
|
// Enter into symbol letter keys.
|
||||||
|
mSwitcher.onOtherKeyPressed();
|
||||||
|
assertSymbolsNormal();
|
||||||
|
// Release symbol letter key, snap back to alphabet.
|
||||||
|
mSwitcher.onCodeInput('1', SINGLE);
|
||||||
|
assertAlphabetNormal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enterShiftLockWithLongPressShift() {
|
||||||
|
// Long press shift key
|
||||||
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
|
assertAlphabetManualShifted();
|
||||||
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
|
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
|
||||||
mSwitcher.toggleCapsLock();
|
mSwitcher.toggleCapsLock();
|
||||||
|
assertAlphabetShiftLocked();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_CAPSLOCK, SINGLE);
|
mSwitcher.onCodeInput(Keyboard.CODE_CAPSLOCK, SINGLE);
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetShiftLocked();
|
||||||
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
|
assertAlphabetShiftLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void leaveShiftLockWithLongPressShift() {
|
public void leaveShiftLockWithLongPressShift() {
|
||||||
// Press shift key.
|
// Press shift key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
|
assertAlphabetManualShifted();
|
||||||
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
|
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
|
||||||
mSwitcher.toggleCapsLock();
|
mSwitcher.toggleCapsLock();
|
||||||
|
assertAlphabetNormal();
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_CAPSLOCK, SINGLE);
|
mSwitcher.onCodeInput(Keyboard.CODE_CAPSLOCK, SINGLE);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Long press shift key.
|
// Long press shift key.
|
||||||
|
@ -251,10 +367,11 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetShiftLocked();
|
||||||
|
|
||||||
// Tap shift key.
|
// Tap shift key.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.toggleShift();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
||||||
|
assertAlphabetManualShifted();
|
||||||
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,11 +379,12 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
// TODO: Move double tap recognizing timer/logic into KeyboardState.
|
// TODO: Move double tap recognizing timer/logic into KeyboardState.
|
||||||
public void testDoubleTapShift() {
|
public void testDoubleTapShift() {
|
||||||
// First shift key tap.
|
// First shift key tap.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
assertAlphabetNormal();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.toggleShift();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
||||||
assertAlphabetManualShifted();
|
assertAlphabetManualShifted();
|
||||||
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
|
assertAlphabetManualShifted();
|
||||||
// Second shift key tap.
|
// Second shift key tap.
|
||||||
// Double tap recognized in LatinKeyboardView.KeyTimerHandler.
|
// Double tap recognized in LatinKeyboardView.KeyTimerHandler.
|
||||||
mSwitcher.toggleCapsLock();
|
mSwitcher.toggleCapsLock();
|
||||||
|
@ -275,10 +393,11 @@ public class KeyboardStateNonDistinctTests extends AndroidTestCase {
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetShiftLocked();
|
||||||
|
|
||||||
// First shift key tap.
|
// First shift key tap.
|
||||||
mSwitcher.onOtherKeyPressed();
|
mSwitcher.onPressShift(NOT_SLIDING);
|
||||||
assertAlphabetShiftLocked();
|
assertAlphabetManualShifted();
|
||||||
mSwitcher.toggleShift();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
||||||
|
assertAlphabetManualShifted();
|
||||||
|
mSwitcher.onReleaseShift(NOT_SLIDING);
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
// Second shift key tap.
|
// Second shift key tap.
|
||||||
// Second tap is ignored in LatinKeyboardView.KeyTimerHandler.
|
// Second tap is ignored in LatinKeyboardView.KeyTimerHandler.
|
||||||
|
|
|
@ -16,84 +16,12 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard.internal;
|
package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
|
|
||||||
public class KeyboardStateTests extends AndroidTestCase {
|
public class KeyboardStateTests extends KeyboardStateNonDistinctTests {
|
||||||
private MockKeyboardSwitcher mSwitcher;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
public boolean hasDistinctMultitouch() {
|
||||||
super.setUp();
|
return true;
|
||||||
|
|
||||||
mSwitcher = new MockKeyboardSwitcher();
|
|
||||||
|
|
||||||
final String layoutSwitchBackSymbols = "";
|
|
||||||
final boolean hasDistinctMultitouch = true;
|
|
||||||
mSwitcher.loadKeyboard(layoutSwitchBackSymbols, hasDistinctMultitouch);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Argument for KeyboardState.onPressShift and onReleaseShift.
|
|
||||||
private static final boolean NOT_SLIDING = false;
|
|
||||||
private static final boolean SLIDING = true;
|
|
||||||
// Argument for KeyboardState.onCodeInput.
|
|
||||||
private static final boolean SINGLE = true;
|
|
||||||
private static final boolean MULTI = false;
|
|
||||||
static final boolean NO_AUTO_CAPS = false;
|
|
||||||
private static final boolean AUTO_CAPS = true;
|
|
||||||
|
|
||||||
private void assertAlphabetNormal() {
|
|
||||||
assertTrue(mSwitcher.assertAlphabetNormal());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertAlphabetManualShifted() {
|
|
||||||
assertTrue(mSwitcher.assertAlphabetManualShifted());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertAlphabetAutomaticShifted() {
|
|
||||||
assertTrue(mSwitcher.assertAlphabetAutomaticShifted());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertAlphabetShiftLocked() {
|
|
||||||
assertTrue(mSwitcher.assertAlphabetShiftLocked());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertSymbolsNormal() {
|
|
||||||
assertTrue(mSwitcher.assertSymbolsNormal());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertSymbolsShifted() {
|
|
||||||
assertTrue(mSwitcher.assertSymbolsShifted());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initial state test.
|
|
||||||
public void testLoadKeyboard() {
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shift key in alphabet mode.
|
|
||||||
public void testShift() {
|
|
||||||
// Press/release shift key, enter into shift state.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
// Press/release shift key, back to normal state.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
|
|
||||||
// Press/release shift key, enter into shift state.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
// Press/release letter key, snap back to normal state.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
mSwitcher.onCodeInput('Z', SINGLE);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift key chording input.
|
// Shift key chording input.
|
||||||
|
@ -117,59 +45,6 @@ public class KeyboardStateTests extends AndroidTestCase {
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift key sliding input.
|
|
||||||
public void testShiftSliding() {
|
|
||||||
// Press shift key.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
// Slide out shift key.
|
|
||||||
mSwitcher.onReleaseShift(SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
|
|
||||||
// Enter into letter key.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
// Release letter key, snap back to alphabet.
|
|
||||||
mSwitcher.onCodeInput('Z', SINGLE);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enterSymbolsMode() {
|
|
||||||
// Press/release "?123" key.
|
|
||||||
mSwitcher.onPressSymbol();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
|
||||||
mSwitcher.onReleaseSymbol();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void leaveSymbolsMode() {
|
|
||||||
// Press/release "ABC" key.
|
|
||||||
mSwitcher.onPressSymbol();
|
|
||||||
assertAlphabetNormal();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switching between alphabet and symbols.
|
|
||||||
public void testAlphabetAndSymbols() {
|
|
||||||
enterSymbolsMode();
|
|
||||||
leaveSymbolsMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switching between alphabet shift locked and symbols.
|
|
||||||
public void testAlphabetShiftLockedAndSymbols() {
|
|
||||||
enterShiftLockWithLongPressShift();
|
|
||||||
enterSymbolsMode();
|
|
||||||
|
|
||||||
// Press/release "ABC" key, switch back to shift locked mode.
|
|
||||||
mSwitcher.onPressSymbol();
|
|
||||||
assertAlphabetShiftLocked();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, SINGLE);
|
|
||||||
mSwitcher.onReleaseSymbol();
|
|
||||||
assertAlphabetShiftLocked();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Symbols key chording input.
|
// Symbols key chording input.
|
||||||
public void testSymbolsChording() {
|
public void testSymbolsChording() {
|
||||||
// Press symbols key and hold, enter into choring shift state.
|
// Press symbols key and hold, enter into choring shift state.
|
||||||
|
@ -191,138 +66,6 @@ public class KeyboardStateTests extends AndroidTestCase {
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Symbols key sliding input.
|
|
||||||
public void testSymbolsSliding() {
|
|
||||||
// Press "123?" key.
|
|
||||||
mSwitcher.onPressSymbol();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
// Slide out from "123?" key.
|
|
||||||
mSwitcher.onReleaseSymbol();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
|
|
||||||
// Enter into letter key.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
// Release letter key, snap back to alphabet.
|
|
||||||
mSwitcher.onCodeInput('z', SINGLE);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Switching between symbols and symbols shifted.
|
|
||||||
public void testSymbolsAndSymbolsShifted() {
|
|
||||||
enterSymbolsMode();
|
|
||||||
|
|
||||||
// Press/release "=\<" key.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertSymbolsShifted();
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertSymbolsShifted();
|
|
||||||
|
|
||||||
// Press/release "?123" key.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertSymbolsNormal();
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertSymbolsNormal();
|
|
||||||
|
|
||||||
leaveSymbolsMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Symbols shift sliding input
|
|
||||||
public void testSymbolsShiftSliding() {
|
|
||||||
enterSymbolsMode();
|
|
||||||
|
|
||||||
// Press "=\<" key.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertSymbolsShifted();
|
|
||||||
// Slide out "=\<" key.
|
|
||||||
mSwitcher.onReleaseShift(SLIDING);
|
|
||||||
assertSymbolsShifted();
|
|
||||||
|
|
||||||
// Enter into symbol shifted letter key.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
assertSymbolsShifted();
|
|
||||||
// Release symbol shifted letter key, snap back to symbols.
|
|
||||||
mSwitcher.onCodeInput('~', SINGLE);
|
|
||||||
assertSymbolsNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Symbols shift sliding input from symbols shifted.
|
|
||||||
public void testSymbolsShiftSliding2() {
|
|
||||||
enterSymbolsMode();
|
|
||||||
|
|
||||||
// Press/release "=\<" key.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertSymbolsShifted();
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertSymbolsShifted();
|
|
||||||
|
|
||||||
// Press "123?" key.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertSymbolsNormal();
|
|
||||||
// Slide out "123?" key.
|
|
||||||
mSwitcher.onReleaseShift(SLIDING);
|
|
||||||
assertSymbolsNormal();
|
|
||||||
|
|
||||||
// Enter into symbol letter key.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
// Release symbol letter key, snap back to symbols shift.
|
|
||||||
mSwitcher.onCodeInput('1', SINGLE);
|
|
||||||
assertSymbolsShifted();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Automatic snap back to alphabet from symbols by space key.
|
|
||||||
public void testSnapBackBySpace() {
|
|
||||||
enterSymbolsMode();
|
|
||||||
|
|
||||||
// Enter a symbol letter.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
mSwitcher.onCodeInput('1', SINGLE);
|
|
||||||
assertSymbolsNormal();
|
|
||||||
// Enter space, snap back to alphabet.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SPACE, SINGLE);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Automatic snap back to alphabet from symbols by registered letters.
|
|
||||||
public void testSnapBack() {
|
|
||||||
final String snapBackChars = "'";
|
|
||||||
final int snapBackCode = snapBackChars.codePointAt(0);
|
|
||||||
final boolean hasDistinctMultitouch = true;
|
|
||||||
mSwitcher.loadKeyboard(snapBackChars, hasDistinctMultitouch);
|
|
||||||
|
|
||||||
enterSymbolsMode();
|
|
||||||
|
|
||||||
// Enter a symbol letter.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
mSwitcher.onCodeInput('1', SINGLE);
|
|
||||||
assertSymbolsNormal();
|
|
||||||
// Enter snap back letter, snap back to alphabet.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
mSwitcher.onCodeInput(snapBackCode, SINGLE);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Automatic upper case test
|
|
||||||
public void testAutomaticUpperCase() {
|
|
||||||
mSwitcher.setAutoCapsMode(AUTO_CAPS);
|
|
||||||
// Update shift state with auto caps enabled.
|
|
||||||
mSwitcher.updateShiftState();
|
|
||||||
assertAlphabetAutomaticShifted();
|
|
||||||
|
|
||||||
// Press shift key.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
// Release shift key.
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Chording shift key in automatic upper case.
|
// Chording shift key in automatic upper case.
|
||||||
public void testAutomaticUpperCaseChording() {
|
public void testAutomaticUpperCaseChording() {
|
||||||
mSwitcher.setAutoCapsMode(AUTO_CAPS);
|
mSwitcher.setAutoCapsMode(AUTO_CAPS);
|
||||||
|
@ -364,143 +107,5 @@ public class KeyboardStateTests extends AndroidTestCase {
|
||||||
assertAlphabetNormal();
|
assertAlphabetNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sliding from shift key in automatic upper case.
|
|
||||||
public void testAutomaticUpperCaseSliding() {
|
|
||||||
mSwitcher.setAutoCapsMode(AUTO_CAPS);
|
|
||||||
// Update shift state with auto caps enabled.
|
|
||||||
mSwitcher.updateShiftState();
|
|
||||||
assertAlphabetAutomaticShifted();
|
|
||||||
|
|
||||||
// Press shift key.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
// Slide out shift key.
|
|
||||||
mSwitcher.onReleaseShift(SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
// Enter into letter key.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
// Release letter key, snap back to alphabet.
|
|
||||||
mSwitcher.onCodeInput('Z', SINGLE);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sliding from symbol key in automatic upper case.
|
|
||||||
public void testAutomaticUpperCaseSliding2() {
|
|
||||||
mSwitcher.setAutoCapsMode(AUTO_CAPS);
|
|
||||||
// Update shift state with auto caps enabled.
|
|
||||||
mSwitcher.updateShiftState();
|
|
||||||
assertAlphabetAutomaticShifted();
|
|
||||||
|
|
||||||
// Press "123?" key.
|
|
||||||
mSwitcher.onPressSymbol();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
// Slide out "123?" key.
|
|
||||||
mSwitcher.onReleaseSymbol();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
// Enter into symbol letter keys.
|
|
||||||
mSwitcher.onOtherKeyPressed();
|
|
||||||
assertSymbolsNormal();
|
|
||||||
// Release symbol letter key, snap back to alphabet.
|
|
||||||
mSwitcher.onCodeInput('1', SINGLE);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enterShiftLockWithLongPressShift() {
|
|
||||||
// Long press shift key
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
|
|
||||||
mSwitcher.toggleCapsLock();
|
|
||||||
assertAlphabetShiftLocked();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_CAPSLOCK, SINGLE);
|
|
||||||
assertAlphabetShiftLocked();
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertAlphabetShiftLocked();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void leaveShiftLockWithLongPressShift() {
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
|
|
||||||
mSwitcher.toggleCapsLock();
|
|
||||||
assertAlphabetNormal();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_CAPSLOCK, SINGLE);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Long press shift key.
|
|
||||||
// TODO: Move long press recognizing timer/logic into KeyboardState.
|
|
||||||
public void testLongPressShift() {
|
|
||||||
enterShiftLockWithLongPressShift();
|
|
||||||
leaveShiftLockWithLongPressShift();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Leave shift lock with single tap shift key.
|
|
||||||
public void testShiftInShiftLock() {
|
|
||||||
enterShiftLockWithLongPressShift();
|
|
||||||
assertAlphabetShiftLocked();
|
|
||||||
|
|
||||||
// Tap shift key.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Double tap shift key.
|
|
||||||
// TODO: Move double tap recognizing timer/logic into KeyboardState.
|
|
||||||
public void testDoubleTapShift() {
|
|
||||||
// First shift key tap.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
// Second shift key tap.
|
|
||||||
// Double tap recognized in LatinKeyboardView.KeyTimerHandler.
|
|
||||||
mSwitcher.toggleCapsLock();
|
|
||||||
assertAlphabetShiftLocked();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
|
||||||
assertAlphabetShiftLocked();
|
|
||||||
|
|
||||||
// First shift key tap.
|
|
||||||
mSwitcher.onPressShift(NOT_SLIDING);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
mSwitcher.onCodeInput(Keyboard.CODE_SHIFT, SINGLE);
|
|
||||||
assertAlphabetManualShifted();
|
|
||||||
mSwitcher.onReleaseShift(NOT_SLIDING);
|
|
||||||
assertAlphabetNormal();
|
|
||||||
// Second shift key tap.
|
|
||||||
// Second tap is ignored in LatinKeyboardView.KeyTimerHandler.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update shift state.
|
|
||||||
public void testUpdateShiftState() {
|
|
||||||
mSwitcher.setAutoCapsMode(AUTO_CAPS);
|
|
||||||
// Update shift state.
|
|
||||||
mSwitcher.updateShiftState();
|
|
||||||
assertAlphabetAutomaticShifted();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update shift state when shift locked.
|
|
||||||
public void testUpdateShiftStateInShiftLocked() {
|
|
||||||
mSwitcher.setAutoCapsMode(AUTO_CAPS);
|
|
||||||
enterShiftLockWithLongPressShift();
|
|
||||||
assertAlphabetShiftLocked();
|
|
||||||
// Update shift state when shift locked
|
|
||||||
mSwitcher.updateShiftState();
|
|
||||||
assertAlphabetShiftLocked();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Multitouch test
|
// TODO: Multitouch test
|
||||||
|
|
||||||
// TODO: Change focus test.
|
|
||||||
|
|
||||||
// TODO: Change orientation test.
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,18 +104,10 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
mState.onUpdateShiftState(mAutoCapsMode && mAutoCapsState);
|
mState.onUpdateShiftState(mAutoCapsMode && mAutoCapsState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleShift() {
|
|
||||||
mState.onToggleShift();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleCapsLock() {
|
public void toggleCapsLock() {
|
||||||
mState.onToggleCapsLock();
|
mState.onToggleCapsLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleAlphabetAndSymbols() {
|
|
||||||
mState.onToggleAlphabetAndSymbols();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateShiftState() {
|
public void updateShiftState() {
|
||||||
mState.onUpdateShiftState(mAutoCapsMode && mAutoCapsState);
|
mState.onUpdateShiftState(mAutoCapsMode && mAutoCapsState);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue