< Summary

Class:TermsOfServiceHUDController
Assembly:TermsOfServiceHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TermsOfServiceHUD/TermsOfServiceHUDController.cs
Covered lines:21
Uncovered lines:9
Coverable lines:30
Total lines:80
Line coverage:70% (21 of 30)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
TermsOfServiceHUDController()0%110100%
ShowTermsOfService(...)0%220100%
SendAgreed(...)0%110100%
SendDeclined(...)0%110100%
OpenToS()0%6200%
OpenPrivacyPolicy()0%6200%
OpenContactEmail()0%6200%
SetVisibility(...)0%110100%
Dispose()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/TermsOfServiceHUD/TermsOfServiceHUDController.cs

#LineLine coverage
 1using DCL.Interface;
 2using System;
 3
 4public class TermsOfServiceHUDController : IHUD
 5{
 6    [Serializable]
 7    public class Model
 8    {
 9        public string sceneId;
 10        public string sceneName;
 11        public bool adultContent;
 12        public bool gamblingContent;
 13        public string tosURL;
 14        public string privacyPolicyURL;
 15        public string emailContactURL;
 16    }
 17
 18    internal TermsOfServiceHUDView view;
 19    internal Model model;
 20
 921    public TermsOfServiceHUDController()
 22    {
 923        view = TermsOfServiceHUDView.CreateView();
 924        view.Initialize(SendAgreed, SendDeclined, OpenToS, OpenPrivacyPolicy, OpenContactEmail);
 925    }
 26
 27    public void ShowTermsOfService(Model model)
 28    {
 829        this.model = model;
 30
 831        if (this.model == null)
 32        {
 133            view.SetVisible(false);
 134            return;
 35        }
 36
 737        view.SetData(model.sceneName, model.adultContent, model.gamblingContent, !string.IsNullOrEmpty(model.tosURL), !s
 738        view.SetVisible(true);
 739    }
 40
 41    private void SendAgreed(bool dontShowAgain)
 42    {
 143        WebInterface.SendTermsOfServiceResponse(model.sceneId, true, dontShowAgain);
 144        view.SetVisible(false);
 145    }
 46
 47    private void SendDeclined(bool dontShowAgain)
 48    {
 149        WebInterface.SendTermsOfServiceResponse(model.sceneId, false, dontShowAgain);
 150        view.SetVisible(false);
 151    }
 52
 53    private void OpenToS()
 54    {
 055        if (!string.IsNullOrEmpty(model.tosURL))
 056            WebInterface.OpenURL(model.tosURL);
 057    }
 58
 59    private void OpenPrivacyPolicy()
 60    {
 061        if (!string.IsNullOrEmpty(model.privacyPolicyURL))
 062            WebInterface.OpenURL(model.privacyPolicyURL);
 063    }
 64
 65    private void OpenContactEmail()
 66    {
 067        if (!string.IsNullOrEmpty(model.emailContactURL))
 068            WebInterface.OpenURL($"mailto:{model.emailContactURL}");
 069    }
 70
 271    public void SetVisibility(bool visible) { view.gameObject.SetActive(visible); }
 72
 73    public void Dispose()
 74    {
 975        if (view != null)
 76        {
 977            UnityEngine.Object.Destroy(view.gameObject);
 78        }
 979    }
 80}