< Summary

Class:DCL.DCLVoiceChatController
Assembly:VoiceChatController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/VoiceChat/DCLVoiceChatController.cs
Covered lines:16
Uncovered lines:5
Coverable lines:21
Total lines:51
Line coverage:76.1% (16 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%110100%
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
 22616        private bool firstTimeVoiceRecorded = true;
 17
 18        void Awake()
 19        {
 12420            voiceChatStartedDelegate = (action) => StartVoiceChatRecording();
 12421            voiceChatFinishedDelegate = (action) => DCL.Interface.WebInterface.SendSetVoiceChatRecording(false);
 12422            voiceChatToggleDelegate = (action) => DCL.Interface.WebInterface.ToggleVoiceChatRecording();
 12423            voiceChatAction.OnStarted += voiceChatStartedDelegate;
 12424            voiceChatAction.OnFinished += voiceChatFinishedDelegate;
 12425            voiceChatToggleAction.OnTriggered += voiceChatToggleDelegate;
 26
 19427            KernelConfig.i.EnsureConfigInitialized().Then(config => EnableVoiceChat(config.comms.voiceChatEnabled));
 12428            KernelConfig.i.OnChange += OnKernelConfigChanged;
 12429        }
 30        void OnDestroy()
 31        {
 12332            voiceChatAction.OnStarted -= voiceChatStartedDelegate;
 12333            voiceChatAction.OnFinished -= voiceChatFinishedDelegate;
 12334            KernelConfig.i.OnChange -= OnKernelConfigChanged;
 12335        }
 36
 1037        void OnKernelConfigChanged(KernelConfigModel current, KernelConfigModel previous) { EnableVoiceChat(current.comm
 38
 15039        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}