< Summary

Class:PublishPopupView
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuildModeHUD/Scripts/Common/PublishPopupView.cs
Covered lines:23
Uncovered lines:3
Coverable lines:26
Total lines:73
Line coverage:88.4% (23 of 26)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Create()0%110100%
Awake()0%110100%
OnDestroy()0%110100%
OnEnable()0%110100%
OnDisable()0%110100%
PublishStart()0%110100%
PublishEnd(...)0%770100%
SetPercentage(...)0%2100%
CloseModal()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuildModeHUD/Scripts/Common/PublishPopupView.cs

#LineLine coverage
 1using TMPro;
 2using UnityEngine;
 3using UnityEngine.UI;
 4
 5public interface IPublishPopupView
 6{
 7    public float currentProgress { get; }
 8
 9    void PublishStart();
 10    void PublishEnd(bool isOk, string message);
 11    void SetPercentage(float newValue);
 12}
 13
 14public class PublishPopupView : MonoBehaviour, IPublishPopupView
 15{
 16    internal const string VIEW_PATH = "Common/PublishPopupView";
 17    internal const string TITLE_INITIAL_MESSAGE = "Publishing Scene...";
 18    internal const string SUCCESS_TITLE_MESSAGE = "Scene Published!";
 19    internal const string FAIL_TITLE_MESSAGE = "Whoops!";
 20    internal const string SUCCESS_MESSAGE = "We successfully publish your scene.";
 21    internal const string FAIL_MESSAGE = "There has been an unexpected error. Please contact the support service on the 
 22
 023    public float currentProgress => loadingBar.currentPercentage;
 24
 25    [SerializeField] internal TMP_Text titleText;
 26    [SerializeField] internal TMP_Text resultText;
 27    [SerializeField] internal TMP_Text errorDetailsText;
 28    [SerializeField] internal LoadingBar loadingBar;
 29    [SerializeField] internal Button closeButton;
 30
 31    internal static PublishPopupView Create()
 32    {
 333        var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<PublishPopupView>();
 334        view.gameObject.name = "_PublishPopupView";
 35
 336        return view;
 37    }
 38
 639    private void Awake() { closeButton.onClick.AddListener(CloseModal); }
 40
 641    private void OnDestroy() { closeButton.onClick.RemoveListener(CloseModal); }
 42
 843    private void OnEnable() { AudioScriptableObjects.dialogOpen.Play(); }
 44
 845    private void OnDisable() { AudioScriptableObjects.dialogClose.Play(); }
 46
 47    public void PublishStart()
 48    {
 149        gameObject.SetActive(true);
 150        loadingBar.SetActive(true);
 151        resultText.gameObject.SetActive(false);
 152        closeButton.gameObject.SetActive(false);
 153        errorDetailsText.gameObject.SetActive(false);
 154        titleText.text = TITLE_INITIAL_MESSAGE;
 55
 156        AudioScriptableObjects.enable.Play();
 157    }
 58
 59    public void PublishEnd(bool isOk, string message)
 60    {
 261        loadingBar.SetActive(false);
 262        titleText.text = isOk ? SUCCESS_TITLE_MESSAGE : FAIL_TITLE_MESSAGE;
 263        resultText.text = isOk ? SUCCESS_MESSAGE : FAIL_MESSAGE;
 264        errorDetailsText.gameObject.SetActive(!isOk);
 265        errorDetailsText.text = isOk ? "" : message;
 266        resultText.gameObject.SetActive(true);
 267        closeButton.gameObject.SetActive(true);
 268    }
 69
 070    public void SetPercentage(float newValue) { loadingBar.SetPercentage(newValue); }
 71
 072    private void CloseModal() { gameObject.SetActive(false); }
 73}