@@ -15,6 +15,8 @@ public partial class ApiTest
1515 protected string m_defaultVideoUpPath ;
1616 protected string m_defaultImgFetchPath ;
1717
18+ private const string SOURCE_MOVIE = "movie" ;
19+
1820 [ OneTimeSetUp ]
1921 public void Init ( )
2022 {
@@ -1120,13 +1122,13 @@ public void TestZoomVideo()
11201122 [ Test ]
11211123 public void TestVideoTag ( )
11221124 {
1123- var expectedUrl = m_defaultVideoUpPath + "movie" ;
1125+ var expectedUrl = m_defaultVideoUpPath + SOURCE_MOVIE ;
11241126 var expectedTag = "<video poster='{0}.jpg'>" + "<source src='{0}.webm' type='video/webm'>"
11251127 + "<source src='{0}.mp4' type='video/mp4'>"
11261128 + "<source src='{0}.ogv' type='video/ogg'>"
11271129 + "</video>" ;
11281130 expectedTag = String . Format ( expectedTag , expectedUrl ) ;
1129- Assert . AreEqual ( expectedTag , m_api . UrlVideoUp . BuildVideoTag ( "movie" ) . ToString ( ) ) ;
1131+ Assert . AreEqual ( expectedTag , m_api . UrlVideoUp . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ) ;
11301132 }
11311133
11321134 [ Test ]
@@ -1140,25 +1142,25 @@ public void TestVideoTagWithAttributes()
11401142 "preload" ,
11411143 "style=border: 1px" ) ;
11421144
1143- var expectedUrl = m_defaultVideoUpPath + "movie" ;
1145+ var expectedUrl = m_defaultVideoUpPath + SOURCE_MOVIE ;
11441146 var expectedTag = "<video autoplay='true' controls loop muted='true' poster='{0}.jpg' preload style='border: 1px'>"
11451147 + "<source src='{0}.webm' type='video/webm'>"
11461148 + "<source src='{0}.mp4' type='video/mp4'>"
11471149 + "<source src='{0}.ogv' type='video/ogg'>" + "</video>" ;
11481150 expectedTag = String . Format ( expectedTag , expectedUrl ) ;
1149- Assert . AreEqual ( expectedTag , m_api . UrlVideoUp . BuildVideoTag ( "movie" , attributes ) . ToString ( ) ) ;
1151+ Assert . AreEqual ( expectedTag , m_api . UrlVideoUp . BuildVideoTag ( SOURCE_MOVIE , attributes ) . ToString ( ) ) ;
11501152 }
11511153
11521154 [ Test ]
11531155 public void TestVideoTagWithTransformation ( )
11541156 {
11551157 var transformation = new Transformation ( ) . VideoCodec ( "codec" , "h264" ) . AudioCodec ( "acc" ) . StartOffset ( 3 ) ;
1156- var expectedUrl = m_defaultVideoUpPath + "ac_acc,so_3.0,vc_h264/movie " ;
1158+ var expectedUrl = m_defaultVideoUpPath + $ "ac_acc,so_3.0,vc_h264/{ SOURCE_MOVIE } ";
11571159 var expectedTag = "<video height='100' poster='{0}.jpg' src='{0}.mp4' width='200'></video>" ;
11581160 expectedTag = String . Format ( expectedTag , expectedUrl ) ;
11591161
11601162 var actualTag = m_api . UrlVideoUp . Transform ( transformation ) . SourceTypes ( new string [ ] { "mp4" } )
1161- . BuildVideoTag ( "movie" , "html_height=100" , "html_width=200" ) . ToString ( ) ;
1163+ . BuildVideoTag ( SOURCE_MOVIE , "html_height=100" , "html_width=200" ) . ToString ( ) ;
11621164 Assert . AreEqual ( expectedTag , actualTag ) ;
11631165
11641166 expectedTag = "<video height='100' poster='{0}.jpg' width='200'>"
@@ -1168,72 +1170,148 @@ public void TestVideoTagWithTransformation()
11681170 + "</video>" ;
11691171 expectedTag = String . Format ( expectedTag , expectedUrl ) ;
11701172 actualTag = m_api . UrlVideoUp . Transform ( transformation )
1171- . BuildVideoTag ( "movie" , new StringDictionary ( ) { { "html_height" , "100" } , { "html_width" , "200" } } )
1173+ . BuildVideoTag ( SOURCE_MOVIE , new StringDictionary ( ) { { "html_height" , "100" } , { "html_width" , "200" } } )
11721174 . ToString ( ) ;
11731175
11741176 Assert . AreEqual ( expectedTag , actualTag ) ;
11751177
11761178 transformation . Width ( 250 ) ;
1177- expectedUrl = m_defaultVideoUpPath + "ac_acc,so_3.0,vc_h264,w_250/movie " ;
1179+ expectedUrl = m_defaultVideoUpPath + $ "ac_acc,so_3.0,vc_h264,w_250/{ SOURCE_MOVIE } ";
11781180 expectedTag = "<video poster='{0}.jpg' width='250'>"
11791181 + "<source src='{0}.webm' type='video/webm'>"
11801182 + "<source src='{0}.mp4' type='video/mp4'>"
11811183 + "<source src='{0}.ogv' type='video/ogg'>"
11821184 + "</video>" ;
11831185 expectedTag = String . Format ( expectedTag , expectedUrl ) ;
11841186 actualTag = m_api . UrlVideoUp . Transform ( transformation )
1185- . BuildVideoTag ( "movie" ) . ToString ( ) ;
1187+ . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ;
11861188 Assert . AreEqual ( expectedTag , actualTag ) ;
11871189
11881190 transformation . Crop ( "fit" ) ;
1189- expectedUrl = m_defaultVideoUpPath + "ac_acc,c_fit,so_3.0,vc_h264,w_250/movie " ;
1191+ expectedUrl = m_defaultVideoUpPath + $ "ac_acc,c_fit,so_3.0,vc_h264,w_250/{ SOURCE_MOVIE } ";
11901192 expectedTag = "<video poster='{0}.jpg'>"
11911193 + "<source src='{0}.webm' type='video/webm'>"
11921194 + "<source src='{0}.mp4' type='video/mp4'>"
11931195 + "<source src='{0}.ogv' type='video/ogg'>"
11941196 + "</video>" ;
11951197 expectedTag = String . Format ( expectedTag , expectedUrl ) ;
11961198 actualTag = m_api . UrlVideoUp . Transform ( transformation )
1197- . BuildVideoTag ( "movie" ) . ToString ( ) ;
1199+ . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ;
1200+ Assert . AreEqual ( expectedTag , actualTag ) ;
1201+ }
1202+
1203+ [ Test ]
1204+ public void TestVideoTagWithDefaultSources ( )
1205+ {
1206+ var expectedTag =
1207+ $ "<video poster=\' { m_defaultVideoUpPath } { SOURCE_MOVIE } .jpg\' >" +
1208+ $ "<source src=\' { m_defaultVideoUpPath } vc_h265/{ SOURCE_MOVIE } .mp4\' type=\' video/mp4; codecs=hev1\' >" +
1209+ $ "<source src=\' { m_defaultVideoUpPath } vc_vp9/{ SOURCE_MOVIE } .webm\' type=\' video/webm; codecs=vp9\' >" +
1210+ $ "<source src=\' { m_defaultVideoUpPath } vc_auto/{ SOURCE_MOVIE } .mp4\' type=\' video/mp4\' >" +
1211+ $ "<source src=\' { m_defaultVideoUpPath } vc_auto/{ SOURCE_MOVIE } .webm\' type=\' video/webm\' >" +
1212+ "</video>" ;
1213+
1214+ var actualTag = m_api . UrlVideoUp . VideoSources ( Url . DefaultVideoSources ) . BuildVideoTag ( SOURCE_MOVIE ) ;
1215+
1216+ Assert . AreEqual ( expectedTag , actualTag ) ;
1217+ }
1218+
1219+ [ Test ]
1220+ public void TestVideoTagWithCustomSources ( )
1221+ {
1222+ var customSources = new [ ]
1223+ {
1224+ new VideoSource
1225+ {
1226+ Type = "mp4" ,
1227+ Codecs = new [ ] { "vp8" , "vorbis" } ,
1228+ Transformation = new Transformation ( ) . VideoCodec ( "auto" )
1229+ } ,
1230+ new VideoSource
1231+ {
1232+ Type = "webm" ,
1233+ Codecs = new [ ] { "avc1.4D401E" , "mp4a.40.2" } ,
1234+ Transformation = new Transformation ( ) . VideoCodec ( "auto" )
1235+ }
1236+ } ;
1237+
1238+ var expectedTag =
1239+ $ "<video poster=\' { m_defaultVideoUpPath } { SOURCE_MOVIE } .jpg\' >" +
1240+ $ "<source src=\' { m_defaultVideoUpPath } vc_auto/{ SOURCE_MOVIE } .mp4\' " +
1241+ " type=\' video/mp4; codecs=vp8, vorbis\' >" +
1242+ $ "<source src=\' { m_defaultVideoUpPath } vc_auto/{ SOURCE_MOVIE } .webm\' " +
1243+ " type=\' video/webm; codecs=avc1.4D401E, mp4a.40.2\' >" +
1244+ "</video>" ;
1245+
1246+ var actualTag = m_api . UrlVideoUp . VideoSources ( customSources ) . BuildVideoTag ( SOURCE_MOVIE ) ;
1247+
1248+ Assert . AreEqual ( expectedTag , actualTag ) ;
1249+ }
1250+
1251+ [ Test ]
1252+ public void TestVideoTagWithTransformations ( )
1253+ {
1254+ var paramsDict = new StringDictionary ( )
1255+ {
1256+ { "html_height" , "100" } ,
1257+ { "html_width" , "200" } ,
1258+ } ;
1259+
1260+ var urlPrefix = $ "{ m_defaultVideoUpPath } ac_acc,so_3,";
1261+
1262+ var expectedTag =
1263+ $ "<video height='100' poster=\' { urlPrefix } vc_h264/{ SOURCE_MOVIE } .jpg\' width='200'>" +
1264+ $ "<source src=\' { urlPrefix } vc_h265/{ SOURCE_MOVIE } .mp4\' type=\' video/mp4; codecs=hev1\' >" +
1265+ $ "<source src=\' { urlPrefix } vc_vp9/{ SOURCE_MOVIE } .webm\' type=\' video/webm; codecs=vp9\' >" +
1266+ $ "<source src=\' { urlPrefix } vc_auto/{ SOURCE_MOVIE } .mp4\' type=\' video/mp4\' >" +
1267+ $ "<source src=\' { urlPrefix } vc_auto/{ SOURCE_MOVIE } .webm\' type=\' video/webm\' >" +
1268+ "</video>" ;
1269+
1270+ var actualTag = m_api . UrlVideoUp
1271+ . VideoSources ( Url . DefaultVideoSources )
1272+ . SourceTypes ( "mp4" )
1273+ . Transform ( new Transformation ( ) . VideoCodec ( "h264" ) . AudioCodec ( "acc" ) . StartOffset ( "3" ) )
1274+ . BuildVideoTag ( SOURCE_MOVIE , paramsDict ) ;
1275+
11981276 Assert . AreEqual ( expectedTag , actualTag ) ;
11991277 }
12001278
12011279 [ Test ]
12021280 public void TestVideoTagWithFallback ( )
12031281 {
1204- var expectedUrl = m_defaultVideoUpPath + "movie" ;
1282+ var expectedUrl = m_defaultVideoUpPath + SOURCE_MOVIE ;
12051283 var fallback = "<span id='spanid'>Cannot display video</span>" ;
12061284 var expectedTag = "<video poster='{0}.jpg' src='{0}.mp4'>{1}</video>" ;
12071285 expectedTag = String . Format ( expectedTag , expectedUrl , fallback ) ;
12081286 var actualTag = m_api . UrlVideoUp . FallbackContent ( fallback ) . SourceTypes ( new String [ ] { "mp4" } )
1209- . BuildVideoTag ( "movie" ) . ToString ( ) ;
1287+ . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ;
12101288 Assert . AreEqual ( expectedTag , actualTag ) ;
12111289
12121290 expectedTag = "<video poster='{0}.jpg'>" + "<source src='{0}.webm' type='video/webm'>"
12131291 + "<source src='{0}.mp4' type='video/mp4'>" + "<source src='{0}.ogv' type='video/ogg'>{1}" + "</video>" ;
12141292 expectedTag = String . Format ( expectedTag , expectedUrl , fallback ) ;
1215- actualTag = m_api . UrlVideoUp . FallbackContent ( fallback ) . BuildVideoTag ( "movie" ) . ToString ( ) ;
1293+ actualTag = m_api . UrlVideoUp . FallbackContent ( fallback ) . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ;
12161294 Assert . AreEqual ( expectedTag , actualTag ) ;
12171295 }
12181296
12191297 [ Test ]
12201298 public void TestVideoTagWithSourceTypes ( )
12211299 {
1222- var expectedUrl = m_defaultVideoUpPath + "movie" ;
1300+ var expectedUrl = m_defaultVideoUpPath + SOURCE_MOVIE ;
12231301 var expectedTag = "<video poster='{0}.jpg'>" + "<source src='{0}.ogv' type='video/ogg'>"
12241302 + "<source src='{0}.mp4' type='video/mp4'>" + "</video>" ;
12251303 expectedTag = String . Format ( expectedTag , expectedUrl ) ;
12261304 string actualTag = m_api . UrlVideoUp . SourceTypes ( new string [ ] { "ogv" , "mp4" } )
1227- . BuildVideoTag ( "movie .mp4") . ToString ( ) ;
1305+ . BuildVideoTag ( $ " { SOURCE_MOVIE } .mp4") . ToString ( ) ;
12281306 Assert . AreEqual ( expectedTag , actualTag ) ;
12291307 }
12301308
12311309 [ Test ]
12321310 public void TestVideoTagWithSourceTransformation ( )
12331311 {
1234- var expectedUrl = m_defaultVideoUpPath + "q_50/w_100/movie " ;
1235- var expectedOgvUrl = m_defaultVideoUpPath + "q_50/w_100/q_70/movie " ;
1236- var expectedMp4Url = m_defaultVideoUpPath + "q_50/w_100/q_30/movie " ;
1312+ var expectedUrl = m_defaultVideoUpPath + $ "q_50/w_100/{ SOURCE_MOVIE } ";
1313+ var expectedOgvUrl = m_defaultVideoUpPath + $ "q_50/w_100/q_70/{ SOURCE_MOVIE } ";
1314+ var expectedMp4Url = m_defaultVideoUpPath + $ "q_50/w_100/q_30/{ SOURCE_MOVIE } ";
12371315 var expectedTag = "<video poster='{0}.jpg' width='100'>"
12381316 + "<source src='{0}.webm' type='video/webm'>"
12391317 + "<source src='{1}.mp4' type='video/mp4'>"
@@ -1243,7 +1321,7 @@ public void TestVideoTagWithSourceTransformation()
12431321 var actualTag = m_api . UrlVideoUp . Transform ( new Transformation ( ) . Quality ( 50 ) . Chain ( ) . Width ( 100 ) )
12441322 . SourceTransformationFor ( "mp4" , new Transformation ( ) . Quality ( 30 ) )
12451323 . SourceTransformationFor ( "ogv" , new Transformation ( ) . Quality ( 70 ) )
1246- . BuildVideoTag ( "movie" ) . ToString ( ) ;
1324+ . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ;
12471325 Assert . AreEqual ( expectedTag , actualTag ) ;
12481326
12491327 expectedTag = "<video poster='{0}.jpg' width='100'>" + "<source src='{0}.webm' type='video/webm'>"
@@ -1252,43 +1330,43 @@ public void TestVideoTagWithSourceTransformation()
12521330 actualTag = m_api . UrlVideoUp . Transform ( new Transformation ( ) . Quality ( 50 ) . Chain ( ) . Width ( 100 ) )
12531331 . SourceTransformationFor ( "mp4" , new Transformation ( ) . Quality ( 30 ) )
12541332 . SourceTransformationFor ( "ogv" , new Transformation ( ) . Quality ( 70 ) )
1255- . SourceTypes ( "webm" , "mp4" ) . BuildVideoTag ( "movie" ) . ToString ( ) ;
1333+ . SourceTypes ( "webm" , "mp4" ) . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ;
12561334 Assert . AreEqual ( expectedTag , actualTag ) ;
12571335 }
12581336
12591337 [ Test ]
12601338 public void TestVideoTagWithPoster ( )
12611339 {
1262- var expectedUrl = m_defaultVideoUpPath + "movie" ;
1340+ var expectedUrl = m_defaultVideoUpPath + SOURCE_MOVIE ;
12631341 var posterUrl = "http://image/somewhere.jpg" ;
12641342 var expectedTag = "<video poster='{0}' src='{1}.mp4'></video>" ;
12651343 expectedTag = String . Format ( expectedTag , posterUrl , expectedUrl ) ;
12661344 var actualTag = m_api . UrlVideoUp . SourceTypes ( "mp4" ) . Poster ( posterUrl )
1267- . BuildVideoTag ( "movie" ) . ToString ( ) ;
1345+ . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ;
12681346 Assert . AreEqual ( expectedTag , actualTag ) ;
12691347
1270- posterUrl = m_defaultVideoUpPath + "g_north/movie .jpg" ;
1348+ posterUrl = m_defaultVideoUpPath + $ "g_north/{ SOURCE_MOVIE } .jpg";
12711349 expectedTag = "<video poster='{0}' src='{1}.mp4'></video>" ;
12721350 expectedTag = String . Format ( expectedTag , posterUrl , expectedUrl ) ;
12731351 actualTag = m_api . UrlVideoUp . SourceTypes ( "mp4" )
12741352 . Poster ( new Transformation ( ) . Gravity ( "north" ) )
1275- . BuildVideoTag ( "movie" ) . ToString ( ) ;
1353+ . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ;
12761354 Assert . AreEqual ( expectedTag , actualTag ) ;
12771355
12781356 posterUrl = m_defaultVideoUpPath + "g_north/my_poster.jpg" ;
12791357 expectedTag = "<video poster='{0}' src='{1}.mp4'></video>" ;
12801358 expectedTag = String . Format ( expectedTag , posterUrl , expectedUrl ) ;
12811359 actualTag = m_api . UrlVideoUp . SourceTypes ( "mp4" )
12821360 . Poster ( m_api . UrlVideoUp . Source ( "my_poster" ) . Format ( "jpg" ) . Transform ( new Transformation ( ) . Gravity ( "north" ) ) )
1283- . BuildVideoTag ( "movie" ) . ToString ( ) ;
1361+ . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ;
12841362 Assert . AreEqual ( expectedTag , actualTag ) ;
12851363
12861364 expectedTag = "<video src='{0}.mp4'></video>" ;
12871365 expectedTag = String . Format ( expectedTag , expectedUrl ) ;
1288- actualTag = m_api . UrlVideoUp . SourceTypes ( "mp4" ) . Poster ( null ) . BuildVideoTag ( "movie" ) . ToString ( ) ;
1366+ actualTag = m_api . UrlVideoUp . SourceTypes ( "mp4" ) . Poster ( null ) . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ;
12891367 Assert . AreEqual ( expectedTag , actualTag ) ;
12901368
1291- actualTag = m_api . UrlVideoUp . SourceTypes ( "mp4" ) . Poster ( false ) . BuildVideoTag ( "movie" ) . ToString ( ) ;
1369+ actualTag = m_api . UrlVideoUp . SourceTypes ( "mp4" ) . Poster ( false ) . BuildVideoTag ( SOURCE_MOVIE ) . ToString ( ) ;
12921370 Assert . AreEqual ( expectedTag , actualTag ) ;
12931371 }
12941372
0 commit comments