Let the test use sample data.
This commit is contained in:
committed by
Benoit Marty
parent
90cd52b5d5
commit
901685471c
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023, 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.designsystem.components.media
|
||||
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* Generate a waveform for testing purposes.
|
||||
*
|
||||
* The waveform is a list of floats between 0 and 1.
|
||||
*
|
||||
* @param length The length of the waveform.
|
||||
*/
|
||||
fun createFakeWaveform(length: Int = 1000): ImmutableList<Float> {
|
||||
val random = Random(seed = 2)
|
||||
return List(length) { random.nextFloat() }
|
||||
.toImmutableList()
|
||||
}
|
||||
@@ -10,7 +10,7 @@ package io.element.android.libraries.mediaviewer.impl.viewer
|
||||
import app.cash.turbine.test
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.designsystem.components.media.createFakeWaveform
|
||||
import io.element.android.libraries.designsystem.components.media.WaveFormSamples
|
||||
import io.element.android.libraries.matrix.api.core.UniqueId
|
||||
import io.element.android.libraries.matrix.api.timeline.Timeline
|
||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||
@@ -128,7 +128,7 @@ class SingleMediaGalleryDataSourceTest {
|
||||
fun `createFrom should create a SingleMediaGalleryDataSource with a voice item`() {
|
||||
testFactory(
|
||||
mediaInfo = aVoiceMediaInfo(
|
||||
waveForm = createFakeWaveform(),
|
||||
waveForm = WaveFormSamples.longRealisticWaveForm,
|
||||
duration = "12:34",
|
||||
),
|
||||
expectedResult = { params ->
|
||||
|
||||
Reference in New Issue
Block a user