< Summary

Class:DCL.Components.UIContainerRect
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/UI/UIContainer/UIContainerRect.cs
Covered lines:18
Uncovered lines:4
Coverable lines:22
Total lines:69
Line coverage:81.8% (18 of 22)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Model()0%110100%
GetDataFromJSON(...)0%110100%
UIContainerRect()0%110100%
GetClassId()0%2100%
AttachTo(...)0%2100%
DetachFrom(...)0%2100%
ApplyChanges(...)0%440100%
Dispose()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/UI/UIContainer/UIContainerRect.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.Helpers;
 3using DCL.Models;
 4using System.Collections;
 5using System.Collections.Generic;
 6using UnityEngine;
 7using UnityEngine.UI;
 8
 9namespace DCL.Components
 10{
 11    public class UIContainerRect : UIShape<UIContainerRectReferencesContainer, UIContainerRect.Model>
 12    {
 13        [System.Serializable]
 14        new public class Model : UIShape.Model
 15        {
 16            public float thickness = 0f;
 15417            public Color color = Color.clear;
 18            public bool adaptWidth = false;
 19            public bool adaptHeight = false;
 20
 6021            public override BaseModel GetDataFromJSON(string json) { return Utils.SafeFromJson<Model>(json); }
 22        }
 23
 3224        public override string referencesContainerPrefabName => "UIContainerRect";
 25
 9626        public UIContainerRect() { model = new Model(); }
 27
 028        public override int GetClassId() { return (int) CLASS_ID.UI_CONTAINER_RECT; }
 29
 30        public override void AttachTo(IDCLEntity entity, System.Type overridenAttachedType = null)
 31        {
 032            Debug.LogError(
 33                "Aborted UIContainerRectShape attachment to an entity. UIShapes shouldn't be attached to entities.");
 034        }
 35
 036        public override void DetachFrom(IDCLEntity entity, System.Type overridenAttachedType = null) { }
 37
 38        public override IEnumerator ApplyChanges(BaseModel newModel)
 39        {
 6140            referencesContainer.image.color = new Color(model.color.r, model.color.g, model.color.b, model.color.a);
 41
 6142            Outline outline = referencesContainer.image.GetComponent<Outline>();
 43
 6144            if (model.thickness > 0f)
 45            {
 346                if (outline == null)
 47                {
 348                    outline = referencesContainer.image.gameObject.AddComponent<Outline>();
 49                }
 50
 351                outline.effectDistance = new Vector2(model.thickness, model.thickness);
 352            }
 5853            else if (outline != null)
 54            {
 155                Object.DestroyImmediate(outline, false);
 56            }
 57
 6158            return null;
 59        }
 60
 61        public override void Dispose()
 62        {
 3363            if (referencesContainer != null)
 2464                Utils.SafeDestroy(referencesContainer.gameObject);
 65
 3366            base.Dispose();
 3367        }
 68    }
 69}