|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|