< Summary

Class:DCL.AssetPromise_Gif
Assembly:AssetPromiseKeeper
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/AssetManager/Gif/AssetPromise_Gif.cs
Covered lines:16
Uncovered lines:3
Coverable lines:19
Total lines:51
Line coverage:84.2% (16 of 19)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
AssetPromise_Gif(...)0%2100%
GetId()0%110100%
OnLoad(...)0%110100%
OnCancelLoading()0%220100%
AddToLibrary()0%2.262060%
OnBeforeLoadOrReuse()0%110100%
OnAfterLoadOrReuse()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/AssetManager/Gif/AssetPromise_Gif.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4namespace DCL
 5{
 6    public class AssetPromise_Gif : AssetPromise<Asset_Gif>
 7    {
 8        private readonly string url;
 9        private Coroutine loadingRoutine;
 10
 011        public AssetPromise_Gif(string url) { this.url = url; }
 12
 7413        public override object GetId() { return url; }
 14
 15        protected override void OnLoad(Action OnSuccess, Action<Exception> OnFail)
 16        {
 1217            var processor = new GifProcessor(url);
 1218            asset.processor = processor;
 1219            loadingRoutine = CoroutineStarter.Start(
 20                processor.Load(
 21                    frames =>
 22                    {
 523                        asset.frames = frames;
 24
 525                        OnSuccess?.Invoke();
 526                    }, OnFail));
 1227        }
 28
 29        protected override void OnCancelLoading()
 30        {
 731            if (loadingRoutine != null)
 732                CoroutineStarter.Stop(loadingRoutine);
 733        }
 34
 35        protected override bool AddToLibrary()
 36        {
 537            if (!library.Add(asset))
 38            {
 039                Debug.Log("add to library fail?");
 040                return false;
 41            }
 42
 543            asset = library.Get(asset.id);
 544            return true;
 45        }
 46
 1547        protected override void OnBeforeLoadOrReuse() { }
 48
 849        protected override void OnAfterLoadOrReuse() { }
 50    }
 51}