mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 01:19:33 +00:00
Allow deleting a recorded voice message (#1635)
--------- Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
@@ -27,4 +27,5 @@ dependencies {
|
||||
implementation(projects.tests.testutils)
|
||||
|
||||
implementation(libs.coroutines.test)
|
||||
implementation(libs.test.truth)
|
||||
}
|
||||
|
||||
+20
@@ -16,6 +16,7 @@
|
||||
|
||||
package io.element.android.libraries.voicerecorder.test
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.voicerecorder.api.VoiceRecorder
|
||||
import io.element.android.libraries.voicerecorder.api.VoiceRecorderState
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
@@ -37,7 +38,12 @@ class FakeVoiceRecorder(
|
||||
|
||||
private var securityException: SecurityException? = null
|
||||
|
||||
private var startedCount = 0
|
||||
private var stoppedCount = 0
|
||||
private var deletedCount = 0
|
||||
|
||||
override suspend fun startRecord() {
|
||||
startedCount += 1
|
||||
val startedAt = timeSource.markNow()
|
||||
securityException?.let { throw it }
|
||||
|
||||
@@ -55,6 +61,8 @@ class FakeVoiceRecorder(
|
||||
override suspend fun stopRecord(
|
||||
cancelled: Boolean
|
||||
) {
|
||||
stoppedCount++
|
||||
|
||||
if (cancelled) {
|
||||
deleteRecording()
|
||||
}
|
||||
@@ -68,6 +76,7 @@ class FakeVoiceRecorder(
|
||||
}
|
||||
|
||||
override suspend fun deleteRecording() {
|
||||
deletedCount++
|
||||
curRecording = null
|
||||
|
||||
_state.emit(
|
||||
@@ -75,6 +84,17 @@ class FakeVoiceRecorder(
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
fun assertCalls(
|
||||
started: Int = 0,
|
||||
stopped: Int = 0,
|
||||
deleted: Int = 0,
|
||||
) {
|
||||
assertThat(startedCount).isEqualTo(started)
|
||||
assertThat(stoppedCount).isEqualTo(stopped)
|
||||
assertThat(deletedCount).isEqualTo(deleted)
|
||||
}
|
||||
|
||||
fun givenThrowsSecurityException(exception: SecurityException) {
|
||||
this.securityException = exception
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user