< Summary

Class:GDX.Developer.IntegerRangeWatch
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Developer/Watches/IntegerRangeWatch.cs
Covered lines:0
Uncovered lines:27
Coverable lines:27
Total lines:57
Line coverage:0% (0 of 27)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:2
Method coverage:0% (0 of 2)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
IntegerRangeWatch(...)0%2100%
Poll()0%12300%

File(s)

./Packages/com.dotbunny.gdx/GDX/Developer/Watches/IntegerRangeWatch.cs

#LineLine coverage
 1// Copyright (c) 2020-2024 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5#if UNITY_2022_2_OR_NEWER
 6
 7using System;
 8using UnityEngine.UIElements;
 9
 10namespace GDX.Developer
 11{
 12    public class IntegerRangeWatch : WatchBase
 13    {
 14        readonly Func<int> m_GetValue;
 15        readonly Func<int, Sentiment> m_GetSentiment;
 16
 17        Sentiment m_CachedSentiment;
 018        int m_CachedValue = int.MinValue;
 19
 20        readonly Label m_ValueLabel;
 21
 22        public IntegerRangeWatch(string uniqueIdentifier, string displayName, Func<int> getValue, Func<int, Sentiment> g
 023            : base(uniqueIdentifier, displayName, enabled, minWidth, minHeight)
 024        {
 025            m_GetValue = getValue;
 026            m_GetSentiment = getSentiment;
 27
 028            Label displayNameLabel = new Label() { text = displayName };
 029            displayNameLabel.AddToClassList("gdx-watch-left");
 30
 031            m_ValueLabel = new Label();
 032            m_ValueLabel.AddToClassList("gdx-watch-right");
 033            m_ValueLabel.AddToClassList("default");
 34
 035            ContainerElement.Add(displayNameLabel);
 036            ContainerElement.Add(m_ValueLabel);
 037        }
 38
 39        public override void Poll()
 040        {
 041            int getValue = m_GetValue();
 042            if (getValue != m_CachedValue)
 043            {
 044                m_ValueLabel.text = getValue.ToString();
 045                Sentiment sentiment = m_GetSentiment(getValue);
 046                if (sentiment != m_CachedSentiment)
 047                {
 048                    AddSentimentToElement(m_ValueLabel, sentiment);
 049                    m_CachedSentiment = sentiment;
 050                    m_CachedValue = getValue;
 051                }
 052            }
 053        }
 54    }
 55}
 56
 57#endif // UNITY_2022_2_OR_NEWER