revert: move the encoding.xml EncoderPreset fix to its own branch
It is an unrelated subsystem and ships as a separate change.
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Model.Tests.Configuration;
|
||||
|
||||
public class EncodingOptionsTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("<EncoderPreset></EncoderPreset>")]
|
||||
[InlineData("<EncoderPreset />")]
|
||||
[InlineData("<EncoderPreset> </EncoderPreset>")]
|
||||
[InlineData("<EncoderPreset>notapreset</EncoderPreset>")]
|
||||
public void Deserialize_UnreadableEncoderPreset_FallsBackToDefault(string encoderPresetElement)
|
||||
{
|
||||
var options = Deserialize($"<EncodingOptions>{encoderPresetElement}<H264Crf>21</H264Crf></EncodingOptions>");
|
||||
|
||||
Assert.Equal(EncoderPreset.auto, options.EncoderPreset);
|
||||
|
||||
// The rest of the file has to survive: a throwing preset used to discard every other encoding setting.
|
||||
Assert.Equal(21, options.H264Crf);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_KnownEncoderPreset_IsKept()
|
||||
{
|
||||
var options = Deserialize("<EncodingOptions><EncoderPreset>veryfast</EncoderPreset></EncodingOptions>");
|
||||
|
||||
Assert.Equal(EncoderPreset.veryfast, options.EncoderPreset);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Serialize_WritesTheEncoderPresetElement()
|
||||
{
|
||||
var serializer = new XmlSerializer(typeof(EncodingOptions));
|
||||
using var writer = new StringWriter();
|
||||
serializer.Serialize(writer, new EncodingOptions { EncoderPreset = EncoderPreset.slow });
|
||||
|
||||
Assert.Contains("<EncoderPreset>slow</EncoderPreset>", writer.ToString(), System.StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private static EncodingOptions Deserialize(string xml)
|
||||
{
|
||||
var serializer = new XmlSerializer(typeof(EncodingOptions));
|
||||
using var reader = new StringReader(xml);
|
||||
return (EncodingOptions)serializer.Deserialize(reader)!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user