Skip to content

Commit 343923c

Browse files
committed
fix tests
1 parent b5ccba2 commit 343923c

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

base/src/main/java/io/github/sds100/keymapper/base/actions/ActionErrorSnapshot.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ class LazyActionErrorSnapshot(
9696

9797
var error = getError(action)
9898

99-
if (error == KMError.NoCompatibleImeChosen && currentImeFromActions != null) {
99+
val isImeNotChosenError =
100+
error == KMError.NoCompatibleImeChosen || (error is KMError.KeyEventActionError && error.baseError == KMError.NoCompatibleImeChosen)
101+
102+
if (isImeNotChosenError && currentImeFromActions != null) {
100103
val isCurrentImeCompatible =
101104
KeyMapperImeHelper.isKeyMapperInputMethod(
102105
currentImeFromActions.packageName,
@@ -121,8 +124,10 @@ class LazyActionErrorSnapshot(
121124
return isSupportedError
122125
}
123126

124-
if (buildConfigProvider.sdkInt >= Constants.SYSTEM_BRIDGE_MIN_API && action is ActionData.InputKeyEvent && keyEventActionsUseSystemBridge && !isSystemBridgeConnected) {
125-
return KMError.KeyEventActionError(SystemBridgeError.Disconnected)
127+
if (buildConfigProvider.sdkInt >= Constants.SYSTEM_BRIDGE_MIN_API && action is ActionData.InputKeyEvent && keyEventActionsUseSystemBridge) {
128+
if (!isSystemBridgeConnected) {
129+
return KMError.KeyEventActionError(SystemBridgeError.Disconnected)
130+
}
126131
} else if (action.canUseImeToPerform()) {
127132
if (!isCompatibleImeEnabled) {
128133
if (action is ActionData.InputKeyEvent) {

base/src/test/java/io/github/sds100/keymapper/base/actions/GetActionErrorUseCaseTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class GetActionErrorUseCaseTest {
8686
private fun setupKeyEventActionTest(
8787
chosenIme: ImeInfo,
8888
isSystemBridgeUsed: Boolean = false,
89-
isSystemBridgeConnected: Boolean = false
89+
isSystemBridgeConnected: Boolean = false,
9090
) {
9191
whenever(mockPermissionAdapter.isGranted(Permission.WRITE_SECURE_SETTINGS)).then { true }
9292
fakeInputMethodAdapter.chosenIme.value = chosenIme
@@ -101,7 +101,7 @@ class GetActionErrorUseCaseTest {
101101

102102
whenever(mockSystemBridgeConnectionManager.connectionState).then {
103103
MutableStateFlow(
104-
connectionState
104+
connectionState,
105105
)
106106
}
107107
}
@@ -191,7 +191,7 @@ class GetActionErrorUseCaseTest {
191191
val errors = useCase.actionErrorSnapshot.first().getErrors(listOf(action))
192192
assertThat(
193193
errors[action],
194-
`is`(KMError.KeyEventActionError(KMError.NoCompatibleImeChosen))
194+
`is`(KMError.KeyEventActionError(KMError.NoCompatibleImeChosen)),
195195
)
196196
}
197197

@@ -254,7 +254,7 @@ class GetActionErrorUseCaseTest {
254254
setupKeyEventActionTest(
255255
chosenIme = GBOARD_IME_INFO,
256256
isSystemBridgeUsed = true,
257-
isSystemBridgeConnected = true
257+
isSystemBridgeConnected = true,
258258
)
259259

260260
val actions = listOf(
@@ -272,7 +272,7 @@ class GetActionErrorUseCaseTest {
272272
setupKeyEventActionTest(
273273
chosenIme = GUI_KEYBOARD_IME_INFO,
274274
isSystemBridgeUsed = true,
275-
isSystemBridgeConnected = false
275+
isSystemBridgeConnected = false,
276276
)
277277

278278
val actions = listOf(
@@ -290,7 +290,7 @@ class GetActionErrorUseCaseTest {
290290
setupKeyEventActionTest(
291291
chosenIme = GBOARD_IME_INFO,
292292
isSystemBridgeUsed = true,
293-
isSystemBridgeConnected = false
293+
isSystemBridgeConnected = false,
294294
)
295295

296296
val actions = listOf(

0 commit comments

Comments
 (0)