< Summary

Class:UIVisualTestsBase
Assembly:VisualTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/Tests/VisualTests/UIVisualTestsBase.cs
Covered lines:16
Uncovered lines:0
Coverable lines:16
Total lines:66
Line coverage:100% (16 of 16)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
InitUIVisualTestScene()0%550100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/Tests/VisualTests/UIVisualTestsBase.cs

#LineLine coverage
 1using DCL.Components;
 2using DCL.Helpers;
 3using DCL.Models;
 4using System.Collections;
 5using DCL;
 6using UnityEngine;
 7
 8public class UIVisualTestsBase : VisualTestsBase
 9{
 10    protected string screenSpaceId;
 11
 12    protected IEnumerator InitUIVisualTestScene(string testName)
 13    {
 614        VisualTestHelpers.snapshotIndex = 0;
 615        VisualTestHelpers.currentTestName = testName;
 16
 617        yield return InitScene();
 18
 19        //NOTE(Brian): If we don't wait a frame, RenderingController.Awake sets the rendering state back to false.
 620        yield return null;
 21
 622        RenderProfileManifest.i.Initialize(RenderProfileManifest.i.testProfile);
 23
 624        base.SetUp_Renderer();
 25
 26        // Create UIScreenSpace
 627        UIScreenSpace screenSpace = TestHelpers.SharedComponentCreate<UIScreenSpace, UIScreenSpace.Model>(scene, CLASS_I
 628        yield return screenSpace.routine;
 29
 630        screenSpaceId = screenSpace.id;
 31
 32        // The canvas has to be in ScreenSpaceCamera mode to be able to render the UI correctly for the snapshots
 633        screenSpace.canvas.renderMode = RenderMode.ScreenSpaceCamera;
 634        screenSpace.canvas.worldCamera = VisualTestController.i.camera;
 635        screenSpace.canvas.planeDistance = 1;
 36
 37        // The camera should only render UI to decrease conflict chance with future ground changes, etc.
 638        VisualTestController.i.camera.cullingMask = 1 << LayerMask.NameToLayer("UI");
 39
 640        int id = GameViewUtils.AddOrGetCustomSize(GameViewUtils.GameViewSizeType.FixedResolution, UnityEditor.GameViewSi
 641        GameViewUtils.SetSize(id);
 642    }
 43
 44    protected IEnumerator CreateUIComponent<SharedComponentType, SharedComponentModel>(CLASS_ID classId, SharedComponent
 45        where SharedComponentType : BaseDisposable
 46        where SharedComponentModel : class, new()
 47    {
 48        if (model == null)
 49            model = new SharedComponentModel();
 50
 51        // Creation
 52        var component = scene.SharedComponentCreate(
 53            componentId,
 54            (int) classId
 55        ) as SharedComponentType;
 56        yield return component.routine;
 57
 58        // "fake" update (triggers 1st ApplyChanges() call)
 59        scene.SharedComponentUpdate(componentId, JsonUtility.ToJson(new SharedComponentModel()));
 60        yield return component.routine;
 61
 62        // "real" update
 63        scene.SharedComponentUpdate(componentId, JsonUtility.ToJson(model));
 64        yield return component.routine;
 65    }
 66}

Methods/Properties

InitUIVisualTestScene()