< Summary

Class:Tests.UUIDComponentTests
Assembly:UUIDComponentTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/UUIDComponent/Tests/UUIDComponentTests.cs
Covered lines:477
Uncovered lines:14
Coverable lines:491
Total lines:1181
Line coverage:97.1% (477 of 491)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%330100%
InstantiateEntityWithShape(...)0%110100%
OnClickComponentInitializesWithBasicShape()0%330100%
OnPointerDownInitializesWithBasicShape()0%330100%
OnPointerUpComponentInitializesWithBasicShape()0%330100%
OnClickComponentInitializesWithGLTFShape()0%4.184077.78%
OnPointerDownInitializesWithGLTFShape()0%440100%
OnPointerUpComponentInitializesWithGLTFShape()0%440100%
OnClickComponentInitializesWithGLTFShapeAsynchronously()0%440100%
OnPointerDownInitializesWithGLTFShapeAsynchronously()0%440100%
OnPointerUpComponentInitializesWithGLTFShapeAsynchronously()0%440100%
OnClickComponentInitializesAfterBasicShapeIsAdded()0%330100%
OnPointerDownInitializesAfterBasicShapeIsAdded()0%220100%
OnPointerUpComponentInitializesAfterBasicShapeIsAdded()0%220100%
OnClickEventIsTriggered()0%660100%
OnPointerDownEventIsTriggered()0%550100%
OnPointerUpEventIsTriggered()0%550100%
OnPointerUpEventNotTriggeredOnInvisibles()0%550100%
OnPointerDownEventWhenEntityIsBehindOther()0%11110100%
OnPointerDownEventAndPointerBlockerShape()0%12120100%
PointerEventNotTriggeredByParent()0%11110100%
OnPointerHoverFeedbackPropertiesAreAppliedCorrectly()0%770100%
OnPointerHoverDistanceIsAppliedCorrectly()0%770100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/UUIDComponent/Tests/UUIDComponentTests.cs

#LineLine coverage
 1using DCL;
 2using DCL.Components;
 3using DCL.Helpers;
 4using DCL.Interface;
 5using DCL.Models;
 6using Newtonsoft.Json;
 7using NUnit.Framework;
 8using System.Collections;
 9using UnityEngine;
 10using UnityEngine.TestTools;
 11using UnityEngine.UI;
 12
 13namespace Tests
 14{
 15    public class UUIDComponentTests : IntegrationTestSuite_Legacy
 16    {
 017        protected override bool enableSceneIntegrityChecker => false;
 18
 19        [UnitySetUp]
 20        protected override IEnumerator SetUp()
 21        {
 2122            yield return base.SetUp();
 2123            Environment.i.world.sceneBoundsChecker.Stop();
 24
 25            // Set character position and camera rotation
 2126            DCLCharacterController.i.PauseGravity();
 2127            DCLCharacterController.i.characterController.enabled = false;
 28
 2129            cameraController.SetRotation(0, 0, 0, new Vector3(0, 0, 1));
 2130            cameraController.SetCameraMode(CameraMode.ModeId.FirstPerson);
 2131        }
 32
 33        void InstantiateEntityWithShape(out IDCLEntity entity, out BoxShape shape)
 34        {
 1535            shape = TestHelpers.InstantiateEntityWithShape<BoxShape, BoxShape.Model>(
 36                scene,
 37                DCL.Models.CLASS_ID.BOX_SHAPE,
 38                Vector3.zero,
 39                out entity,
 40                new BoxShape.Model() { });
 1541        }
 42
 43        [UnityTest]
 44        public IEnumerator OnClickComponentInitializesWithBasicShape()
 45        {
 46            IDCLEntity entity;
 47            BoxShape shape;
 148            InstantiateEntityWithShape(out entity, out shape);
 49
 150            yield return shape.routine;
 51
 152            string onPointerId = "pointerevent-1";
 153            var OnClickComponentModel = new OnClick.Model()
 54            {
 55                type = OnClick.NAME,
 56                uuid = onPointerId
 57            };
 158            var component = TestHelpers.EntityComponentCreate<OnClick, OnClick.Model>(scene, entity,
 59                OnClickComponentModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 60
 161            var componentGO = component.gameObject;
 62
 163            var meshFilter = component.entity.gameObject.GetComponentInChildren<MeshFilter>();
 164            var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 65
 166            Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 67
 168            Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 69                "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 170        }
 71
 72        [UnityTest]
 73        public IEnumerator OnPointerDownInitializesWithBasicShape()
 74        {
 75            IDCLEntity entity;
 76            BoxShape shape;
 177            InstantiateEntityWithShape(out entity, out shape);
 78
 179            yield return shape.routine;
 80
 181            string onPointerId = "pointerevent-1";
 182            var OnPointerDownModel = new OnPointerDown.Model()
 83            {
 84                type = "pointerUp",
 85                uuid = onPointerId
 86            };
 87
 188            var component = TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, entity,
 89                OnPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 90
 191            var meshFilter = entity.gameObject.GetComponentInChildren<MeshFilter>();
 192            var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 93
 194            Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 95
 196            Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 97                "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 198        }
 99
 100        [UnityTest]
 101        public IEnumerator OnPointerUpComponentInitializesWithBasicShape()
 102        {
 103            IDCLEntity entity;
 104            BoxShape shape;
 1105            InstantiateEntityWithShape(out entity, out shape);
 106
 1107            yield return shape.routine;
 108
 1109            string onPointerId = "pointerevent-1";
 1110            var OnPointerUpComponentModel = new OnPointerUp.Model()
 111            {
 112                type = "pointerUp",
 113                uuid = onPointerId
 114            };
 1115            var component = TestHelpers.EntityComponentCreate<OnPointerUp, OnPointerUp.Model>(scene, entity,
 116                OnPointerUpComponentModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 117
 1118            var meshFilter = entity.gameObject.GetComponentInChildren<MeshFilter>();
 1119            var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 120
 1121            Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 122
 1123            Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 124                "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 1125        }
 126
 127        [UnityTest]
 128        public IEnumerator OnClickComponentInitializesWithGLTFShape()
 129        {
 1130            string entityId = "1";
 131
 1132            TestHelpers.CreateSceneEntity(scene, entityId);
 133
 1134            Assert.IsTrue(
 135                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() == null,
 136                "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist");
 137
 1138            string shapeId = TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE,
 139                JsonConvert.SerializeObject(new
 140                {
 141                    src = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb"
 142                }));
 143
 1144            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]);
 11145            yield return new DCL.WaitUntil(() => gltfShape.alreadyLoaded, 7f);
 146
 1147            Assert.IsTrue(
 148                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() != null,
 149                "'GLTFScene' child object with 'InstantiatedGLTF' component should exist if the GLTF was loaded correctl
 150
 1151            string clickUuid = "pointerevent-1";
 1152            var OnClickComponentModel = new OnClick.Model()
 153            {
 154                type = OnClick.NAME,
 155                uuid = clickUuid
 156            };
 157
 1158            var component = TestHelpers.EntityComponentCreate<OnClick, OnClick.Model>(scene, scene.entities[entityId],
 159                OnClickComponentModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 160
 1161            var componentGO = component.gameObject;
 162
 2163            foreach (var meshFilter in componentGO.GetComponentsInChildren<MeshFilter>())
 164            {
 0165                var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 166
 0167                Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 168
 0169                Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 170                    "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 171            }
 1172        }
 173
 174        [UnityTest]
 175        public IEnumerator OnPointerDownInitializesWithGLTFShape()
 176        {
 1177            string entityId = "1";
 178
 1179            TestHelpers.CreateSceneEntity(scene, entityId);
 180
 1181            Assert.IsTrue(
 182                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() == null,
 183                "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist");
 184
 1185            string shapeId = TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE,
 186                JsonConvert.SerializeObject(new
 187                {
 188                    src = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb"
 189                }));
 190
 1191            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]);
 11192            yield return new DCL.WaitUntil(() => gltfShape.alreadyLoaded, 7f);
 193
 1194            Assert.IsTrue(
 195                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() != null,
 196                "'GLTFScene' child object with 'InstantiatedGLTF' component should exist if the GLTF was loaded correctl
 197
 1198            string clickUuid = "pointerevent-1";
 1199            var OnPointerDownModel = new OnPointerDown.Model()
 200            {
 201                type = "pointerDown",
 202                uuid = clickUuid
 203            };
 204
 1205            var component = TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, scene.entities[
 206                OnPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 207
 8208            foreach (var meshFilter in scene.entities[entityId].gameObject.GetComponentsInChildren<MeshFilter>())
 209            {
 3210                var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 211
 3212                Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 213
 3214                Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 215                    "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 216            }
 1217        }
 218
 219        [UnityTest]
 220        public IEnumerator OnPointerUpComponentInitializesWithGLTFShape()
 221        {
 1222            string entityId = "1";
 223
 1224            TestHelpers.CreateSceneEntity(scene, entityId);
 225
 1226            Assert.IsTrue(
 227                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() == null,
 228                "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist");
 229
 1230            string shapeId = TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE,
 231                JsonConvert.SerializeObject(new
 232                {
 233                    src = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb"
 234                }));
 235
 1236            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]);
 11237            yield return new DCL.WaitUntil(() => gltfShape.alreadyLoaded, 7f);
 238
 1239            Assert.IsTrue(
 240                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() != null,
 241                "'GLTFScene' child object with 'InstantiatedGLTF' component should exist if the GLTF was loaded correctl
 242
 1243            string clickUuid = "pointerevent-1";
 1244            var OnPointerUpComponentModel = new OnPointerUp.Model()
 245            {
 246                type = "pointerUp",
 247                uuid = clickUuid
 248            };
 249
 1250            var component = TestHelpers.EntityComponentCreate<OnPointerUp, OnPointerUp.Model>(scene, scene.entities[enti
 251                OnPointerUpComponentModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 252
 8253            foreach (var meshFilter in scene.entities[entityId].gameObject.GetComponentsInChildren<MeshFilter>())
 254            {
 3255                var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 256
 3257                Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 258
 3259                Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 260                    "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 261            }
 1262        }
 263
 264        [UnityTest]
 265        public IEnumerator OnClickComponentInitializesWithGLTFShapeAsynchronously()
 266        {
 1267            string entityId = "1";
 1268            TestHelpers.CreateSceneEntity(scene, entityId);
 269
 1270            Assert.IsTrue(
 271                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() == null,
 272                "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist");
 273
 1274            TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
 275                new
 276                {
 277                    src = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb"
 278                }));
 279
 1280            string clickUuid = "pointerevent-1";
 1281            var OnClickComponentModel = new OnClick.Model()
 282            {
 283                type = OnClick.NAME,
 284                uuid = clickUuid
 285            };
 286
 1287            var uuidComponent = TestHelpers.EntityComponentCreate<OnClick, OnClick.Model>(scene, scene.entities[entityId
 288                OnClickComponentModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 289
 1290            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]);
 11291            yield return new DCL.WaitUntil(() => gltfShape.alreadyLoaded, 7f);
 292
 1293            Assert.IsTrue(
 294                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() != null,
 295                "'GLTFScene' child object with 'InstantiatedGLTF' component should exist if the GLTF was loaded correctl
 296
 8297            foreach (var meshFilter in scene.entities[entityId].gameObject.GetComponentsInChildren<MeshFilter>())
 298            {
 3299                var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 300
 3301                Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 302
 3303                Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 304                    "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 305            }
 1306        }
 307
 308        [UnityTest]
 309        public IEnumerator OnPointerDownInitializesWithGLTFShapeAsynchronously()
 310        {
 1311            string entityId = "1";
 1312            TestHelpers.CreateSceneEntity(scene, entityId);
 313
 1314            Assert.IsTrue(
 315                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() == null,
 316                "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist");
 317
 1318            TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
 319                new
 320                {
 321                    src = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb"
 322                }));
 323
 1324            string clickUuid = "pointerevent-1";
 1325            var OnPointerDownModel = new OnPointerDown.Model()
 326            {
 327                type = "pointerDown",
 328                uuid = clickUuid
 329            };
 1330            TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, scene.entities[entityId],
 331                OnPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 332
 1333            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]);
 11334            yield return new DCL.WaitUntil(() => gltfShape.alreadyLoaded, 7f);
 335
 1336            Assert.IsTrue(
 337                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() != null,
 338                "'GLTFScene' child object with 'InstantiatedGLTF' component should exist if the GLTF was loaded correctl
 339
 8340            foreach (var meshFilter in scene.entities[entityId].gameObject.GetComponentsInChildren<MeshFilter>())
 341            {
 3342                var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 343
 3344                Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 345
 3346                Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 347                    "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 348            }
 1349        }
 350
 351        [UnityTest]
 352        public IEnumerator OnPointerUpComponentInitializesWithGLTFShapeAsynchronously()
 353        {
 1354            string entityId = "1";
 1355            TestHelpers.CreateSceneEntity(scene, entityId);
 356
 1357            Assert.IsTrue(
 358                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() == null,
 359                "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist");
 360
 1361            TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
 362                new
 363                {
 364                    src = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb"
 365                }));
 366
 1367            string clickUuid = "pointerevent-1";
 1368            var OnPointerUpModel = new OnPointerUp.Model()
 369            {
 370                type = "pointerUp",
 371                uuid = clickUuid
 372            };
 373
 1374            var component = TestHelpers.EntityComponentCreate<OnPointerUp, OnPointerUp.Model>(scene, scene.entities[enti
 375                OnPointerUpModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 376
 1377            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]);
 11378            yield return new DCL.WaitUntil(() => gltfShape.alreadyLoaded, 7f);
 379
 1380            Assert.IsTrue(
 381                scene.entities[entityId].gameObject.GetComponentInChildren<UnityGLTF.InstantiatedGLTFObject>() != null,
 382                "'GLTFScene' child object with 'InstantiatedGLTF' component should exist if the GLTF was loaded correctl
 383
 8384            foreach (var meshFilter in scene.entities[entityId].gameObject.GetComponentsInChildren<MeshFilter>())
 385            {
 3386                var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 387
 3388                Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 389
 3390                Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 391                    "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 392            }
 1393        }
 394
 395        [UnityTest]
 396        public IEnumerator OnClickComponentInitializesAfterBasicShapeIsAdded()
 397        {
 1398            string entityId = "1";
 1399            TestHelpers.CreateSceneEntity(scene, entityId);
 400
 1401            string clickUuid = "pointerevent-1";
 1402            var OnClickComponentModel = new OnClick.Model()
 403            {
 404                type = OnClick.NAME,
 405                uuid = clickUuid
 406            };
 407
 1408            var component = TestHelpers.EntityComponentCreate<OnClick, OnClick.Model>(scene, scene.entities[entityId],
 409                OnClickComponentModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 410
 1411            Assert.IsTrue(component != null, "component is null?");
 412
 1413            yield return component.routine;
 414
 1415            Assert.IsTrue(component.gameObject.GetComponent<Rigidbody>() == null,
 416                "the root object shouldn't have a rigidbody attached until a shape is added");
 417
 1418            Assert.IsTrue(component.gameObject.transform.Find(OnPointerEventColliders.COLLIDER_NAME) == null,
 419                "the OnPointerEventCollider object shouldn't exist until a shape is added");
 420
 1421            TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.BOX_SHAPE,
 422                JsonConvert.SerializeObject(new BoxShape.Model { })
 423            );
 424
 1425            var meshFilter = component.entity.gameObject.GetComponentInChildren<MeshFilter>();
 1426            var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 427
 1428            Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 429
 1430            Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 431                "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 1432        }
 433
 434        [UnityTest]
 435        public IEnumerator OnPointerDownInitializesAfterBasicShapeIsAdded()
 436        {
 1437            string entityId = "1";
 1438            TestHelpers.CreateSceneEntity(scene, entityId);
 439
 1440            string clickUuid = "pointerevent-1";
 1441            var OnPointerDownModel = new OnPointerDown.Model()
 442            {
 443                type = "pointerDown",
 444                uuid = clickUuid
 445            };
 446
 1447            var uuidComponent = TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, scene.entit
 448                OnPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 449
 1450            Assert.IsTrue(uuidComponent.gameObject.GetComponent<Rigidbody>() == null,
 451                "the root object shouldn't have a rigidbody attached until a shape is added");
 452
 1453            Assert.IsTrue(scene.entities[entityId].gameObject.transform.Find(OnPointerEventColliders.COLLIDER_NAME) == n
 454                "the OnPointerEventCollider object shouldn't exist until a shape is added");
 455
 1456            TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.BOX_SHAPE,
 457                JsonConvert.SerializeObject(new BoxShape.Model { })
 458            );
 459
 1460            var meshFilter = scene.entities[entityId].gameObject.GetComponentInChildren<MeshFilter>();
 1461            var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 462
 1463            Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 464
 1465            Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 466                "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 467
 1468            yield break;
 469        }
 470
 471        [UnityTest]
 472        public IEnumerator OnPointerUpComponentInitializesAfterBasicShapeIsAdded()
 473        {
 1474            string entityId = "1";
 1475            TestHelpers.CreateSceneEntity(scene, entityId);
 476
 1477            string clickUuid = "pointerevent-1";
 1478            var OnPointerUpComponentModel = new OnPointerUp.Model()
 479            {
 480                type = "pointerUp",
 481                uuid = clickUuid
 482            };
 483
 1484            var component = TestHelpers.EntityComponentCreate<OnPointerUp, OnPointerUp.Model>(scene, scene.entities[enti
 485                OnPointerUpComponentModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 486
 1487            Assert.IsTrue(component.gameObject.GetComponent<Rigidbody>() == null,
 488                "the root object shouldn't have a rigidbody attached until a shape is added");
 489
 1490            Assert.IsTrue(scene.entities[entityId].gameObject.transform.Find(OnPointerEventColliders.COLLIDER_NAME) == n
 491                "the OnPointerEventCollider object shouldn't exist until a shape is added");
 492
 1493            TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.BOX_SHAPE,
 494                JsonConvert.SerializeObject(new BoxShape.Model { })
 495            );
 496
 1497            var meshFilter = scene.entities[entityId].gameObject.GetComponentInChildren<MeshFilter>();
 1498            var onPointerEventCollider = meshFilter.transform.Find(OnPointerEventColliders.COLLIDER_NAME);
 499
 1500            Assert.IsTrue(onPointerEventCollider != null, "OnPointerEventCollider should exist under any rendeder");
 501
 1502            Assert.AreSame(meshFilter.sharedMesh, onPointerEventCollider.GetComponent<MeshCollider>().sharedMesh,
 503                "OnPointerEventCollider should have the same mesh info as the mesh renderer");
 504
 1505            yield break;
 506        }
 507
 508        [UnityTest]
 509        public IEnumerator OnClickEventIsTriggered()
 510        {
 1511            InstantiateEntityWithShape(out IDCLEntity entity, out BoxShape shape);
 1512            TestHelpers.SetEntityTransform(scene, entity, new Vector3(9f, 1.5f, 11.0f), Quaternion.identity, new Vector3
 513
 1514            cameraController.SetRotation(0, 0, 0, new Vector3(1, 0, 0));
 1515            DCLCharacterController.i.SetPosition(new Vector3(3, 2, 12));
 516
 1517            yield return shape.routine;
 518
 1519            string onPointerId = "pointerevent-1";
 1520            var OnClickComponentModel = new OnPointerEvent.Model()
 521            {
 522                type = OnClick.NAME,
 523                uuid = onPointerId
 524            };
 525
 1526            var component = TestHelpers.EntityComponentCreate<OnClick, OnPointerEvent.Model>(
 527                scene,
 528                entity,
 529                OnClickComponentModel,
 530                CLASS_ID_COMPONENT.UUID_CALLBACK
 531            );
 532
 1533            Assert.IsTrue(component != null);
 534
 1535            yield return null;
 536
 1537            string targetEventType = "SceneEvent";
 538
 1539            var onPointerEvent = new WebInterface.OnClickEvent();
 1540            onPointerEvent.uuid = onPointerId;
 541
 1542            var sceneEvent = new WebInterface.SceneEvent<WebInterface.OnClickEvent>();
 1543            sceneEvent.sceneId = scene.sceneData.id;
 1544            sceneEvent.payload = onPointerEvent;
 1545            sceneEvent.eventType = "uuidEvent";
 1546            bool eventTriggered = false;
 547
 1548            Debug.Log("Starting... 1");
 549
 1550            yield return TestHelpers.ExpectMessageToKernel(
 551                targetEventType,
 552                sceneEvent,
 553                () =>
 554                {
 1555                    InputController_Legacy.i.RaiseEvent(
 556                        WebInterface.ACTION_BUTTON.POINTER,
 557                        DCL.InputController_Legacy.EVENT.BUTTON_DOWN,
 558                        true);
 1559                },
 560                (eventObj) =>
 561                {
 3562                    if (eventTriggered)
 2563                        return true;
 564
 1565                    if (eventObj.eventType != sceneEvent.eventType)
 0566                        return false;
 567
 1568                    if (eventObj.payload.uuid != sceneEvent.payload.uuid)
 0569                        return false;
 570
 1571                    eventTriggered = true;
 1572                    return true;
 573                });
 574
 1575            Debug.Log("Starting... 2 " + eventTriggered);
 1576            Assert.IsTrue(eventTriggered);
 1577        }
 578
 579        [UnityTest]
 580        public IEnumerator OnPointerDownEventIsTriggered()
 581        {
 1582            InstantiateEntityWithShape(out IDCLEntity entity, out BoxShape shape);
 1583            TestHelpers.SetEntityTransform(scene, entity, new Vector3(9f, 1.5f, 11.0f), Quaternion.identity, new Vector3
 584
 1585            cameraController.SetRotation(0, 0, 0, new Vector3(1, 0, 0));
 1586            DCLCharacterController.i.SetPosition(new Vector3(3, 2, 12));
 587
 1588            yield return shape.routine;
 589
 1590            string onPointerId = "pointerevent-1";
 1591            var OnPointerDownModel = new OnPointerEvent.Model()
 592            {
 593                type = OnPointerDown.NAME,
 594                uuid = onPointerId
 595            };
 1596            var component = TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, entity,
 597                OnPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 598
 1599            Assert.IsTrue(component != null);
 600
 1601            string targetEventType = "SceneEvent";
 602
 1603            var onPointerDownEvent = new WebInterface.OnPointerDownEvent();
 1604            onPointerDownEvent.uuid = onPointerId;
 1605            onPointerDownEvent.payload = new WebInterface.OnPointerEventPayload();
 1606            onPointerDownEvent.payload.hit = new WebInterface.OnPointerEventPayload.Hit();
 1607            onPointerDownEvent.payload.hit.entityId = component.entity.entityId;
 1608            onPointerDownEvent.payload.hit.meshName = component.name;
 609
 1610            var sceneEvent = new WebInterface.SceneEvent<WebInterface.OnPointerDownEvent>();
 1611            sceneEvent.sceneId = scene.sceneData.id;
 1612            sceneEvent.payload = onPointerDownEvent;
 1613            sceneEvent.eventType = "uuidEvent";
 1614            bool eventTriggered = false;
 615
 1616            yield return TestHelpers.ExpectMessageToKernel(targetEventType, sceneEvent,
 2617                () => { DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_
 618                (pointerEvent) =>
 619                {
 3620                    if (eventTriggered)
 2621                        return true;
 622
 623                    //Debug.Log($"triggered? \npointerEvent {JsonUtility.ToJson(pointerEvent, true)}\nsceneEvent {JsonUt
 624
 1625                    if (pointerEvent.eventType == sceneEvent.eventType &&
 626                        pointerEvent.payload.uuid == sceneEvent.payload.uuid &&
 627                        pointerEvent.payload.payload.hit.entityId == sceneEvent.payload.payload.hit.entityId)
 628                    {
 1629                        eventTriggered = true;
 1630                        return true;
 631                    }
 632
 0633                    return false;
 634                });
 635
 1636            Assert.IsTrue(eventTriggered);
 1637        }
 638
 639        [UnityTest]
 640        public IEnumerator OnPointerUpEventIsTriggered()
 641        {
 642            IDCLEntity entity;
 643            BoxShape shape;
 1644            InstantiateEntityWithShape(out entity, out shape);
 1645            TestHelpers.SetEntityTransform(scene, entity, new Vector3(9f, 1.5f, 11.0f), Quaternion.identity, new Vector3
 646
 1647            cameraController.SetRotation(0, 0, 0, new Vector3(1, 0, 0));
 1648            DCLCharacterController.i.SetPosition(new Vector3(3, 2, 12));
 649
 1650            yield return shape.routine;
 651
 1652            string onPointerId = "pointerevent-1";
 1653            var OnPointerUpComponentModel = new OnPointerUp.Model()
 654            {
 655                type = OnPointerUp.NAME,
 656                uuid = onPointerId
 657            };
 1658            var component = TestHelpers.EntityComponentCreate<OnPointerUp, OnPointerUp.Model>(scene, entity,
 659                OnPointerUpComponentModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 660
 1661            Assert.IsTrue(component != null);
 662
 1663            string targetEventType = "SceneEvent";
 664
 1665            var onPointerUpEvent = new WebInterface.OnPointerUpEvent();
 1666            onPointerUpEvent.uuid = onPointerId;
 1667            onPointerUpEvent.payload = new WebInterface.OnPointerEventPayload();
 1668            onPointerUpEvent.payload.hit = new WebInterface.OnPointerEventPayload.Hit();
 1669            onPointerUpEvent.payload.hit.entityId = component.entity.entityId;
 1670            onPointerUpEvent.payload.hit.meshName = component.name;
 671
 1672            var sceneEvent = new WebInterface.SceneEvent<WebInterface.OnPointerUpEvent>();
 1673            sceneEvent.sceneId = scene.sceneData.id;
 1674            sceneEvent.payload = onPointerUpEvent;
 1675            sceneEvent.eventType = "uuidEvent";
 1676            bool eventTriggered = false;
 677
 1678            DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_Legacy.EVENT
 679
 1680            yield return TestHelpers.ExpectMessageToKernel(targetEventType, sceneEvent,
 2681                () => { DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_
 682                (pointerEvent) =>
 683                {
 2684                    if (eventTriggered)
 1685                        return true;
 686
 1687                    if (pointerEvent.eventType == sceneEvent.eventType &&
 688                        pointerEvent.payload.uuid == sceneEvent.payload.uuid &&
 689                        pointerEvent.payload.payload.hit.entityId == sceneEvent.payload.payload.hit.entityId)
 690                    {
 1691                        eventTriggered = true;
 1692                        return true;
 693                    }
 694
 0695                    return false;
 696                });
 697
 1698            Assert.IsTrue(eventTriggered);
 1699        }
 700
 701        [UnityTest]
 702        public IEnumerator OnPointerUpEventNotTriggeredOnInvisibles()
 703        {
 704            IDCLEntity entity;
 705            BoxShape shape;
 1706            InstantiateEntityWithShape(out entity, out shape);
 1707            TestHelpers.SetEntityTransform(scene, entity, new Vector3(9f, 1.5f, 11.0f), Quaternion.identity, new Vector3
 708
 1709            cameraController.SetRotation(0, 0, 0, new Vector3(1, 0, 0));
 1710            DCLCharacterController.i.SetPosition(new Vector3(3, 2, 12));
 711
 1712            yield return shape.routine;
 713
 1714            string onPointerId = "pointerevent-1";
 1715            var OnPointerUpComponentModel = new OnPointerUp.Model()
 716            {
 717                type = OnPointerUp.NAME,
 718                uuid = onPointerId
 719            };
 1720            var component = TestHelpers.EntityComponentCreate<OnPointerUp, OnPointerUp.Model>(scene, entity,
 721                OnPointerUpComponentModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 722
 1723            Assert.IsTrue(component != null);
 724
 1725            string targetEventType = "SceneEvent";
 726
 1727            var onPointerUpEvent = new WebInterface.OnPointerUpEvent();
 1728            onPointerUpEvent.uuid = onPointerId;
 1729            onPointerUpEvent.payload = new WebInterface.OnPointerEventPayload();
 1730            onPointerUpEvent.payload.hit = new WebInterface.OnPointerEventPayload.Hit();
 1731            onPointerUpEvent.payload.hit.entityId = component.entity.entityId;
 1732            onPointerUpEvent.payload.hit.meshName = component.name;
 733
 1734            var sceneEvent = new WebInterface.SceneEvent<WebInterface.OnPointerUpEvent>();
 1735            sceneEvent.sceneId = scene.sceneData.id;
 1736            sceneEvent.payload = onPointerUpEvent;
 1737            sceneEvent.eventType = "uuidEvent";
 738
 1739            bool eventTriggered1 = false;
 1740            DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_Legacy.EVENT
 741
 1742            yield return TestHelpers.ExpectMessageToKernel(targetEventType, sceneEvent,
 2743                () => { DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_
 744                (pointerEvent) =>
 745                {
 2746                    if (eventTriggered1)
 1747                        return true;
 748
 1749                    if (pointerEvent.eventType == sceneEvent.eventType &&
 750                        pointerEvent.payload.uuid == sceneEvent.payload.uuid &&
 751                        pointerEvent.payload.payload.hit.entityId == sceneEvent.payload.payload.hit.entityId)
 752                    {
 1753                        eventTriggered1 = true;
 1754                        return true;
 755                    }
 756
 0757                    return false;
 758                });
 759
 1760            Assert.IsTrue(eventTriggered1);
 761
 762            // turn shape invisible
 1763            TestHelpers.UpdateShape(scene, shape.id, JsonConvert.SerializeObject(new { visible = false }));
 1764            DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_Legacy.EVENT
 765
 1766            var pointerUpReceived = false;
 767
 768            void MsgFromEngineCallback(string eventType, string eventPayload)
 769            {
 1770                if (string.IsNullOrEmpty(eventPayload) || eventType != targetEventType)
 0771                    return;
 772
 1773                var pointerEvent = JsonUtility.FromJson<WebInterface.SceneEvent<WebInterface.OnPointerUpEvent>>(eventPay
 1774                if (pointerEvent.eventType == sceneEvent.eventType
 775                    && pointerEvent.payload.uuid == sceneEvent.payload.uuid
 776                    && pointerEvent.payload.payload.hit.entityId == sceneEvent.payload.payload.hit.entityId)
 777                {
 0778                    pointerUpReceived = true;
 779                }
 1780            }
 781
 782            // Hook up to web interface engine message reporting
 1783            WebInterface.OnMessageFromEngine += MsgFromEngineCallback;
 1784            InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, InputController_Legacy.EVENT.BUTTON_
 1785            WebInterface.OnMessageFromEngine -= MsgFromEngineCallback;
 786
 1787            Assert.IsFalse(pointerUpReceived);
 1788        }
 789
 790        [UnityTest]
 791        public IEnumerator OnPointerDownEventWhenEntityIsBehindOther()
 792        {
 1793            Assert.IsNotNull(cameraController, "camera is null?");
 794
 795            // Create blocking entity
 796            IDCLEntity blockingEntity;
 797            BoxShape blockingShape;
 1798            InstantiateEntityWithShape(out blockingEntity, out blockingShape);
 1799            TestHelpers.SetEntityTransform(scene, blockingEntity, new Vector3(3, 3, 3), Quaternion.identity, new Vector3
 1800            yield return blockingShape.routine;
 801
 802            // Create target entity for click
 803            IDCLEntity clickTargetEntity;
 804            BoxShape clickTargetShape;
 1805            InstantiateEntityWithShape(out clickTargetEntity, out clickTargetShape);
 1806            TestHelpers.SetEntityTransform(scene, clickTargetEntity, new Vector3(3, 3, 5), Quaternion.identity, new Vect
 1807            yield return clickTargetShape.routine;
 808
 809            // Set character position and camera rotation
 1810            DCLCharacterController.i.SetPosition(new Vector3(3, 2, 1));
 811
 1812            yield return null;
 813
 814            // Create pointer down component and add it to target entity
 1815            string onPointerId = "pointerevent-1";
 1816            var OnPointerDownModel = new OnPointerDown.Model()
 817            {
 818                type = OnPointerDown.NAME,
 819                uuid = onPointerId
 820            };
 1821            var component = TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, clickTargetEnti
 822                OnPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 823
 1824            Assert.IsTrue(component != null);
 825
 1826            string targetEventType = "SceneEvent";
 827
 1828            var onPointerDownEvent = new WebInterface.OnPointerDownEvent();
 1829            onPointerDownEvent.uuid = onPointerId;
 1830            onPointerDownEvent.payload = new WebInterface.OnPointerEventPayload();
 1831            onPointerDownEvent.payload.hit = new WebInterface.OnPointerEventPayload.Hit();
 1832            onPointerDownEvent.payload.hit.entityId = component.entity.entityId;
 1833            onPointerDownEvent.payload.hit.meshName = component.name;
 834
 1835            var sceneEvent = new WebInterface.SceneEvent<WebInterface.OnPointerDownEvent>();
 1836            sceneEvent.sceneId = scene.sceneData.id;
 1837            sceneEvent.payload = onPointerDownEvent;
 1838            sceneEvent.eventType = "uuidEvent";
 839
 840            // Check if target entity is hit behind other entity
 1841            bool targetEntityHit = false;
 1842            yield return TestHelpers.ExpectMessageToKernel(targetEventType, sceneEvent,
 2843                () => { DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_
 844                (pointerEvent) =>
 845                {
 1846                    if (pointerEvent.eventType == "uuidEvent" &&
 847                        pointerEvent.payload.uuid == onPointerId &&
 848                        pointerEvent.payload.payload.hit.entityId == clickTargetEntity.entityId)
 849                    {
 0850                        targetEntityHit = true;
 851                    }
 852
 1853                    return true;
 854                });
 855
 1856            Assert.IsTrue(!targetEntityHit, "Target entity was hit but other entity was blocking it");
 857
 858
 859            // Move character in front of target entity and rotate camera
 1860            DCLCharacterController.i.SetPosition(new Vector3(3, 2, 6));
 1861            cameraController.SetRotation(0, 0, 0, new Vector3(0, 0, -1));
 862
 1863            yield return null;
 864
 865            // Check if target entity is hit in front of the camera without being blocked
 1866            targetEntityHit = false;
 1867            yield return TestHelpers.ExpectMessageToKernel(targetEventType, sceneEvent,
 2868                () => { DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_
 869                (pointerEvent) =>
 870                {
 2871                    if (pointerEvent.eventType == "uuidEvent" &&
 872                        pointerEvent.payload.uuid == onPointerId &&
 873                        pointerEvent.payload.payload.hit.entityId == clickTargetEntity.entityId)
 874                    {
 1875                        targetEntityHit = true;
 876                    }
 877
 2878                    return true;
 879                });
 880
 1881            yield return null;
 1882            Assert.IsTrue(targetEntityHit, "Target entity wasn't hit and no other entity is blocking it");
 1883        }
 884
 885        [UnityTest]
 886        public IEnumerator OnPointerDownEventAndPointerBlockerShape()
 887        {
 1888            Assert.IsNotNull(cameraController, "camera is null?");
 889
 890            // Create blocking entity
 891            IDCLEntity blockingEntity;
 892            BoxShape blockingShape;
 1893            InstantiateEntityWithShape(out blockingEntity, out blockingShape);
 1894            TestHelpers.SetEntityTransform(scene, blockingEntity, new Vector3(3, 3, 3), Quaternion.identity, new Vector3
 895
 1896            yield return blockingShape.routine;
 897
 898            // Create target entity for click
 899            IDCLEntity clickTargetEntity;
 900            BoxShape clickTargetShape;
 1901            InstantiateEntityWithShape(out clickTargetEntity, out clickTargetShape);
 1902            TestHelpers.SetEntityTransform(scene, clickTargetEntity, new Vector3(3, 3, 5), Quaternion.identity, new Vect
 903
 1904            yield return clickTargetShape.routine;
 905
 906            // Set character position and camera rotation
 1907            DCLCharacterController.i.SetPosition(new Vector3(3, 2, 1));
 908
 1909            yield return null;
 910
 911            // Create pointer down component and add it to target entity
 1912            string onPointerId = "pointerevent-1";
 1913            var OnPointerDownModel = new OnPointerDown.Model()
 914            {
 915                type = OnPointerDown.NAME,
 916                uuid = onPointerId
 917            };
 918
 1919            var component = TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, clickTargetEnti
 920                OnPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 921
 1922            yield return component.routine;
 923
 1924            Assert.IsTrue(component != null);
 1925            Assert.IsTrue(clickTargetEntity != null);
 1926            Assert.IsTrue(component.entity != null);
 927
 1928            string targetEventType = "SceneEvent";
 929
 1930            var onPointerDownEvent = new WebInterface.OnPointerDownEvent();
 1931            onPointerDownEvent.uuid = onPointerId;
 1932            onPointerDownEvent.payload = new WebInterface.OnPointerEventPayload();
 1933            onPointerDownEvent.payload.hit = new WebInterface.OnPointerEventPayload.Hit();
 1934            onPointerDownEvent.payload.hit.entityId = component.entity.entityId;
 1935            onPointerDownEvent.payload.hit.meshName = component.name;
 936
 1937            var sceneEvent = new WebInterface.SceneEvent<WebInterface.OnPointerDownEvent>();
 1938            sceneEvent.sceneId = scene.sceneData.id;
 1939            sceneEvent.payload = onPointerDownEvent;
 1940            sceneEvent.eventType = "uuidEvent";
 941
 942            // Check the target entity is not hit behind the 'isPointerBlocker' shape
 1943            bool targetEntityHit = false;
 1944            yield return TestHelpers.ExpectMessageToKernel(targetEventType, sceneEvent,
 2945                () => { DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_
 946                (pointerEvent) =>
 947                {
 1948                    if (pointerEvent.eventType == "uuidEvent" &&
 949                        pointerEvent.payload.uuid == onPointerId &&
 950                        pointerEvent.payload.payload.hit.entityId == clickTargetEntity.entityId)
 951                    {
 0952                        targetEntityHit = true;
 953                    }
 954
 1955                    return true;
 956                });
 957
 1958            Assert.IsFalse(targetEntityHit, "Target entity was hit but other entity was blocking it");
 959
 960            // Toggle 'isPointerBlocker' property
 1961            yield return TestHelpers.SharedComponentUpdate(blockingShape, new BoxShape.Model
 962            {
 963                isPointerBlocker = false
 964            });
 965
 966            // Check the target entity is hit behind the 'isPointerBlocker' shape now
 1967            targetEntityHit = false;
 1968            yield return TestHelpers.ExpectMessageToKernel(targetEventType, sceneEvent,
 2969                () => { DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_
 970                (pointerEvent) =>
 971                {
 2972                    if (pointerEvent.eventType == "uuidEvent" &&
 973                        pointerEvent.payload.uuid == onPointerId &&
 974                        pointerEvent.payload.payload.hit.entityId == clickTargetEntity.entityId)
 975                    {
 1976                        targetEntityHit = true;
 977                    }
 978
 2979                    return true;
 980                });
 981
 1982            yield return null;
 983
 1984            Assert.IsTrue(targetEntityHit, "Target entity wasn't hit and no other entity is blocking it");
 1985        }
 986
 987        [UnityTest]
 988        public IEnumerator PointerEventNotTriggeredByParent()
 989        {
 990            // Create parent entity
 1991            InstantiateEntityWithShape(out IDCLEntity blockingEntity, out BoxShape blockingShape);
 1992            TestHelpers.SetEntityTransform(scene, blockingEntity, new Vector3(3, 3, 3), Quaternion.identity, new Vector3
 1993            yield return blockingShape.routine;
 994
 995            // Create target entity for click
 996            IDCLEntity clickTargetEntity;
 997            BoxShape clickTargetShape;
 1998            InstantiateEntityWithShape(out clickTargetEntity, out clickTargetShape);
 1999            TestHelpers.SetEntityTransform(scene, clickTargetEntity, new Vector3(0, 0, 5), Quaternion.identity, new Vect
 11000            yield return clickTargetShape.routine;
 1001
 1002            // Enparent target entity as a child of the blocking entity
 11003            TestHelpers.SetEntityParent(scene, clickTargetEntity, blockingEntity);
 1004
 1005            // Set character position and camera rotation
 11006            DCLCharacterController.i.SetPosition(new Vector3(3, 2, 1));
 11007            yield return null;
 1008
 1009            // Create pointer down component and add it to target entity
 11010            string onPointerId = "pointerevent-1";
 11011            var OnPointerDownModel = new OnPointerDown.Model()
 1012            {
 1013                type = OnPointerDown.NAME,
 1014                uuid = onPointerId
 1015            };
 11016            var component = TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, clickTargetEnti
 1017                OnPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 1018
 11019            Assert.IsTrue(component != null);
 1020
 11021            string targetEventType = "SceneEvent";
 1022
 11023            var onPointerDownEvent = new WebInterface.OnPointerDownEvent();
 11024            onPointerDownEvent.uuid = onPointerId;
 11025            onPointerDownEvent.payload = new WebInterface.OnPointerEventPayload();
 11026            onPointerDownEvent.payload.hit = new WebInterface.OnPointerEventPayload.Hit();
 11027            onPointerDownEvent.payload.hit.entityId = component.entity.entityId;
 11028            onPointerDownEvent.payload.hit.meshName = component.name;
 1029
 11030            var sceneEvent = new WebInterface.SceneEvent<WebInterface.OnPointerDownEvent>();
 11031            sceneEvent.sceneId = scene.sceneData.id;
 11032            sceneEvent.payload = onPointerDownEvent;
 11033            sceneEvent.eventType = "uuidEvent";
 1034
 1035            // Check if target entity is triggered by hitting the parent entity
 11036            bool targetEntityHit = false;
 11037            yield return TestHelpers.ExpectMessageToKernel(targetEventType, sceneEvent,
 21038                () => { DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_
 1039                (pointerEvent) =>
 1040                {
 11041                    if (pointerEvent.eventType == "uuidEvent" &&
 1042                        pointerEvent.payload.uuid == onPointerId &&
 1043                        pointerEvent.payload.payload.hit.entityId == clickTargetEntity.entityId)
 1044                    {
 01045                        targetEntityHit = true;
 1046                    }
 1047
 11048                    return true;
 1049                });
 1050
 11051            Assert.IsFalse(targetEntityHit, "Target entity was hit but other entity was blocking it");
 1052
 1053            // Move character in front of target entity and rotate camera
 11054            DCLCharacterController.i.SetPosition(new Vector3(3, 2, 12));
 11055            cameraController.SetRotation(0, 0, 0, new Vector3(0, 0, -1));
 1056
 11057            yield return null;
 1058
 1059            // Check if target entity is triggered when hit directly
 11060            targetEntityHit = false;
 11061            yield return TestHelpers.ExpectMessageToKernel(targetEventType, sceneEvent,
 21062                () => { DCL.InputController_Legacy.i.RaiseEvent(WebInterface.ACTION_BUTTON.POINTER, DCL.InputController_
 1063                (pointerEvent) =>
 1064                {
 21065                    if (pointerEvent.eventType == "uuidEvent" &&
 1066                        pointerEvent.payload.uuid == onPointerId &&
 1067                        pointerEvent.payload.payload.hit.entityId == clickTargetEntity.entityId)
 1068                    {
 11069                        targetEntityHit = true;
 1070                    }
 1071
 21072                    return true;
 1073                });
 1074
 11075            yield return null;
 11076            Assert.IsTrue(targetEntityHit, "Target entity wasn't hit and no other entity is blocking it");
 11077        }
 1078
 1079        [UnityTest]
 1080        public IEnumerator OnPointerHoverFeedbackPropertiesAreAppliedCorrectly()
 1081        {
 1082            IDCLEntity entity;
 1083            BoxShape shape;
 11084            InstantiateEntityWithShape(out entity, out shape);
 11085            TestHelpers.SetEntityTransform(scene, entity, new Vector3(8, 2, 10), Quaternion.identity, new Vector3(3, 3, 
 11086            yield return shape.routine;
 1087
 11088            var onPointerDownModel = new OnPointerDown.Model()
 1089            {
 1090                type = OnPointerDown.NAME,
 1091                uuid = "pointerevent-1"
 1092            };
 11093            var component = TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, entity,
 1094                onPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 11095            Assert.IsTrue(component != null);
 1096
 11097            yield return null;
 1098
 11099            DCLCharacterController.i.SetPosition(new Vector3(8, 1, 7f));
 1100
 11101            var cameraController = GameObject.FindObjectOfType<DCL.Camera.CameraController>();
 1102
 1103            // Rotate camera towards the interactive object
 11104            cameraController.SetRotation(45, 0, 0);
 1105
 11106            yield return null;
 1107
 11108            var hoverCanvasController = InteractionHoverCanvasController.i;
 11109            Assert.IsNotNull(hoverCanvasController);
 11110            Assert.IsTrue(hoverCanvasController.canvas.enabled);
 1111
 1112            // Check default properties
 11113            Assert.AreEqual("AnyButtonHoverIcon", hoverCanvasController.GetCurrentHoverIcon().name);
 11114            Assert.AreEqual("Interact", hoverCanvasController.text.text);
 11115            yield return null;
 1116
 11117            onPointerDownModel.button = "PRIMARY";
 11118            onPointerDownModel.hoverText = "Click!";
 1119
 1120            // we can't use TestHelpers.EntityComponentUpdate() to update UUIDComponents until we separate every UUIComp
 11121            component = TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, entity,
 1122                onPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 1123
 11124            yield return null;
 1125
 11126            Assert.AreEqual("PrimaryButtonHoverIcon", hoverCanvasController.GetCurrentHoverIcon().name);
 11127            Assert.AreEqual("Click!", hoverCanvasController.text.text);
 1128
 11129            DCLCharacterController.i.ResumeGravity();
 11130        }
 1131
 1132        [UnityTest]
 1133        public IEnumerator OnPointerHoverDistanceIsAppliedCorrectly()
 1134        {
 1135            IDCLEntity entity;
 1136            BoxShape shape;
 11137            InstantiateEntityWithShape(out entity, out shape);
 11138            TestHelpers.SetEntityTransform(scene, entity, new Vector3(8, 2, 10), Quaternion.identity, new Vector3(3, 3, 
 11139            yield return shape.routine;
 1140
 11141            var onPointerDownModel = new OnPointerDown.Model()
 1142            {
 1143                type = OnPointerDown.NAME,
 1144                uuid = "pointerevent-1"
 1145            };
 11146            var component = TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, entity,
 1147                onPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 11148            Assert.IsTrue(component != null);
 1149
 11150            yield return null;
 1151
 11152            DCLCharacterController.i.SetPosition(new Vector3(8, 1, 7));
 1153
 11154            var cameraController = GameObject.FindObjectOfType<DCL.Camera.CameraController>();
 1155
 1156            // Rotate camera towards the interactive object
 11157            cameraController.SetRotation(45, 0, 0);
 1158
 11159            yield return null;
 1160
 11161            var hoverCanvas = InteractionHoverCanvasController.i.canvas;
 11162            Assert.IsNotNull(hoverCanvas);
 1163
 11164            Assert.IsTrue(hoverCanvas.enabled);
 11165            yield return null;
 1166
 11167            onPointerDownModel.distance = 1f;
 1168            // we can't use TestHelpers.EntityComponentUpdate() to update UUIDComponents until we separate every UUIComp
 11169            component = TestHelpers.EntityComponentCreate<OnPointerDown, OnPointerDown.Model>(scene, entity,
 1170                onPointerDownModel, CLASS_ID_COMPONENT.UUID_CALLBACK);
 1171
 11172            yield return null;
 1173
 11174            Assert.IsFalse(hoverCanvas.enabled);
 1175
 11176            Object.Destroy(component);
 1177
 11178            DCLCharacterController.i.ResumeGravity();
 11179        }
 1180    }
 1181}