Fix KeyboardLayoutTest when new_settings flag is on
getKeyboardLayoutsForInputDevice() method doesn't work in new settings scenario, hence breaking the KeyboardLayoutTest. Modify the CTS test to work with or without the new setting API. Test: atest KeyboardLayoutTest Bug: 270125316 Change-Id: I8b56153f804a4486b1f1528c12ce75fd2b98290b
This commit is contained in:
@@ -283,7 +283,8 @@ final class KeyboardLayoutManager implements InputManager.InputDeviceListener {
|
||||
public KeyboardLayout[] getKeyboardLayoutsForInputDevice(
|
||||
final InputDeviceIdentifier identifier) {
|
||||
if (useNewSettingsUi()) {
|
||||
return new KeyboardLayout[0];
|
||||
// Provide all supported keyboard layouts since Ime info is not provided
|
||||
return getKeyboardLayouts();
|
||||
}
|
||||
final String[] enabledLayoutDescriptors =
|
||||
getEnabledKeyboardLayoutsForInputDevice(identifier);
|
||||
|
||||
@@ -256,12 +256,16 @@ class KeyboardLayoutManagerTests {
|
||||
@Test
|
||||
fun testNewUi_getKeyboardLayoutsForInputDevice() {
|
||||
NewSettingsApiFlag(true).use {
|
||||
val keyboardLayouts =
|
||||
keyboardLayoutManager.getKeyboardLayoutsForInputDevice(keyboardDevice.identifier)
|
||||
assertEquals(
|
||||
"New UI: getKeyboardLayoutsForInputDevice API should always return empty array",
|
||||
0,
|
||||
keyboardLayouts.size
|
||||
val keyboardLayouts = keyboardLayoutManager.keyboardLayouts
|
||||
assertNotEquals(
|
||||
"New UI: getKeyboardLayoutsForInputDevice API should not return empty array",
|
||||
0,
|
||||
keyboardLayouts.size
|
||||
)
|
||||
assertTrue(
|
||||
"New UI: getKeyboardLayoutsForInputDevice API should provide English(US) " +
|
||||
"layout",
|
||||
hasLayout(keyboardLayouts, ENGLISH_US_LAYOUT_DESCRIPTOR)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user