< Summary

Class:PublicationDetailsController
Assembly:BuildModeHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/Common/PublicationDetailsController.cs
Covered lines:33
Uncovered lines:1
Coverable lines:34
Total lines:96
Line coverage:97% (33 of 34)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize(...)0%110100%
Dispose()0%110100%
SetActive(...)0%110100%
Cancel()0%220100%
Publish(...)0%330100%
ValidatePublicationInfo(...)0%110100%
SetDefaultPublicationInfo()0%110100%
SetCustomPublicationInfo(...)0%110100%
SetPublicationScreenshot(...)0%2100%
GetSceneName()0%110100%
GetSceneDescription()0%110100%
GetSceneScreenshotTexture()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/BuildModeHUD/Scripts/Common/PublicationDetailsController.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4public interface IPublicationDetailsController
 5{
 6    event Action OnCancel;
 7    event Action OnConfirm;
 8
 9    void Initialize(IPublicationDetailsView publicationDetailsView);
 10    void Dispose();
 11    void SetActive(bool isActive);
 12    void Cancel();
 13    void Publish(string sceneName, string sceneDescription);
 14    void ValidatePublicationInfo(string sceneName);
 15    void SetDefaultPublicationInfo();
 16    void SetCustomPublicationInfo(string sceneName, string sceneDescription);
 17    void SetPublicationScreenshot(Texture2D sceneScreenshot);
 18    string GetSceneName();
 19    string GetSceneDescription();
 20    Texture2D GetSceneScreenshotTexture();
 21}
 22
 23public class PublicationDetailsController : IPublicationDetailsController
 24{
 25    public event Action OnCancel;
 26    public event Action OnConfirm;
 27
 28    internal const string DEFAULT_SCENE_NAME = "My new place";
 29    internal const string DEFAULT_SCENE_DESC = "";
 30
 31    internal IPublicationDetailsView publicationDetailsView;
 32    internal bool isValidated = false;
 33
 34    public void Initialize(IPublicationDetailsView publicationDetailsView)
 35    {
 1236        this.publicationDetailsView = publicationDetailsView;
 37
 1238        publicationDetailsView.OnCancel += Cancel;
 1239        publicationDetailsView.OnPublish += Publish;
 1240        publicationDetailsView.OnSceneNameChange += ValidatePublicationInfo;
 41
 1242        SetDefaultPublicationInfo();
 1243        ValidatePublicationInfo(publicationDetailsView.currentSceneName);
 1244    }
 45
 46    public void Dispose()
 47    {
 1248        publicationDetailsView.OnCancel -= Cancel;
 1249        publicationDetailsView.OnPublish -= Publish;
 1250        publicationDetailsView.OnSceneNameChange -= ValidatePublicationInfo;
 1251    }
 52
 853    public void SetActive(bool isActive) { publicationDetailsView.SetActive(isActive); }
 54
 55    public void Cancel()
 56    {
 157        SetActive(false);
 158        OnCancel?.Invoke();
 159    }
 60
 61    public void Publish(string sceneName, string sceneDescription)
 62    {
 263        if (!isValidated)
 164            return;
 65
 166        SetActive(false);
 167        OnConfirm?.Invoke();
 168    }
 69
 70    public void ValidatePublicationInfo(string sceneName)
 71    {
 1472        isValidated = sceneName.Length > 0;
 1473        publicationDetailsView.SetSceneNameValidationActive(!isValidated);
 1474        publicationDetailsView.SetPublishButtonActive(isValidated);
 1475    }
 76
 77    public void SetDefaultPublicationInfo()
 78    {
 1379        publicationDetailsView.SetSceneName(DEFAULT_SCENE_NAME);
 1380        publicationDetailsView.SetSceneDescription(DEFAULT_SCENE_DESC);
 1381    }
 82
 83    public void SetCustomPublicationInfo(string sceneName, string sceneDescription)
 84    {
 185        publicationDetailsView.SetSceneName(sceneName);
 186        publicationDetailsView.SetSceneDescription(sceneDescription);
 187    }
 88
 089    public void SetPublicationScreenshot(Texture2D sceneScreenshot) { publicationDetailsView.SetPublicationScreenshot(sc
 90
 191    public string GetSceneName() { return publicationDetailsView.GetSceneName(); }
 92
 193    public string GetSceneDescription() { return publicationDetailsView.GetSceneDescription(); }
 94
 195    public Texture2D GetSceneScreenshotTexture() { return publicationDetailsView.GetSceneScreenshotTexture(); }
 96}