aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoe Rogers <1337joe@gmail.com>2021-11-12 16:30:30 +0100
committerJoe Rogers <1337joe@gmail.com>2021-11-12 16:30:30 +0100
commit1d729b2b0fa1e2cd2ca6db516b84bc7876f9bd83 (patch)
treeb937790538e972edd60ab09978ac99667ddf2c02 /tests
parentf73a7a6ed8554a188809c955ddccb48445f4dd71 (diff)
Use codec to determine image format
Diffstat (limited to 'tests')
-rw-r--r--tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs28
1 files changed, 16 insertions, 12 deletions
diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs
index b6d6c3b25..ec8aa4319 100644
--- a/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs
+++ b/tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs
@@ -50,7 +50,7 @@ namespace Jellyfin.Providers.Tests.MediaInfo
[InlineData("clearlogo.png", null, 1, ImageType.Logo, ImageFormat.Png)] // extract extension from name
[InlineData("backdrop", "image/bmp", 2, ImageType.Backdrop, ImageFormat.Bmp)] // extract extension from mimetype
[InlineData("poster", null, 3, ImageType.Primary, ImageFormat.Jpg)] // default extension to jpg
- public async void GetImage_Attachment_ReturnsCorrectSelection(string filename, string mimetype, int targetIndex, ImageType type, ImageFormat? format)
+ public async void GetImage_Attachment_ReturnsCorrectSelection(string filename, string mimetype, int targetIndex, ImageType type, ImageFormat? expectedFormat)
{
var attachments = new List<MediaAttachment>();
string pathPrefix = "path";
@@ -74,24 +74,27 @@ namespace Jellyfin.Providers.Tests.MediaInfo
var actual = await embeddedImageProvider.GetImage(input, type, CancellationToken.None);
Assert.NotNull(actual);
- if (format == null)
+ if (expectedFormat == null)
{
Assert.False(actual.HasImage);
}
else
{
Assert.True(actual.HasImage);
- Assert.Equal(pathPrefix + targetIndex + "." + format, actual.Path, StringComparer.OrdinalIgnoreCase);
- Assert.Equal(format, actual.Format);
+ Assert.Equal(pathPrefix + targetIndex + "." + expectedFormat, actual.Path, StringComparer.OrdinalIgnoreCase);
+ Assert.Equal(expectedFormat, actual.Format);
}
}
[Theory]
- [InlineData(null, 1, ImageType.Backdrop, false)] // no label, can only find primary
- [InlineData(null, 1, ImageType.Primary, true)] // no label, finds primary
- [InlineData("backdrop", 2, ImageType.Backdrop, true)] // uses label to find index 2, not just pulling first stream
- [InlineData("cover", 2, ImageType.Primary, true)] // uses label to find index 2, not just pulling first stream
- public async void GetImage_Embedded_ReturnsCorrectSelection(string label, int targetIndex, ImageType type, bool hasImage)
+ [InlineData(null, null, 1, ImageType.Backdrop, false, ImageFormat.Jpg)] // no label, can only find primary
+ [InlineData(null, null, 1, ImageType.Primary, true, ImageFormat.Jpg)] // no label, finds primary
+ [InlineData("backdrop", null, 2, ImageType.Backdrop, true, ImageFormat.Jpg)] // uses label to find index 2, not just pulling first stream
+ [InlineData("cover", null, 2, ImageType.Primary, true, ImageFormat.Jpg)] // uses label to find index 2, not just pulling first stream
+ [InlineData(null, "mjpeg", 1, ImageType.Primary, true, ImageFormat.Jpg)]
+ [InlineData(null, "png", 1, ImageType.Primary, true, ImageFormat.Png)]
+ [InlineData(null, "gif", 1, ImageType.Primary, true, ImageFormat.Gif)]
+ public async void GetImage_Embedded_ReturnsCorrectSelection(string label, string? codec, int targetIndex, ImageType type, bool hasImage, ImageFormat expectedFormat)
{
var streams = new List<MediaStream>();
for (int i = 1; i <= targetIndex; i++)
@@ -101,7 +104,8 @@ namespace Jellyfin.Providers.Tests.MediaInfo
{
Type = MediaStreamType.EmbeddedImage,
Index = i,
- Comment = comment
+ Comment = comment,
+ Codec = codec
});
}
@@ -122,8 +126,8 @@ namespace Jellyfin.Providers.Tests.MediaInfo
Assert.Equal(hasImage, actual.HasImage);
if (hasImage)
{
- Assert.Equal(pathPrefix + targetIndex + ".jpg", actual.Path, StringComparer.OrdinalIgnoreCase);
- Assert.Equal(ImageFormat.Jpg, actual.Format);
+ Assert.Equal(pathPrefix + targetIndex + "." + expectedFormat, actual.Path, StringComparer.OrdinalIgnoreCase);
+ Assert.Equal(expectedFormat, actual.Format);
}
}