< Summary

Class:ExploreFriendsView
Assembly:ExploreHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ExploreHUD/Scripts/Friends/ExploreFriendsView.cs
Covered lines:18
Uncovered lines:9
Coverable lines:27
Total lines:69
Line coverage:66.6% (18 of 27)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUserProfile(...)0%220100%
OnFaceSnapshotReadyEvent(...)0%2100%
OnHeadHoverEnter()0%12300%
OnHeadHoverExit()0%2100%
Awake()0%110100%
OnDestroy()0%330100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ExploreHUD/Scripts/Friends/ExploreFriendsView.cs

#LineLine coverage
 1using UnityEngine;
 2using UnityEngine.UI;
 3using TMPro;
 4
 5internal class ExploreFriendsView : MonoBehaviour
 6{
 7    [SerializeField] RawImage friendPortrait;
 8    [SerializeField] Image friendBackground;
 9    [SerializeField] ShowHideAnimator showHideAnimator;
 10    [SerializeField] TextMeshProUGUI friendName;
 11    [SerializeField] UIHoverCallback hoverCallback;
 12
 13    UserProfile userProfile;
 14
 15    public void SetUserProfile(UserProfile profile, Color backgroundColor)
 16    {
 217        userProfile = profile;
 218        friendPortrait.texture = profile.faceSnapshot;
 219        friendName.text = profile.userName;
 220        friendBackground.color = backgroundColor;
 21
 222        if (profile.faceSnapshot == null)
 23        {
 224            profile.OnFaceSnapshotReadyEvent += OnFaceSnapshotReadyEvent;
 25        }
 226        gameObject.SetActive(true);
 227    }
 28
 29    void OnFaceSnapshotReadyEvent(Texture2D texture)
 30    {
 031        userProfile.OnFaceSnapshotReadyEvent -= OnFaceSnapshotReadyEvent;
 032        friendPortrait.texture = userProfile.faceSnapshot;
 033    }
 34
 35    void OnHeadHoverEnter()
 36    {
 037        if (userProfile)
 38        {
 039            if (!showHideAnimator.gameObject.activeSelf)
 40            {
 041                showHideAnimator.gameObject.SetActive(true);
 42            }
 043            showHideAnimator.Show();
 44        }
 045    }
 46
 047    void OnHeadHoverExit() { showHideAnimator.Hide(); }
 48
 49    void Awake()
 50    {
 251        hoverCallback.OnPointerEnter += OnHeadHoverEnter;
 252        hoverCallback.OnPointerExit += OnHeadHoverExit;
 253        showHideAnimator.gameObject.SetActive(false);
 254    }
 55
 56    void OnDestroy()
 57    {
 258        if (userProfile)
 59        {
 260            userProfile.OnFaceSnapshotReadyEvent -= OnFaceSnapshotReadyEvent;
 61        }
 62
 263        if (hoverCallback)
 64        {
 265            hoverCallback.OnPointerEnter -= OnHeadHoverEnter;
 266            hoverCallback.OnPointerExit -= OnHeadHoverExit;
 67        }
 268    }
 69}