Fix tests
This commit is contained in:
parent
7425c3905b
commit
d0664dae0d
2 changed files with 5 additions and 4 deletions
|
|
@ -44,6 +44,7 @@ import io.element.android.libraries.textcomposer.model.VoiceMessageState
|
||||||
import io.element.android.libraries.voicerecorder.test.FakeVoiceRecorder
|
import io.element.android.libraries.voicerecorder.test.FakeVoiceRecorder
|
||||||
import io.element.android.services.analytics.test.FakeAnalyticsService
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
import io.element.android.tests.testutils.WarmUpRule
|
import io.element.android.tests.testutils.WarmUpRule
|
||||||
|
import kotlinx.collections.immutable.toPersistentList
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.test.TestScope
|
import kotlinx.coroutines.test.TestScope
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
|
|
@ -66,7 +67,7 @@ class VoiceMessageComposerPresenterTest {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val RECORDING_DURATION = 1.seconds
|
private val RECORDING_DURATION = 1.seconds
|
||||||
private val RECORDING_STATE = VoiceMessageState.Recording(RECORDING_DURATION, 0.2f)
|
private val RECORDING_STATE = VoiceMessageState.Recording(RECORDING_DURATION, listOf(0.1f, 0.2f).toPersistentList())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -145,7 +146,7 @@ class VoiceMessageComposerPresenterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing should happen
|
// Nothing should happen
|
||||||
assertThat(finalState.voiceMessageState).isEqualTo(VoiceMessageState.Recording(RECORDING_DURATION, 0.2f))
|
assertThat(finalState.voiceMessageState).isEqualTo(VoiceMessageState.Recording(RECORDING_DURATION, RECORDING_STATE.levels))
|
||||||
voiceRecorder.assertCalls(started = 1, stopped = 0, deleted = 0)
|
voiceRecorder.assertCalls(started = 1, stopped = 0, deleted = 0)
|
||||||
|
|
||||||
testPauseAndDestroy(finalState)
|
testPauseAndDestroy(finalState)
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,8 @@ class FakeVoiceRecorder(
|
||||||
curRecording = File("file.ogg")
|
curRecording = File("file.ogg")
|
||||||
|
|
||||||
timeSource += recordingDuration
|
timeSource += recordingDuration
|
||||||
levels.forEach {
|
for(i in 1..levels.size) {
|
||||||
_state.emit(VoiceRecorderState.Recording(startedAt.elapsedNow(), it))
|
_state.emit(VoiceRecorderState.Recording(startedAt.elapsedNow(), levels.take(i)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue