Skip to content

Commit ec7fe2c

Browse files
committed
#1394 fix tests
1 parent ccd0246 commit ec7fe2c

File tree

3 files changed

+1
-47
lines changed

3 files changed

+1
-47
lines changed

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

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ import io.github.sds100.keymapper.common.utils.KMError
77
import io.github.sds100.keymapper.system.inputmethod.ImeInfo
88
import io.github.sds100.keymapper.system.permissions.Permission
99
import io.github.sds100.keymapper.system.permissions.PermissionAdapter
10-
import io.github.sds100.keymapper.system.shizuku.ShizukuAdapter
1110
import kotlinx.coroutines.ExperimentalCoroutinesApi
12-
import kotlinx.coroutines.flow.MutableStateFlow
1311
import kotlinx.coroutines.flow.first
14-
import kotlinx.coroutines.flow.update
1512
import kotlinx.coroutines.test.StandardTestDispatcher
1613
import kotlinx.coroutines.test.TestScope
1714
import kotlinx.coroutines.test.runTest
@@ -52,13 +49,11 @@ class GetActionErrorUseCaseTest {
5249

5350
private lateinit var useCase: GetActionErrorUseCaseImpl
5451

55-
private lateinit var mockShizukuAdapter: ShizukuAdapter
5652
private lateinit var fakeInputMethodAdapter: FakeInputMethodAdapter
5753
private lateinit var mockPermissionAdapter: PermissionAdapter
5854

5955
@Before
6056
fun init() {
61-
mockShizukuAdapter = mock()
6257
fakeInputMethodAdapter = FakeInputMethodAdapter()
6358
mockPermissionAdapter = mock()
6459

@@ -77,7 +72,6 @@ class GetActionErrorUseCaseTest {
7772
}
7873

7974
private fun setupKeyEventActionTest(chosenIme: ImeInfo) {
80-
whenever(mockShizukuAdapter.isInstalled).then { MutableStateFlow(false) }
8175
whenever(mockPermissionAdapter.isGranted(Permission.WRITE_SECURE_SETTINGS)).then { true }
8276
fakeInputMethodAdapter.chosenIme.value = chosenIme
8377
fakeInputMethodAdapter.inputMethods.value = listOf(GBOARD_IME_INFO, GUI_KEYBOARD_IME_INFO)
@@ -221,42 +215,4 @@ class GetActionErrorUseCaseTest {
221215
assertThat(errors[1], nullValue())
222216
assertThat(errors[2], `is`(KMError.NoCompatibleImeChosen))
223217
}
224-
225-
/**
226-
* #776
227-
*/
228-
@Test
229-
fun `don't show Shizuku errors if a compatible ime is selected`() = testScope.runTest {
230-
// GIVEN
231-
whenever(mockShizukuAdapter.isInstalled).then { MutableStateFlow(true) }
232-
fakeInputMethodAdapter.chosenIme.update { GUI_KEYBOARD_IME_INFO }
233-
234-
val action = ActionData.InputKeyEvent(keyCode = KeyEvent.KEYCODE_VOLUME_DOWN)
235-
236-
// WHEN
237-
val errorMap = useCase.actionErrorSnapshot.first().getErrors(listOf(action))
238-
239-
// THEN
240-
assertThat(errorMap[action], nullValue())
241-
}
242-
243-
/**
244-
* #776
245-
*/
246-
@Test
247-
fun `show Shizuku errors if a compatible ime is not selected and Shizuku is installed`() =
248-
testScope.runTest {
249-
// GIVEN
250-
whenever(mockShizukuAdapter.isInstalled).then { MutableStateFlow(true) }
251-
whenever(mockShizukuAdapter.isStarted).then { MutableStateFlow(false) }
252-
fakeInputMethodAdapter.chosenIme.update { GBOARD_IME_INFO }
253-
254-
val action = ActionData.InputKeyEvent(keyCode = KeyEvent.KEYCODE_VOLUME_DOWN)
255-
256-
// WHEN
257-
val errorMap = useCase.actionErrorSnapshot.first().getErrors(listOf(action))
258-
259-
// THEN
260-
assertThat(errorMap[action], `is`(KMError.ShizukuNotStarted))
261-
}
262218
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ class PerformActionsUseCaseTest {
254254
val action = ActionData.InputKeyEvent(
255255
keyCode = 1,
256256
metaState = 0,
257-
useShell = false,
258257
device = ActionData.InputKeyEvent.Device(
259258
descriptor = descriptor,
260259
name = "fake_name_2",
@@ -316,7 +315,6 @@ class PerformActionsUseCaseTest {
316315
val action = ActionData.InputKeyEvent(
317316
keyCode = 1,
318317
metaState = 0,
319-
useShell = false,
320318
device = ActionData.InputKeyEvent.Device(descriptor = descriptor, name = ""),
321319
)
322320

data/src/main/java/io/github/sds100/keymapper/data/entities/TriggerKeyEntity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ sealed class TriggerKeyEntity : Parcelable {
132132
uid: String,
133133
): KeyEventTriggerKeyEntity {
134134
val keyCode by json.byInt(KeyEventTriggerKeyEntity.NAME_KEYCODE)
135-
val scanCode by json.byInt(KeyEventTriggerKeyEntity.NAME_SCANCODE)
135+
val scanCode by json.byNullableInt(KeyEventTriggerKeyEntity.NAME_SCANCODE)
136136
val deviceId by json.byString(KeyEventTriggerKeyEntity.NAME_DEVICE_ID)
137137
val deviceName by json.byNullableString(KeyEventTriggerKeyEntity.NAME_DEVICE_NAME)
138138
val clickType by json.byInt(NAME_CLICK_TYPE)

0 commit comments

Comments
 (0)