2
0
Эх сурвалжийг харах

added StreamBuilder unit test

Luke Pulverenti 10 жил өмнө
parent
commit
da4b87033e

+ 78 - 0
MediaBrowser.Tests/Dlna/StreamBuilderTests.cs

@@ -0,0 +1,78 @@
+using MediaBrowser.Model.Dlna;
+using MediaBrowser.Model.Dlna.Profiles;
+using MediaBrowser.Model.Dto;
+using MediaBrowser.Model.Entities;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Collections.Generic;
+
+namespace MediaBrowser.Tests.Dlna
+{
+    [TestClass]
+    public class StreamBuilderTests
+    {
+        [TestMethod]
+        public void TestVideoProfile()
+        {
+            var profile = new AndroidProfile(true, false, new[]
+            {
+                "high",
+                "baseline",
+                "constrained baseline"
+            });
+
+            var builder = new StreamBuilder();
+
+            var mediaSources = new List<MediaSourceInfo>
+            {
+                new MediaSourceInfo
+                {
+                      Bitrate = 6200000,
+                      Container = "mkv",
+                      Path= "\\server\\test.mkv",
+                      Protocol = Model.MediaInfo.MediaProtocol.File,
+                      RunTimeTicks = TimeSpan.FromMinutes(60).Ticks,
+                      VideoType = VideoType.VideoFile,
+                      Type = MediaSourceType.Default,
+                      MediaStreams = new List<MediaStream>
+                      {
+                          new MediaStream
+                          {
+                              Codec = "H264",
+                              Type = MediaStreamType.Video,
+                              Profile = "High",
+                              IsCabac = true
+                          },
+                          new MediaStream
+                          {
+                              Codec = "AC3",
+                              Type = MediaStreamType.Audio
+                          }
+                      }
+                }
+            };
+
+            var options = new VideoOptions
+            {
+                Context = EncodingContext.Streaming,
+                DeviceId = Guid.NewGuid().ToString(),
+                ItemId = Guid.NewGuid().ToString(),
+                Profile = profile,
+                MediaSources = mediaSources
+            };
+
+            var streamInfo = builder.BuildVideoItem(options);
+
+            var url = streamInfo.ToDlnaUrl("http://localhost:8096");
+
+            var containsHighProfile = url.IndexOf(";high;", StringComparison.OrdinalIgnoreCase) != -1;
+            var containsBaseline = url.IndexOf(";baseline;", StringComparison.OrdinalIgnoreCase) != -1;
+
+            Assert.IsTrue(containsHighProfile);
+            Assert.IsFalse(containsBaseline);
+
+            var isHls = url.IndexOf("master.m3u8?", StringComparison.OrdinalIgnoreCase) != -1;
+            Assert.IsTrue(isHls);
+        }
+    }
+}

+ 1 - 0
MediaBrowser.Tests/MediaBrowser.Tests.csproj

@@ -50,6 +50,7 @@
     </Otherwise>
   </Choose>
   <ItemGroup>
+    <Compile Include="Dlna\StreamBuilderTests.cs" />
     <Compile Include="MediaEncoding\Subtitles\AssParserTests.cs" />
     <Compile Include="MediaEncoding\Subtitles\SrtParserTests.cs" />
     <Compile Include="MediaEncoding\Subtitles\VttWriterTest.cs" />