< Summary

Class:DCL.JSGifProcessor
Assembly:GifProcessor
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/AssetManager/Gif/GifProcessor/JSGifProcessor.cs
Covered lines:0
Uncovered lines:20
Coverable lines:20
Total lines:54
Line coverage:0% (0 of 20)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
JSGifProcessor(...)0%2100%
Load()0%20400%
Internal_Load()0%12300%
OnComplete(...)0%20400%
OnFail()0%6200%
DisposeGif()0%2100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Threading;
 3using Cysharp.Threading.Tasks;
 4
 5namespace DCL
 6{
 7    public class JSGifProcessor : IGifProcessor
 8    {
 9        private readonly string url;
 10        private Action<GifFrameData[]> successCallback;
 11        private Action<Exception> failCallback;
 12
 013        public JSGifProcessor(string url) { this.url = url; }
 14
 15        public async UniTask Load(Action<GifFrameData[]> OnSuccess, Action<Exception> OnFail, CancellationToken cancella
 16        {
 17            try
 18            {
 019                await Internal_Load(OnSuccess, OnFail, cancellationToken);
 020            }
 021            catch (Exception e)
 22            {
 023                if (!(e is OperationCanceledException))
 24                {
 025                    OnFail(e);
 26                }
 027            }
 028        }
 29
 30        private async UniTask Internal_Load(Action<GifFrameData[]> OnSuccess, Action<Exception> OnFail, CancellationToke
 31        {
 032            successCallback = OnSuccess;
 033            failCallback = OnFail;
 34
 035            token.ThrowIfCancellationRequested();
 036            await GIFProcessingBridge.i.RequestGIFProcessor(url, OnComplete, this.OnFail).ToUniTask(cancellationToken: t
 037        }
 38
 39        private void OnComplete(GifFrameData[] newTextures)
 40        {
 041            if (newTextures == null || newTextures.Length == 0)
 42            {
 043                OnFail();
 044                return;
 45            }
 46
 047            successCallback?.Invoke(newTextures);
 048        }
 49
 050        private void OnFail() { failCallback?.Invoke( new Exception("JS Gif fetch failed")); }
 51
 052        public void DisposeGif() { GIFProcessingBridge.i.DeleteGIF(url); }
 53    }
 54}