< Summary

Class:LeftMenuHandler
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Scripts/Handlers/LeftMenuHandler.cs
Covered lines:31
Uncovered lines:4
Coverable lines:35
Total lines:79
Line coverage:88.5% (31 of 35)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LeftMenuHandler(...)0%110100%
Dispose()0%110100%
SetToPreviousMainPanel()0%2.062075%
OnToggleOn(...)0%2100%
OnOpenSectionId(...)0%550100%
OnSceneSettingsBackPressed()0%110100%
SetMainLeftPanel()0%2.032080%
SetSettingsLeftPanel()0%2.032080%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Scripts/Handlers/LeftMenuHandler.cs

#LineLine coverage
 1using System;
 2
 3internal class LeftMenuHandler : IDisposable
 4{
 5    private readonly IBuilderProjectsPanelView view;
 6    private readonly ISectionsController sectionsController;
 7
 8    private bool isMainPanel = false;
 9    private SectionId lastMainSectionId;
 10
 1611    public LeftMenuHandler(IBuilderProjectsPanelView view, ISectionsController sectionsController)
 12    {
 1613        this.view = view;
 1614        this.sectionsController = sectionsController;
 15
 1616        view.OnBackToMainMenuPressed += OnSceneSettingsBackPressed;
 17
 1618        sectionsController.OnOpenSectionId += OnOpenSectionId;
 1619        LeftMenuButtonToggleView.OnToggleOn += OnToggleOn;
 1620    }
 21
 22    public void Dispose()
 23    {
 1624        view.OnBackToMainMenuPressed -= OnSceneSettingsBackPressed;
 25
 1626        sectionsController.OnOpenSectionId -= OnOpenSectionId;
 1627        LeftMenuButtonToggleView.OnToggleOn -= OnToggleOn;
 1628    }
 29
 30    public void SetToPreviousMainPanel()
 31    {
 132        if (isMainPanel)
 033            return;
 34
 135        sectionsController.OpenSection(lastMainSectionId);
 136    }
 37
 038    void OnToggleOn(LeftMenuButtonToggleView toggle) { sectionsController.OpenSection(toggle.openSection); }
 39
 40    void OnOpenSectionId(SectionId sectionId)
 41    {
 342        view.SetTogglOnWithoutNotify(sectionId);
 43
 344        bool isMainPanelSection = sectionId == SectionId.SCENES_MAIN ||
 45                                  sectionId == SectionId.SCENES_DEPLOYED ||
 46                                  sectionId == SectionId.SCENES_PROJECT ||
 47                                  sectionId == SectionId.LAND;
 48
 349        if (isMainPanelSection)
 50        {
 251            lastMainSectionId = sectionId;
 252            SetMainLeftPanel();
 253        }
 54        else
 55        {
 156            SetSettingsLeftPanel();
 57        }
 158    }
 59
 260    void OnSceneSettingsBackPressed() { SetToPreviousMainPanel(); }
 61
 62    void SetMainLeftPanel()
 63    {
 264        if (isMainPanel)
 065            return;
 66
 267        isMainPanel = true;
 268        view.SetMainLeftPanel();
 269    }
 70
 71    void SetSettingsLeftPanel()
 72    {
 173        if (!isMainPanel)
 074            return;
 75
 176        isMainPanel = false;
 177        view.SetProjectSettingsLeftPanel();
 178    }
 79}