| | 1 | | using DCL; |
| | 2 | | using DCL.Components; |
| | 3 | | using DCL.Configuration; |
| | 4 | | using DCL.Controllers; |
| | 5 | | using DCL.Helpers; |
| | 6 | | using DCL.Models; |
| | 7 | | using Newtonsoft.Json; |
| | 8 | | using NUnit.Framework; |
| | 9 | | using System.Collections; |
| | 10 | | using System.Collections.Generic; |
| | 11 | | using System.Linq; |
| | 12 | | using UnityEngine; |
| | 13 | | using UnityEngine.TestTools; |
| | 14 | |
|
| | 15 | | namespace Tests |
| | 16 | | { |
| | 17 | | public class SceneTests : IntegrationTestSuite_Legacy |
| | 18 | | { |
| 0 | 19 | | protected override bool enableSceneIntegrityChecker => false; |
| | 20 | |
|
| | 21 | | protected override IEnumerator SetUp() |
| | 22 | | { |
| 10 | 23 | | yield return base.SetUp(); |
| 10 | 24 | | Environment.i.platform.debugController.SetDebug(); |
| 10 | 25 | | DCL.Configuration.EnvironmentSettings.DEBUG = true; |
| 10 | 26 | | } |
| | 27 | |
|
| | 28 | | [UnityTest] |
| | 29 | | public IEnumerator CreateGlobalScene() |
| | 30 | | { |
| | 31 | | // Position character inside parcel (0,0) |
| 1 | 32 | | TestHelpers.SetCharacterPosition(Vector3.zero); |
| | 33 | |
|
| 1 | 34 | | string sceneGameObjectNamePrefix = "Global Scene - "; |
| 1 | 35 | | string sceneId = "Test Global Scene"; |
| 1 | 36 | | sceneController.CreateGlobalScene(JsonUtility.ToJson(new CreateGlobalSceneMessage() { id = sceneId })); |
| | 37 | |
|
| 1 | 38 | | GameObject sceneGo = GameObject.Find(sceneGameObjectNamePrefix + sceneId); |
| | 39 | |
|
| 1 | 40 | | GlobalScene globalScene = Environment.i.world.state.loadedScenes[sceneId] as GlobalScene; |
| | 41 | |
|
| 1 | 42 | | Assert.IsTrue(globalScene != null, "Scene isn't a GlobalScene?"); |
| 1 | 43 | | Assert.IsTrue(sceneGo != null, "scene game object not found!"); |
| 1 | 44 | | Assert.IsTrue(Environment.i.world.state.loadedScenes[sceneId] != null, "Scene not in loaded dictionary!"); |
| 1 | 45 | | Assert.IsTrue(globalScene.unloadWithDistance == false, |
| | 46 | | "Scene will unload when far!"); |
| | 47 | |
|
| 1 | 48 | | Assert.IsTrue(globalScene.IsInsideSceneBoundaries(new Vector2Int(1000, 1000)), |
| | 49 | | "IsInsideSceneBoundaries() should always return true."); |
| 1 | 50 | | Assert.IsTrue(globalScene.IsInsideSceneBoundaries(new Vector2Int(-1000, -1000)), |
| | 51 | | "IsInsideSceneBoundaries() should always return true."); |
| | 52 | |
|
| 1 | 53 | | yield return null; |
| | 54 | |
|
| | 55 | | // Position character inside parcel (0,0) |
| 1 | 56 | | TestHelpers.SetCharacterPosition(new Vector3(100f, 0f, 100f)); |
| | 57 | |
|
| 1 | 58 | | yield return null; |
| | 59 | |
|
| 1 | 60 | | sceneGo = GameObject.Find(sceneGameObjectNamePrefix + sceneId); |
| | 61 | |
|
| 1 | 62 | | Assert.IsTrue(sceneGo != null, "scene game object not found! GlobalScenes must not be unloaded by distance!" |
| 1 | 63 | | Assert.IsTrue(Environment.i.world.state.loadedScenes[sceneId] != null, |
| | 64 | | "Scene not in loaded dictionary when far! GlobalScenes must not be unloaded by distance!"); |
| 1 | 65 | | } |
| | 66 | |
|
| | 67 | | [Test] |
| | 68 | | public void ParcelScene_TrackDisposables_AfterInitDone() |
| | 69 | | { |
| 1 | 70 | | SetUp_TestScene(); |
| 1 | 71 | | TestHelpers.CreateEntityWithBoxShape(scene, Vector3.zero, true); |
| 1 | 72 | | TestHelpers.CreateEntityWithBoxShape(scene, Vector3.zero, true); |
| 1 | 73 | | TestHelpers.CreateEntityWithBoxShape(scene, Vector3.zero, true); |
| | 74 | |
|
| 1 | 75 | | scene.sceneLifecycleHandler.SetInitMessagesDone(); |
| | 76 | |
|
| 1 | 77 | | Assert.AreEqual(0, scene.sceneLifecycleHandler.disposableNotReadyCount); |
| 1 | 78 | | } |
| | 79 | |
|
| | 80 | | [Test] |
| | 81 | | public void ParcelScene_TrackDisposables_Empty() |
| | 82 | | { |
| 1 | 83 | | SetUp_TestScene(); |
| 1 | 84 | | Assert.AreEqual(0, scene.sceneLifecycleHandler.disposableNotReadyCount); |
| 1 | 85 | | } |
| | 86 | |
|
| | 87 | | [UnityTest] |
| | 88 | | public IEnumerator PerformanceLimitControllerTests() |
| | 89 | | { |
| 1 | 90 | | yield return new WaitForAllMessagesProcessed(); |
| | 91 | |
|
| 1 | 92 | | var scenesToLoad = (Resources.Load("TestJSON/SceneLoadingTest") as TextAsset).text; |
| 1 | 93 | | sceneController.LoadParcelScenes(scenesToLoad); |
| | 94 | |
|
| 1 | 95 | | yield return new WaitForAllMessagesProcessed(); |
| | 96 | |
|
| 1 | 97 | | string loadedSceneID = "0,0"; |
| 1 | 98 | | Assert.IsTrue(Environment.i.world.state.loadedScenes.ContainsKey(loadedSceneID)); |
| | 99 | |
|
| 1 | 100 | | ParcelScene scene = Environment.i.world.state.loadedScenes[loadedSceneID] as ParcelScene; |
| | 101 | |
|
| 1 | 102 | | var coneShape = TestHelpers.SharedComponentCreate<ConeShape, ConeShape.Model>(scene, DCL.Models.CLASS_ID.CON |
| | 103 | | { |
| | 104 | | radiusTop = 1, |
| | 105 | | radiusBottom = 0 |
| | 106 | | }); |
| | 107 | |
|
| 1 | 108 | | var planeShape = TestHelpers.SharedComponentCreate<PlaneShape, PlaneShape.Model>(scene, DCL.Models.CLASS_ID. |
| | 109 | | { |
| | 110 | | height = 1.5f, |
| | 111 | | width = 1 |
| | 112 | | }); |
| | 113 | |
|
| | 114 | |
|
| 1 | 115 | | var shapeEntity = TestHelpers.CreateSceneEntity(scene); |
| 1 | 116 | | TestHelpers.SetEntityTransform(scene, shapeEntity, Vector3.one, Quaternion.identity, Vector3.one); |
| 1 | 117 | | TestHelpers.SharedComponentAttach(coneShape, shapeEntity); |
| | 118 | |
|
| 1 | 119 | | TestHelpers.UpdateShape(scene, coneShape.id, JsonUtility.ToJson(new ConeShape.Model() |
| | 120 | | { |
| | 121 | | segmentsRadial = 180, |
| | 122 | | segmentsHeight = 1.5f |
| | 123 | | })); |
| | 124 | |
|
| 1 | 125 | | TestHelpers.DetachSharedComponent(scene, shapeEntity.entityId, coneShape.id); |
| 1 | 126 | | TestHelpers.SharedComponentAttach(planeShape, shapeEntity); |
| | 127 | |
|
| 1 | 128 | | var lanternEntity = TestHelpers.CreateSceneEntity(scene); |
| 1 | 129 | | var lanternShape = TestHelpers.AttachGLTFShape(lanternEntity, scene, new Vector3(8, 1, 8), new LoadableShape |
| | 130 | | { |
| | 131 | | src = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb" |
| | 132 | | }); |
| 1 | 133 | | yield return TestHelpers.WaitForGLTFLoad(lanternEntity); |
| | 134 | |
|
| 1 | 135 | | var cesiumManEntity = TestHelpers.CreateSceneEntity(scene); |
| 1 | 136 | | var cesiumManShape = TestHelpers.AttachGLTFShape(cesiumManEntity, scene, new Vector3(8, 1, 8), new LoadableS |
| | 137 | | { |
| | 138 | | src = TestAssetsUtils.GetPath() + "/GLB/Shark/shark_anim.gltf" |
| | 139 | | }); |
| 1 | 140 | | yield return TestHelpers.WaitForGLTFLoad(cesiumManEntity); |
| | 141 | |
|
| 1 | 142 | | TestHelpers.RemoveSceneEntity(scene, lanternEntity); |
| 1 | 143 | | yield return null; |
| | 144 | |
|
| 1 | 145 | | TestHelpers.DetachSharedComponent(scene, cesiumManEntity.entityId, cesiumManShape.id); |
| 1 | 146 | | cesiumManShape = TestHelpers.AttachGLTFShape(cesiumManEntity, scene, new Vector3(8, 1, 8), new LoadableShape |
| | 147 | | { |
| | 148 | | src = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb" |
| | 149 | | }); |
| 1 | 150 | | yield return TestHelpers.WaitForGLTFLoad(cesiumManEntity); |
| | 151 | |
|
| 1 | 152 | | TestHelpers.InstantiateEntityWithShape(scene, "1", DCL.Models.CLASS_ID.BOX_SHAPE, new Vector3(8, 1, 8)); |
| 1 | 153 | | TestHelpers.InstantiateEntityWithShape(scene, "2", DCL.Models.CLASS_ID.SPHERE_SHAPE, new Vector3(8, 1, 8)); |
| | 154 | |
|
| 1 | 155 | | AssertMetricsModel(scene, |
| | 156 | | triangles: 1126, |
| | 157 | | materials: 2, |
| | 158 | | entities: 4, |
| | 159 | | meshes: 4, |
| | 160 | | bodies: 4, |
| | 161 | | textures: 0); |
| | 162 | |
|
| 1 | 163 | | TestHelpers.RemoveSceneEntity(scene, "1"); |
| 1 | 164 | | TestHelpers.RemoveSceneEntity(scene, "2"); |
| 1 | 165 | | TestHelpers.RemoveSceneEntity(scene, cesiumManEntity); |
| | 166 | |
|
| 1 | 167 | | yield return null; |
| | 168 | |
|
| 1 | 169 | | AssertMetricsModel(scene, |
| | 170 | | triangles: 4, |
| | 171 | | materials: 1, |
| | 172 | | entities: 1, |
| | 173 | | meshes: 1, |
| | 174 | | bodies: 1, |
| | 175 | | textures: 0); |
| | 176 | |
|
| 1 | 177 | | sceneController.UnloadAllScenes(); |
| 1 | 178 | | yield return null; |
| 1 | 179 | | } |
| | 180 | |
|
| | 181 | | void AssertMetricsModel(ParcelScene scene, int triangles, int materials, int entities, int meshes, int bodies, |
| | 182 | | int textures) |
| | 183 | | { |
| 2 | 184 | | SceneMetricsModel inputModel = scene.metricsController.GetModel(); |
| | 185 | |
|
| 2 | 186 | | Assert.AreEqual(triangles, inputModel.triangles, "Incorrect triangle count, was: " + triangles); |
| 2 | 187 | | Assert.AreEqual(materials, inputModel.materials, "Incorrect materials count"); |
| 2 | 188 | | Assert.AreEqual(entities, inputModel.entities, "Incorrect entities count"); |
| 2 | 189 | | Assert.AreEqual(meshes, inputModel.meshes, "Incorrect geometries/meshes count"); |
| 2 | 190 | | Assert.AreEqual(bodies, inputModel.bodies, "Incorrect bodies count"); |
| 2 | 191 | | Assert.AreEqual(textures, inputModel.textures, "Incorrect textures count"); |
| 2 | 192 | | } |
| | 193 | |
|
| | 194 | | [UnityTest] |
| | 195 | | public IEnumerator SceneLoading() |
| | 196 | | { |
| 1 | 197 | | sceneController.LoadParcelScenes((Resources.Load("TestJSON/SceneLoadingTest") as TextAsset).text); |
| 1 | 198 | | yield return new WaitForAllMessagesProcessed(); |
| | 199 | |
|
| 1 | 200 | | string loadedSceneID = "0,0"; |
| | 201 | |
|
| 1 | 202 | | Assert.IsTrue(Environment.i.world.state.loadedScenes.ContainsKey(loadedSceneID)); |
| 1 | 203 | | Assert.IsTrue(Environment.i.world.state.loadedScenes[loadedSceneID] != null); |
| 1 | 204 | | } |
| | 205 | |
|
| | 206 | | [UnityTest] |
| | 207 | | public IEnumerator SceneUnloading() |
| | 208 | | { |
| 1 | 209 | | sceneController.LoadParcelScenes((Resources.Load("TestJSON/SceneLoadingTest") as TextAsset).text); |
| | 210 | |
|
| 1 | 211 | | yield return new WaitForAllMessagesProcessed(); |
| | 212 | |
|
| 1 | 213 | | string loadedSceneID = "0,0"; |
| | 214 | |
|
| 1 | 215 | | Assert.IsTrue(Environment.i.world.state.loadedScenes.ContainsKey(loadedSceneID)); |
| | 216 | |
|
| 1 | 217 | | var loadedScene = Environment.i.world.state.loadedScenes[loadedSceneID] as ParcelScene; |
| | 218 | | // Add 1 entity to the loaded scene |
| 1 | 219 | | TestHelpers.CreateSceneEntity(loadedScene, "6"); |
| | 220 | |
|
| 1 | 221 | | var sceneEntities = loadedScene.entities; |
| | 222 | |
|
| 1 | 223 | | sceneController.UnloadScene(loadedSceneID); |
| | 224 | |
|
| 1 | 225 | | yield return new WaitForAllMessagesProcessed(); |
| 1 | 226 | | yield return new WaitForSeconds(0.1f); |
| | 227 | |
|
| 1 | 228 | | Assert.IsTrue(Environment.i.world.state.loadedScenes.ContainsKey(loadedSceneID) == false); |
| | 229 | |
|
| 1 | 230 | | Assert.IsTrue(loadedScene == null, "Scene root gameobject reference is not getting destroyed."); |
| | 231 | |
|
| 2 | 232 | | foreach (var entity in sceneEntities) |
| | 233 | | { |
| 0 | 234 | | Assert.IsFalse(entity.Value.gameObject.activeInHierarchy, "Every entity should be disabled after returni |
| | 235 | | } |
| | 236 | |
|
| 1 | 237 | | sceneController.UnloadAllScenes(includePersistent: true); |
| | 238 | |
|
| 1 | 239 | | yield return null; |
| 1 | 240 | | } |
| | 241 | |
|
| | 242 | | [UnityTest] |
| | 243 | | public IEnumerator SeveralParcelsFromJSON() |
| | 244 | | { |
| 1 | 245 | | string severalParcelsJson = (Resources.Load("TestJSON/TestSceneSeveralParcels") as TextAsset).text; |
| | 246 | |
|
| | 247 | | //Not really elegant, but does the trick |
| 1 | 248 | | var jsonScenes = JsonConvert |
| | 249 | | .DeserializeObject<LoadParcelScenesMessage.UnityParcelScene[]>(severalParcelsJson) |
| 22 | 250 | | .Select(x => JsonUtility.ToJson(x)); |
| | 251 | |
|
| 1 | 252 | | Assert.AreEqual(Environment.i.world.state.loadedScenes.Count, 1); |
| | 253 | |
|
| 24 | 254 | | foreach (string jsonScene in jsonScenes) |
| | 255 | | { |
| 11 | 256 | | sceneController.LoadParcelScenes(jsonScene); |
| | 257 | | } |
| | 258 | |
|
| 1 | 259 | | yield return new WaitForAllMessagesProcessed(); |
| | 260 | |
|
| 1 | 261 | | var referenceCheck = new List<DCL.Controllers.ParcelScene>(); |
| | 262 | |
|
| 26 | 263 | | foreach (var kvp in Environment.i.world.state.loadedScenes) |
| | 264 | | { |
| 12 | 265 | | referenceCheck.Add(kvp.Value as ParcelScene); |
| | 266 | | } |
| | 267 | |
|
| 1 | 268 | | Assert.AreEqual(12, Environment.i.world.state.loadedScenes.Count); |
| | 269 | |
|
| 24 | 270 | | foreach (var jsonScene in jsonScenes) |
| | 271 | | { |
| 11 | 272 | | sceneController.LoadParcelScenes(jsonScene); |
| | 273 | | } |
| | 274 | |
|
| 1 | 275 | | Assert.AreEqual(12, Environment.i.world.state.loadedScenes.Count); |
| | 276 | |
|
| 26 | 277 | | foreach (var reference in referenceCheck) |
| | 278 | | { |
| 12 | 279 | | Assert.IsTrue(Environment.i.world.state.loadedScenes.ContainsValue(reference), "References must be the s |
| | 280 | | } |
| | 281 | |
|
| 1 | 282 | | sceneController.UnloadAllScenes(includePersistent: true); |
| 1 | 283 | | yield return null; |
| 1 | 284 | | } |
| | 285 | |
|
| | 286 | | [UnityTest] |
| | 287 | | public IEnumerator PositionParcels() |
| | 288 | | { |
| 1 | 289 | | Assert.AreEqual(1, Environment.i.world.state.loadedScenes.Count); |
| | 290 | |
|
| 1 | 291 | | var jsonMessageToLoad = "{\"id\":\"xxx\",\"basePosition\":{\"x\":0,\"y\":0},\"parcels\":[{\"x\":-1,\"y\":0}, |
| 1 | 292 | | sceneController.LoadParcelScenes(jsonMessageToLoad); |
| | 293 | |
|
| 1 | 294 | | yield return new WaitForAllMessagesProcessed(); |
| | 295 | |
|
| 1 | 296 | | Assert.AreEqual(2, Environment.i.world.state.loadedScenes.Count); |
| | 297 | |
|
| 1 | 298 | | var theScene = Environment.i.world.state.loadedScenes["xxx"]; |
| 1 | 299 | | yield return null; |
| | 300 | |
|
| 1 | 301 | | Assert.AreEqual(3, theScene.sceneData.parcels.Length); |
| 1 | 302 | | Assert.AreEqual(3, theScene.GetSceneTransform().childCount); |
| | 303 | |
|
| 1 | 304 | | Assert.IsTrue(theScene.GetSceneTransform().GetChild(0).localPosition == new Vector3(-ParcelSettings.PARCEL_S |
| | 305 | | DCL.Configuration.ParcelSettings.DEBUG_FLOOR_HEIGHT, ParcelSettings.PARCEL_SIZE / 2)); |
| 1 | 306 | | Assert.IsTrue(theScene.GetSceneTransform().GetChild(1).localPosition == new Vector3(ParcelSettings.PARCEL_SI |
| | 307 | | DCL.Configuration.ParcelSettings.DEBUG_FLOOR_HEIGHT, ParcelSettings.PARCEL_SIZE / 2)); |
| 1 | 308 | | Assert.IsTrue(theScene.GetSceneTransform().GetChild(2).localPosition == new Vector3(-ParcelSettings.PARCEL_S |
| | 309 | | DCL.Configuration.ParcelSettings.DEBUG_FLOOR_HEIGHT, |
| | 310 | | ParcelSettings.PARCEL_SIZE + ParcelSettings.PARCEL_SIZE / 2)); |
| 1 | 311 | | } |
| | 312 | |
|
| | 313 | | [UnityTest] |
| | 314 | | public IEnumerator PositionParcels2() |
| | 315 | | { |
| 1 | 316 | | Assert.AreEqual(1, Environment.i.world.state.loadedScenes.Count); |
| | 317 | |
|
| 1 | 318 | | var jsonMessageToLoad = "{\"id\":\"xxx\",\"basePosition\":{\"x\":90,\"y\":90},\"parcels\":[{\"x\":89,\"y\":9 |
| 1 | 319 | | sceneController.LoadParcelScenes(jsonMessageToLoad); |
| | 320 | |
|
| 1 | 321 | | yield return new WaitForAllMessagesProcessed(); |
| | 322 | |
|
| 1 | 323 | | Assert.AreEqual(2, Environment.i.world.state.loadedScenes.Count); |
| | 324 | |
|
| 1 | 325 | | var theScene = Environment.i.world.state.loadedScenes["xxx"] as ParcelScene; |
| 1 | 326 | | yield return null; |
| | 327 | |
|
| 1 | 328 | | Assert.AreEqual(3, theScene.sceneData.parcels.Length); |
| 1 | 329 | | Assert.AreEqual(3, theScene.transform.childCount); |
| | 330 | |
|
| 1 | 331 | | Assert.IsTrue(theScene.transform.GetChild(0).localPosition == new Vector3(-ParcelSettings.PARCEL_SIZE / 2, |
| | 332 | | DCL.Configuration.ParcelSettings.DEBUG_FLOOR_HEIGHT, ParcelSettings.PARCEL_SIZE / 2)); |
| 1 | 333 | | Assert.IsTrue(theScene.transform.GetChild(1).localPosition == new Vector3(ParcelSettings.PARCEL_SIZE / 2, |
| | 334 | | DCL.Configuration.ParcelSettings.DEBUG_FLOOR_HEIGHT, ParcelSettings.PARCEL_SIZE / 2)); |
| 1 | 335 | | Assert.IsTrue(theScene.transform.GetChild(2).localPosition == new Vector3(-ParcelSettings.PARCEL_SIZE / 2, |
| | 336 | | DCL.Configuration.ParcelSettings.DEBUG_FLOOR_HEIGHT, |
| | 337 | | ParcelSettings.PARCEL_SIZE + ParcelSettings.PARCEL_SIZE / 2)); |
| 1 | 338 | | } |
| | 339 | |
|
| | 340 | | [UnityTest] |
| | 341 | | [Explicit] |
| | 342 | | [Category("Explicit")] |
| | 343 | | public IEnumerator ParcelScene_TrackDisposables_OneGLTF() |
| | 344 | | { |
| 0 | 345 | | SetUp_TestScene(); |
| 0 | 346 | | var entity = TestHelpers.CreateSceneEntity(scene); |
| | 347 | |
|
| 0 | 348 | | TestHelpers.AttachGLTFShape(entity, scene, Vector3.zero, new LoadableShape.Model() |
| | 349 | | { |
| | 350 | | src = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb" |
| | 351 | | }); |
| | 352 | |
|
| 0 | 353 | | Assert.AreEqual(1, scene.sceneLifecycleHandler.disposableNotReadyCount); |
| 0 | 354 | | scene.sceneLifecycleHandler.SetInitMessagesDone(); |
| 0 | 355 | | Assert.AreEqual(1, scene.sceneLifecycleHandler.disposableNotReadyCount); |
| 0 | 356 | | yield return TestHelpers.WaitForGLTFLoad(entity); |
| 0 | 357 | | Assert.AreEqual(0, scene.sceneLifecycleHandler.disposableNotReadyCount); |
| 0 | 358 | | } |
| | 359 | |
|
| | 360 | | [Test] |
| | 361 | | [Explicit] |
| | 362 | | [Category("Explicit")] |
| | 363 | | public void ParcelScene_TrackDisposables_BeforeInitDone() |
| | 364 | | { |
| 0 | 365 | | SetUp_TestScene(); |
| 0 | 366 | | TestHelpers.CreateEntityWithBoxShape(scene, Vector3.zero, true); |
| 0 | 367 | | TestHelpers.CreateEntityWithBoxShape(scene, Vector3.zero, true); |
| 0 | 368 | | TestHelpers.CreateEntityWithBoxShape(scene, Vector3.zero, true); |
| | 369 | |
|
| 0 | 370 | | Assert.AreEqual(3, scene.sceneLifecycleHandler.disposableNotReadyCount); |
| 0 | 371 | | } |
| | 372 | |
|
| | 373 | | [UnityTest] |
| | 374 | | [Explicit] |
| | 375 | | [Category("Explicit")] |
| | 376 | | public IEnumerator ParcelScene_TrackDisposables_InstantReadyDisposable() |
| | 377 | | { |
| 0 | 378 | | SetUp_TestScene(); |
| 0 | 379 | | var boxShape = TestHelpers.CreateEntityWithBoxShape(scene, Vector3.zero, true); |
| 0 | 380 | | Assert.AreEqual(1, scene.sceneLifecycleHandler.disposableNotReadyCount); |
| 0 | 381 | | scene.sceneLifecycleHandler.SetInitMessagesDone(); |
| 0 | 382 | | Assert.AreEqual(0, scene.sceneLifecycleHandler.disposableNotReadyCount); |
| 0 | 383 | | yield return boxShape.routine; |
| 0 | 384 | | Assert.AreEqual(0, scene.sceneLifecycleHandler.disposableNotReadyCount); |
| 0 | 385 | | } |
| | 386 | |
|
| | 387 | | [Test] |
| | 388 | | public void ParcelScene_SetEntityParent() |
| | 389 | | { |
| 1 | 390 | | SetUp_TestScene(); |
| 1 | 391 | | var entityId = "entityId"; |
| 1 | 392 | | var entity = TestHelpers.CreateSceneEntity(scene, entityId); |
| | 393 | |
|
| | 394 | | // Make sure that it doesn't have a parent |
| 1 | 395 | | Assert.IsNull(entity.parent); |
| 1 | 396 | | Assert.IsFalse(Environment.i.world.sceneBoundsChecker.WasAddedAsPersistent(entity)); |
| | 397 | |
|
| | 398 | | // Set player reference as parent |
| 1 | 399 | | TestHelpers.SetEntityParent(scene, entityId, "FirstPersonCameraEntityReference"); |
| 1 | 400 | | Assert.AreEqual(entity.parent, DCLCharacterController.i.firstPersonCameraReference); |
| 1 | 401 | | Assert.IsTrue(Environment.i.world.sceneBoundsChecker.WasAddedAsPersistent(entity)); |
| | 402 | |
|
| | 403 | | // Set avatar position reference as parent |
| 1 | 404 | | TestHelpers.SetEntityParent(scene, entityId, "AvatarEntityReference"); |
| 1 | 405 | | Assert.AreEqual(entity.parent, DCLCharacterController.i.avatarReference); |
| 1 | 406 | | Assert.IsTrue(Environment.i.world.sceneBoundsChecker.WasAddedAsPersistent(entity)); |
| | 407 | |
|
| | 408 | | // Remove all parents |
| 1 | 409 | | TestHelpers.SetEntityParent(scene, entityId, "0"); |
| 1 | 410 | | Assert.IsNull(entity.parent); |
| 1 | 411 | | Assert.IsFalse(Environment.i.world.sceneBoundsChecker.WasAddedAsPersistent(entity)); |
| 1 | 412 | | } |
| | 413 | | } |
| | 414 | | } |