< Summary

Class:EntityMaterialUpdateTestController
Assembly:TestHelpers
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/Tests/EntityMaterialUpdateTestController.cs
Covered lines:0
Uncovered lines:15
Coverable lines:15
Total lines:80
Line coverage:0% (0 of 15)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Start()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/Tests/EntityMaterialUpdateTestController.cs

#LineLine coverage
 1using DCL;
 2using DCL.Components;
 3using DCL.Controllers;
 4using DCL.Helpers;
 5using DCL.Models;
 6using UnityEngine;
 7
 8public class EntityMaterialUpdateTestController : MonoBehaviour
 9{
 10    void Start()
 11    {
 012        var sceneController = Environment.i.world.sceneController;
 013        var scenesToLoad = (Resources.Load("TestJSON/SceneLoadingTest") as TextAsset).text;
 14
 015        sceneController.UnloadAllScenes();
 016        sceneController.LoadParcelScenes(scenesToLoad);
 17
 018        var scene = Environment.i.world.state.loadedScenes["0,0"] as ParcelScene;
 19
 020        DCLTexture dclAtlasTexture = TestHelpers.CreateDCLTexture(
 21            scene,
 22            TestAssetsUtils.GetPath() + "/Images/atlas.png",
 23            DCLTexture.BabylonWrapMode.CLAMP,
 24            FilterMode.Bilinear);
 25
 026        DCLTexture dclAvatarTexture = TestHelpers.CreateDCLTexture(
 27            scene,
 28            TestAssetsUtils.GetPath() + "/Images/avatar.png",
 29            DCLTexture.BabylonWrapMode.CLAMP,
 30            FilterMode.Bilinear);
 31
 32
 33        IDCLEntity entity;
 34
 035        TestHelpers.CreateEntityWithBasicMaterial(
 36            scene,
 37            new BasicMaterial.Model
 38            {
 39                texture = dclAtlasTexture.id,
 40            },
 41            out entity);
 42
 043        TestHelpers.CreateEntityWithPBRMaterial(scene,
 44            new PBRMaterial.Model
 45            {
 46                albedoTexture = dclAvatarTexture.id,
 47                metallic = 0,
 48                roughness = 1,
 49            },
 50            out entity);
 51
 052        PBRMaterial mat = TestHelpers.CreateEntityWithPBRMaterial(scene,
 53            new PBRMaterial.Model
 54            {
 55                albedoTexture = dclAvatarTexture.id,
 56                metallic = 1,
 57                roughness = 1,
 58                alphaTexture = dclAvatarTexture.id,
 59            },
 60            out entity);
 61
 62        // Re-assign last PBR material to new entity
 063        BoxShape shape = TestHelpers.CreateEntityWithBoxShape(scene, new Vector3(5, 1, 2));
 064        BasicMaterial m =
 65            TestHelpers.SharedComponentCreate<BasicMaterial, BasicMaterial.Model>(scene, CLASS_ID.BASIC_MATERIAL);
 66
 67        Color color1;
 068        ColorUtility.TryParseHtmlString("#FF9292", out color1);
 69
 70        // Update material attached to 2 entities, adding albedoColor
 071        scene.SharedComponentUpdate(m.id, JsonUtility.ToJson(new DCL.Components.PBRMaterial.Model
 72        {
 73            albedoTexture = dclAvatarTexture.id,
 74            metallic = 1,
 75            roughness = 1,
 76            alphaTexture = dclAvatarTexture.id,
 77            albedoColor = color1
 78        }));
 079    }
 80}

Methods/Properties

Start()