| | 1 | | using DCL.Models; |
| | 2 | | using NUnit.Framework; |
| | 3 | | using System.Collections; |
| | 4 | | using System.Linq; |
| | 5 | | using DCL; |
| | 6 | | using DCL.Components; |
| | 7 | | using DCL.Controllers; |
| | 8 | | using DCL.Helpers; |
| | 9 | | using UnityEngine; |
| | 10 | | using UnityEngine.TestTools; |
| | 11 | |
|
| | 12 | | namespace SceneBoundariesCheckerTests |
| | 13 | | { |
| | 14 | | public class SceneBoundariesCheckerTests : IntegrationTestSuite_Legacy |
| | 15 | | { |
| | 16 | | [UnitySetUp] |
| | 17 | | protected override IEnumerator SetUp() |
| | 18 | | { |
| 14 | 19 | | yield return base.SetUp(); |
| 14 | 20 | | Environment.i.world.sceneBoundsChecker.timeBetweenChecks = 0f; |
| 14 | 21 | | } |
| | 22 | |
|
| | 23 | | [UnityTest] |
| 2 | 24 | | public IEnumerator EntitiesAreBeingCorrectlyRegistered() { yield return SBC_Asserts.EntitiesAreBeingCorrectlyReg |
| | 25 | |
|
| | 26 | | [UnityTest] |
| 2 | 27 | | public IEnumerator PShapeIsInvalidatedWhenStartingOutOfBounds() { yield return SBC_Asserts.PShapeIsInvalidatedWh |
| | 28 | |
|
| | 29 | | [UnityTest] |
| 2 | 30 | | public IEnumerator GLTFShapeIsInvalidatedWhenStartingOutOfBounds() { yield return SBC_Asserts.GLTFShapeIsInvalid |
| | 31 | |
|
| | 32 | | [UnityTest] |
| | 33 | | [Explicit("Test taking too long")] |
| | 34 | | [Category("Explicit")] |
| 0 | 35 | | public IEnumerator NFTShapeIsInvalidatedWhenStartingOutOfBounds() { yield return SBC_Asserts.NFTShapeIsInvalidat |
| | 36 | |
|
| | 37 | | [UnityTest] |
| 2 | 38 | | public IEnumerator PShapeIsInvalidatedWhenLeavingBounds() { yield return SBC_Asserts.PShapeIsInvalidatedWhenLeav |
| | 39 | |
|
| | 40 | | [UnityTest] |
| 2 | 41 | | public IEnumerator GLTFShapeIsInvalidatedWhenLeavingBounds() { yield return SBC_Asserts.GLTFShapeIsInvalidatedWh |
| | 42 | |
|
| | 43 | | [UnityTest] |
| | 44 | | [Explicit("Test taking too long")] |
| | 45 | | [Category("Explicit")] |
| 0 | 46 | | public IEnumerator NFTShapeIsInvalidatedWhenLeavingBounds() { yield return SBC_Asserts.NFTShapeIsInvalidatedWhen |
| | 47 | |
|
| | 48 | | [UnityTest] |
| 2 | 49 | | 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")] |
| 0 | 54 | | public IEnumerator GLTFShapeIsResetWhenReenteringBounds() { yield return SBC_Asserts.GLTFShapeIsResetWhenReenter |
| | 55 | |
|
| | 56 | | [UnityTest] |
| | 57 | | [Explicit("Test taking too long")] |
| | 58 | | [Category("Explicit")] |
| 0 | 59 | | public IEnumerator NFTShapeIsResetWhenReenteringBounds() { yield return SBC_Asserts.NFTShapeIsResetWhenReenterin |
| | 60 | |
|
| | 61 | | [UnityTest] |
| 2 | 62 | | public IEnumerator ChildShapeIsEvaluated() { yield return SBC_Asserts.ChildShapeIsEvaluated(scene); } |
| | 63 | |
|
| | 64 | | [UnityTest] |
| 2 | 65 | | public IEnumerator ChildShapeIsEvaluatedOnShapelessParent() { yield return SBC_Asserts.ChildShapeIsEvaluatedOnSh |
| | 66 | |
|
| | 67 | | [UnityTest] |
| 2 | 68 | | public IEnumerator HeightIsEvaluated() { yield return SBC_Asserts.HeightIsEvaluated(scene); } |
| | 69 | |
|
| | 70 | | [UnityTest] |
| | 71 | | public IEnumerator AudioSourceIsMuted() |
| | 72 | | { |
| 1 | 73 | | var entity = TestHelpers.CreateSceneEntity(scene); |
| | 74 | |
|
| 1 | 75 | | TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model { position = new Vector3(-28, 1, 8) }); |
| 1 | 76 | | yield return TestHelpers.CreateAudioSourceWithClipForEntity(entity); |
| | 77 | |
|
| 1 | 78 | | AudioSource dclAudioSource = entity.gameObject.GetComponentInChildren<AudioSource>(); |
| 1 | 79 | | Assert.AreEqual(0, dclAudioSource.volume); |
| 1 | 80 | | } |
| | 81 | |
|
| | 82 | | [UnityTest] |
| | 83 | | public IEnumerator AudioSourceWithMeshIsDisabled() |
| | 84 | | { |
| 1 | 85 | | TestHelpers.CreateEntityWithGLTFShape(scene, new Vector3(8, 1, 8), TestAssetsUtils.GetPath() + "/GLB/PalmTre |
| 1 | 86 | | LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(entity); |
| 7 | 87 | | yield return new UnityEngine.WaitUntil(() => gltfShape.alreadyLoaded); |
| 1 | 88 | | TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model { position = new Vector3(-28, 1, 8) }); |
| 1 | 89 | | yield return TestHelpers.CreateAudioSourceWithClipForEntity(entity); |
| | 90 | |
|
| 1 | 91 | | AudioSource dclAudioSource = entity.gameObject.GetComponentInChildren<AudioSource>(); |
| 1 | 92 | | Assert.AreEqual(0, dclAudioSource.volume); |
| 1 | 93 | | } |
| | 94 | |
|
| | 95 | | [UnityTest] |
| | 96 | | public IEnumerator HighPrioEntitiesAreRegistered_Position() |
| | 97 | | { |
| 1 | 98 | | var boxShape1 = TestHelpers.CreateEntityWithBoxShape(scene, new Vector3(SceneBoundsChecker.TRIGGER_HIGHPRIO_ |
| 1 | 99 | | var boxShape2 = TestHelpers.CreateEntityWithBoxShape(scene, new Vector3(0, SceneBoundsChecker.TRIGGER_HIGHPR |
| 1 | 100 | | var boxShape3 = TestHelpers.CreateEntityWithBoxShape(scene, new Vector3(0, 0, SceneBoundsChecker.TRIGGER_HIG |
| | 101 | |
|
| 1 | 102 | | var entity1 = boxShape1.attachedEntities.First(); |
| 1 | 103 | | var entity2 = boxShape2.attachedEntities.First(); |
| 1 | 104 | | var entity3 = boxShape3.attachedEntities.First(); |
| | 105 | |
|
| 1 | 106 | | Assert.AreEqual(3, Environment.i.world.sceneBoundsChecker.highPrioEntitiesToCheckCount, "entities to check c |
| | 107 | |
|
| 1 | 108 | | yield return null; |
| | 109 | |
|
| 1 | 110 | | TestHelpers.RemoveSceneEntity(scene, entity1.entityId); |
| 1 | 111 | | TestHelpers.RemoveSceneEntity(scene, entity2.entityId); |
| 1 | 112 | | TestHelpers.RemoveSceneEntity(scene, entity3.entityId); |
| | 113 | |
|
| 1 | 114 | | Environment.i.platform.parcelScenesCleaner.ForceCleanup(); |
| | 115 | |
|
| 1 | 116 | | Assert.AreEqual(0, Environment.i.world.sceneBoundsChecker.highPrioEntitiesToCheckCount, "entities to check s |
| 1 | 117 | | } |
| | 118 | |
|
| | 119 | | [UnityTest] |
| | 120 | | public IEnumerator HighPrioEntitiesAreRegistered_Scale() |
| | 121 | | { |
| 1 | 122 | | var boxShape1 = TestHelpers.CreateEntityWithBoxShape(scene, Vector3.one); |
| 1 | 123 | | var boxShape2 = TestHelpers.CreateEntityWithBoxShape(scene, Vector3.one); |
| 1 | 124 | | var boxShape3 = TestHelpers.CreateEntityWithBoxShape(scene, Vector3.one); |
| | 125 | |
|
| 1 | 126 | | var entity1 = boxShape1.attachedEntities.First(); |
| 1 | 127 | | TestHelpers.SetEntityTransform(scene, entity1, Vector3.one, Quaternion.identity, new Vector3(SceneBoundsChec |
| 1 | 128 | | var entity2 = boxShape2.attachedEntities.First(); |
| 1 | 129 | | TestHelpers.SetEntityTransform(scene, entity2, Vector3.one, Quaternion.identity, new Vector3(0, SceneBoundsC |
| 1 | 130 | | var entity3 = boxShape3.attachedEntities.First(); |
| 1 | 131 | | TestHelpers.SetEntityTransform(scene, entity3, Vector3.one, Quaternion.identity, new Vector3(0, 0, SceneBoun |
| | 132 | |
|
| 1 | 133 | | Assert.AreEqual(3, Environment.i.world.sceneBoundsChecker.highPrioEntitiesToCheckCount, "entities to check c |
| | 134 | |
|
| 1 | 135 | | yield return null; |
| | 136 | |
|
| 1 | 137 | | TestHelpers.RemoveSceneEntity(scene, entity1.entityId); |
| 1 | 138 | | TestHelpers.RemoveSceneEntity(scene, entity2.entityId); |
| 1 | 139 | | TestHelpers.RemoveSceneEntity(scene, entity3.entityId); |
| | 140 | |
|
| 1 | 141 | | Environment.i.platform.parcelScenesCleaner.ForceCleanup(); |
| | 142 | |
|
| 1 | 143 | | Assert.AreEqual(0, Environment.i.world.sceneBoundsChecker.highPrioEntitiesToCheckCount, "entities to check s |
| 1 | 144 | | } |
| | 145 | |
|
| | 146 | | [UnityTest] |
| | 147 | | public IEnumerator AudioSourcePlaysBackOnReentering() |
| | 148 | | { |
| 1 | 149 | | var entity = TestHelpers.CreateSceneEntity(scene); |
| | 150 | |
|
| 1 | 151 | | TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model { position = new Vector3(-28, 1, 8) }); |
| 1 | 152 | | yield return TestHelpers.CreateAudioSourceWithClipForEntity(entity); |
| 1 | 153 | | TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model { position = new Vector3(2, 1, 2) }); |
| 1 | 154 | | yield return null; |
| | 155 | |
|
| 1 | 156 | | AudioSource dclAudioSource = entity.gameObject.GetComponentInChildren<AudioSource>(); |
| 1 | 157 | | Assert.IsTrue(dclAudioSource.enabled); |
| 1 | 158 | | } |
| | 159 | | } |
| | 160 | | } |