@@ -7,11 +7,8 @@ import io.github.sds100.keymapper.common.utils.KMError
77import io.github.sds100.keymapper.system.inputmethod.ImeInfo
88import io.github.sds100.keymapper.system.permissions.Permission
99import io.github.sds100.keymapper.system.permissions.PermissionAdapter
10- import io.github.sds100.keymapper.system.shizuku.ShizukuAdapter
1110import kotlinx.coroutines.ExperimentalCoroutinesApi
12- import kotlinx.coroutines.flow.MutableStateFlow
1311import kotlinx.coroutines.flow.first
14- import kotlinx.coroutines.flow.update
1512import kotlinx.coroutines.test.StandardTestDispatcher
1613import kotlinx.coroutines.test.TestScope
1714import 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}
0 commit comments