< 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:17
Uncovered lines:3
Coverable lines:20
Total lines:53
Line coverage:85% (17 of 20)
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%110100%
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
 6313        public override object GetId() { return url; }
 14
 15        protected override void OnLoad(Action OnSuccess, Action OnFail)
 16        {
 1017            var processor = new GifProcessor(url);
 1018            asset.processor = processor;
 1019            loadingRoutine = CoroutineStarter.Start(
 20                processor.Load(
 21                    frames =>
 22                    {
 423                        asset.frames = frames;
 24
 36825                        foreach ( var frame in asset.frames )
 26                        {
 18027                            frame.texture.Compress(false);
 18028                            frame.texture.Apply(true, true);
 29                        }
 30
 431                        OnSuccess?.Invoke();
 432                    }, OnFail));
 1033        }
 34
 1235        protected override void OnCancelLoading() { CoroutineStarter.Stop(loadingRoutine); }
 36
 37        protected override bool AddToLibrary()
 38        {
 439            if (!library.Add(asset))
 40            {
 041                Debug.Log("add to library fail?");
 042                return false;
 43            }
 44
 445            asset = library.Get(asset.id);
 446            return true;
 47        }
 48
 1349        protected override void OnBeforeLoadOrReuse() { }
 50
 751        protected override void OnAfterLoadOrReuse() { }
 52    }
 53}