< Summary

Class:UIComponentsPlugin
Assembly:DCL.Plugins.UIComponents
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/UIComponentsPlugin/UIComponentsPlugin.cs
Covered lines:29
Uncovered lines:1
Coverable lines:30
Total lines:63
Line coverage:96.6% (29 of 30)
Covered branches:0
Total branches:0
Covered methods:4
Total methods:4
Method coverage:100% (4 of 4)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
UIComponentsPlugin()0%110100%
CanCreateScreenShape(...)0%2.062075%
BuildComponent[T]()0%110100%
Dispose()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/UIComponentsPlugin/UIComponentsPlugin.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using DCL;
 4using DCL.Components;
 5using DCL.Controllers;
 6using DCL.Models;
 7using UnityEngine;
 8
 9public class UIComponentsPlugin : IPlugin
 10{
 6711    public UIComponentsPlugin()
 12    {
 6713        IRuntimeComponentFactory factory = Environment.i.world.componentFactory;
 14
 15        // UI
 6716        factory.RegisterBuilder((int) CLASS_ID.UI_INPUT_TEXT_SHAPE, BuildComponent<UIInputText>);
 6717        factory.RegisterBuilder((int) CLASS_ID.UI_FULLSCREEN_SHAPE, BuildComponent<UIScreenSpace>);
 6718        factory.RegisterBuilder((int) CLASS_ID.UI_SCREEN_SPACE_SHAPE, BuildComponent<UIScreenSpace>);
 6719        factory.RegisterBuilder((int) CLASS_ID.UI_CONTAINER_RECT, BuildComponent<UIContainerRect>);
 6720        factory.RegisterBuilder((int) CLASS_ID.UI_SLIDER_SHAPE, BuildComponent<UIScrollRect>);
 6721        factory.RegisterBuilder((int) CLASS_ID.UI_CONTAINER_STACK, BuildComponent<UIContainerStack>);
 6722        factory.RegisterBuilder((int) CLASS_ID.UI_IMAGE_SHAPE, BuildComponent<UIImage>);
 6723        factory.RegisterBuilder((int) CLASS_ID.UI_TEXT_SHAPE, BuildComponent<UIText>);
 24
 6725        factory.createConditions.Add((int) CLASS_ID.UI_SCREEN_SPACE_SHAPE, CanCreateScreenShape);
 6726        factory.createConditions.Add((int) CLASS_ID.UI_FULLSCREEN_SHAPE, CanCreateScreenShape);
 6727    }
 28
 29    bool CanCreateScreenShape(int sceneNumber, int classId)
 30    {
 4631        IParcelScene scene = Environment.i.world.state.GetScene(sceneNumber);
 32
 4633        if (scene.componentsManagerLegacy.GetSceneSharedComponent<UIScreenSpace>() != null)
 034            return false;
 35
 4636        return true;
 37    }
 38
 39
 40    protected T BuildComponent<T>()
 41        where T : IComponent, new()
 42    {
 12643        return new T();
 44    }
 45
 46
 47    public void Dispose()
 48    {
 6749        IRuntimeComponentFactory factory = Environment.i.world.componentFactory;
 50
 6751        factory.UnregisterBuilder((int) CLASS_ID.UI_INPUT_TEXT_SHAPE);
 6752        factory.UnregisterBuilder((int) CLASS_ID.UI_FULLSCREEN_SHAPE);
 6753        factory.UnregisterBuilder((int) CLASS_ID.UI_SCREEN_SPACE_SHAPE);
 6754        factory.UnregisterBuilder((int) CLASS_ID.UI_CONTAINER_RECT);
 6755        factory.UnregisterBuilder((int) CLASS_ID.UI_SLIDER_SHAPE);
 6756        factory.UnregisterBuilder((int) CLASS_ID.UI_CONTAINER_STACK);
 6757        factory.UnregisterBuilder((int) CLASS_ID.UI_IMAGE_SHAPE);
 6758        factory.UnregisterBuilder((int) CLASS_ID.UI_TEXT_SHAPE);
 59
 6760        factory.createConditions.Remove((int) CLASS_ID.UI_SCREEN_SPACE_SHAPE);
 6761        factory.createConditions.Remove((int) CLASS_ID.UI_FULLSCREEN_SHAPE);
 6762    }
 63}