parent
60c4594ee6
commit
06bc1db017
|
@ -315,7 +315,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates state machine to figure out when to automatically snap back to the previous mode.
|
||||
* Updates state machine to figure out when to automatically switch back to the previous mode.
|
||||
*/
|
||||
public void onCodeInput(int code) {
|
||||
mState.onCodeInput(code, isSinglePointer(), mInputMethodService.getCurrentAutoCapsState());
|
||||
|
|
|
@ -269,7 +269,7 @@ public class KeyboardState {
|
|||
}
|
||||
|
||||
private void onReleaseSymbol() {
|
||||
// Snap back to the previous keyboard mode if the user chords the mode change key and
|
||||
// Switch back to the previous keyboard mode if the user chords the mode change key and
|
||||
// another key, then releases the mode change key.
|
||||
if (mSwitchState == SWITCH_STATE_CHORDING_ALPHA) {
|
||||
toggleAlphabetAndSymbols();
|
||||
|
@ -355,8 +355,8 @@ public class KeyboardState {
|
|||
setShifted(SwitchActions.UNSHIFT);
|
||||
}
|
||||
} else {
|
||||
// In symbol mode, snap back to the previous keyboard mode if the user chords the shift
|
||||
// key and another key, then releases the shift key.
|
||||
// In symbol mode, switch back to the previous keyboard mode if the user chords the
|
||||
// shift key and another key, then releases the shift key.
|
||||
if (mSwitchState == SWITCH_STATE_CHORDING_SYMBOL) {
|
||||
toggleShiftInSymbols();
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ public class KeyboardState {
|
|||
if (DEBUG_EVENT) {
|
||||
Log.d(TAG, "onCancelInput: single=" + isSinglePointer + " " + this);
|
||||
}
|
||||
// Snap back to the previous keyboard mode if the user cancels sliding input.
|
||||
// Switch back to the previous keyboard mode if the user cancels sliding input.
|
||||
if (isSinglePointer) {
|
||||
if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) {
|
||||
toggleAlphabetAndSymbols();
|
||||
|
@ -427,13 +427,13 @@ public class KeyboardState {
|
|||
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
||||
}
|
||||
} else if (isSinglePointer) {
|
||||
// Snap back to the previous keyboard mode if the user pressed the mode change key
|
||||
// Switch back to the previous keyboard mode if the user pressed the mode change key
|
||||
// and slid to other key, then released the finger.
|
||||
// If the user cancels the sliding input, snapping back to the previous keyboard
|
||||
// If the user cancels the sliding input, switching back to the previous keyboard
|
||||
// mode is handled by {@link #onCancelInput}.
|
||||
toggleAlphabetAndSymbols();
|
||||
} else {
|
||||
// Chording input is being started. The keyboard mode will be snapped back to the
|
||||
// Chording input is being started. The keyboard mode will be switched back to the
|
||||
// previous mode in {@link onReleaseSymbol} when the mode change key is released.
|
||||
mSwitchState = SWITCH_STATE_CHORDING_ALPHA;
|
||||
}
|
||||
|
@ -443,12 +443,12 @@ public class KeyboardState {
|
|||
// Detected only the shift key has been pressed on symbol layout, and then released.
|
||||
mSwitchState = SWITCH_STATE_SYMBOL_BEGIN;
|
||||
} else if (isSinglePointer) {
|
||||
// Snap back to the previous keyboard mode if the user pressed the shift key on
|
||||
// Switch back to the previous keyboard mode if the user pressed the shift key on
|
||||
// symbol mode and slid to other key, then released the finger.
|
||||
toggleShiftInSymbols();
|
||||
mSwitchState = SWITCH_STATE_SYMBOL;
|
||||
} else {
|
||||
// Chording input is being started. The keyboard mode will be snapped back to the
|
||||
// Chording input is being started. The keyboard mode will be switched back to the
|
||||
// previous mode in {@link onReleaseShift} when the shift key is released.
|
||||
mSwitchState = SWITCH_STATE_CHORDING_SYMBOL;
|
||||
}
|
||||
|
@ -458,14 +458,14 @@ public class KeyboardState {
|
|||
|| code == Keyboard.CODE_OUTPUT_TEXT)) {
|
||||
mSwitchState = SWITCH_STATE_SYMBOL;
|
||||
}
|
||||
// Snap back to alpha keyboard mode immediately if user types a quote character.
|
||||
// Switch back to alpha keyboard mode immediately if user types a quote character.
|
||||
if (isLayoutSwitchBackCharacter(code)) {
|
||||
setAlphabetKeyboard();
|
||||
}
|
||||
break;
|
||||
case SWITCH_STATE_SYMBOL:
|
||||
case SWITCH_STATE_CHORDING_SYMBOL:
|
||||
// Snap back to alpha keyboard mode if user types one or more non-space/enter
|
||||
// Switch back to alpha keyboard mode if user types one or more non-space/enter
|
||||
// characters followed by a space/enter or a quote character.
|
||||
if (isSpaceCharacter(code) || isLayoutSwitchBackCharacter(code)) {
|
||||
setAlphabetKeyboard();
|
||||
|
|
|
@ -18,7 +18,7 @@ package com.android.inputmethod.keyboard.internal;
|
|||
|
||||
public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
|
||||
// Shift key chording input.
|
||||
public void testShiftChording() {
|
||||
public void testChording() {
|
||||
// Press shift key and hold, enter into choring shift state.
|
||||
pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED);
|
||||
|
||||
|
@ -26,23 +26,102 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
|
|||
chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
|
||||
chordingPressAndReleaseKey('X', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
|
||||
|
||||
// Release shift key, snap back to normal state.
|
||||
// Release shift key, switch back to alphabet.
|
||||
releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED);
|
||||
}
|
||||
|
||||
// Symbols key chording input.
|
||||
public void testSymbolsChording() {
|
||||
// Press symbols key and hold, enter into choring shift state.
|
||||
// Press symbols key and hold, enter into choring symbols state.
|
||||
pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Press/release symbol letter keys.
|
||||
chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
chordingPressAndReleaseKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Release shift key, snap back to normal state.
|
||||
// Release symbols key, switch back to alphabet.
|
||||
releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED);
|
||||
}
|
||||
|
||||
// Shift key chording input in shift locked.
|
||||
public void testShiftChordingShiftLocked() {
|
||||
// Long press shift key, enter alphabet shift locked.
|
||||
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
|
||||
|
||||
// Press shift key and hold, enter into choring shift state.
|
||||
pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED);
|
||||
|
||||
// Press/release letter keys.
|
||||
chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
|
||||
chordingPressAndReleaseKey('X', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
|
||||
|
||||
// TODO: This test fails due to bug, though external behavior is correct.
|
||||
// Release shift key, switch back to alphabet shift locked.
|
||||
// releaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED);
|
||||
//
|
||||
// // Press symbols key and hold, enter into choring symbols state.
|
||||
// pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED);
|
||||
//
|
||||
// // Press/release symbol letter keys.
|
||||
// chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
// chordingPressAndReleaseKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
//
|
||||
// // Release symbols key, switch back to alphabet shift locked.
|
||||
// releaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED);
|
||||
}
|
||||
|
||||
// Symbols key chording input.
|
||||
public void testSymbolsChording() {
|
||||
// Press/release symbols key, enter symbols.
|
||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Press shift key and hold, enter into choring symbols shifted state.
|
||||
pressKey(CODE_SHIFT, SYMBOLS_SHIFTED);
|
||||
|
||||
// Press/release symbols keys.
|
||||
chordingPressAndReleaseKey('1', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
|
||||
chordingPressAndReleaseKey('2', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
|
||||
|
||||
// Release shift key, switch back to symbols.
|
||||
releaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Press "ABC" key and hold, enter into choring alphabet state.
|
||||
pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED);
|
||||
|
||||
// Press/release letter keys.
|
||||
chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
|
||||
chordingPressAndReleaseKey('b', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
|
||||
|
||||
// Release "ABC" key, switch back to symbols.
|
||||
releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED);
|
||||
}
|
||||
|
||||
// Symbols shifted key chording input in symbol.
|
||||
public void testSymbolsShiftedChording() {
|
||||
// Press/release symbols key, enter symbols.
|
||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
// Press/release shift key, enter symbols shifted.
|
||||
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
|
||||
|
||||
// Press shift key and hold, enter into chording symbols state.
|
||||
pressKey(CODE_SHIFT, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Press/release symbol letter keys.
|
||||
chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
chordingPressAndReleaseKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Release shift key, switch back to symbols shifted state.
|
||||
releaseKey(CODE_SHIFT, SYMBOLS_SHIFTED);
|
||||
|
||||
// TODO: This test fails due to bug.
|
||||
// // Press "ABC" key and hold, enter into choring alphabet state.
|
||||
// pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED);
|
||||
//
|
||||
// // Press/release letter keys.
|
||||
// chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
|
||||
// chordingPressAndReleaseKey('b', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
|
||||
//
|
||||
// // Release "ABC" key, switch back to symbols.
|
||||
// releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED);
|
||||
}
|
||||
|
||||
// Chording shift key in automatic upper case.
|
||||
public void testAutomaticUpperCaseChording() {
|
||||
// Set auto caps mode on.
|
||||
|
@ -51,13 +130,13 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
|
|||
// Update shift state with auto caps enabled.
|
||||
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
|
||||
|
||||
// Press shift key.
|
||||
// Press shift key and hold, enter into chording shift state.
|
||||
pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED);
|
||||
|
||||
// Press/release letter keys.
|
||||
chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
|
||||
|
||||
// Release shift key, snap back to alphabet.
|
||||
// Release shift key, switch back to alphabet.
|
||||
releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED);
|
||||
}
|
||||
|
||||
|
@ -69,13 +148,13 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
|
|||
// Update shift state with auto caps enabled.
|
||||
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
|
||||
|
||||
// Press "123?" key.
|
||||
// Press "123?" key and hold, enter into chording symbols state.
|
||||
pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Press/release symbol letter keys.
|
||||
chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Release "123?" key, snap back to alphabet.
|
||||
// Release "123?" key, switch back to alphabet.
|
||||
releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
|
|||
|
||||
// Press/release shift key, enter into shift state.
|
||||
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
|
||||
// Press/release letter key, snap back to normal state.
|
||||
// Press/release letter key, switch back to normal state.
|
||||
pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
|
|||
// Press and slide from shift key.
|
||||
pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
|
||||
|
||||
// Enter/release letter key, snap back to alphabet.
|
||||
// Enter/release letter key, switch back to alphabet.
|
||||
pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
|
|||
// Press and slide from "123?" key.
|
||||
pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Enter/release into symbol key, snap back to alphabet.
|
||||
// Enter/release into symbol key, switch back to alphabet.
|
||||
pressAndReleaseKey('!', SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
|
|||
// Press and slide from "=\<" key.
|
||||
pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
|
||||
|
||||
// Enter/release symbol shifted letter key, snap back to symbols.
|
||||
// Enter/release symbol shifted letter key, switch back to symbols.
|
||||
pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_UNSHIFTED);
|
||||
}
|
||||
|
||||
|
@ -103,30 +103,26 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
|
|||
// Press and slide from "123?" key.
|
||||
pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Enter/release symbol letter key, snap back to symbols shifted.
|
||||
// Enter/release symbol letter key, switch back to symbols shifted.
|
||||
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_SHIFTED);
|
||||
}
|
||||
|
||||
// Automatic snap back to alphabet from symbols by space key.
|
||||
public void testSnapBackBySpace() {
|
||||
// Automatic switch back to alphabet from symbols by space key.
|
||||
public void testSwitchBackBySpace() {
|
||||
// Press/release "?123" key, enter into symbols.
|
||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Enter a symbol letter.
|
||||
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Enter space, snap back to alphabet.
|
||||
// Enter space, switch back to alphabet.
|
||||
pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED);
|
||||
}
|
||||
|
||||
// TODO: Add automatic snap back to shift locked test.
|
||||
|
||||
// Automatic snap back to alphabet from symbols by registered letters.
|
||||
public void testSnapBack() {
|
||||
// Set snap back chars.
|
||||
final String snapBackChars = "'";
|
||||
final int snapBackCode = snapBackChars.codePointAt(0);
|
||||
loadKeyboard(snapBackChars, ALPHABET_UNSHIFTED);
|
||||
// Automatic switch back to shift locked test.
|
||||
public void testSwitchBackBySpaceInShiftLocked() {
|
||||
// Long press shift key, enter alphabet shift locked.
|
||||
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
|
||||
|
||||
// Press/release "?123" key, enter into symbols.
|
||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
@ -134,8 +130,27 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
|
|||
// Enter a symbol letter.
|
||||
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Enter snap back letter, snap back to alphabet.
|
||||
pressAndReleaseKey(snapBackCode, SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED);
|
||||
// Enter space, switch back to alphabet.
|
||||
pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_SHIFT_LOCKED);
|
||||
}
|
||||
|
||||
|
||||
// Automatic switch back to alphabet from symbols by registered letters.
|
||||
public void testSwitchBackChar() {
|
||||
// Set switch back chars.
|
||||
final String switchBackSymbols = "'";
|
||||
final int switchBackCode = switchBackSymbols.codePointAt(0);
|
||||
setLayoutSwitchBackSymbols(switchBackSymbols);
|
||||
loadKeyboard(ALPHABET_UNSHIFTED);
|
||||
|
||||
// Press/release "?123" key, enter into symbols.
|
||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Enter a symbol letter.
|
||||
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Enter switch back letter, switch back to alphabet.
|
||||
pressAndReleaseKey(switchBackCode, SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED);
|
||||
}
|
||||
|
||||
// Automatic upper case test
|
||||
|
@ -255,7 +270,84 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
|
|||
updateShiftState(ALPHABET_SHIFT_LOCKED);
|
||||
}
|
||||
|
||||
// TODO: Change focus test.
|
||||
// Change focus to new text field.
|
||||
public void testChangeFocus() {
|
||||
// Press/release shift key.
|
||||
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
|
||||
// Change focus to new text field.
|
||||
loadKeyboard(ALPHABET_UNSHIFTED);
|
||||
|
||||
// TODO: Change orientation test.
|
||||
// Long press shift key, enter alphabet shift locked.
|
||||
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
|
||||
// Change focus to new text field.
|
||||
loadKeyboard(ALPHABET_UNSHIFTED);
|
||||
|
||||
// Press/release symbol key.
|
||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
// Change focus to new text field.
|
||||
loadKeyboard(ALPHABET_UNSHIFTED);
|
||||
|
||||
// Press/release symbol key.
|
||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
// Press/release shift key.
|
||||
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
|
||||
// Change focus to new text field.
|
||||
loadKeyboard(ALPHABET_UNSHIFTED);
|
||||
}
|
||||
|
||||
// Change focus to auto caps text field.
|
||||
public void testChangeFocusAutoCaps() {
|
||||
// Set auto caps mode on.
|
||||
setAutoCapsMode(AUTO_CAPS);
|
||||
|
||||
// Update shift state.
|
||||
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
|
||||
// Change focus to new text field.
|
||||
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
|
||||
|
||||
// Press/release shift key, enter alphabet.
|
||||
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
|
||||
// Change focus to new text field.
|
||||
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
|
||||
|
||||
// Long press shift key, enter alphabet shift locked.
|
||||
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
|
||||
// Change focus to new text field.
|
||||
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
|
||||
|
||||
// Press/release symbol key.
|
||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
// Change focus to new text field.
|
||||
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
|
||||
|
||||
// Press/release symbol key.
|
||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
// Press/release shift key.
|
||||
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
|
||||
// Change focus to new text field.
|
||||
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
|
||||
}
|
||||
|
||||
// Change orientation.
|
||||
public void testChangeOrientation() {
|
||||
// Press/release shift key.
|
||||
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
|
||||
// Rotate device.
|
||||
rotateDevice(ALPHABET_MANUAL_SHIFTED);
|
||||
|
||||
// Long press shift key, enter alphabet shift locked.
|
||||
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
|
||||
// Rotate device.
|
||||
rotateDevice(ALPHABET_SHIFT_LOCKED);
|
||||
|
||||
// Press/release symbol key.
|
||||
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
|
||||
// Rotate device.
|
||||
rotateDevice(SYMBOLS_UNSHIFTED);
|
||||
|
||||
// Press/release shift key.
|
||||
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
|
||||
// Rotate device.
|
||||
rotateDevice(SYMBOLS_SHIFTED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,12 @@ package com.android.inputmethod.keyboard.internal;
|
|||
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
public abstract class KeyboardStateTestsBase extends AndroidTestCase
|
||||
public class KeyboardStateTestsBase extends AndroidTestCase
|
||||
implements MockKeyboardSwitcher.Constants {
|
||||
protected MockKeyboardSwitcher mSwitcher;
|
||||
|
||||
private String mLayoutSwitchBackSymbols = "";
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
@ -29,24 +31,33 @@ public abstract class KeyboardStateTestsBase extends AndroidTestCase
|
|||
mSwitcher = new MockKeyboardSwitcher();
|
||||
mSwitcher.setAutoCapsMode(NO_AUTO_CAPS);
|
||||
|
||||
final String layoutSwitchBackSymbols = "";
|
||||
loadKeyboard(layoutSwitchBackSymbols, ALPHABET_UNSHIFTED);
|
||||
loadKeyboard(ALPHABET_UNSHIFTED);
|
||||
}
|
||||
|
||||
public void setAutoCapsMode(boolean autoCaps) {
|
||||
mSwitcher.setAutoCapsMode(autoCaps);
|
||||
}
|
||||
|
||||
public void setLayoutSwitchBackSymbols(String switchBackSymbols) {
|
||||
mLayoutSwitchBackSymbols = switchBackSymbols;
|
||||
}
|
||||
|
||||
public void updateShiftState(int afterUpdate) {
|
||||
mSwitcher.updateShiftState();
|
||||
assertEquals(afterUpdate, mSwitcher.getLayoutId());
|
||||
}
|
||||
|
||||
public void loadKeyboard(String layoutSwitchBackSymbols, int afterLoad) {
|
||||
mSwitcher.loadKeyboard(layoutSwitchBackSymbols);
|
||||
public void loadKeyboard(int afterLoad) {
|
||||
mSwitcher.loadKeyboard(mLayoutSwitchBackSymbols);
|
||||
updateShiftState(afterLoad);
|
||||
}
|
||||
|
||||
public void rotateDevice(int afterRotate) {
|
||||
mSwitcher.saveKeyboardState();
|
||||
mSwitcher.loadKeyboard(mLayoutSwitchBackSymbols);
|
||||
assertEquals(afterRotate, mSwitcher.getLayoutId());
|
||||
}
|
||||
|
||||
public void pressKey(int code, int afterPress) {
|
||||
mSwitcher.onPressKey(code);
|
||||
assertEquals(afterPress, mSwitcher.getLayoutId());
|
||||
|
|
|
@ -108,6 +108,10 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
mState.onLoadKeyboard(layoutSwitchBackSymbols);
|
||||
}
|
||||
|
||||
public void saveKeyboardState() {
|
||||
mState.onSaveKeyboardState();
|
||||
}
|
||||
|
||||
public void onPressKey(int code) {
|
||||
mState.onPressKey(code);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue