Skip to content

Commit f49a78f

Browse files
committed
Add WaveformSlider screenshot tests
1 parent ec37e63 commit f49a78f

7 files changed

Lines changed: 90 additions & 16 deletions

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/audio/WaveformSlider.kt

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -225,27 +225,40 @@ internal fun WaveformTrack(
225225
@Preview(showBackground = true, widthDp = 250)
226226
@Composable
227227
private fun StaticWaveformSliderAtStartPreview() {
228-
ChatPreviewTheme { StaticWaveformSliderSample(progress = 0f, isPlaying = true) }
228+
ChatPreviewTheme { StaticWaveformSliderAtStart() }
229229
}
230230

231231
@Preview(showBackground = true, widthDp = 250)
232232
@Composable
233233
private fun StaticWaveformSliderMidwayPreview() {
234-
ChatPreviewTheme { StaticWaveformSliderSample(progress = 0.5f, isPlaying = true) }
234+
ChatPreviewTheme { StaticWaveformSliderMidway() }
235235
}
236236

237237
@Preview(showBackground = true, widthDp = 250)
238238
@Composable
239239
private fun StaticWaveformSliderPausedPreview() {
240-
ChatPreviewTheme { StaticWaveformSliderSample(progress = 0.3f, isPlaying = false) }
240+
ChatPreviewTheme { StaticWaveformSliderPaused() }
241241
}
242242

243243
@Preview(showBackground = true, widthDp = 250)
244244
@Composable
245245
private fun StaticWaveformSliderWithoutThumbPreview() {
246-
ChatPreviewTheme { StaticWaveformSliderSample(progress = 0.7f, isPlaying = true, isThumbVisible = false) }
246+
ChatPreviewTheme { StaticWaveformSliderWithoutThumb() }
247247
}
248248

249+
@Composable
250+
internal fun StaticWaveformSliderAtStart() = StaticWaveformSliderSample(progress = 0f, isPlaying = true)
251+
252+
@Composable
253+
internal fun StaticWaveformSliderMidway() = StaticWaveformSliderSample(progress = 0.5f, isPlaying = true)
254+
255+
@Composable
256+
internal fun StaticWaveformSliderPaused() = StaticWaveformSliderSample(progress = 0.3f, isPlaying = false)
257+
258+
@Composable
259+
internal fun StaticWaveformSliderWithoutThumb() =
260+
StaticWaveformSliderSample(progress = 0.7f, isPlaying = true, isThumbVisible = false)
261+
249262
@Composable
250263
private fun StaticWaveformSliderSample(progress: Float, isPlaying: Boolean, isThumbVisible: Boolean = true) {
251264
val previewWaveform = remember {
@@ -267,18 +280,21 @@ private fun StaticWaveformSliderSample(progress: Float, isPlaying: Boolean, isTh
267280
@Preview(showBackground = true, widthDp = 250)
268281
@Composable
269282
private fun FullWaveformTrackPreview() {
270-
ChatPreviewTheme {
271-
val waveform = List(100) { (it + 1) / 100f }
272-
WaveformTrack(
273-
modifier = Modifier
274-
.fillMaxWidth()
275-
.height(60.dp),
276-
waveformData = waveform,
277-
progress = 1f,
278-
adjustBarWidthToLimit = true,
279-
visibleBarLimit = 100,
280-
)
281-
}
283+
ChatPreviewTheme { FullWaveformTrack() }
284+
}
285+
286+
@Composable
287+
internal fun FullWaveformTrack() {
288+
val waveform = List(100) { (it + 1) / 100f }
289+
WaveformTrack(
290+
modifier = Modifier
291+
.fillMaxWidth()
292+
.height(36.dp),
293+
waveformData = waveform,
294+
progress = 1f,
295+
adjustBarWidthToLimit = true,
296+
visibleBarLimit = 100,
297+
)
282298
}
283299

284300
private fun Offset.toHorizontalProgress(base: Float, isRtl: Boolean): Float {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (c) 2014-2026 Stream.io Inc. All rights reserved.
3+
*
4+
* Licensed under the Stream License;
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.getstream.chat.android.compose.ui.components.audio
18+
19+
import app.cash.paparazzi.DeviceConfig
20+
import app.cash.paparazzi.Paparazzi
21+
import com.android.ide.common.rendering.api.SessionParams
22+
import io.getstream.chat.android.compose.ui.PaparazziComposeTest
23+
import org.junit.Rule
24+
import org.junit.Test
25+
26+
internal class WaveformSliderTest : PaparazziComposeTest {
27+
28+
@get:Rule
29+
override val paparazzi = Paparazzi(
30+
deviceConfig = DeviceConfig.PIXEL_2,
31+
renderingMode = SessionParams.RenderingMode.SHRINK,
32+
)
33+
34+
@Test
35+
fun `slider playing at start`() {
36+
snapshotWithDarkModeRow { StaticWaveformSliderAtStart() }
37+
}
38+
39+
@Test
40+
fun `slider playing midway`() {
41+
snapshotWithDarkModeRow { StaticWaveformSliderMidway() }
42+
}
43+
44+
@Test
45+
fun `slider paused`() {
46+
snapshotWithDarkModeRow { StaticWaveformSliderPaused() }
47+
}
48+
49+
@Test
50+
fun `slider without thumb`() {
51+
snapshotWithDarkModeRow { StaticWaveformSliderWithoutThumb() }
52+
}
53+
54+
@Test
55+
fun `full track`() {
56+
snapshotWithDarkModeRow { FullWaveformTrack() }
57+
}
58+
}
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)