< Summary

Class:GraphicCardWarningHUDController
Assembly:GraphicCardWarningHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/GraphicCardWarningHUD/GraphicCardWarningHUDController.cs
Covered lines:10
Uncovered lines:16
Coverable lines:26
Total lines:68
Line coverage:38.4% (10 of 26)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GraphicCardWarningHUDController()0%330100%
Dispose()0%110100%
SetVisibility(...)0%8.125050%
TutorialActiveChanged(...)0%6200%
RendererStateChanged(...)0%6200%
TryShowNotification()0%3.333066.67%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/GraphicCardWarningHUD/GraphicCardWarningHUDController.cs

#LineLine coverage
 1using DCL.Interface;
 2using DCL.NotificationModel;
 3using UnityEngine;
 4
 5public class GraphicCardWarningHUDController : IHUD
 6{
 17    private readonly string warningMessage =
 8        "Your machine is not using a dedicated graphics card to run Decentraland. "
 9        + "This might lead to performance issues. Check your browser and OS configuration "
 10        + "and restart " + (Application.platform == RuntimePlatform.WebGLPlayer ? "your browser." : "the experience.");
 11
 112    public void Dispose() { }
 13
 14    public void SetVisibility(bool visible)
 15    {
 116        CommonScriptableObjects.tutorialActive.OnChange -= TutorialActiveChanged;
 117        CommonScriptableObjects.rendererState.OnChange -= RendererStateChanged;
 18
 119        if (!visible)
 020            return;
 21
 122        if (!CommonScriptableObjects.tutorialActive.Get() && CommonScriptableObjects.rendererState)
 123            TryShowNotification();
 24        else
 25        {
 026            if (CommonScriptableObjects.tutorialActive)
 027                CommonScriptableObjects.tutorialActive.OnChange += TutorialActiveChanged;
 28            else
 029                CommonScriptableObjects.rendererState.OnChange += RendererStateChanged;
 30        }
 031    }
 32
 33    private void TutorialActiveChanged(bool newState, bool _)
 34    {
 035        if (newState)
 036            return;
 37
 038        CommonScriptableObjects.tutorialActive.OnChange -= TutorialActiveChanged;
 039        TryShowNotification();
 040    }
 41
 42    private void RendererStateChanged(bool newState, bool _)
 43    {
 044        if (!newState)
 045            return;
 46
 047        CommonScriptableObjects.rendererState.OnChange -= RendererStateChanged;
 048        TryShowNotification();
 049    }
 50
 51    private void TryShowNotification()
 52    {
 153        if (GraphicCardNotification.CanShowGraphicCardPopup() && IsIntegratedGraphicCard())
 054            NotificationsController.i.ShowNotification(
 55                new Model
 56                {
 57                    buttonMessage = "Dismiss",
 58                    destroyOnFinish = true,
 59                    groupID = "GraphicCard",
 60                    message = warningMessage,
 61                    timer = 0,
 62                    type = Type.GRAPHIC_CARD_WARNING,
 63                });
 64
 65        bool IsIntegratedGraphicCard() =>
 166            WebInterface.GetGraphicCard().ToLower().Contains("intel");
 167    }
 68}