Add more sliding input unit test

Bug: 5881820
Change-Id: I9249d8b702ba9afbd1c7d0a4889ac5b2e929f85d
main
Tadashi G. Takaoka 2012-01-23 18:11:37 +09:00
parent 4eb240eb2c
commit 373f452584
4 changed files with 423 additions and 228 deletions

View File

@ -17,146 +17,106 @@
package com.android.inputmethod.keyboard.internal; package com.android.inputmethod.keyboard.internal;
public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase {
// Shift key chording input. // Chording input in alphabet.
public void testChording() { public void testChordingAlphabet() {
// Press shift key and hold, enter into choring shift state. // Press shift key and hold, enter into choring shift state.
pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED);
// Press/release letter key.
// Press/release letter keys.
chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
chordingPressAndReleaseKey('X', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Release shift key, switch back to alphabet. // Release shift key, switch back to alphabet.
releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); 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); pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED);
// Press/release symbol letter key.
// Press/release symbol letter keys.
chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
chordingPressAndReleaseKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Release "ABC" key, switch back to alphabet.
// Release symbols key, switch back to alphabet.
releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED);
} }
// Shift key chording input in shift locked. // Chording input in shift locked.
public void testShiftChordingShiftLocked() { public void testChordingShiftLocked() {
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Press shift key and hold, enter into choring shift state. // Press shift key and hold, enter into choring shift state.
pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED);
// Press/release letter key.
// Press/release letter keys.
chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); 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. // Release shift key, switch back to alphabet shift locked.
releaseKey(CODE_SHIFT, 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); pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED);
// Press/release symbol letter key.
// Press/release symbol letter keys.
chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
chordingPressAndReleaseKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Release "123?" key, switch back to alphabet shift locked.
// Release symbols key, switch back to alphabet shift locked.
releaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED); releaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED);
} }
// Symbols key chording input. // Chording input in symbols.
public void testSymbolsChording() { public void testChordingSymbols() {
// Press/release symbols key, enter symbols. // Press/release "?123" key, enter symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 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); pressKey(CODE_SHIFT, SYMBOLS_SHIFTED);
// Press/release symbol letter key.
// Press/release symbols keys.
chordingPressAndReleaseKey('1', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); chordingPressAndReleaseKey('1', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
chordingPressAndReleaseKey('2', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); // Release "=\<" key, switch back to symbols.
// Release shift key, switch back to symbols.
releaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); releaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED);
// Press "ABC" key and hold, enter into choring alphabet state. // Press "ABC" key and hold, enter into choring alphabet state.
pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED);
// Press/release letter key.
// Press/release letter keys.
chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
chordingPressAndReleaseKey('b', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Release "ABC" key, switch back to symbols. // Release "ABC" key, switch back to symbols.
releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED);
} }
// Symbols shifted key chording input in symbol. // Chording input in symbol shifted.
public void testSymbolsShiftedChording() { public void testChordingSymbolsShifted() {
// Press/release symbols key, enter symbols. // Press/release "?123" key, enter symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); 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); 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); pressKey(CODE_SHIFT, SYMBOLS_UNSHIFTED);
// Press/release symbol letter key.
// Press/release symbol letter keys.
chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
chordingPressAndReleaseKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Release "=\<" key, switch back to symbols shifted state.
// Release shift key, switch back to symbols shifted state.
releaseKey(CODE_SHIFT, SYMBOLS_SHIFTED); releaseKey(CODE_SHIFT, SYMBOLS_SHIFTED);
// Press "ABC" key and hold, enter into choring alphabet state. // Press "ABC" key and hold, enter into choring alphabet state.
pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED);
// Press/release letter key.
// Press/release letter keys.
chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
chordingPressAndReleaseKey('b', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
// Release "ABC" key, switch back to symbols. // Release "ABC" key, switch back to symbols.
releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED); releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED);
} }
// Chording shift key in automatic upper case. // Chording input in automatic upper case.
public void testAutomaticUpperCaseChording() { public void testChordingAutomaticUpperCase() {
// Set auto caps mode on. // Set auto caps mode on.
setAutoCapsMode(AUTO_CAPS); setAutoCapsMode(AUTO_CAPS);
// Update shift state with auto caps enabled. // 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. // Press shift key and hold, enter into chording shift state.
pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED);
// Press/release letter key.
// Press/release letter keys.
chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Release shift key, switch back to alphabet. // Release shift key, switch back to alphabet.
releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); 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. // 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. // Press "123?" key and hold, enter into chording symbols state.
pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED);
// Press/release symbol letter key.
// Press/release symbol letter keys.
chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Release "123?" key, switch back to alphabet. // Release "123?" key, switch back to alphabet.
releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); 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; package com.android.inputmethod.keyboard.internal;
public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Shift key in alphabet mode. // Shift key in alphabet.
public void testShift() { public void testShiftAlphabet() {
// 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); 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); 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); 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); pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
} }
// Shift key sliding input. // Shift key in symbols.
public void testShiftSliding() { public void testShiftSymbols() {
// Press and slide from shift key. // Press/release "?123" key, enter into symbols.
pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter/release letter key, switch back to alphabet. // Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); 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. // Switching between alphabet and symbols.
public void testAlphabetAndSymbols() { public void testAlphabetAndSymbols() {
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// 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); pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED);
} }
@ -54,88 +93,62 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "ABC" key, back to alphabet shift locked (not alphabet).
// Press/release "ABC" key, switch back to shift locked mode.
pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); 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. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted. // Press/release "=\<" key, enter into symbols shifted.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// // TODO: This test fails due to bug.
// Press/release "?123" key, enter into symbols. // // Press/release "ABC" key, back to alphabet shift locked (not alphabet).
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // 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 // Automatic switch back to alphabet by space key.
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.
public void testSwitchBackBySpace() { public void testSwitchBackBySpace() {
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter symbol letter.
// Enter a symbol letter.
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter space, switch back to alphabet. // Enter space, switch back to alphabet.
pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED); 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. // Automatic switch back to alphabet shift locked test by space key.
public void testSwitchBackBySpaceInShiftLocked() { public void testSwitchBackBySpaceShiftLocked() {
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter symbol letter.
// Enter a symbol letter.
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter space, switch back to alphabet shift locked (not alphabet).
// Enter space, switch back to alphabet.
pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_SHIFT_LOCKED); 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 by registered letters.
// Automatic switch back to alphabet from symbols by registered letters.
public void testSwitchBackChar() { public void testSwitchBackChar() {
// Set switch back chars. // Set switch back chars.
final String switchBackSymbols = "'"; final String switchBackSymbols = "'";
@ -145,54 +158,82 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Press/release "?123" key, enter into symbols. // Press/release "?123" key, enter into symbols.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter symbol letter.
// Enter a symbol letter.
pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Enter switch back letter, switch back to alphabet. // Enter switch back letter, switch back to alphabet.
pressAndReleaseKey(switchBackCode, SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED); 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 // Automatic upper case test
public void testAutomaticUpperCase() { public void testAutomaticUpperCase() {
// Set auto caps mode on. // Set auto caps mode on.
setAutoCapsMode(AUTO_CAPS); setAutoCapsMode(AUTO_CAPS);
// Load keyboard, should be in automatic shifted.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
// Update shift state with auto caps enabled. // Press/release letter key, switch to alphabet.
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED); 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. // Press/release shift key, back to alphabet.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); 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. // Press/release "?123" key, enter into symbols.
public void testAutomaticUpperCaseSliding() { pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Set auto caps mode on. // Press/release symbol letter key, remain in symbols.
setAutoCapsMode(AUTO_CAPS); 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. // Press/release "?123" key, enter into symbols.
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release "=\<" key, enter into symbols shifted.
// Press and slide from shift key. pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); // Press/release symbol shift letter key, remain in symbols shifted.
pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Enter and release letter key, back to alphabet. // Press/release space, switch back to automatic shifted (not alphabet).
pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_AUTOMATIC_SHIFTED);
}
// 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);
} }
// Long press shift key. // Long press shift key.
@ -203,24 +244,17 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Press/release letter key, remain in shift locked. // Press/release letter key, remain in shift locked.
pressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); pressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
// Press/release letter key, remain in shift locked.
pressAndReleaseKey('B', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
// Press/release word separator, remain in shift locked. // Press/release word separator, remain in shift locked.
pressAndReleaseKey(CODE_SPACE, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); pressAndReleaseKey(CODE_SPACE, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED);
// Long press shift key, back to alphabet. // Press/release shift key, back to alphabet.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); 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. // Long press shift key, enter alphabet shift locked.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Press/release shift key, back to alphabet. // Long press shift key, back to alphabet.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
} }
// Double tap shift key. // Double tap shift key.
@ -228,46 +262,229 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
public void testDoubleTapShift() { public void testDoubleTapShift() {
// First shift key tap. // First shift key tap.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Second shift key tap. // Second shift key tap.
// Double tap recognized in LatinKeyboardView.KeyTimerHandler. // Double tap recognized in LatinKeyboardView.KeyTimerHandler.
secondTapShiftKey(ALPHABET_SHIFT_LOCKED); secondTapShiftKey(ALPHABET_SHIFT_LOCKED);
// First shift key tap. // First shift key tap.
pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED);
// Second shift key tap. // Second shift key tap.
// Second tap is ignored in LatinKeyboardView.KeyTimerHandler. // Second tap is ignored in LatinKeyboardView.KeyTimerHandler.
} }
// Update shift state. // Update shift state.
public void testUpdateShiftState() { public void testUpdateShiftState() {
// Set auto caps mode on. // Set auto caps mode off.
setAutoCapsMode(AUTO_CAPS); 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. // Press/release shift key, enter alphabet shifted.
updateShiftState(ALPHABET_AUTOMATIC_SHIFTED); pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED);
// Update shift state, back to alphabet.
// Press/release letter key, back to alphabet. updateShiftState(ALPHABET_UNSHIFTED);
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);
// Long press shift key, enter alphabet shift locked. // Long press shift key, enter alphabet shift locked.
longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED);
// Update shift state, remained in alphabet shift locked.
// Update shift state when shift locked
updateShiftState(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. // Change focus to new text field.
@ -282,14 +499,14 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Change focus to new text field. // Change focus to new text field.
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Press/release symbol key. // Press/release "?123" key.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Change focus to new text field. // Change focus to new text field.
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
// Press/release symbol key. // Press/release "?123" key.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release shift key. // Press/release "=\<" key.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Change focus to new text field. // Change focus to new text field.
loadKeyboard(ALPHABET_UNSHIFTED); loadKeyboard(ALPHABET_UNSHIFTED);
@ -315,14 +532,14 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Change focus to new text field. // Change focus to new text field.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
// Press/release symbol key. // Press/release "?123" key.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Change focus to new text field. // Change focus to new text field.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
// Press/release symbol key. // Press/release "?123" key.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Press/release shift key. // Press/release "=\<" key.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Change focus to new text field. // Change focus to new text field.
loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED);
@ -340,12 +557,12 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase {
// Rotate device. // Rotate device.
rotateDevice(ALPHABET_SHIFT_LOCKED); rotateDevice(ALPHABET_SHIFT_LOCKED);
// Press/release symbol key. // Press/release "?123" key.
pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED);
// Rotate device. // Rotate device.
rotateDevice(SYMBOLS_UNSHIFTED); rotateDevice(SYMBOLS_UNSHIFTED);
// Press/release shift key. // Press/release "=\<" key.
pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED);
// Rotate device. // Rotate device.
rotateDevice(SYMBOLS_SHIFTED); rotateDevice(SYMBOLS_SHIFTED);

View File

@ -42,9 +42,15 @@ public class KeyboardStateTestsBase extends AndroidTestCase
mLayoutSwitchBackSymbols = switchBackSymbols; 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) { public void updateShiftState(int afterUpdate) {
mSwitcher.updateShiftState(); mSwitcher.updateShiftState();
assertEquals(afterUpdate, mSwitcher.getLayoutId()); assertLayout(afterUpdate, mSwitcher.getLayoutId());
} }
public void loadKeyboard(int afterLoad) { public void loadKeyboard(int afterLoad) {
@ -55,18 +61,18 @@ public class KeyboardStateTestsBase extends AndroidTestCase
public void rotateDevice(int afterRotate) { public void rotateDevice(int afterRotate) {
mSwitcher.saveKeyboardState(); mSwitcher.saveKeyboardState();
mSwitcher.loadKeyboard(mLayoutSwitchBackSymbols); mSwitcher.loadKeyboard(mLayoutSwitchBackSymbols);
assertEquals(afterRotate, mSwitcher.getLayoutId()); assertLayout(afterRotate, mSwitcher.getLayoutId());
} }
public void pressKey(int code, int afterPress) { public void pressKey(int code, int afterPress) {
mSwitcher.onPressKey(code); mSwitcher.onPressKey(code);
assertEquals(afterPress, mSwitcher.getLayoutId()); assertLayout(afterPress, mSwitcher.getLayoutId());
} }
public void releaseKey(int code, int afterRelease) { public void releaseKey(int code, int afterRelease) {
mSwitcher.onCodeInput(code, SINGLE); mSwitcher.onCodeInput(code, SINGLE);
mSwitcher.onReleaseKey(code, NOT_SLIDING); mSwitcher.onReleaseKey(code, NOT_SLIDING);
assertEquals(afterRelease, mSwitcher.getLayoutId()); assertLayout(afterRelease, mSwitcher.getLayoutId());
} }
public void pressAndReleaseKey(int code, int afterPress, int afterRelease) { 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) { public void chordingReleaseKey(int code, int afterRelease) {
mSwitcher.onCodeInput(code, MULTI); mSwitcher.onCodeInput(code, MULTI);
mSwitcher.onReleaseKey(code, NOT_SLIDING); mSwitcher.onReleaseKey(code, NOT_SLIDING);
assertEquals(afterRelease, mSwitcher.getLayoutId()); assertLayout(afterRelease, mSwitcher.getLayoutId());
} }
public void chordingPressAndReleaseKey(int code, int afterPress, int afterRelease) { 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) { public void pressAndSlideFromKey(int code, int afterPress, int afterSlide) {
pressKey(code, afterPress); pressKey(code, afterPress);
mSwitcher.onReleaseKey(code, SLIDING); mSwitcher.onReleaseKey(code, SLIDING);
assertEquals(afterSlide, mSwitcher.getLayoutId()); assertLayout(afterSlide, mSwitcher.getLayoutId());
} }
public void longPressShiftKey(int afterPress, int afterLongPress) { public void longPressShiftKey(int afterPress, int afterLongPress) {
// Long press shift key // Long press shift key
mSwitcher.onPressKey(CODE_SHIFT); mSwitcher.onPressKey(CODE_SHIFT);
assertEquals(afterPress, mSwitcher.getLayoutId()); assertLayout(afterPress, mSwitcher.getLayoutId());
// Long press recognized in LatinKeyboardView.KeyTimerHandler. // Long press recognized in LatinKeyboardView.KeyTimerHandler.
mSwitcher.onCodeInput(CODE_CAPSLOCK, SINGLE); mSwitcher.onCodeInput(CODE_CAPSLOCK, SINGLE);
assertEquals(afterLongPress, mSwitcher.getLayoutId()); assertLayout(afterLongPress, mSwitcher.getLayoutId());
mSwitcher.onReleaseKey(CODE_SHIFT, NOT_SLIDING); mSwitcher.onReleaseKey(CODE_SHIFT, NOT_SLIDING);
assertEquals(afterLongPress, mSwitcher.getLayoutId()); assertLayout(afterLongPress, mSwitcher.getLayoutId());
} }
public void secondTapShiftKey(int afterTap) { public void secondTapShiftKey(int afterTap) {
mSwitcher.onCodeInput(CODE_CAPSLOCK, SINGLE); 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; 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) { public void setAutoCapsMode(boolean autoCaps) {
mAutoCapsMode = autoCaps; mAutoCapsMode = autoCaps;
} }