2019-09-27 23:29:54 +00:00
|
|
|
using System;
|
|
|
|
using MediaBrowser.MediaEncoding.Encoder;
|
|
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace Jellyfin.MediaEncoding.Tests
|
|
|
|
{
|
|
|
|
public class EncoderValidatorTests
|
|
|
|
{
|
2021-04-04 21:02:28 +00:00
|
|
|
private readonly EncoderValidator _encoderValidator = new EncoderValidator(new NullLogger<EncoderValidatorTests>(), "ffmpeg");
|
|
|
|
|
2019-09-27 23:29:54 +00:00
|
|
|
[Theory]
|
|
|
|
[ClassData(typeof(GetFFmpegVersionTestData))]
|
2020-01-31 21:46:10 +00:00
|
|
|
public void GetFFmpegVersionTest(string versionOutput, Version? version)
|
2019-09-27 23:29:54 +00:00
|
|
|
{
|
2021-08-30 18:02:31 +00:00
|
|
|
Assert.Equal(version, _encoderValidator.GetFFmpegVersionInternal(versionOutput));
|
2019-09-27 23:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Theory]
|
2024-03-17 14:08:05 +00:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV611Output, true)]
|
2023-03-10 00:38:15 +00:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV60Output, true)]
|
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV512Output, true)]
|
2021-07-24 16:52:03 +00:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV44Output, true)]
|
2024-03-17 14:08:05 +00:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV432Output, false)]
|
2020-08-20 15:45:40 +00:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegGitUnknownOutput2, true)]
|
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegGitUnknownOutput, false)]
|
2019-09-27 23:29:54 +00:00
|
|
|
public void ValidateVersionInternalTest(string versionOutput, bool valid)
|
|
|
|
{
|
2021-04-04 21:02:28 +00:00
|
|
|
Assert.Equal(valid, _encoderValidator.ValidateVersionInternal(versionOutput));
|
2019-09-27 23:29:54 +00:00
|
|
|
}
|
2020-06-15 10:15:05 +00:00
|
|
|
|
2022-12-14 21:03:03 +00:00
|
|
|
private sealed class GetFFmpegVersionTestData : TheoryData<string, Version?>
|
2020-06-15 10:15:05 +00:00
|
|
|
{
|
2021-09-11 20:31:24 +00:00
|
|
|
public GetFFmpegVersionTestData()
|
2020-06-15 10:15:05 +00:00
|
|
|
{
|
2024-03-17 14:08:05 +00:00
|
|
|
Add(EncoderValidatorTestsData.FFmpegV611Output, new Version(6, 1, 1));
|
2023-03-10 00:38:15 +00:00
|
|
|
Add(EncoderValidatorTestsData.FFmpegV60Output, new Version(6, 0));
|
|
|
|
Add(EncoderValidatorTestsData.FFmpegV512Output, new Version(5, 1, 2));
|
2021-09-11 20:31:24 +00:00
|
|
|
Add(EncoderValidatorTestsData.FFmpegV44Output, new Version(4, 4));
|
|
|
|
Add(EncoderValidatorTestsData.FFmpegV432Output, new Version(4, 3, 2));
|
2024-03-17 14:08:05 +00:00
|
|
|
Add(EncoderValidatorTestsData.FFmpegGitUnknownOutput2, new Version(4, 4));
|
2021-09-11 20:31:24 +00:00
|
|
|
Add(EncoderValidatorTestsData.FFmpegGitUnknownOutput, null);
|
2020-06-15 10:15:05 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-27 23:29:54 +00:00
|
|
|
}
|
|
|
|
}
|