< Summary

Class:AirdroppingItemPanel
Assembly:AirdroppingHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AirdroppingHUD/AirdroppingItemPanel.cs
Covered lines:16
Uncovered lines:8
Coverable lines:24
Total lines:57
Line coverage:66.6% (16 of 24)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetData(...)0%220100%
OnEnable()0%110100%
OnDisable()0%110100%
ThumbnailReady(...)0%6200%
GetThumbnail()0%110100%
ForgetThumbnail()0%3.192033.33%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/AirdroppingHUD/AirdroppingItemPanel.cs

#LineLine coverage
 1using DCL;
 2using TMPro;
 3using UnityEngine;
 4using UnityEngine.UI;
 5
 6public class AirdroppingItemPanel : MonoBehaviour
 7{
 8    [SerializeField] internal TextMeshProUGUI name;
 9    [SerializeField] internal TextMeshProUGUI subtitle;
 10    [SerializeField] internal Image thumbnail;
 11
 12    private string currentThumbnailUrl;
 13    private AssetPromise_Texture currentThumbnailPromise;
 14
 15    public void SetData(string name, string subtitle, string thumbnailURL)
 16    {
 717        this.name.text = name;
 718        this.name.gameObject.SetActive(!string.IsNullOrEmpty(this.name.text));
 19
 720        this.subtitle.text = subtitle;
 721        this.subtitle.gameObject.SetActive(!string.IsNullOrEmpty(this.subtitle.text));
 22
 723        currentThumbnailUrl = thumbnailURL;
 24
 725        if (gameObject.activeInHierarchy)
 426            GetThumbnail();
 727    }
 28
 829    private void OnEnable() { GetThumbnail(); }
 30
 831    private void OnDisable() { ForgetThumbnail(); }
 32
 33    public void ThumbnailReady(Asset_Texture texture)
 34    {
 035        if (thumbnail.sprite != null)
 036            Destroy(thumbnail.sprite);
 37
 038        thumbnail.sprite = ThumbnailsManager.CreateSpriteFromTexture(texture.texture);
 039    }
 40
 41    private void GetThumbnail()
 42    {
 843        var newCurrentThumbnailPromise = ThumbnailsManager.GetThumbnail(currentThumbnailUrl, ThumbnailReady);
 844        ThumbnailsManager.ForgetThumbnail(currentThumbnailPromise);
 845        currentThumbnailPromise = newCurrentThumbnailPromise;
 846    }
 47
 48    private void ForgetThumbnail()
 49    {
 450        if (currentThumbnailPromise == null)
 451            return;
 52
 053        ThumbnailsManager.ForgetThumbnail(currentThumbnailPromise);
 054        ThumbnailReady(null);
 055        currentThumbnailPromise = null;
 056    }
 57}