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