< Summary

Class:DCL.WrappedTextureUtils
Assembly:WrappedTextureAsset
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Textures/WrappedTextureAsset/WrappedTextureAsset.cs
Covered lines:19
Uncovered lines:6
Coverable lines:25
Total lines:58
Line coverage:76% (19 of 25)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetHeader()0%660100%
Fetch()0%440100%
Fetch()0%7.465053.85%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Textures/WrappedTextureAsset/WrappedTextureAsset.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using DCL.Helpers;
 4using UnityEngine.Networking;
 5
 6namespace DCL
 7{
 8    public static class WrappedTextureUtils
 9    {
 10        public static IEnumerator GetHeader(string url, string headerField, Action<string> OnSuccess, Action<string> OnF
 11        {
 1212            using (var headReq = UnityWebRequest.Head(url))
 13            {
 1214                yield return headReq.SendWebRequest();
 15
 1216                if (headReq.WebRequestSucceded())
 17                {
 618                    OnSuccess?.Invoke(headReq.GetResponseHeader(headerField));
 619                }
 20                else
 21                {
 622                    OnFail?.Invoke(headReq.error);
 23                }
 1224            }
 1225        }
 26
 27        public static IEnumerator Fetch(string url, Action<IPromiseLike_TextureAsset> OnSuccess, Action OnFail = null)
 28        {
 1229            string contentType = null;
 1830            yield return GetHeader(url, "Content-Type", type => contentType = type, null);
 1231            yield return Fetch(contentType, url, OnSuccess, OnFail);
 1232        }
 33
 34        public static IEnumerator Fetch(string contentType, string url, Action<IPromiseLike_TextureAsset> OnSuccess, Act
 35        {
 1236            if (contentType == "image/gif")
 37            {
 038                AssetPromise_Gif gifPromise = new AssetPromise_Gif(url);
 039                gifPromise.OnSuccessEvent += texture => { OnSuccess?.Invoke(new PromiseLike_Gif(gifPromise)); };
 040                gifPromise.OnFailEvent += (x) => OnFail?.Invoke();
 41
 042                AssetPromiseKeeper_Gif.i.Keep(gifPromise);
 43
 044                yield return gifPromise;
 045            }
 46            else
 47            {
 1248                AssetPromise_Texture texturePromise = new AssetPromise_Texture(url, storeTexAsNonReadable: false);
 2449                texturePromise.OnSuccessEvent += texture => { OnSuccess?.Invoke(new PromiseLike_Texture(texturePromise))
 1850                texturePromise.OnFailEvent += (x) => OnFail?.Invoke();
 51
 1252                AssetPromiseKeeper_Texture.i.Keep(texturePromise);
 53
 1254                yield return texturePromise;
 55            }
 1256        }
 57    }
 58}

Methods/Properties

GetHeader()
Fetch()
Fetch()