< 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:18
Uncovered lines:7
Coverable lines:25
Total lines:73
Line coverage:72% (18 of 25)
Covered branches:0
Total branches:0
Covered methods:9
Total methods:11
Method coverage:81.8% (9 of 11)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DCLVideoClip()0%110100%
GetDataFromJSON(...)0%110100%
GetDataFromPb(...)0%12300%
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.Linq;
 4using DCL.Helpers;
 5using DCL.Models;
 6using Decentraland.Sdk.Ecs6;
 7
 8namespace DCL.Components
 9{
 10    public class DCLVideoClip : BaseDisposable
 11    {
 112        private static readonly string[] NO_STREAM_EXTENSIONS = { ".mp4", ".ogg", ".mov", ".webm" };
 13
 14        [Serializable]
 15        public class Model : BaseModel
 16        {
 17            public string url;
 18
 19            public override BaseModel GetDataFromJSON(string json) =>
 1720                Utils.SafeFromJson<Model>(json);
 21
 22            public override BaseModel GetDataFromPb(ComponentBodyPayload pbModel)
 23            {
 024                if (pbModel.PayloadCase != ComponentBodyPayload.PayloadOneofCase.VideoClip)
 025                    return Utils.SafeUnimplemented<DCLVideoClip, Model>(expected: ComponentBodyPayload.PayloadOneofCase.
 26
 027                var pb = new Model();
 028                if (pbModel.VideoClip.HasUrl) pb.url = pbModel.VideoClip.Url;
 29
 030                return pb;
 31            }
 32        }
 33
 3534        public bool isExternalURL { get; private set; }
 3535        public bool isStream { get; private set; }
 36
 1737        public DCLVideoClip()
 38        {
 1739            model = new Model();
 1740        }
 41
 42        public override int GetClassId() =>
 043            (int) CLASS_ID.VIDEO_CLIP;
 44
 45        public override IEnumerator ApplyChanges(BaseModel newModel)
 46        {
 1747            Model model = (Model) newModel;
 1748            isExternalURL = model.url.StartsWith("http://") || model.url.StartsWith("https://");
 49
 1750            string urlPath = model.url;
 1751            if (Uri.TryCreate(urlPath, UriKind.Absolute, out Uri uri))
 52            {
 1753                urlPath = uri.AbsolutePath;
 54            }
 8555            isStream = !NO_STREAM_EXTENSIONS.Any(x => urlPath.EndsWith(x));
 1756            yield break;
 57        }
 58
 59        public string GetUrl()
 60        {
 1861            Model model = (Model) this.model;
 62
 1863            string contentsUrl = model.url;
 64
 1865            if (!isExternalURL)
 66            {
 067                scene.contentProvider.TryGetContentsUrl(model.url, out contentsUrl);
 68            }
 69
 1870            return contentsUrl;
 71        }
 72    }
 73}