< Summary

Class:ChatHeadButton
Assembly:TaskbarHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TaskbarHUD/ChatHeadButton.cs
Covered lines:14
Uncovered lines:5
Coverable lines:19
Total lines:49
Line coverage:73.6% (14 of 19)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ChatHeadButton()0%110100%
Initialize(...)0%2.012088.89%
Profile_OnFaceSnapshotReadyEvent(...)0%2100%
OnDestroy()0%220100%
OnPointerEnter(...)0%2100%
OnPointerExit(...)0%2100%
SetOnlineStatus(...)0%330100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TaskbarHUD/ChatHeadButton.cs

#LineLine coverage
 1using UnityEngine;
 2using UnityEngine.EventSystems;
 3using UnityEngine.UI;
 4
 5public class ChatHeadButton : TaskbarButton, IPointerEnterHandler, IPointerExitHandler
 6{
 7    [SerializeField] internal ShowHideAnimator labelContainer;
 8    [SerializeField] internal TMPro.TextMeshProUGUI label;
 9    [SerializeField] internal RawImage portrait;
 10    [SerializeField] internal UnreadNotificationBadge unreadNotificationBadge;
 11    [SerializeField] internal Image onlineStatusIndicator;
 212    [SerializeField] internal Color onlineColor = Color.green;
 213    [SerializeField] internal Color offlineColor = Color.gray;
 14
 15    internal ulong lastTimestamp;
 16    internal UserProfile profile;
 17
 18    public void Initialize(UserProfile profile)
 19    {
 120        base.Initialize();
 121        this.profile = profile;
 122        unreadNotificationBadge.Initialize(ChatController.i, profile.userId);
 23
 124        if (profile.userName.Length > 10)
 125            label.text = profile.userName.Substring(0, 10) + "...";
 26        else
 027            label.text = profile.userName;
 28
 129        profile.snapshotObserver.AddListener(Profile_OnFaceSnapshotReadyEvent);
 130        SetOnlineStatus(false);
 131    }
 32
 33    private void Profile_OnFaceSnapshotReadyEvent(Texture2D portraitTexture)
 34    {
 035        this.portrait.texture = portraitTexture;
 036    }
 37
 38    private void OnDestroy()
 39    {
 140        if (profile != null)
 141            profile.snapshotObserver.RemoveListener(Profile_OnFaceSnapshotReadyEvent);
 142    }
 43
 044    public void OnPointerEnter(PointerEventData eventData) { labelContainer.Show(); }
 45
 046    public void OnPointerExit(PointerEventData eventData) { labelContainer.Hide(); }
 47
 248    public void SetOnlineStatus(bool isOnline) { onlineStatusIndicator.color = isOnline ? onlineColor : offlineColor; }
 49}