2019-09-27 16:29:54 -07:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using MediaBrowser.MediaEncoding.Encoder;
|
|
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace Jellyfin.MediaEncoding.Tests
|
|
|
|
{
|
|
|
|
public class EncoderValidatorTests
|
|
|
|
{
|
|
|
|
[Theory]
|
|
|
|
[ClassData(typeof(GetFFmpegVersionTestData))]
|
2020-01-31 14:46:10 -07:00
|
|
|
public void GetFFmpegVersionTest(string versionOutput, Version? version)
|
2019-09-27 16:29:54 -07:00
|
|
|
{
|
2020-05-31 22:10:15 -07:00
|
|
|
var val = new EncoderValidator(new NullLogger<EncoderValidatorTests>());
|
|
|
|
Assert.Equal(version, val.GetFFmpegVersion(versionOutput));
|
2019-09-27 16:29:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
[Theory]
|
2020-08-20 08:16:09 -07:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV431Output, true)]
|
2020-07-04 04:14:49 -07:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV43Output, true)]
|
2019-09-29 04:41:24 -07:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV421Output, true)]
|
2019-09-27 16:29:54 -07:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV42Output, true)]
|
2019-09-28 10:49:41 -07:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV414Output, true)]
|
2019-09-27 16:29:54 -07:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV404Output, true)]
|
2020-08-20 08:45:40 -07:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegGitUnknownOutput2, true)]
|
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegGitUnknownOutput, false)]
|
2019-09-27 16:29:54 -07:00
|
|
|
public void ValidateVersionInternalTest(string versionOutput, bool valid)
|
|
|
|
{
|
|
|
|
var val = new EncoderValidator(new NullLogger<EncoderValidatorTests>());
|
|
|
|
Assert.Equal(valid, val.ValidateVersionInternal(versionOutput));
|
|
|
|
}
|
2020-06-15 03:15:05 -07:00
|
|
|
|
|
|
|
private class GetFFmpegVersionTestData : IEnumerable<object?[]>
|
|
|
|
{
|
|
|
|
public IEnumerator<object?[]> GetEnumerator()
|
|
|
|
{
|
2020-08-20 08:16:09 -07:00
|
|
|
yield return new object?[] { EncoderValidatorTestsData.FFmpegV431Output, new Version(4, 3, 1) };
|
2020-07-04 04:14:49 -07:00
|
|
|
yield return new object?[] { EncoderValidatorTestsData.FFmpegV43Output, new Version(4, 3) };
|
2020-06-15 03:15:05 -07:00
|
|
|
yield return new object?[] { EncoderValidatorTestsData.FFmpegV421Output, new Version(4, 2, 1) };
|
|
|
|
yield return new object?[] { EncoderValidatorTestsData.FFmpegV42Output, new Version(4, 2) };
|
|
|
|
yield return new object?[] { EncoderValidatorTestsData.FFmpegV414Output, new Version(4, 1, 4) };
|
|
|
|
yield return new object?[] { EncoderValidatorTestsData.FFmpegV404Output, new Version(4, 0, 4) };
|
2020-08-20 08:45:40 -07:00
|
|
|
yield return new object?[] { EncoderValidatorTestsData.FFmpegGitUnknownOutput2, new Version(4, 0) };
|
|
|
|
yield return new object?[] { EncoderValidatorTestsData.FFmpegGitUnknownOutput, null };
|
2020-06-15 03:15:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
|
|
}
|
2019-09-27 16:29:54 -07:00
|
|
|
}
|
|
|
|
}
|