| | 1 | | using System.Collections; |
| | 2 | | using DCL.Components; |
| | 3 | | using DCL.Helpers; |
| | 4 | | using DCL.Models; |
| | 5 | | using NUnit.Framework; |
| | 6 | | using UnityEngine; |
| | 7 | | using UnityEngine.TestTools; |
| | 8 | |
|
| | 9 | | public class PlaneShapeShould : IntegrationTestSuite_Legacy |
| | 10 | | { |
| | 11 | | [UnityTest] |
| | 12 | | public IEnumerator BeUpdatedCorrectly() |
| | 13 | | { |
| 1 | 14 | | string entityId = "3"; |
| 1 | 15 | | TestHelpers.InstantiateEntityWithShape(scene, entityId, DCL.Models.CLASS_ID.PLANE_SHAPE, Vector3.zero); |
| | 16 | |
|
| 1 | 17 | | var meshName = scene.entities[entityId].gameObject.GetComponentInChildren<MeshFilter>().mesh.name; |
| 1 | 18 | | Assert.AreEqual("DCL Plane Instance", meshName); |
| 1 | 19 | | yield break; |
| | 20 | | } |
| | 21 | |
|
| | 22 | | [UnityTest] |
| | 23 | | public IEnumerator UpdateUVsCorrectly() |
| | 24 | | { |
| 1 | 25 | | float[] uvs = new float[] { 0, 0.75f, 0.25f, 0.75f, 0.25f, 1, 0, 1, 0, 0.75f, 0.25f, 0.75f, 0.25f, 1, 0, 1 }; |
| | 26 | |
|
| | 27 | | IDCLEntity entity; |
| | 28 | |
|
| 1 | 29 | | PlaneShape plane = TestHelpers.InstantiateEntityWithShape<PlaneShape, PlaneShape.Model>( |
| | 30 | | scene, |
| | 31 | | DCL.Models.CLASS_ID.PLANE_SHAPE, |
| | 32 | | Vector3.zero, |
| | 33 | | out entity, |
| | 34 | | new PlaneShape.Model() |
| | 35 | | { |
| | 36 | | height = 1, |
| | 37 | | width = 1, |
| | 38 | | uvs = uvs |
| | 39 | | }); |
| | 40 | |
|
| 1 | 41 | | yield return plane.routine; |
| | 42 | |
|
| 1 | 43 | | Assert.IsTrue(entity != null); |
| 1 | 44 | | Assert.IsTrue(plane != null); |
| 1 | 45 | | Assert.IsTrue(plane.currentMesh != null); |
| 1 | 46 | | CollectionAssert.AreEqual(Utils.FloatArrayToV2List(uvs), plane.currentMesh.uv); |
| 1 | 47 | | } |
| | 48 | |
|
| | 49 | | [UnityTest] |
| | 50 | | public IEnumerator DefaultMissingValuesOnUpdate() |
| | 51 | | { |
| 1 | 52 | | var component = |
| | 53 | | TestHelpers.SharedComponentCreate<PlaneShape, PlaneShape.Model>(scene, CLASS_ID.PLANE_SHAPE); |
| 1 | 54 | | yield return component.routine; |
| | 55 | |
|
| 1 | 56 | | Assert.IsFalse(component == null); |
| | 57 | |
|
| 1 | 58 | | yield return TestHelpers.TestSharedComponentDefaultsOnUpdate<PlaneShape.Model, PlaneShape>(scene, |
| | 59 | | CLASS_ID.PLANE_SHAPE); |
| 1 | 60 | | } |
| | 61 | |
|
| | 62 | | [UnityTest] |
| | 63 | | public IEnumerator BeReplacedCorrectlyWhenAnotherComponentIsAttached() |
| | 64 | | { |
| 1 | 65 | | yield return TestHelpers.TestAttachedSharedComponentOfSameTypeIsReplaced<PlaneShape.Model, PlaneShape>( |
| | 66 | | scene, CLASS_ID.PLANE_SHAPE); |
| 1 | 67 | | } |
| | 68 | | } |