TextKeyListenerTest#testPressKey fails
The test was using KeyCharacterMap#BUILT_IN_KEYBOARD for checking the keyboard
type while the instrumentation uses KeyCharacterMap.VIRTUAL_KEYBOARD. Note that
KeyCharacterMap#BUILT_IN_KEYBOARD is deprecated. Also the test was not taking
into account for a FULL keyboard.
bug:5587476
Change-Id: I9b3b21cb89935e5e9359c67bcc7493f5a8559340
diff --git a/tests/tests/text/src/android/text/method/cts/TextKeyListenerTest.java b/tests/tests/text/src/android/text/method/cts/TextKeyListenerTest.java
index 1d239f7..932e5c0 100644
--- a/tests/tests/text/src/android/text/method/cts/TextKeyListenerTest.java
+++ b/tests/tests/text/src/android/text/method/cts/TextKeyListenerTest.java
@@ -244,11 +244,6 @@
}
}
- private int getKeyboardType() {
- KeyCharacterMap kmap = KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD);
- return kmap.getKeyboardType();
- }
-
/**
* Check point:
* 1. press KEYCODE_4 once. if it's ALPHA key board, text will be "4", if it's
@@ -274,7 +269,6 @@
public void testPressKey() {
final TextKeyListener textKeyListener
= TextKeyListener.getInstance(false, Capitalize.NONE);
- int keyType = getKeyboardType();
mActivity.runOnUiThread(new Runnable() {
public void run() {
@@ -290,7 +284,9 @@
sendKeys(KeyEvent.KEYCODE_4);
waitForListenerTimeout();
String text = mTextView.getText().toString();
- if (KeyCharacterMap.ALPHA == keyType) {
+ int keyType = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD).getKeyboardType();
+ if (KeyCharacterMap.ALPHA == keyType
+ || KeyCharacterMap.FULL == keyType) {
assertEquals("4", text);
} else if (KeyCharacterMap.NUMERIC == keyType) {
assertEquals("g", text);