< Summary

Class:PrivateChatHUDView
Assembly:PrivateChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/PrivateChatWindow/PrivateChatHUDView.cs
Covered lines:25
Uncovered lines:4
Coverable lines:29
Total lines:63
Line coverage:86.2% (25 of 29)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PrivateChatHUDView()0%110100%
AddEntry(...)0%5.015091.67%
OnMessageTriggerHover(...)0%12300%
AddSeparatorEntryIfNeeded(...)0%220100%
GetDateTimeFromUnixTimestampMilliseconds(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/PrivateChatWindow/PrivateChatHUDView.cs

#LineLine coverage
 1using DCL.Helpers;
 2using System;
 3using UnityEngine;
 4
 5public class PrivateChatHUDView : ChatHUDView
 6{
 167    string ENTRY_PATH_SENT = "ChatEntrySent";
 168    string ENTRY_PATH_RECEIVED = "ChatEntryReceived";
 169    string ENTRY_PATH_SEPARATOR = "ChatEntrySeparator";
 10
 11    public override void AddEntry(ChatEntry.Model chatEntryModel, bool setScrollPositionToBottom = false)
 12    {
 713        AddSeparatorEntryIfNeeded(chatEntryModel);
 14
 715        var chatEntryGO = Instantiate(Resources.Load(chatEntryModel.subType == ChatEntry.Model.SubType.PRIVATE_TO ? ENTR
 716        ChatEntry chatEntry = chatEntryGO.GetComponent<ChatEntry>();
 17
 718        chatEntry.SetFadeout(false);
 719        chatEntry.Populate(chatEntryModel);
 20
 721        chatEntry.OnTriggerHover += OnMessageTriggerHover;
 722        chatEntry.OnCancelHover += OnMessageCancelHover;
 23
 724        entries.Add(chatEntry);
 725        Utils.ForceUpdateLayout(transform as RectTransform, delayed: false);
 26
 727        if (setScrollPositionToBottom && scrollRect.verticalNormalizedPosition > 0)
 028            scrollRect.verticalNormalizedPosition = 0;
 729    }
 30
 31    protected override void OnMessageTriggerHover(ChatEntry chatEntry)
 32    {
 033        (messageHoverPanel.transform as RectTransform).pivot = new Vector2(chatEntry.model.subType == ChatEntry.Model.Su
 34
 035        base.OnMessageTriggerHover(chatEntry);
 036    }
 37
 38    private void AddSeparatorEntryIfNeeded(ChatEntry.Model chatEntryModel)
 39    {
 740        DateTime entryDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
 741        entryDateTime = GetDateTimeFromUnixTimestampMilliseconds(chatEntryModel.timestamp);
 42
 743        if (!dateSeparators.Exists(separator =>
 444            separator.model.date.Year == entryDateTime.Year &&
 45            separator.model.date.Month == entryDateTime.Month &&
 46            separator.model.date.Day == entryDateTime.Day))
 47        {
 348            var chatEntrySeparatorGO = Instantiate(Resources.Load(ENTRY_PATH_SEPARATOR) as GameObject, chatEntriesContai
 349            DateSeparatorEntry dateSeparatorEntry = chatEntrySeparatorGO.GetComponent<DateSeparatorEntry>();
 350            dateSeparatorEntry.Populate(new DateSeparatorEntry.Model
 51            {
 52                date = entryDateTime
 53            });
 354            dateSeparators.Add(dateSeparatorEntry);
 55        }
 756    }
 57
 58    private DateTime GetDateTimeFromUnixTimestampMilliseconds(ulong milliseconds)
 59    {
 760        System.DateTime result = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 761        return result.AddMilliseconds(milliseconds);
 62    }
 63}