< Summary

Class:SceneBoundariesCheckerTests.SceneBoundariesCheckerTests
Assembly:SceneBoundariesCheckerTests
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/SceneBoundariesController/Tests/SceneBoundariesCheckerTests.cs
Covered lines:65
Uncovered lines:4
Coverable lines:69
Total lines:160
Line coverage:94.2% (65 of 69)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetUp()0%330100%
EntitiesAreBeingCorrectlyRegistered()0%330100%
PShapeIsInvalidatedWhenStartingOutOfBounds()0%330100%
GLTFShapeIsInvalidatedWhenStartingOutOfBounds()0%330100%
NFTShapeIsInvalidatedWhenStartingOutOfBounds()0%12300%
PShapeIsInvalidatedWhenLeavingBounds()0%330100%
GLTFShapeIsInvalidatedWhenLeavingBounds()0%330100%
NFTShapeIsInvalidatedWhenLeavingBounds()0%12300%
PShapeIsResetWhenReenteringBounds()0%330100%
GLTFShapeIsResetWhenReenteringBounds()0%12300%
NFTShapeIsResetWhenReenteringBounds()0%12300%
ChildShapeIsEvaluated()0%330100%
ChildShapeIsEvaluatedOnShapelessParent()0%330100%
HeightIsEvaluated()0%330100%
AudioSourceIsMuted()0%330100%
AudioSourceWithMeshIsDisabled()0%440100%
HighPrioEntitiesAreRegistered_Position()0%330100%
HighPrioEntitiesAreRegistered_Scale()0%330100%
AudioSourcePlaysBackOnReentering()0%440100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/SceneBoundariesController/Tests/SceneBoundariesCheckerTests.cs

#LineLine coverage
 1using DCL.Models;
 2using NUnit.Framework;
 3using System.Collections;
 4using System.Linq;
 5using DCL;
 6using DCL.Components;
 7using DCL.Controllers;
 8using DCL.Helpers;
 9using UnityEngine;
 10using UnityEngine.TestTools;
 11
 12namespace SceneBoundariesCheckerTests
 13{
 14    public class SceneBoundariesCheckerTests : IntegrationTestSuite_Legacy
 15    {
 16        [UnitySetUp]
 17        protected override IEnumerator SetUp()
 18        {
 1419            yield return base.SetUp();
 1420            Environment.i.world.sceneBoundsChecker.timeBetweenChecks = 0f;
 1421        }
 22
 23        [UnityTest]
 224        public IEnumerator EntitiesAreBeingCorrectlyRegistered() { yield return SBC_Asserts.EntitiesAreBeingCorrectlyReg
 25
 26        [UnityTest]
 227        public IEnumerator PShapeIsInvalidatedWhenStartingOutOfBounds() { yield return SBC_Asserts.PShapeIsInvalidatedWh
 28
 29        [UnityTest]
 230        public IEnumerator GLTFShapeIsInvalidatedWhenStartingOutOfBounds() { yield return SBC_Asserts.GLTFShapeIsInvalid
 31
 32        [UnityTest]
 33        [Explicit("Test taking too long")]
 34        [Category("Explicit")]
 035        public IEnumerator NFTShapeIsInvalidatedWhenStartingOutOfBounds() { yield return SBC_Asserts.NFTShapeIsInvalidat
 36
 37        [UnityTest]
 238        public IEnumerator PShapeIsInvalidatedWhenLeavingBounds() { yield return SBC_Asserts.PShapeIsInvalidatedWhenLeav
 39
 40        [UnityTest]
 241        public IEnumerator GLTFShapeIsInvalidatedWhenLeavingBounds() { yield return SBC_Asserts.GLTFShapeIsInvalidatedWh
 42
 43        [UnityTest]
 44        [Explicit("Test taking too long")]
 45        [Category("Explicit")]
 046        public IEnumerator NFTShapeIsInvalidatedWhenLeavingBounds() { yield return SBC_Asserts.NFTShapeIsInvalidatedWhen
 47
 48        [UnityTest]
 249        public IEnumerator PShapeIsResetWhenReenteringBounds() { yield return SBC_Asserts.PShapeIsResetWhenReenteringBou
 50
 51        [UnityTest]
 52        [NUnit.Framework.Explicit("This test started failing on the CI out of the blue. Will be re-enabled after impleme
 53        [Category("Explicit")]
 054        public IEnumerator GLTFShapeIsResetWhenReenteringBounds() { yield return SBC_Asserts.GLTFShapeIsResetWhenReenter
 55
 56        [UnityTest]
 57        [Explicit("Test taking too long")]
 58        [Category("Explicit")]
 059        public IEnumerator NFTShapeIsResetWhenReenteringBounds() { yield return SBC_Asserts.NFTShapeIsResetWhenReenterin
 60
 61        [UnityTest]
 262        public IEnumerator ChildShapeIsEvaluated() { yield return SBC_Asserts.ChildShapeIsEvaluated(scene); }
 63
 64        [UnityTest]
 265        public IEnumerator ChildShapeIsEvaluatedOnShapelessParent() { yield return SBC_Asserts.ChildShapeIsEvaluatedOnSh
 66
 67        [UnityTest]
 268        public IEnumerator HeightIsEvaluated() { yield return SBC_Asserts.HeightIsEvaluated(scene); }
 69
 70        [UnityTest]
 71        public IEnumerator AudioSourceIsMuted()
 72        {
 173            var entity = TestHelpers.CreateSceneEntity(scene);
 74
 175            TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model { position = new Vector3(-28, 1, 8) });
 176            yield return TestHelpers.CreateAudioSourceWithClipForEntity(entity);
 77
 178            AudioSource dclAudioSource = entity.gameObject.GetComponentInChildren<AudioSource>();
 179            Assert.AreEqual(0, dclAudioSource.volume);
 180        }
 81
 82        [UnityTest]
 83        public IEnumerator AudioSourceWithMeshIsDisabled()
 84        {
 185            TestHelpers.CreateEntityWithGLTFShape(scene, new Vector3(8, 1, 8), TestAssetsUtils.GetPath() + "/GLB/PalmTre
 186            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(entity);
 787            yield return new UnityEngine.WaitUntil(() => gltfShape.alreadyLoaded);
 188            TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model { position = new Vector3(-28, 1, 8) });
 189            yield return TestHelpers.CreateAudioSourceWithClipForEntity(entity);
 90
 191            AudioSource dclAudioSource = entity.gameObject.GetComponentInChildren<AudioSource>();
 192            Assert.AreEqual(0, dclAudioSource.volume);
 193        }
 94
 95        [UnityTest]
 96        public IEnumerator HighPrioEntitiesAreRegistered_Position()
 97        {
 198            var boxShape1 = TestHelpers.CreateEntityWithBoxShape(scene, new Vector3(SceneBoundsChecker.TRIGGER_HIGHPRIO_
 199            var boxShape2 = TestHelpers.CreateEntityWithBoxShape(scene, new Vector3(0, SceneBoundsChecker.TRIGGER_HIGHPR
 1100            var boxShape3 = TestHelpers.CreateEntityWithBoxShape(scene, new Vector3(0, 0, SceneBoundsChecker.TRIGGER_HIG
 101
 1102            var entity1 = boxShape1.attachedEntities.First();
 1103            var entity2 = boxShape2.attachedEntities.First();
 1104            var entity3 = boxShape3.attachedEntities.First();
 105
 1106            Assert.AreEqual(3, Environment.i.world.sceneBoundsChecker.highPrioEntitiesToCheckCount, "entities to check c
 107
 1108            yield return null;
 109
 1110            TestHelpers.RemoveSceneEntity(scene, entity1.entityId);
 1111            TestHelpers.RemoveSceneEntity(scene, entity2.entityId);
 1112            TestHelpers.RemoveSceneEntity(scene, entity3.entityId);
 113
 1114            Environment.i.platform.parcelScenesCleaner.ForceCleanup();
 115
 1116            Assert.AreEqual(0, Environment.i.world.sceneBoundsChecker.highPrioEntitiesToCheckCount, "entities to check s
 1117        }
 118
 119        [UnityTest]
 120        public IEnumerator HighPrioEntitiesAreRegistered_Scale()
 121        {
 1122            var boxShape1 = TestHelpers.CreateEntityWithBoxShape(scene, Vector3.one);
 1123            var boxShape2 = TestHelpers.CreateEntityWithBoxShape(scene, Vector3.one);
 1124            var boxShape3 = TestHelpers.CreateEntityWithBoxShape(scene, Vector3.one);
 125
 1126            var entity1 = boxShape1.attachedEntities.First();
 1127            TestHelpers.SetEntityTransform(scene, entity1, Vector3.one, Quaternion.identity, new Vector3(SceneBoundsChec
 1128            var entity2 = boxShape2.attachedEntities.First();
 1129            TestHelpers.SetEntityTransform(scene, entity2, Vector3.one, Quaternion.identity, new Vector3(0, SceneBoundsC
 1130            var entity3 = boxShape3.attachedEntities.First();
 1131            TestHelpers.SetEntityTransform(scene, entity3, Vector3.one, Quaternion.identity, new Vector3(0, 0, SceneBoun
 132
 1133            Assert.AreEqual(3, Environment.i.world.sceneBoundsChecker.highPrioEntitiesToCheckCount, "entities to check c
 134
 1135            yield return null;
 136
 1137            TestHelpers.RemoveSceneEntity(scene, entity1.entityId);
 1138            TestHelpers.RemoveSceneEntity(scene, entity2.entityId);
 1139            TestHelpers.RemoveSceneEntity(scene, entity3.entityId);
 140
 1141            Environment.i.platform.parcelScenesCleaner.ForceCleanup();
 142
 1143            Assert.AreEqual(0, Environment.i.world.sceneBoundsChecker.highPrioEntitiesToCheckCount, "entities to check s
 1144        }
 145
 146        [UnityTest]
 147        public IEnumerator AudioSourcePlaysBackOnReentering()
 148        {
 1149            var entity = TestHelpers.CreateSceneEntity(scene);
 150
 1151            TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model { position = new Vector3(-28, 1, 8) });
 1152            yield return TestHelpers.CreateAudioSourceWithClipForEntity(entity);
 1153            TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model { position = new Vector3(2, 1, 2) });
 1154            yield return null;
 155
 1156            AudioSource dclAudioSource = entity.gameObject.GetComponentInChildren<AudioSource>();
 1157            Assert.IsTrue(dclAudioSource.enabled);
 1158        }
 159    }
 160}