< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LocalHintRequestSource(...)0%2100%
GetHintsAsync(...)0%6200%
Dispose()0%2100%
LoadHintsFromAddressable()0%30500%

File(s)

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

#LineLine coverage
 1using Cysharp.Threading.Tasks;
 2using DCL.Providers;
 3using System;
 4using System.Collections.Generic;
 5using System.Threading;
 6using UnityEngine;
 7
 8namespace DCL.Controllers.LoadingScreenV2
 9{
 10    /// <summary>
 11    ///     The LocalHintRequestSource class manages the retrieval of loading screen hints from a local JSON source.
 12    /// </summary>
 13    public class LocalHintRequestSource : IHintRequestSource
 14    {
 15        private const string LOCAL_HINTS_JSON_SOURCE = "LoadingScreenV2LocalHintsJsonSource";
 16
 17        private readonly IAddressableResourceProvider addressablesProvider;
 18
 019        public LocalHintRequestSource(string sourceAddressableSceneJson, SourceTag sourceTag, IAddressableResourceProvid
 20        {
 021            Source = sourceAddressableSceneJson;
 022            this.SourceTag = sourceTag;
 023            LoadingHints = new List<Hint>();
 024            this.addressablesProvider = addressablesProvider;
 025        }
 26
 027        public string Source { get; }
 028        public SourceTag SourceTag { get; }
 029        public List<Hint> LoadingHints { get; private set; }
 30
 31        public UniTask<List<Hint>> GetHintsAsync(CancellationToken ctx)
 32        {
 33            // If cancellation is requested, return an empty list
 034            if (ctx.IsCancellationRequested)
 035                return UniTask.FromResult(new List<Hint>());
 36
 37            // Otherwise, return hints when they are loaded from the addressable
 038            return LoadHintsFromAddressable(Source, ctx);
 39        }
 40
 41        public void Dispose()
 42        {
 043            LoadingHints.Clear();
 044        }
 45
 46        internal async UniTask<List<Hint>> LoadHintsFromAddressable(string addressableSourceKey, CancellationToken ctx)
 47        {
 48            try
 49            {
 050                if (ctx.IsCancellationRequested)
 051                    return LoadingHints;
 52
 053                TextAsset containerSceneAddressable = await addressablesProvider.GetAddressable<TextAsset>(addressableSo
 54
 055                if (containerSceneAddressable == null) { throw new Exception("Failed to load the addressable asset"); }
 56
 057                LoadingHints = HintSceneParserUtil.ParseJsonToHints(containerSceneAddressable.text);
 058                return LoadingHints;
 59            }
 060            catch (Exception ex)
 61            {
 062                Debug.LogWarning($"Failed to load hints from addressable: {ex.Message}");
 63
 064                return LoadingHints;
 65            }
 066        }
 67    }
 68}