mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-22 23:58:47 +01:00
Try to fix tests, address review comments.
This commit is contained in:
parent
64334c3437
commit
c204f41bec
@ -29,7 +29,7 @@ def jjwt = "0.11.5"
|
||||
def vanniktechEmoji = "0.15.0"
|
||||
|
||||
// Testing
|
||||
def mockk = "1.12.3"
|
||||
def mockk = "1.12.3" // We need to use 1.12.3 to have mocking in androidTest until a new version is released: https://github.com/mockk/mockk/issues/819
|
||||
def espresso = "3.4.0"
|
||||
def androidxTest = "1.4.0"
|
||||
def androidxOrchestrator = "1.4.1"
|
||||
|
@ -337,7 +337,6 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.aar", "*.jar"])
|
||||
implementation project(':library:opusencoder')
|
||||
|
||||
implementation project(":vector-config")
|
||||
|
@ -20,7 +20,6 @@ import android.Manifest
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import io.mockk.spyk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import org.amshove.kluent.shouldBeNull
|
||||
import org.amshove.kluent.shouldExist
|
||||
@ -60,14 +59,13 @@ class VoiceRecorderLTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelRecordRemovesFileAfterStopping() = with(recorder) {
|
||||
fun cancelRecordRemovesFile() = with(recorder) {
|
||||
startRecord("some_room_id")
|
||||
val file = recorder.getVoiceMessageFile()
|
||||
file.shouldNotBeNullAndExist()
|
||||
|
||||
cancelRecord()
|
||||
|
||||
verify { stopRecord() }
|
||||
getVoiceMessageFile().shouldBeNull()
|
||||
file!!.shouldNotExist()
|
||||
}
|
||||
|
@ -17,10 +17,14 @@
|
||||
package im.vector.app.features.voice
|
||||
|
||||
import android.Manifest
|
||||
import android.os.Build
|
||||
import androidx.test.filters.SdkSuppress
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import io.mockk.spyk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.amshove.kluent.shouldBeNull
|
||||
import org.amshove.kluent.shouldExist
|
||||
import org.amshove.kluent.shouldNotBeNull
|
||||
@ -29,6 +33,7 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.Q)
|
||||
class VoiceRecorderQTests {
|
||||
|
||||
@get:Rule
|
||||
@ -38,38 +43,50 @@ class VoiceRecorderQTests {
|
||||
private val recorder = spyk(VoiceRecorderQ(context))
|
||||
|
||||
@Test
|
||||
fun startRecordCreatesOggFile() = with(recorder) {
|
||||
getVoiceMessageFile().shouldBeNull()
|
||||
fun startRecordCreatesOggFile() = runBlocking {
|
||||
with(recorder) {
|
||||
getVoiceMessageFile().shouldBeNull()
|
||||
|
||||
startRecord("some_room_id")
|
||||
startRecord("some_room_id")
|
||||
waitForRecording()
|
||||
|
||||
getVoiceMessageFile().shouldNotBeNullAndExist()
|
||||
getVoiceMessageFile().shouldNotBeNullAndExist()
|
||||
|
||||
stopRecord()
|
||||
stopRecord()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun stopRecordKeepsFile() = with(recorder) {
|
||||
getVoiceMessageFile().shouldBeNull()
|
||||
fun stopRecordKeepsFile() = runBlocking {
|
||||
with(recorder) {
|
||||
getVoiceMessageFile().shouldBeNull()
|
||||
|
||||
startRecord("some_room_id")
|
||||
stopRecord()
|
||||
startRecord("some_room_id")
|
||||
waitForRecording()
|
||||
stopRecord()
|
||||
|
||||
getVoiceMessageFile().shouldNotBeNullAndExist()
|
||||
getVoiceMessageFile().shouldNotBeNullAndExist()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelRecordRemovesFileAfterStopping() = with(recorder) {
|
||||
startRecord("some_room_id")
|
||||
val file = recorder.getVoiceMessageFile()
|
||||
file.shouldNotBeNullAndExist()
|
||||
fun cancelRecordRemovesFileAfterStopping() = runBlocking {
|
||||
with(recorder) {
|
||||
startRecord("some_room_id")
|
||||
val file = recorder.getVoiceMessageFile()
|
||||
file.shouldNotBeNullAndExist()
|
||||
|
||||
cancelRecord()
|
||||
waitForRecording()
|
||||
cancelRecord()
|
||||
|
||||
verify { stopRecord() }
|
||||
getVoiceMessageFile().shouldBeNull()
|
||||
file!!.shouldNotExist()
|
||||
verify { stopRecord() }
|
||||
getVoiceMessageFile().shouldBeNull()
|
||||
file!!.shouldNotExist()
|
||||
}
|
||||
}
|
||||
|
||||
// Give MediaRecorder some time to actually start recording
|
||||
private suspend fun waitForRecording() = delay(10)
|
||||
}
|
||||
|
||||
private fun File?.shouldNotBeNullAndExist() {
|
||||
|
Loading…
Reference in New Issue
Block a user