package com.doublesymmetry.trackplayer import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test /** * Unit tests for [isHlsUri], the pure extension-based HLS detection used to * decide whether a preload must warm the media SEGMENTS (HlsDownloader) rather * than only the manifest bytes (CacheWriter). Mirrors the iOS `.m3u8`/`.m3u` * extension check so both platforms classify the same URLs identically. */ class HlsUriTest { @Test fun `m3u8 extension is HLS`() { assertTrue(isHlsUri("https://example.com/master.m3u8")) } @Test fun `m3u extension is HLS`() { assertTrue(isHlsUri("https://example.com/playlist.m3u")) } @Test fun `extension is matched case-insensitively`() { assertTrue(isHlsUri("https://example.com/Master.M3U8")) } @Test fun `query string after the extension is ignored`() { assertTrue(isHlsUri("https://example.com/index.m3u8?token=abc&exp=123")) } @Test fun `fragment after the extension is ignored`() { assertTrue(isHlsUri("https://example.com/index.m3u8#frag")) } @Test fun `mp3 is not HLS`() { assertFalse(isHlsUri("https://example.com/audio.mp3")) } @Test fun `mp4 is not HLS`() { assertFalse(isHlsUri("https://example.com/video.mp4")) } @Test fun `a path segment containing m3u8 but not as the extension is not HLS`() { assertFalse(isHlsUri("https://example.com/m3u8/audio.mp3")) } @Test fun `empty string is not HLS`() { assertFalse(isHlsUri("")) } }