am 9507b4a0: Merge "Add more sliding input unit test"

* commit '9507b4a086c70b68c957cbe91f43a8d901a17a4e':
  Add more sliding input unit test
main
Tadashi G. Takaoka 2012-01-23 19:03:55 -08:00 committed by Android Git Automerger
commit 133fda16c2
4 changed files with 423 additions and 228 deletions

View File

@ -17,146 +17,106 @@
package com.android.inputmethod.keyboard.internal;
public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
// Shift key chording input.
public void testChording() {
// Chording input in alphabet.
public void testChordingAlphabet() {
// Press shift key and hold, enter into choring shift state.
pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED);
// Press/release letter keys.
// Press/release letter key.
chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
chordingPressAndReleaseKey('X', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Release shift key, switch back to alphabet.
releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED);
// Press symbols key and hold, enter into choring symbols state.
// Press "?123" key and hold, enter into choring symbols state.
pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED);
// Press/release symbol letter keys.
// Press/release symbol letter key.
chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
chordingPressAndReleaseKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Release symbols key, switch back to alphabet.
// Release "ABC" key, switch back to alphabet.
releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED);
}
// Shift key chording input in shift locked.
public void testShiftChordingShiftLocked() {
// Chording input in shift locked.
public void testChordingShiftLocked() {
// 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.
// Press/release letter key.
chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
chordingPressAndReleaseKey('X', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// 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.
// Press "?123" key and hold, enter into choring symbols state.
pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED);
// Press/release symbol letter keys.
// Press/release symbol letter key.
chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
chordingPressAndReleaseKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Release symbols key, switch back to alphabet shift locked.
// Release "123?" 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.
// Chording input in symbols.
public void testChordingSymbols() {
// Press/release "?123" key, enter symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press shift key and hold, enter into choring symbols shifted state.
// Press "=\<" key and hold, enter into choring symbols shifted state.
pressKey(CODE_SHIFT, SYMBOLS_SHIFTED);
// Press/release symbols keys.
// Press/release symbol letter key.
chordingPressAndReleaseKey('1', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
chordingPressAndReleaseKey('2', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Release shift key, switch back to symbols.
// Release "=\<" 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.
// Press/release letter key.
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.
// Chording input in symbol shifted.
public void testChordingSymbolsShifted() {
// Press/release "?123" key, enter symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release shift key, enter symbols shifted.
// Press/release "=\<" key, enter symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press shift key and hold, enter into chording symbols state.
// Press "=\<" key and hold, enter into chording symbols state.
pressKey(CODE_SHIFT, SYMBOLS_UNSHIFTED);
// Press/release symbol letter keys.
// Press/release symbol letter key.
chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
chordingPressAndReleaseKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Release shift key, switch back to symbols shifted state.
// Release "=\<" key, switch back to symbols shifted state.
releaseKey(CODE_SHIFT, SYMBOLS_SHIFTED);
// Press "ABC" key and hold, enter into choring alphabet state.
pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED);
// Press/release letter keys.
// Press/release letter key.
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() {
// Chording input in automatic upper case.
public void testChordingAutomaticUpperCase() {
// Set auto caps mode on.
setAutoCapsMode(AUTO_CAPS);
// Update shift state with auto caps enabled.
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED);
// Press shift key and hold, enter into chording shift state.
pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED);
// Press/release letter keys.
// Press/release letter key.
chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Release shift key, switch back to alphabet.
releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED);
}
// Chording symbol key in automatic upper case.
public void testAutomaticUpperCaseChording2() {
// Set auto caps mode on.
setAutoCapsMode(AUTO_CAPS);
// Update shift state with auto caps enabled.
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED);
// Press "123?" key and hold, enter into chording symbols state.
pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED);
// Press/release symbol letter keys.
// Press/release symbol letter key.
chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Release "123?" key, switch back to alphabet.
releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED);
}
// TODO: Multitouch test
// TODO: n-Keys roll over test
}

View File

@ -17,33 +17,72 @@
package com.android.inputmethod.keyboard.internal;
public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Shift key in alphabet mode.
public void testShift() {
// Press/release shift key, enter into shift state.
// Shift key in alphabet.
public void testShiftAlphabet() {
// Press/release shift key, enter into alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Press/release shift key, back to normal state.
// Press/release shift key, back to alphabet.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Press/release shift key, enter into shift state.
// Press/release shift key, enter into alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Press/release letter key, switch back to normal state.
// Press/release letter key, switch back to alphabet.
pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
}
// Shift key sliding input.
public void testShiftSliding() {
// Press and slide from shift key.
pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Shift key in symbols.
public void testShiftSymbols() {
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter/release letter key, switch back to alphabet.
pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press/release "?123" key, back to symbols.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press/release symbol letter key, remain in symbols shifted.
pressAndReleaseKey('1', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
}
// Switching between alphabet and symbols.
public void testAlphabetAndSymbols() {
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "?123" key, back to alphabet.
// Press/release "ABC" key, back to alphabet.
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press/release "ABC" key, back to alphabet.
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// // TODO: This test failed due to bug.
// // Press/release "?123" key, back to symbols (not symbols shifted).
// pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
}
// Switching between alphabet shifted and symbols.
public void testAlphabetShiftedAndSymbols() {
// Press/release shift key, enter into alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "ABC" key, back to alphabet (not alphabet shifted).
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Press/release shift key, enter into alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\< key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press/release "ABC" key, back to alphabet (not alphabet shifted).
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
}
@ -54,88 +93,62 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "ABC" key, switch back to shift locked mode.
// Press/release "ABC" key, back to alphabet shift locked (not alphabet).
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
}
// Symbols key sliding input.
public void testSymbolsSliding() {
// Press and slide from "123?" key.
pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter/release into symbol key, switch back to alphabet.
pressAndReleaseKey('!', SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED);
}
// Switching between symbols and symbols shifted.
public void testSymbolsAndSymbolsShifted() {
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// // TODO: This test fails due to bug.
// // Press/release "ABC" key, back to alphabet shift locked (not alphabet).
// pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_SHIFT_LOCKED);
// // Press/release "?123" key, back to symbols (not symbols shifted).
// pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
}
// Symbols shift sliding input
public void testSymbolsShiftSliding() {
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press and slide from "=\<" key.
pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Enter/release symbol shifted letter key, switch back to symbols.
pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_UNSHIFTED);
}
// Symbols shift sliding input from symbols shifted.
public void testSymbolsShiftSliding2() {
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press and slide from "123?" key.
pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter/release symbol letter key, switch back to symbols shifted.
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_SHIFTED);
}
// Automatic switch back to alphabet from symbols by space key.
// Automatic switch back to alphabet by space key.
public void testSwitchBackBySpace() {
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter a symbol letter.
// Enter symbol letter.
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter space, switch back to alphabet.
pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Enter symbol shift letter.
pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Enter space, switch back to alphabet.
pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_UNSHIFTED);
}
// Automatic switch back to shift locked test.
public void testSwitchBackBySpaceInShiftLocked() {
// Automatic switch back to alphabet shift locked test by space key.
public void testSwitchBackBySpaceShiftLocked() {
// 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);
// Enter a symbol letter.
// Enter symbol letter.
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter space, switch back to alphabet.
// Enter space, switch back to alphabet shift locked (not alphabet).
pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Enter symbol shift letter.
pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Enter space, switch back to alphabet shift locked (not alphabet).
pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_SHIFT_LOCKED);
}
// Automatic switch back to alphabet from symbols by registered letters.
// Automatic switch back to alphabet by registered letters.
public void testSwitchBackChar() {
// Set switch back chars.
final String switchBackSymbols = "'";
@ -145,54 +158,82 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter a symbol letter.
// Enter symbol letter.
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter switch back letter, switch back to alphabet.
pressAndReleaseKey(switchBackCode, SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Enter symbol shift letter.
pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Enter switch abck letter, switch back to alphabet.
pressAndReleaseKey(switchBackCode, SYMBOLS_SHIFTED, ALPHABET_UNSHIFTED);
}
// Automatic switch back to alphabet shift locked by registered letters.
public void testSwitchBackCharShiftLocked() {
// Set switch back chars.
final String switchBackSymbols = "'";
final int switchBackCode = switchBackSymbols.codePointAt(0);
setLayoutSwitchBackSymbols(switchBackSymbols);
loadKeyboard(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter symbol letter.
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter switch back letter, switch back to alphabet shift locked. (not alphabet).
pressAndReleaseKey(switchBackCode, SYMBOLS_UNSHIFTED, ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Enter symbol shift letter.
pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Enter switch back letter, switch back to alphabet shift locked (not alphabet).
pressAndReleaseKey(switchBackCode, SYMBOLS_SHIFTED, ALPHABET_SHIFT_LOCKED);
}
// Automatic upper case test
public void testAutomaticUpperCase() {
// Set auto caps mode on.
setAutoCapsMode(AUTO_CAPS);
// Load keyboard, should be in automatic shifted.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
// Update shift state with auto caps enabled.
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
// Press/release letter key, switch to alphabet.
pressAndReleaseKey('A', ALPHABET_AUTOMATIC_SHIFTED, ALPHABET_UNSHIFTED);
// Press/release auto caps trigger letter, should be in automatic shifted.
pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED);
// Press/release shift key, back to alphabet.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
}
// Press/release letter key, remain in alphabet.
pressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Press/release auto caps trigger letter, should be in automatic shifted.
pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED);
// Sliding from shift key in automatic upper case.
public void testAutomaticUpperCaseSliding() {
// Set auto caps mode on.
setAutoCapsMode(AUTO_CAPS);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release symbol letter key, remain in symbols.
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release space, switch back to automatic shifted (not alphabet).
pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED);
// Update shift state with auto caps enabled.
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
// Press and slide from shift key.
pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Enter and release letter key, back to alphabet.
pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
}
// Sliding from symbol key in automatic upper case.
public void testAutomaticUpperCaseSliding2() {
// Set auto caps mode on.
setAutoCapsMode(AUTO_CAPS);
// Update shift state with auto caps enabled.
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
// Press and slide from "123?" key.
pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter and release symbol letter keys, back to alphabet.
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press/release symbol shift letter key, remain in symbols shifted.
pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press/release space, switch back to automatic shifted (not alphabet).
pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_AUTOMATIC_SHIFTED);
}
// Long press shift key.
@ -203,24 +244,17 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Press/release letter key, remain in shift locked.
pressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
// Press/release letter key, remain in shift locked.
pressAndReleaseKey('B', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
// Press/release word separator, remain in shift locked.
pressAndReleaseKey(CODE_SPACE, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
// Long press shift key, back to alphabet.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
}
// Press/release shift key, back to alphabet.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Leave shift lock with single tap shift key.
public void testShiftInShiftLock() {
// Long press shift key, enter alphabet shift locked.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Press/release shift key, back to alphabet.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Long press shift key, back to alphabet.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
}
// Double tap shift key.
@ -228,46 +262,229 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
public void testDoubleTapShift() {
// First shift key tap.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Second shift key tap.
// Double tap recognized in LatinKeyboardView.KeyTimerHandler.
secondTapShiftKey(ALPHABET_SHIFT_LOCKED);
// First shift key tap.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Second shift key tap.
// Second tap is ignored in LatinKeyboardView.KeyTimerHandler.
}
// Update shift state.
public void testUpdateShiftState() {
// Set auto caps mode on.
setAutoCapsMode(AUTO_CAPS);
// Set auto caps mode off.
setAutoCapsMode(NO_AUTO_CAPS);
// Load keyboard, should be in alphabet.
loadKeyboard(ALPHABET_UNSHIFTED);
// Update shift state, remained in alphabet.
updateShiftState(ALPHABET_UNSHIFTED);
// Update shift state.
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
// Press/release letter key, back to alphabet.
pressAndReleaseKey('A', ALPHABET_AUTOMATIC_SHIFTED, ALPHABET_UNSHIFTED);
// Press/release letter key
pressAndReleaseKey('b', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Press/release auto caps trigger letter, back to automatic shifted.
pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED);
}
// Update shift state when shift locked.
public void testUpdateShiftStateInShiftLocked() {
// Set auto caps mode on.
setAutoCapsMode(AUTO_CAPS);
// Press/release shift key, enter alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Update shift state, back to alphabet.
updateShiftState(ALPHABET_UNSHIFTED);
// Long press shift key, enter alphabet shift locked.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Update shift state when shift locked
// Update shift state, remained in alphabet shift locked.
updateShiftState(ALPHABET_SHIFT_LOCKED);
// Long press shift key, back to alphabet.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Update shift state, remained in symbols.
updateShiftState(SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Update shift state, remained in symbols shifted.
updateShiftState(SYMBOLS_SHIFTED);
// Set auto caps mode on.
setAutoCapsMode(AUTO_CAPS);
// Load keyboard, should be in automatic shifted.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
// Update shift state, remained in automatic shifted.
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
// Press/release shift key, enter alphabet.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Press/release shift key, enter alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Update shift state, enter to automatic shifted (not alphabet shifted).
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED);
// Long press shift key, enter alphabet shift locked.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Update shift state, remained in alphabet shift locked (not automatic shifted).
updateShiftState(ALPHABET_SHIFT_LOCKED);
// Long press shift key, back to alphabet.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Load keyboard, should be in automatic shifted.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Update shift state, remained in symbols.
updateShiftState(SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Update shift state, remained in symbols shifted.
updateShiftState(SYMBOLS_SHIFTED);
}
// Sliding input in alphabet.
public void testSlidingAlphabet() {
// Alphabet -> shift key + letter -> alphabet.
// Press and slide from shift key, enter alphabet shifted.
pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Enter/release letter key, switch back to alphabet.
pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Alphabet -> "?123" key + letter -> alphabet.
// Press and slide from "123?" key, enter symbols.
pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter/release into symbol letter key, switch back to alphabet.
pressAndReleaseKey('!', SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED);
// Alphabet shifted -> shift key + letter -> alphabet.
// Press/release shift key, enter alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Press and slide from shift key, remain alphabet shifted.
pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Enter/release letter key, switch back to alphabet (not alphabet shifted).
pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Alphabet shifted -> "?123" key + letter -> alphabet.
// Press/release shift key, enter alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Press and slide from "123?" key, enter symbols.
pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter/release into symbol letter key, switch back to alphabet (not alphabet shifted).
pressAndReleaseKey('!', SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED);
// Alphabet shift locked -> shift key + letter -> alphabet shift locked.
// Long press shift key, enter alphabet shift locked.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Press and slide from "123?" key, enter symbols.
pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter/release into symbol letter key, switch back to alphabet shift locked (not alphabet).
pressAndReleaseKey('!', SYMBOLS_UNSHIFTED, ALPHABET_SHIFT_LOCKED);
// Alphabet shift locked -> "?123" key + letter -> alphabet shift locked.
// Press and slide from shift key, enter alphabet shifted.
pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Enter/release letter key, switch back to shift locked (not alphabet).
// TODO: This test fails due to bug, though the external behavior is correct.
// pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// TODO: Replace this with the above line once the bug fixed.
pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
}
// Sliding input in symbols.
public void testSlidingSymbols() {
// Symbols -> "=\<" key + letter -> symbols.
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press and slide from shift key, enter symols shifted.
pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Enter/release symbol shifted letter key, switch back to symbols.
pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_UNSHIFTED);
// Symbols -> "ABC" key + letter -> Symbols.
// Press and slide from "ABC" key, enter alphabet.
pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Enter/release letter key, switch back to symbols.
pressAndReleaseKey('a', ALPHABET_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "ABC" key, switch to alphabet.
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Alphabet shifted -> symbols -> "ABC" key + letter -> symbols -> alphabet.
// Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED);
// Press/release shift key, enter alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press and slide from "ABC" key.
pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Enter/release letter key, switch back to symbols.
pressAndReleaseKey('a', ALPHABET_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "ABC" key, switch to alphabet (not alphabet shifted).
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Alphabet shift locked -> symbols -> "ABC" key + letter -> symbols.
// -> alphabet shift locked.
// Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED);
// 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);
// Press and slide from "ABC" key, enter alphabet shift locked (not alphabet).
pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
// Enter/release letter key, switch back to symbols.
pressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, SYMBOLS_UNSHIFTED);
// Press/release "ABC" key, switch to alphabet shift locked. (not alphabet).
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
}
// Sliding input in symbols shifted.
public void testSlidingSymbolsShifted() {
// Symbols shifted -> "?123" + letter -> symbols shifted.
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press and slide from shift key, enter symbols.
pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter/release symbol letter key, switch back to symbols shifted.
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_SHIFTED);
// Symbols shifted -> "ABC" key + letter -> symbols shifted.
// Press and slide from "ABC" key, enter alphabet.
pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Enter/release letter key, switch back to symbols shifted.
pressAndReleaseKey('a', ALPHABET_UNSHIFTED, SYMBOLS_SHIFTED);
// Press/release "ABC" key, switch to alphabet.
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Alphabet shifted -> symbols shifted -> "ABC" + letter -> symbols shifted -> alphabet.
// Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED);
// Press/release shift key, enter alphabet shifted.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press and slide from "ABC" key.
pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Enter/release letter key, switch back to symbols shifted.
pressAndReleaseKey('a', ALPHABET_UNSHIFTED, SYMBOLS_SHIFTED);
// Press/release "ABC" key, switch to alphabet (not alphabet shifted).
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Alphabet shift locked -> symbols shifted -> "ABC" + letter -> symbols shifted
// -> alphabet shift locked.
// Load keyboard
loadKeyboard(ALPHABET_UNSHIFTED);
// 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);
// Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Press and slide from "ABC" key.
pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
// Enter/release letter key, switch back to symbols shifted.
pressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, SYMBOLS_SHIFTED);
// Press/release "ABC" key, switch to alphabet shift locked. (not alphabet).
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
}
// Change focus to new text field.
@ -282,14 +499,14 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Change focus to new text field.
loadKeyboard(ALPHABET_UNSHIFTED);
// Press/release symbol key.
// Press/release "?123" key.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Change focus to new text field.
loadKeyboard(ALPHABET_UNSHIFTED);
// Press/release symbol key.
// Press/release "?123" key.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release shift key.
// Press/release "=\<" key.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Change focus to new text field.
loadKeyboard(ALPHABET_UNSHIFTED);
@ -315,14 +532,14 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Change focus to new text field.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
// Press/release symbol key.
// Press/release "?123" key.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Change focus to new text field.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
// Press/release symbol key.
// Press/release "?123" key.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release shift key.
// Press/release "=\<" key.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Change focus to new text field.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
@ -340,12 +557,12 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Rotate device.
rotateDevice(ALPHABET_SHIFT_LOCKED);
// Press/release symbol key.
// Press/release "?123" key.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Rotate device.
rotateDevice(SYMBOLS_UNSHIFTED);
// Press/release shift key.
// Press/release "=\<" key.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Rotate device.
rotateDevice(SYMBOLS_SHIFTED);

View File

@ -42,9 +42,15 @@ public class KeyboardStateTestsBase extends AndroidTestCase
mLayoutSwitchBackSymbols = switchBackSymbols;
}
private static void assertLayout(int expected, int actual) {
assertTrue("expected=" + MockKeyboardSwitcher.getLayoutName(expected)
+ " actual=" + MockKeyboardSwitcher.getLayoutName(actual),
expected == actual);
}
public void updateShiftState(int afterUpdate) {
mSwitcher.updateShiftState();
assertEquals(afterUpdate, mSwitcher.getLayoutId());
assertLayout(afterUpdate, mSwitcher.getLayoutId());
}
public void loadKeyboard(int afterLoad) {
@ -55,18 +61,18 @@ public class KeyboardStateTestsBase extends AndroidTestCase
public void rotateDevice(int afterRotate) {
mSwitcher.saveKeyboardState();
mSwitcher.loadKeyboard(mLayoutSwitchBackSymbols);
assertEquals(afterRotate, mSwitcher.getLayoutId());
assertLayout(afterRotate, mSwitcher.getLayoutId());
}
public void pressKey(int code, int afterPress) {
mSwitcher.onPressKey(code);
assertEquals(afterPress, mSwitcher.getLayoutId());
assertLayout(afterPress, mSwitcher.getLayoutId());
}
public void releaseKey(int code, int afterRelease) {
mSwitcher.onCodeInput(code, SINGLE);
mSwitcher.onReleaseKey(code, NOT_SLIDING);
assertEquals(afterRelease, mSwitcher.getLayoutId());
assertLayout(afterRelease, mSwitcher.getLayoutId());
}
public void pressAndReleaseKey(int code, int afterPress, int afterRelease) {
@ -81,7 +87,7 @@ public class KeyboardStateTestsBase extends AndroidTestCase
public void chordingReleaseKey(int code, int afterRelease) {
mSwitcher.onCodeInput(code, MULTI);
mSwitcher.onReleaseKey(code, NOT_SLIDING);
assertEquals(afterRelease, mSwitcher.getLayoutId());
assertLayout(afterRelease, mSwitcher.getLayoutId());
}
public void chordingPressAndReleaseKey(int code, int afterPress, int afterRelease) {
@ -92,22 +98,22 @@ public class KeyboardStateTestsBase extends AndroidTestCase
public void pressAndSlideFromKey(int code, int afterPress, int afterSlide) {
pressKey(code, afterPress);
mSwitcher.onReleaseKey(code, SLIDING);
assertEquals(afterSlide, mSwitcher.getLayoutId());
assertLayout(afterSlide, mSwitcher.getLayoutId());
}
public void longPressShiftKey(int afterPress, int afterLongPress) {
// Long press shift key
mSwitcher.onPressKey(CODE_SHIFT);
assertEquals(afterPress, mSwitcher.getLayoutId());
assertLayout(afterPress, mSwitcher.getLayoutId());
// Long press recognized in LatinKeyboardView.KeyTimerHandler.
mSwitcher.onCodeInput(CODE_CAPSLOCK, SINGLE);
assertEquals(afterLongPress, mSwitcher.getLayoutId());
assertLayout(afterLongPress, mSwitcher.getLayoutId());
mSwitcher.onReleaseKey(CODE_SHIFT, NOT_SLIDING);
assertEquals(afterLongPress, mSwitcher.getLayoutId());
assertLayout(afterLongPress, mSwitcher.getLayoutId());
}
public void secondTapShiftKey(int afterTap) {
mSwitcher.onCodeInput(CODE_CAPSLOCK, SINGLE);
assertEquals(afterTap, mSwitcher.getLayoutId());
assertLayout(afterTap, mSwitcher.getLayoutId());
}
}

View File

@ -56,6 +56,18 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
return mLayout;
}
public static String getLayoutName(int layoutId) {
switch (layoutId) {
case Constants.ALPHABET_UNSHIFTED: return "ALPHABET_UNSHIFTED";
case Constants.ALPHABET_MANUAL_SHIFTED: return "ALPHABET_MANUAL_SHIFTED";
case Constants.ALPHABET_AUTOMATIC_SHIFTED: return "ALPHABET_AUTOMATIC_SHIFTED";
case Constants.ALPHABET_SHIFT_LOCKED: return "ALPHABET_SHIFT_LOCKED";
case Constants.SYMBOLS_UNSHIFTED: return "SYMBOLS_UNSHIFTED";
case Constants.SYMBOLS_SHIFTED: return "SYMBOLS_SHIFTED";
default: return "UNKNOWN<" + layoutId + ">";
}
}
public void setAutoCapsMode(boolean autoCaps) {
mAutoCapsMode = autoCaps;
}