< Summary

Class:DCL.ECSComponents.UIPointerEventsUtils
Assembly:DCL.ECSComponents.UIComponentsUtils
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/UIComponentsUtils/UIPointerEventsUtils.cs
Covered lines:5
Uncovered lines:0
Coverable lines:5
Total lines:45
Line coverage:100% (5 of 5)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:2
Method coverage:100% (2 of 2)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
RegisterFeedback[TEvent](...)0%110100%
UnregisterFeedback[TEvent](...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/ECSComponents/UIComponentsUtils/UIPointerEventsUtils.cs

#LineLine coverage
 1using DCL.Controllers;
 2using DCL.ECS7.ComponentWrapper;
 3using DCL.ECS7.InternalComponents;
 4using DCL.Models;
 5using System;
 6using System.Collections.Generic;
 7using UnityEngine.UIElements;
 8
 9namespace DCL.ECSComponents
 10{
 11    public static class UIPointerEventsUtils
 12    {
 13        public static EventCallback<TEvent> RegisterFeedback<TEvent>(
 14            IInternalECSComponent<InternalUIInputResults> inputResults,
 15            Func<TEvent, IPooledWrappedComponent> createResult,
 16            IParcelScene scene,
 17            IDCLEntity entity,
 18            VisualElement uiElement,
 19            int resultComponentId)
 20            where TEvent: EventBase<TEvent>, new()
 21        {
 1422            EventCallback<TEvent> callback = evt =>
 23            {
 24                var model = inputResults.GetFor(scene, entity)?.model ?? new InternalUIInputResults(new Queue<InternalUI
 25                var result = createResult(evt);
 26                if (result != null)
 27                {
 28                    model.Results.Enqueue(new InternalUIInputResults.Result(result, resultComponentId));
 29                    inputResults.PutFor(scene, entity, model);
 30                }
 31            };
 32
 1433            uiElement.RegisterCallback(callback);
 1434            return callback;
 35        }
 36
 37        public static void UnregisterFeedback<TEvent>(
 38            this VisualElement uiElement,
 39            EventCallback<TEvent> callback
 40        ) where TEvent: EventBase<TEvent>, new()
 41        {
 842            uiElement.UnregisterCallback(callback);
 843        }
 44    }
 45}