< Summary

Class:ExternalUrlPromptView
Assembly:ExternalUrlPromptHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ExternalUrlPromptHUD/ExternalUrlPromptView.cs
Covered lines:11
Uncovered lines:0
Coverable lines:11
Total lines:38
Line coverage:100% (11 of 11)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%110100%
RequestOpenUrl(...)0%110100%
Dismiss()0%220100%
Approve()0%440100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/ExternalUrlPromptHUD/ExternalUrlPromptView.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5public class ExternalUrlPromptView : MonoBehaviour
 6{
 7    [SerializeField] internal GameObject content;
 8    [SerializeField] internal Button closeButton;
 9    [SerializeField] internal Button continueButton;
 10    [SerializeField] internal Button cancelButton;
 11    [SerializeField] internal TMPro.TextMeshProUGUI domainText;
 12    [SerializeField] internal TMPro.TextMeshProUGUI urlText;
 13    [SerializeField] internal Toggle trustToggle;
 14    [SerializeField] internal ShowHideAnimator showHideAnimator;
 15
 16    internal enum ResultType { CANCELED, APPROVED, APPROVED_TRUSTED }
 17
 18    Action<ResultType> resultCallback = null;
 19
 20    void Awake()
 21    {
 522        closeButton.onClick.AddListener(Dismiss);
 523        cancelButton.onClick.AddListener(Dismiss);
 524        continueButton.onClick.AddListener(Approve);
 525    }
 26
 27    internal void RequestOpenUrl(Uri uri, Action<ResultType> result)
 28    {
 529        resultCallback = result;
 530        domainText.text = uri.Host;
 531        urlText.text = uri.OriginalString;
 532        trustToggle.isOn = false;
 533    }
 34
 435    private void Dismiss() { resultCallback?.Invoke(ResultType.CANCELED); }
 36
 437    private void Approve() { resultCallback?.Invoke(trustToggle.isOn ? ResultType.APPROVED_TRUSTED : ResultType.APPROVED
 38}