< 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:16
Uncovered lines:9
Coverable lines:25
Total lines:61
Line coverage:64% (16 of 25)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUserProfile(...)0%110100%
OnFaceSnapshotLoaded(...)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 DCL;
 2using UnityEngine;
 3using UnityEngine.UI;
 4using TMPro;
 5
 6internal class ExploreFriendsView : MonoBehaviour
 7{
 8    [SerializeField] RawImage friendPortrait;
 9    [SerializeField] Image friendBackground;
 10    [SerializeField] ShowHideAnimator showHideAnimator;
 11    [SerializeField] TextMeshProUGUI friendName;
 12    [SerializeField] UIHoverCallback hoverCallback;
 13
 14    UserProfile userProfile;
 15
 16    public void SetUserProfile(UserProfile profile, Color backgroundColor)
 17    {
 218        userProfile = profile;
 219        friendName.text = profile.userName;
 220        friendBackground.color = backgroundColor;
 221        userProfile.snapshotObserver.AddListener(OnFaceSnapshotLoaded);
 222        gameObject.SetActive(true);
 223    }
 24
 25    void OnFaceSnapshotLoaded(Texture2D texture)
 26    {
 027        friendPortrait.texture = texture;
 028    }
 29
 30    void OnHeadHoverEnter()
 31    {
 032        if (!userProfile)
 033            return;
 34
 035        if (!showHideAnimator.gameObject.activeSelf)
 036            showHideAnimator.gameObject.SetActive(true);
 37
 038        showHideAnimator.Show();
 039    }
 40
 041    void OnHeadHoverExit() { showHideAnimator.Hide(); }
 42
 43    void Awake()
 44    {
 245        hoverCallback.OnPointerEnter += OnHeadHoverEnter;
 246        hoverCallback.OnPointerExit += OnHeadHoverExit;
 247        showHideAnimator.gameObject.SetActive(false);
 248    }
 49
 50    void OnDestroy()
 51    {
 252        if (userProfile != null)
 253            userProfile.snapshotObserver.RemoveListener(OnFaceSnapshotLoaded);
 54
 255        if (hoverCallback)
 56        {
 257            hoverCallback.OnPointerEnter -= OnHeadHoverEnter;
 258            hoverCallback.OnPointerExit -= OnHeadHoverExit;
 59        }
 260    }
 61}