< Summary

Class:DCL.Components.DCLVideoClip
Assembly:DCL.Components.Video
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Video/DCLVideoClip.cs
Covered lines:16
Uncovered lines:2
Coverable lines:18
Total lines:58
Line coverage:88.8% (16 of 18)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DCLVideoClip()0%110100%
GetDataFromJSON(...)0%110100%
DCLVideoClip()0%110100%
GetClassId()0%2100%
ApplyChanges()0%440100%
GetUrl()0%2.032080%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Video/DCLVideoClip.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.Linq;
 5using DCL.Controllers;
 6using DCL.Helpers;
 7using DCL.Models;
 8
 9namespace DCL.Components
 10{
 11    public class DCLVideoClip : BaseDisposable
 12    {
 113        private static readonly string[] NO_STREAM_EXTENSIONS = new[] { ".mp4", ".ogg", ".mov", ".webm" };
 14
 15        [System.Serializable]
 16        public class Model : BaseModel
 17        {
 18            public string url;
 19
 1520            public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<Model>(json); }
 21        }
 22
 3023        public bool isExternalURL { get; private set; }
 3024        public bool isStream { get; private set; }
 25
 4526        public DCLVideoClip() { model = new Model(); }
 27
 028        public override int GetClassId() { return (int) CLASS_ID.VIDEO_CLIP; }
 29
 30        public override IEnumerator ApplyChanges(BaseModel newModel)
 31        {
 1532            Model model = (Model) newModel;
 1533            isExternalURL = model.url.StartsWith("http://") || model.url.StartsWith("https://");
 34
 1535            string urlPath = model.url;
 1536            if (Uri.TryCreate(urlPath, UriKind.Absolute, out Uri uri))
 37            {
 1538                urlPath = uri.AbsolutePath;
 39            }
 7540            isStream = !NO_STREAM_EXTENSIONS.Any(x => urlPath.EndsWith(x));
 1541            yield break;
 42        }
 43
 44        public string GetUrl()
 45        {
 1546            Model model = (Model) this.model;
 47
 1548            string contentsUrl = model.url;
 49
 1550            if (!isExternalURL)
 51            {
 052                scene.contentProvider.TryGetContentsUrl(model.url, out contentsUrl);
 53            }
 54
 1555            return contentsUrl;
 56        }
 57    }
 58}