diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Jellyfin.Api.Tests/Controllers/SubtitleControllerTests.cs | 40 | ||||
| -rw-r--r-- | tests/Jellyfin.Api.Tests/Helpers/DynamicHlsHelperTests.cs | 26 |
2 files changed, 66 insertions, 0 deletions
diff --git a/tests/Jellyfin.Api.Tests/Controllers/SubtitleControllerTests.cs b/tests/Jellyfin.Api.Tests/Controllers/SubtitleControllerTests.cs index 77321f0b05..36b4e7156e 100644 --- a/tests/Jellyfin.Api.Tests/Controllers/SubtitleControllerTests.cs +++ b/tests/Jellyfin.Api.Tests/Controllers/SubtitleControllerTests.cs @@ -134,4 +134,44 @@ public class SubtitleControllerTests fileSystem.Object, NullLogger<SubtitleController>.Instance); } + + [Theory] + [MemberData(nameof(GetVttTimestampMap_Success_TestData))] + public static void GetVttTimestampMap_Success(long mpegTimestamp, string expected) + { + Assert.Equal(expected, SubtitleController.GetVttTimestampMap(mpegTimestamp)); + } + + public static TheoryData<long, string> GetVttTimestampMap_Success_TestData() + { + var data = new TheoryData<long, string>(); + data.Add(900000, "X-TIMESTAMP-MAP=MPEGTS:900000,LOCAL:00:00:00.000"); + data.Add(0, "X-TIMESTAMP-MAP=MPEGTS:0,LOCAL:00:00:00.000"); + return data; + } + + [Theory] + [MemberData(nameof(GetSubtitleSegmentUrl_Success_TestData))] + public static void GetSubtitleSegmentUrl_Success(long positionTicks, long endPositionTicks, string accessToken, long vttTimestampMapMpegts, string expected) + { + Assert.Equal(expected, SubtitleController.GetSubtitleSegmentUrl(positionTicks, endPositionTicks, accessToken, vttTimestampMapMpegts)); + } + + public static TheoryData<long, long, string, long, string> GetSubtitleSegmentUrl_Success_TestData() + { + var data = new TheoryData<long, long, string, long, string>(); + data.Add( + 0, + 300000000, + "abc123", + 0, + "stream.vtt?CopyTimestamps=true&AddVttTimeMap=true&StartPositionTicks=0&EndPositionTicks=300000000&ApiKey=abc123&VttTimestampMapMpegts=0"); + data.Add( + 300000000, + 600000000, + "abc123", + 900000, + "stream.vtt?CopyTimestamps=true&AddVttTimeMap=true&StartPositionTicks=300000000&EndPositionTicks=600000000&ApiKey=abc123&VttTimestampMapMpegts=900000"); + return data; + } } diff --git a/tests/Jellyfin.Api.Tests/Helpers/DynamicHlsHelperTests.cs b/tests/Jellyfin.Api.Tests/Helpers/DynamicHlsHelperTests.cs new file mode 100644 index 0000000000..d17ce0f896 --- /dev/null +++ b/tests/Jellyfin.Api.Tests/Helpers/DynamicHlsHelperTests.cs @@ -0,0 +1,26 @@ +using Jellyfin.Api.Helpers; +using Xunit; + +namespace Jellyfin.Api.Tests.Helpers +{ + public static class DynamicHlsHelperTests + { + [Theory] + [MemberData(nameof(GetVttTimestampMapMpegts_Success_TestData))] + public static void GetVttTimestampMapMpegts_Success(string? segmentContainer, long expected) + { + Assert.Equal(expected, DynamicHlsHelper.GetVttTimestampMapMpegts(segmentContainer)); + } + + public static TheoryData<string?, long> GetVttTimestampMapMpegts_Success_TestData() + { + var data = new TheoryData<string?, long>(); + data.Add(null, 900000); + data.Add(string.Empty, 900000); + data.Add("ts", 900000); + data.Add("mp4", 0); + data.Add("MP4", 0); + return data; + } + } +} |
