< Summary

Class:DCL.Builder.PublishProgressController
Assembly:BuilderPublisher
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Publisher/ProjectPublishHUD/Scripts/PublishProgressController.cs
Covered lines:0
Uncovered lines:20
Coverable lines:20
Total lines:96
Line coverage:0% (0 of 20)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize()0%2100%
Dispose()0%2100%
BackPressed()0%6200%
ShowConfirmDeploy()0%2100%
ConfirmPressed()0%6200%
DeploySuccess()0%2100%
SetInfoToPublish(...)0%2100%
DeployError(...)0%2100%
ViewClosed()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Publisher/ProjectPublishHUD/Scripts/PublishProgressController.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEngine;
 5
 6namespace DCL.Builder
 7{
 8    public interface IPublishProgressController
 9    {
 10        /// <summary>
 11        /// Fired when the user confirm the deployment
 12        /// </summary>
 13        event Action OnConfirm;
 14
 15        /// <summary>
 16        /// The back button has been pressed
 17        /// </summary>
 18        event Action OnBackPressed;
 19
 20        void Initialize();
 21
 22        void Dispose();
 23
 24        /// <summary>
 25        /// This will show the confirmation pop up
 26        /// </summary>
 27        void ShowConfirmDeploy();
 28
 29        /// <summary>
 30        /// This is called when the deployment has succeed
 31        /// </summary>
 32        /// <param name="publishedScene"></param>
 33        void DeploySuccess();
 34
 35        /// <summary>
 36        /// Set the scene to publish
 37        /// </summary>
 38        /// <param name="scene"></param>
 39        void SetInfoToPublish(IBuilderScene scene, PublishInfo info);
 40
 41        /// <summary>
 42        /// This is called when the deployment has failed with the error as parameter
 43        /// </summary>
 44        /// <param name="error"></param>
 45        void DeployError(string error);
 46    }
 47
 48    public class PublishProgressController : IPublishProgressController
 49    {
 50        public event Action OnConfirm;
 51        public event Action OnBackPressed;
 52
 53        private const string PROGRESS_PREFAB_PATH = "PublishProgressView";
 54
 55        internal IPublishProgressView view;
 56
 57        public void Initialize()
 58        {
 059            view = GameObject.Instantiate(Resources.Load<PublishProgressView>(PROGRESS_PREFAB_PATH));
 60
 061            view.OnViewClosed += ViewClosed;
 062            view.OnBackPressed += BackPressed;
 063            view.OnPublishConfirmButtonPressed += ConfirmPressed;
 064        }
 65
 66        public void Dispose()
 67        {
 068            view.OnViewClosed -= ViewClosed;
 069            view.OnBackPressed -= BackPressed;
 070            view.OnPublishConfirmButtonPressed -= ConfirmPressed;
 71
 072            view.Dispose();
 073        }
 74
 75        private void BackPressed()
 76        {
 077            OnBackPressed?.Invoke();
 078        }
 79
 080        public void ShowConfirmDeploy() { view.ConfirmDeployment(); }
 81
 82        private void ConfirmPressed()
 83        {
 084            OnConfirm?.Invoke();
 085            view.PublishStarted();
 086        }
 87
 088        public void DeploySuccess() { view.ProjectPublished(); }
 89
 090        public void SetInfoToPublish(IBuilderScene scene, PublishInfo info) { view.SetPublishInfo(scene, info); }
 91
 092        public void DeployError(string error) { view.PublishError(error); }
 93
 094        private void ViewClosed() { view.Hide(); }
 95    }
 96}