< Summary

Class:DCL.DCLVoiceChatController
Assembly:VoiceChatController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/VoiceChat/DCLVoiceChatController.cs
Covered lines:15
Uncovered lines:6
Coverable lines:21
Total lines:51
Line coverage:71.4% (15 of 21)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DCLVoiceChatController()0%110100%
Awake()0%330100%
OnDestroy()0%110100%
OnKernelConfigChanged(...)0%2100%
EnableVoiceChat(...)0%110100%
StartVoiceChatRecording()0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/VoiceChat/DCLVoiceChatController.cs

#LineLine coverage
 1using UnityEngine;
 2using UnityEngine.Analytics;
 3
 4namespace DCL
 5{
 6    public class DCLVoiceChatController : MonoBehaviour
 7    {
 8        [Header("InputActions")]
 9        public InputAction_Hold voiceChatAction;
 10        public InputAction_Trigger voiceChatToggleAction;
 11
 12        private InputAction_Hold.Started voiceChatStartedDelegate;
 13        private InputAction_Hold.Finished voiceChatFinishedDelegate;
 14        private InputAction_Trigger.Triggered voiceChatToggleDelegate;
 15
 59816        private bool firstTimeVoiceRecorded = true;
 17
 18        void Awake()
 19        {
 59720            voiceChatStartedDelegate = (action) => StartVoiceChatRecording();
 59721            voiceChatFinishedDelegate = (action) => DCL.Interface.WebInterface.SendSetVoiceChatRecording(false);
 59722            voiceChatToggleDelegate = (action) => DCL.Interface.WebInterface.ToggleVoiceChatRecording();
 59723            voiceChatAction.OnStarted += voiceChatStartedDelegate;
 59724            voiceChatAction.OnFinished += voiceChatFinishedDelegate;
 59725            voiceChatToggleAction.OnTriggered += voiceChatToggleDelegate;
 26
 86327            KernelConfig.i.EnsureConfigInitialized().Then(config => EnableVoiceChat(config.comms.voiceChatEnabled));
 59728            KernelConfig.i.OnChange += OnKernelConfigChanged;
 59729        }
 30        void OnDestroy()
 31        {
 59732            voiceChatAction.OnStarted -= voiceChatStartedDelegate;
 59733            voiceChatAction.OnFinished -= voiceChatFinishedDelegate;
 59734            KernelConfig.i.OnChange -= OnKernelConfigChanged;
 59735        }
 36
 037        void OnKernelConfigChanged(KernelConfigModel current, KernelConfigModel previous) { EnableVoiceChat(current.comm
 38
 53239        void EnableVoiceChat(bool enable) { CommonScriptableObjects.voiceChatDisabled.Set(!enable); }
 40
 41        private void StartVoiceChatRecording()
 42        {
 043            DCL.Interface.WebInterface.SendSetVoiceChatRecording(true);
 044            if (firstTimeVoiceRecorded)
 45            {
 046                AnalyticsHelper.SendVoiceChatStartedAnalytic();
 047                firstTimeVoiceRecorded = false;
 48            }
 049        }
 50    }
 51}