From d26d63b35d34333a8f6737572b1c306b774eebd0 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 19 Jan 2012 18:48:02 +0900 Subject: [PATCH] Fix KeyboardState to pass KeyboardStateMultiTouchTests Change-Id: If2b9ee7cf3fad7633d64b98758f802792d66f7a8 --- .../keyboard/internal/KeyboardState.java | 6 ++++- .../KeyboardStateMultiTouchTests.java | 25 ++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index 9bad1a9f3..54b1c1f09 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -338,7 +338,11 @@ public class KeyboardState { final boolean isShiftLocked = mAlphabetShiftState.isShiftLocked(); if (mShiftKeyState.isMomentary()) { // After chording input while normal state. - setShifted(SwitchActions.UNSHIFT); + if (mAlphabetShiftState.isShiftLockShifted()) { + setShiftLocked(true); + } else { + setShifted(SwitchActions.UNSHIFT); + } } else if (isShiftLocked && !mAlphabetShiftState.isShiftLockShifted() && (mShiftKeyState.isPressing() || mShiftKeyState.isPressingOnShifted()) && !withSliding) { diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java index 0394ad731..7ca65cd69 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java @@ -52,21 +52,18 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { 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); - releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); + // Release shift key, switch back to alphabet shift locked. + releaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED); - // TODO: This test fails due to bug, though external behavior is correct. -// // 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); + // 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.