< Summary

Class:DCL.Services.WebBrowserAudioDevicesBridge
Assembly:AudioDevicesService
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/AudioDevicesService/WebBrowserAudioDevicesBridge.cs
Covered lines:4
Uncovered lines:11
Coverable lines:15
Total lines:45
Line coverage:26.6% (4 of 15)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetOrCreate()0%660100%
RequestAudioDevices()0%2100%
SetAudioDevices(...)0%12300%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLServices/AudioDevicesService/WebBrowserAudioDevicesBridge.cs

#LineLine coverage
 1using System;
 2using DCL.Helpers;
 3using DCL.Interface;
 4using JetBrains.Annotations;
 5using UnityEngine;
 6
 7namespace DCL.Services
 8{
 9    public class WebBrowserAudioDevicesBridge : MonoBehaviour, IAudioDevicesBridge
 10    {
 11        public event Action<AudioDevicesResponse> OnAudioDevicesRecieved;
 12
 13        public static WebBrowserAudioDevicesBridge GetOrCreate()
 14        {
 49315            GameObject brigeGO = SceneReferences.i?.bridgeGameObject;
 49316            if (SceneReferences.i?.bridgeGameObject == null)
 49217                return new GameObject("Bridge").AddComponent<WebBrowserAudioDevicesBridge>();
 18
 119            return brigeGO.GetOrCreateComponent<WebBrowserAudioDevicesBridge>();
 20        }
 21
 22        public void RequestAudioDevices() =>
 023            WebInterface.RequestAudioDevices();
 24
 25        [PublicAPI]
 26        public void SetAudioDevices(string payload)
 27        {
 028            AudioDevicesResponse response = null;
 29
 30            try
 31            {
 032                response = JsonUtility.FromJson<AudioDevicesResponse>(payload);
 033            }
 034            catch (Exception e)
 35            {
 036                Debug.LogError($"Fail to parse audio devices json {e}");
 037            }
 38
 039            if (response == null)
 040                return;
 41
 042            OnAudioDevicesRecieved?.Invoke(response);
 043        }
 44    }
 45}