Check if using `UiAutomation.grantRuntimePermission()` instead of rule fixes tests
This commit is contained in:
parent
8624199be3
commit
db562b99f8
|
@ -71,7 +71,7 @@ jobs:
|
|||
force-avd-creation: false
|
||||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||
disable-animations: true
|
||||
# emulator-build: 7425822
|
||||
emulator-build: 7425822
|
||||
script: |
|
||||
./gradlew gatherGplayDebugStringTemplates $CI_GRADLE_ARG_PROPERTIES
|
||||
./gradlew unitTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
||||
|
|
|
@ -18,7 +18,6 @@ package im.vector.app.features.voice
|
|||
|
||||
import android.Manifest
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import io.mockk.spyk
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
@ -26,18 +25,20 @@ import org.amshove.kluent.shouldBeNull
|
|||
import org.amshove.kluent.shouldExist
|
||||
import org.amshove.kluent.shouldNotBeNull
|
||||
import org.amshove.kluent.shouldNotExist
|
||||
import org.junit.Rule
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class VoiceRecorderLTests {
|
||||
|
||||
@get:Rule
|
||||
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(Manifest.permission.RECORD_AUDIO)
|
||||
|
||||
private val context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
private val recorder = spyk(VoiceRecorderL(context, Dispatchers.IO))
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
InstrumentationRegistry.getInstrumentation().uiAutomation.grantRuntimePermission(context.packageName, Manifest.permission.RECORD_AUDIO)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startRecordCreatesOggFile() = with(recorder) {
|
||||
getVoiceMessageFile().shouldBeNull()
|
||||
|
|
Loading…
Reference in New Issue