aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-01-16 00:13:35 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-01-16 00:13:35 -0800
commitd3f1caec0ed2e65fdd489e61c487f61d6f169678 (patch)
tree48617eb210757811bbb581cf4f5c63a1b2d80a08
parentfe9dca7ec3814956e6e545c383106156f568d047 (diff)
parent8ece45bb32a350a4c73c9708eedc18389970f07d (diff)
downloadlatinime-d3f1caec0ed2e65fdd489e61c487f61d6f169678.tar.gz
latinime-d3f1caec0ed2e65fdd489e61c487f61d6f169678.tar.xz
latinime-d3f1caec0ed2e65fdd489e61c487f61d6f169678.zip
Merge "Add auto caps function simulation to MockKeyboardSwitcher"
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
index 7491079f9..d5c647cd2 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
@@ -19,6 +19,8 @@ package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.keyboard.internal.KeyboardState.SwitchActions;
public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
+ public static final String WORD_SEPARATORS = " ,.";
+
private static final int ALPHABET_UNSHIFTED = 0;
private static final int ALPHABET_MANUAL_SHIFTED = 1;
private static final int ALPHABET_AUTOMATIC_SHIFTED = 2;
@@ -28,8 +30,9 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
private int mLayout = ALPHABET_UNSHIFTED;
- // TODO: Separate Auto Caps mode and Auto Caps state of input.
- private boolean mAutoCaps = KeyboardStateTests.NO_AUTO_CAPS;
+ private boolean mAutoCapsMode = KeyboardStateTests.NO_AUTO_CAPS;
+ // Following InputConnection's behavior. Simulating InputType.TYPE_TEXT_FLAG_CAP_WORDS.
+ private boolean mAutoCapsState = true;
private final KeyboardState mState = new KeyboardState(this);
@@ -58,7 +61,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
}
public void setAutoCapsMode(boolean autoCaps) {
- mAutoCaps = autoCaps;
+ mAutoCapsMode = autoCaps;
}
@Override
@@ -98,7 +101,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
@Override
public void requestUpdatingShiftState() {
- mState.onUpdateShiftState(mAutoCaps);
+ mState.onUpdateShiftState(mAutoCapsMode && mAutoCapsState);
}
public void toggleCapsLock() {
@@ -106,7 +109,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
}
public void updateShiftState() {
- mState.onUpdateShiftState(mAutoCaps);
+ mState.onUpdateShiftState(mAutoCapsMode && mAutoCapsState);
}
public void loadKeyboard(String layoutSwitchBackSymbols,
@@ -135,7 +138,8 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
}
public void onCodeInput(int code, boolean isSinglePointer) {
- mState.onCodeInput(code, isSinglePointer, mAutoCaps);
+ mAutoCapsState = (WORD_SEPARATORS.indexOf(code) >= 0);
+ mState.onCodeInput(code, isSinglePointer, mAutoCapsMode && mAutoCapsState);
}
public void onCancelInput(boolean isSinglePointer) {