|
| 1 | +using System; |
| 2 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 3 | +using System.Text; |
| 4 | +using Qiniu.Test.Utils; |
| 5 | + |
| 6 | +namespace Qiniu.Test |
| 7 | +{ |
| 8 | + [TestClass] |
| 9 | + public class PersistentOpsAvthumbTest |
| 10 | + { |
| 11 | + [TestMethod] |
| 12 | + public void TestPersistentOpsAvthumb() |
| 13 | + { |
| 14 | + var sbOps = new StringBuilder("avthumb"); |
| 15 | + |
| 16 | + var avthumb = new Models.PersistentOpsAvthumbTest(new string[] { Util.AVThumbFormats.mp2, Util.AVThumbFormats.mp3, Util.AVThumbFormats.mp4 }.RandomGetFromArray()); |
| 17 | + sbOps.AppendFormat("/{0}", avthumb.Format); |
| 18 | + |
| 19 | + avthumb.BitRate = new string[] { "64k", "128k", "192k", "256k", "320k" }.RandomGetFromArray(); |
| 20 | + sbOps.AppendFormat("/ab/{0}", avthumb.BitRate); |
| 21 | + |
| 22 | + avthumb.AudioQuality = new Random().Next(0, 9); |
| 23 | + sbOps.AppendFormat("/aq/{0}", avthumb.AudioQuality); |
| 24 | + |
| 25 | + avthumb.SamplingRate = new int[] { 8000, 12050, 22050, 44100 }.RandomGetFromArray(); |
| 26 | + sbOps.AppendFormat("/ar/{0}", avthumb.SamplingRate); |
| 27 | + |
| 28 | + avthumb.FrameRate = new int[] { 24, 25, 30 }.RandomGetFromArray(); |
| 29 | + sbOps.AppendFormat("/r/{0}", avthumb.FrameRate); |
| 30 | + |
| 31 | + avthumb.VideoBitRate = new string[] { "128k", "1.25m", "1.5m" }.RandomGetFromArray(); |
| 32 | + sbOps.AppendFormat("/vb/{0}", avthumb.VideoBitRate); |
| 33 | + |
| 34 | + avthumb.VideoCodec = new string[] { Util.VideoCodec.a64multi, Util.VideoCodec.a64multi5, Util.VideoCodec.amv, Util.VideoCodec.asv1, Util.VideoCodec.asv2 }.RandomGetFromArray(); |
| 35 | + sbOps.AppendFormat("/vcodec/{0}", avthumb.VideoCodec); |
| 36 | + |
| 37 | + avthumb.AudioCodec = new string[] { Util.AudioCodec.aac, Util.AudioCodec.ac3, Util.AudioCodec.ac3_fixed, Util.AudioCodec.adpcm_adx, Util.AudioCodec.adpcm_ima_qt }.RandomGetFromArray(); |
| 38 | + sbOps.AppendFormat("/acodec/{0}", avthumb.AudioCodec); |
| 39 | + |
| 40 | + avthumb.Profile = new string[] { "aac_he" }.RandomGetFromArray(); |
| 41 | + sbOps.AppendFormat("/audioProfile/{0}", avthumb.Profile); |
| 42 | + |
| 43 | + avthumb.SubtitleCodec = new string[] { "mov_text" }.RandomGetFromArray(); |
| 44 | + sbOps.AppendFormat("/scodec/{0}", avthumb.SubtitleCodec); |
| 45 | + |
| 46 | + avthumb.SubtitleURL = Guid.NewGuid().ToString(); |
| 47 | + sbOps.AppendFormat("/subtitle/{0}", avthumb.SubtitleURL); |
| 48 | + |
| 49 | + avthumb.SeekStart = new Random().Next(1, 10000) / 100d; |
| 50 | + sbOps.AppendFormat("/ss/{0}s", avthumb.SeekStart); |
| 51 | + |
| 52 | + avthumb.Duration = new Random().Next(1, 10000) / 100d; |
| 53 | + sbOps.AppendFormat("/t/{0}s", avthumb.Duration); |
| 54 | + |
| 55 | + avthumb.Resolution = string.Format("{0}x{1}", new Random().Next(20, 3840), new Random().Next(20, 2160)); |
| 56 | + sbOps.AppendFormat("/s/{0}", avthumb.Resolution); |
| 57 | + |
| 58 | + avthumb.Autoscale = new int[] { 0, 1 }.RandomGetFromArray(); |
| 59 | + sbOps.AppendFormat("/autoscale/{0}", avthumb.Autoscale); |
| 60 | + |
| 61 | + avthumb.Aspect = new string[] { "4:3", "16:9" }.RandomGetFromArray(); |
| 62 | + sbOps.AppendFormat("/aspect/{0}", avthumb.Aspect); |
| 63 | + |
| 64 | + avthumb.StripMeta = new int[] { 0, 1 }.RandomGetFromArray(); |
| 65 | + sbOps.AppendFormat("/stripmeta/{0}", avthumb.StripMeta); |
| 66 | + |
| 67 | + avthumb.H264Crf = new Random().Next(18, 28); |
| 68 | + sbOps.AppendFormat("/h264Crf/{0}", avthumb.H264Crf); |
| 69 | + |
| 70 | + avthumb.Degree = new int[] { 90, 180, 270 }.RandomGetFromArray(); |
| 71 | + sbOps.AppendFormat("/rotate/{0}", avthumb.Degree); |
| 72 | + |
| 73 | + avthumb.EncodedRemoteImageUrl = Guid.NewGuid().ToString(); |
| 74 | + sbOps.AppendFormat("/wmImage/{0}", avthumb.EncodedRemoteImageUrl); |
| 75 | + |
| 76 | + avthumb.Gravity = Guid.NewGuid().ToString(); |
| 77 | + sbOps.AppendFormat("/wmGravity/{0}", avthumb.Gravity); |
| 78 | + |
| 79 | + avthumb.EncodedText = Guid.NewGuid().ToString(); |
| 80 | + sbOps.AppendFormat("/wmText/{0}", avthumb.EncodedText); |
| 81 | + |
| 82 | + avthumb.GravityText = Guid.NewGuid().ToString(); |
| 83 | + sbOps.AppendFormat("/wmGravityText/{0}", avthumb.GravityText); |
| 84 | + |
| 85 | + avthumb.Font = Guid.NewGuid().ToString(); |
| 86 | + sbOps.AppendFormat("/wmFont/{0}", avthumb.Font); |
| 87 | + |
| 88 | + avthumb.FontColor = Guid.NewGuid().ToString(); |
| 89 | + sbOps.AppendFormat("/wmFontColor/{0}", avthumb.FontColor); |
| 90 | + |
| 91 | + avthumb.FontSize = new Random().Next(1, 64); |
| 92 | + sbOps.AppendFormat("/wmFontSize/{0}", avthumb.FontSize); |
| 93 | + |
| 94 | + avthumb.Xing = Guid.NewGuid().ToString(); |
| 95 | + sbOps.AppendFormat("/writeXing/{0}", avthumb.Xing); |
| 96 | + |
| 97 | + avthumb.AudioNo = new int[] { 0, 1 }.RandomGetFromArray(); |
| 98 | + sbOps.AppendFormat("/an/{0}", avthumb.AudioNo); |
| 99 | + |
| 100 | + avthumb.VideoNo = new int[] { 0, 1 }.RandomGetFromArray(); |
| 101 | + sbOps.AppendFormat("/vn/{0}", avthumb.VideoNo); |
| 102 | + |
| 103 | + avthumb.SaveAs = Guid.NewGuid().ToString(); |
| 104 | + sbOps.AppendFormat("|saveas/{0}", avthumb.SaveAs); |
| 105 | + |
| 106 | + var expected = sbOps.ToString(); |
| 107 | + var actual = avthumb.GetOpsString(); |
| 108 | + Assert.AreEqual(expected, actual); |
| 109 | + } |
| 110 | + } |
| 111 | +} |
0 commit comments