< Summary

Class:DCL.Social.Chat.CreateChannelWindowComponentView
Assembly:WorldChatWindowHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/CreateChannelWindowComponentView.cs
Covered lines:53
Uncovered lines:23
Coverable lines:76
Total lines:143
Line coverage:69.7% (53 of 76)
Covered branches:0
Total branches:0
Covered methods:11
Total methods:15
Method coverage:73.3% (11 of 15)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%220100%
RefreshControl()0%2100%
Show()0%110100%
Hide()0%110100%
ShowChannelExistsError(...)0%110100%
ClearError()0%110100%
DisableCreateButton()0%110100%
EnableCreateButton()0%110100%
ClearInputText()0%110100%
FocusInputField()0%110100%
ShowWrongFormatError()0%110100%
ShowTooShortError()0%2100%
ShowChannelsExceededError()0%110100%
ShowUnknownError()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/WorldChatWindowHUD/CreateChannelWindowComponentView.cs

#LineLine coverage
 1using DCL.Social.Chat;
 2using System;
 3using TMPro;
 4using UnityEngine;
 5using UnityEngine.UI;
 6
 7namespace DCL.Social.Chat
 8{
 9    public class CreateChannelWindowComponentView : BaseComponentView, ICreateChannelWindowView
 10    {
 11        [SerializeField] internal Button createButton;
 12        [SerializeField] internal Button[] closeButtons;
 13        [SerializeField] internal Button joinButton;
 14        [SerializeField] internal TMP_InputField channelNameInput;
 15        [SerializeField] internal GameObject channelExistsContainer;
 16        [SerializeField] internal GameObject channelExistsWithJoinOptionContainer;
 17        [SerializeField] internal GameObject specialCharactersErrorContainer;
 18        [SerializeField] internal GameObject tooShortErrorContainer;
 19        [SerializeField] internal GameObject exceededLimitErrorContainer;
 20        [SerializeField] internal GameObject unknownErrorContainer;
 21        [SerializeField] internal TMP_Text channelNameLengthLabel;
 22        [SerializeField] internal GameObject inputFieldErrorBevel;
 23        [SerializeField] internal Color errorColor;
 24
 25        private Color lengthLabelOriginalColor;
 26
 27        public event Action<string> OnChannelNameUpdated;
 28        public event Action OnCreateSubmit;
 29        public event Action OnClose;
 30        public event Action OnJoinChannel;
 31
 32        public override void Awake()
 33        {
 1634            base.Awake();
 35
 1736            createButton.onClick.AddListener(() => OnCreateSubmit?.Invoke());
 1637            channelNameInput.onValueChanged.AddListener(text =>
 38            {
 339                channelNameLengthLabel.text = $"{Mathf.Min(20, text.Length)}/20";
 340                OnChannelNameUpdated?.Invoke(text);
 041            });
 1642            channelNameInput.onSubmit.AddListener(text =>
 43            {
 044                OnCreateSubmit?.Invoke();
 045            });
 9646            foreach (var button in closeButtons)
 3347                button.onClick.AddListener(() => OnClose?.Invoke());
 1748            joinButton.onClick.AddListener(() => OnJoinChannel?.Invoke());
 1649            lengthLabelOriginalColor = channelNameLengthLabel.color;
 1650        }
 51
 52        public override void RefreshControl()
 53        {
 054            throw new NotImplementedException();
 55        }
 56
 057        public RectTransform Transform => (RectTransform) transform;
 58
 259        public void Show() => gameObject.SetActive(true);
 60
 261        public void Hide() => gameObject.SetActive(false);
 62
 63        public void ShowChannelExistsError(bool showJoinChannelOption)
 64        {
 265            channelExistsContainer.SetActive(!showJoinChannelOption);
 266            channelExistsWithJoinOptionContainer.SetActive(showJoinChannelOption);
 267            inputFieldErrorBevel.SetActive(true);
 268            specialCharactersErrorContainer.SetActive(false);
 269            tooShortErrorContainer.SetActive(false);
 270            exceededLimitErrorContainer.SetActive(false);
 271            unknownErrorContainer.SetActive(false);
 272            channelNameLengthLabel.color = errorColor;
 273        }
 74
 75        public void ClearError()
 76        {
 277            channelExistsContainer.SetActive(false);
 278            channelExistsWithJoinOptionContainer.SetActive(false);
 279            inputFieldErrorBevel.SetActive(false);
 280            specialCharactersErrorContainer.SetActive(false);
 281            tooShortErrorContainer.SetActive(false);
 282            exceededLimitErrorContainer.SetActive(false);
 283            unknownErrorContainer.SetActive(false);
 284            channelNameLengthLabel.color = lengthLabelOriginalColor;
 285        }
 86
 287        public void DisableCreateButton() => createButton.interactable = false;
 88
 289        public void EnableCreateButton() => createButton.interactable = true;
 90
 191        public void ClearInputText() => channelNameInput.text = "";
 92
 193        public void FocusInputField() => channelNameInput.Select();
 94
 95        public void ShowWrongFormatError()
 96        {
 197            channelExistsContainer.SetActive(false);
 198            channelExistsWithJoinOptionContainer.SetActive(false);
 199            inputFieldErrorBevel.SetActive(true);
 1100            specialCharactersErrorContainer.SetActive(true);
 1101            tooShortErrorContainer.SetActive(false);
 1102            exceededLimitErrorContainer.SetActive(false);
 1103            unknownErrorContainer.SetActive(false);
 1104            channelNameLengthLabel.color = errorColor;
 1105        }
 106
 107        public void ShowTooShortError()
 108        {
 0109            channelExistsContainer.SetActive(false);
 0110            channelExistsWithJoinOptionContainer.SetActive(false);
 0111            inputFieldErrorBevel.SetActive(true);
 0112            specialCharactersErrorContainer.SetActive(false);
 0113            tooShortErrorContainer.SetActive(true);
 0114            exceededLimitErrorContainer.SetActive(false);
 0115            unknownErrorContainer.SetActive(false);
 0116            channelNameLengthLabel.color = errorColor;
 0117        }
 118
 119        public void ShowChannelsExceededError()
 120        {
 1121            channelExistsContainer.SetActive(false);
 1122            channelExistsWithJoinOptionContainer.SetActive(false);
 1123            inputFieldErrorBevel.SetActive(true);
 1124            specialCharactersErrorContainer.SetActive(false);
 1125            tooShortErrorContainer.SetActive(false);
 1126            exceededLimitErrorContainer.SetActive(true);
 1127            unknownErrorContainer.SetActive(false);
 1128            channelNameLengthLabel.color = errorColor;
 1129        }
 130
 131        public void ShowUnknownError()
 132        {
 0133            channelExistsContainer.SetActive(false);
 0134            channelExistsWithJoinOptionContainer.SetActive(false);
 0135            inputFieldErrorBevel.SetActive(true);
 0136            specialCharactersErrorContainer.SetActive(false);
 0137            tooShortErrorContainer.SetActive(false);
 0138            exceededLimitErrorContainer.SetActive(false);
 0139            unknownErrorContainer.SetActive(true);
 0140            channelNameLengthLabel.color = errorColor;
 0141        }
 142    }
 143}