| | 1 | | using DCL.Components; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using DCL.Models; |
| | 4 | | using NUnit.Framework; |
| | 5 | | using System.Collections; |
| | 6 | | using UnityEngine; |
| | 7 | | using UnityEngine.TestTools; |
| | 8 | |
|
| | 9 | | public class NFTShape_Tests : IntegrationTestSuite_Legacy |
| | 10 | | { |
| | 11 | |
|
| | 12 | | [UnityTest] |
| | 13 | | public IEnumerator ShapeUpdate() |
| | 14 | | { |
| | 15 | |
|
| | 16 | |
|
| 1 | 17 | | string entityId = "1"; |
| 1 | 18 | | TestHelpers.CreateSceneEntity(scene, entityId); |
| | 19 | |
|
| 1 | 20 | | var entity = scene.entities[entityId]; |
| 1 | 21 | | Assert.IsTrue(entity.meshRootGameObject == null, "entity mesh object should be null as the NFTShape hasn't been |
| | 22 | |
|
| 1 | 23 | | var componentModel = new NFTShape.Model() |
| | 24 | | { |
| | 25 | | src = "ethereum://0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/558536" |
| | 26 | | }; |
| | 27 | |
|
| 1 | 28 | | NFTShape component = TestHelpers.SharedComponentCreate<NFTShape, NFTShape.Model>(scene, CLASS_ID.NFT_SHAPE, comp |
| 1 | 29 | | yield return component.routine; |
| | 30 | |
|
| 1 | 31 | | TestHelpers.SharedComponentAttach(component, entity); |
| | 32 | |
|
| 1 | 33 | | Assert.IsTrue(entity.meshRootGameObject != null, "entity mesh object should already exist as the NFTShape alread |
| | 34 | |
|
| 1 | 35 | | var nftShape = LoadableShape.GetLoaderForEntity(entity) as LoadWrapper_NFT; |
| | 36 | |
|
| 1 | 37 | | var backgroundMaterial = nftShape.loaderController.backgroundMaterial; |
| | 38 | |
|
| 1 | 39 | | Assert.IsTrue(backgroundMaterial.GetColor("_BaseColor") == new Color(0.6404918f, 0.611472f, 0.8584906f), "The NF |
| | 40 | |
|
| | 41 | | // Update color and check if it changed |
| 1 | 42 | | componentModel.color = Color.yellow; |
| 1 | 43 | | yield return TestHelpers.SharedComponentUpdate(component, componentModel); |
| | 44 | |
|
| 1 | 45 | | Assert.AreEqual(Color.yellow, backgroundMaterial.GetColor("_BaseColor"), "The NFT frame background color should |
| 1 | 46 | | } |
| | 47 | |
|
| | 48 | | [UnityTest] |
| | 49 | | public IEnumerator MissingValuesGetDefaultedOnUpdate() |
| | 50 | | { |
| | 51 | |
|
| | 52 | |
|
| 1 | 53 | | var component = TestHelpers.SharedComponentCreate<NFTShape, NFTShape.Model>(scene, CLASS_ID.NFT_SHAPE); |
| 1 | 54 | | yield return component.routine; |
| | 55 | |
|
| 1 | 56 | | Assert.IsFalse(component == null); |
| | 57 | |
|
| 1 | 58 | | yield return TestHelpers.TestSharedComponentDefaultsOnUpdate<NFTShape.Model, NFTShape>(scene, CLASS_ID.NFT_SHAPE |
| 1 | 59 | | } |
| | 60 | |
|
| | 61 | | [UnityTest] |
| | 62 | | [Explicit] |
| | 63 | | [Category("Explicit")] |
| | 64 | | public IEnumerator CollisionProperty() |
| | 65 | | { |
| | 66 | |
|
| | 67 | |
|
| 0 | 68 | | string entityId = "entityId"; |
| 0 | 69 | | TestHelpers.CreateSceneEntity(scene, entityId); |
| 0 | 70 | | var entity = scene.entities[entityId]; |
| 0 | 71 | | yield return null; |
| | 72 | |
|
| | 73 | | // Create shape component |
| 0 | 74 | | var shapeModel = new LoadableShape<LoadWrapper_NFT, NFTShape.Model>.Model(); |
| 0 | 75 | | shapeModel.src = "ethereum://0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/558536"; |
| | 76 | |
|
| 0 | 77 | | var shapeComponent = TestHelpers.SharedComponentCreate<LoadableShape<LoadWrapper_NFT, NFTShape.Model>, LoadableS |
| 0 | 78 | | yield return shapeComponent.routine; |
| | 79 | |
|
| 0 | 80 | | TestHelpers.SharedComponentAttach(shapeComponent, entity); |
| | 81 | |
|
| 0 | 82 | | var shapeLoader = entity.gameObject.GetComponentInChildren<LoadWrapper_NFT>(true); |
| 0 | 83 | | yield return new WaitUntil(() => shapeLoader.alreadyLoaded); |
| | 84 | |
|
| 0 | 85 | | yield return TestHelpers.TestShapeCollision(shapeComponent, shapeModel, entity); |
| 0 | 86 | | } |
| | 87 | |
|
| | 88 | | [UnityTest] |
| | 89 | | [Explicit] |
| | 90 | | [Category("Explicit")] |
| | 91 | | public IEnumerator VisibleProperty() |
| | 92 | | { |
| 0 | 93 | | string entityId = "entityId"; |
| 0 | 94 | | TestHelpers.CreateSceneEntity(scene, entityId); |
| 0 | 95 | | var entity = scene.entities[entityId]; |
| 0 | 96 | | yield return null; |
| | 97 | |
|
| | 98 | | // Create shape component |
| 0 | 99 | | var shapeModel = new LoadableShape<LoadWrapper_NFT, NFTShape.Model>.Model(); |
| 0 | 100 | | shapeModel.src = "ethereum://0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/558536"; |
| | 101 | |
|
| 0 | 102 | | var shapeComponent = TestHelpers.SharedComponentCreate<LoadableShape<LoadWrapper_NFT, NFTShape.Model>, LoadableS |
| 0 | 103 | | yield return shapeComponent.routine; |
| | 104 | |
|
| 0 | 105 | | TestHelpers.SharedComponentAttach(shapeComponent, entity); |
| | 106 | |
|
| 0 | 107 | | var shapeLoader = entity.gameObject.GetComponentInChildren<LoadWrapper_NFT>(true); |
| 0 | 108 | | yield return new WaitUntil(() => shapeLoader.alreadyLoaded); |
| | 109 | |
|
| 0 | 110 | | yield return TestHelpers.TestShapeVisibility(shapeComponent, shapeModel, entity); |
| 0 | 111 | | } |
| | 112 | | } |