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
|
force-avd-creation: false
|
||||||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||||
disable-animations: true
|
disable-animations: true
|
||||||
# emulator-build: 7425822
|
emulator-build: 7425822
|
||||||
script: |
|
script: |
|
||||||
./gradlew gatherGplayDebugStringTemplates $CI_GRADLE_ARG_PROPERTIES
|
./gradlew gatherGplayDebugStringTemplates $CI_GRADLE_ARG_PROPERTIES
|
||||||
./gradlew unitTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
./gradlew unitTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
||||||
|
@ -129,26 +129,26 @@ jobs:
|
||||||
# Unneeded as part of the test suite above, kept around in case we want to re-enable them.
|
# Unneeded as part of the test suite above, kept around in case we want to re-enable them.
|
||||||
#
|
#
|
||||||
# # Build Android Tests
|
# # Build Android Tests
|
||||||
# build-android-tests:
|
# build-android-tests:
|
||||||
# name: Build Android Tests
|
# name: Build Android Tests
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
# concurrency:
|
# concurrency:
|
||||||
# group: ${{ github.ref == 'refs/heads/main' && format('unit-tests-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('unit-tests-develop-{0}', github.sha) || format('build-android-tests-{0}', github.ref) }}
|
# group: ${{ github.ref == 'refs/heads/main' && format('unit-tests-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('unit-tests-develop-{0}', github.sha) || format('build-android-tests-{0}', github.ref) }}
|
||||||
# cancel-in-progress: true
|
# cancel-in-progress: true
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@v3
|
# - uses: actions/checkout@v3
|
||||||
# - uses: actions/setup-java@v3
|
# - uses: actions/setup-java@v3
|
||||||
# with:
|
# with:
|
||||||
# distribution: 'adopt'
|
# distribution: 'adopt'
|
||||||
# java-version: 11
|
# java-version: 11
|
||||||
# - uses: actions/cache@v3
|
# - uses: actions/cache@v3
|
||||||
# with:
|
# with:
|
||||||
# path: |
|
# path: |
|
||||||
# ~/.gradle/caches
|
# ~/.gradle/caches
|
||||||
# ~/.gradle/wrapper
|
# ~/.gradle/wrapper
|
||||||
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||||
# restore-keys: |
|
# restore-keys: |
|
||||||
# ${{ runner.os }}-gradle-
|
# ${{ runner.os }}-gradle-
|
||||||
# - name: Build Android Tests
|
# - name: Build Android Tests
|
||||||
# run: ./gradlew clean assembleAndroidTest $CI_GRADLE_ARG_PROPERTIES
|
# run: ./gradlew clean assembleAndroidTest $CI_GRADLE_ARG_PROPERTIES
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ package im.vector.app.features.voice
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import androidx.test.rule.GrantPermissionRule
|
|
||||||
import io.mockk.spyk
|
import io.mockk.spyk
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
@ -26,18 +25,20 @@ import org.amshove.kluent.shouldBeNull
|
||||||
import org.amshove.kluent.shouldExist
|
import org.amshove.kluent.shouldExist
|
||||||
import org.amshove.kluent.shouldNotBeNull
|
import org.amshove.kluent.shouldNotBeNull
|
||||||
import org.amshove.kluent.shouldNotExist
|
import org.amshove.kluent.shouldNotExist
|
||||||
import org.junit.Rule
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class VoiceRecorderLTests {
|
class VoiceRecorderLTests {
|
||||||
|
|
||||||
@get:Rule
|
|
||||||
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(Manifest.permission.RECORD_AUDIO)
|
|
||||||
|
|
||||||
private val context = InstrumentationRegistry.getInstrumentation().targetContext
|
private val context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
private val recorder = spyk(VoiceRecorderL(context, Dispatchers.IO))
|
private val recorder = spyk(VoiceRecorderL(context, Dispatchers.IO))
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setup() {
|
||||||
|
InstrumentationRegistry.getInstrumentation().uiAutomation.grantRuntimePermission(context.packageName, Manifest.permission.RECORD_AUDIO)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun startRecordCreatesOggFile() = with(recorder) {
|
fun startRecordCreatesOggFile() = with(recorder) {
|
||||||
getVoiceMessageFile().shouldBeNull()
|
getVoiceMessageFile().shouldBeNull()
|
||||||
|
|
Loading…
Reference in New Issue