< Summary

Class:LoadingHUDController
Assembly:LoadingHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/LoadingHUD/LoadingHUDController.cs
Covered lines:29
Uncovered lines:1
Coverable lines:30
Total lines:53
Line coverage:96.6% (29 of 30)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CreateView()0%110100%
Initialize()0%440100%
OnVisibleHUDChanged(...)0%110100%
OnMessageChanged(...)0%220100%
OnPercentageChanged(...)0%6200%
OnShowTipsChanged(...)0%220100%
SetVisibility(...)0%110100%
Dispose()0%220100%
ClearEvents()0%110100%
SetViewVisible(...)0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/LoadingHUD/LoadingHUDController.cs

#LineLine coverage
 1using DCL;
 2
 3    public class LoadingHUDController : IHUD
 4    {
 5        internal LoadingHUDView view;
 206        internal BaseVariable<bool> visible => DataStore.i.HUDs.loadingHUD.visible;
 197        internal BaseVariable<string> message => DataStore.i.HUDs.loadingHUD.message;
 198        internal BaseVariable<float> percentage => DataStore.i.HUDs.loadingHUD.percentage;
 199        internal BaseVariable<bool> showTips => DataStore.i.HUDs.loadingHUD.showTips;
 10
 611        protected internal virtual LoadingHUDView CreateView() { return LoadingHUDView.CreateView(); }
 12
 13        public void Initialize()
 14        {
 615            view = CreateView();
 16
 617            ClearEvents();
 18
 619            SetViewVisible(visible.Get());
 620            view?.SetMessage(message.Get());
 621            view?.SetPercentage(percentage.Get() / 100f);
 622            view?.SetTips(showTips.Get());
 23
 24            // set initial states to prevent reconciliation errors
 625            visible.OnChange += OnVisibleHUDChanged;
 626            message.OnChange += OnMessageChanged;
 627            percentage.OnChange += OnPercentageChanged;
 628            showTips.OnChange += OnShowTipsChanged;
 629        }
 30
 631        private void OnVisibleHUDChanged(bool current, bool previous) { SetViewVisible(current); }
 232        private void OnMessageChanged(string current, string previous) { view?.SetMessage(current); }
 033        private void OnPercentageChanged(float current, float previous) { view?.SetPercentage(current / 100f); }
 234        private void OnShowTipsChanged(bool current, bool previous) { view?.SetTips(current); }
 35
 236        public void SetVisibility(bool visible) { this.visible.Set(visible); }
 37
 38        public void Dispose()
 39        {
 140            ClearEvents();
 141            view?.Dispose();
 142        }
 43
 44        internal void ClearEvents()
 45        {
 746            visible.OnChange -= OnVisibleHUDChanged;
 747            message.OnChange -= OnMessageChanged;
 748            percentage.OnChange -= OnPercentageChanged;
 749            showTips.OnChange -= OnShowTipsChanged;
 750        }
 51
 1852        internal void SetViewVisible(bool isVisible) { view?.SetVisible(isVisible); }
 53    }