< Summary

Class:DCL.Controllers.LoadingScreenV2.HintTextureRequestHandler
Assembly:DCL.LoadingScreenV2
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/LoadingScreenV2/HintServiceScripts/HintTextureRequestHandler.cs
Covered lines:0
Uncovered lines:20
Coverable lines:20
Total lines:61
Line coverage:0% (0 of 20)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:1
Method coverage:0% (0 of 1)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DownloadTexture()0%90900%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/LoadingScreenV2/HintServiceScripts/HintTextureRequestHandler.cs

#LineLine coverage
 1using Cysharp.Threading.Tasks;
 2using System;
 3using System.Threading;
 4using UnityEngine;
 5using UnityEngine.Experimental.Rendering;
 6using UnityEngine.Networking;
 7
 8namespace DCL.Controllers.LoadingScreenV2
 9{
 10    /// <summary>
 11    ///     The HintTextureRequestHandler class is responsible for downloading textures for loading screen hints.
 12    /// </summary>
 13    public class HintTextureRequestHandler : IHintTextureRequestHandler
 14    {
 15        public async UniTask<Texture2D> DownloadTexture(string url, CancellationToken ctx, int timeout = 2)
 16        {
 017            Texture2D tex = null;
 018            UnityWebRequest www = null;
 19
 20            try
 21            {
 022                www = UnityWebRequest.Get(url);
 23
 024                www.timeout = timeout;
 25
 026                UnityWebRequestAsyncOperation operation = www.SendWebRequest();
 27
 028                while (!operation.isDone)
 29                {
 030                    await UniTask.Yield();
 31
 032                    if (ctx.IsCancellationRequested)
 33                    {
 034                        Debug.LogWarning("Hint DownloadTexture interrupted");
 035                        www.Abort();
 036                        return null;
 37                    }
 38                }
 39
 040                if (www.result != UnityWebRequest.Result.Success) { Debug.LogWarning("Hint DownloadTexture Error: " + ww
 41                else
 42                {
 043                    tex = new Texture2D(2, 2, GraphicsFormatUtility.GetGraphicsFormat(TextureFormat.RGBA32, false), Text
 44                    {
 45                        wrapMode = TextureWrapMode.Clamp,
 46                    };
 47
 048                    tex.LoadImage(www.downloadHandler.data);
 049                    tex.Apply(false, false);
 50                }
 051            }
 052            catch (Exception ex) { Debug.LogWarning("DownloadTexture Exception: " + ex.Message); }
 53            finally
 54            {
 055                if (www != null) { www.Dispose(); }
 56            }
 57
 058            return tex;
 059        }
 60    }
 61}

Methods/Properties

DownloadTexture()