Exemplo n.º 1
0
        public IEnumerator CreateAndLoadAudioClip(bool waitForLoading = true)
        {
            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene);

            yield return(null);

            yield return(TestHelpers.CreateAudioSourceWithClipForEntity(entity));

            DCLAudioSource dclAudioSource   = entity.gameObject.GetComponentInChildren <DCLAudioSource>();
            AudioSource    unityAudioSource = dclAudioSource.GetComponentInChildren <AudioSource>();

            Assert.IsTrue(scene.entities.ContainsKey(entity.entityId), "Entity was not created correctly!");
            Assert.IsTrue(dclAudioSource != null, "DCLAudioSource Creation Failure!");
            Assert.IsTrue(unityAudioSource != null, "Unity AudioSource Creation Failure!");

            yield return(dclAudioSource.routine);

            Assert.IsTrue(unityAudioSource.isPlaying, "Audio Source is not playing when it should!");

            //NOTE(Brian): Stop test
            yield return(TestHelpers.CreateAudioSource(scene,
                                                       entityId: entity.entityId,
                                                       audioClipId: "audioClipTest",
                                                       playing: false));

            yield return(null);

            Assert.IsTrue(!unityAudioSource.isPlaying, "Audio Source is playing when it should NOT play!");
        }
Exemplo n.º 2
0
        public IEnumerator VolumeIsUnmutedWhenUserEntersScene()
        {
            // We disable SceneController monobehaviour to avoid its current scene id update
            sceneController.enabled = false;

            // Set current scene as a different one
            CommonScriptableObjects.sceneID.Set("unexistent-scene");

            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene);

            yield return(null);

            yield return(TestHelpers.CreateAudioSourceWithClipForEntity(entity));

            DCLAudioSource dclAudioSource = entity.gameObject.GetComponentInChildren <DCLAudioSource>();

            yield return(dclAudioSource.routine);

            AudioSource unityAudioSource = dclAudioSource.GetComponentInChildren <AudioSource>();

            // Set current scene with this scene's id
            CommonScriptableObjects.sceneID.Set(scene.sceneData.id);

            // Check the volume
            Assert.AreEqual(unityAudioSource.volume, dclAudioSource.model.volume);
        }
Exemplo n.º 3
0
        public IEnumerator CreateAndLoadAudioClip(bool waitForLoading = true)
        {
            yield return(LoadAudioClip(scene,
                                       audioClipId: "audioClipTest",
                                       url: DCL.Helpers.Utils.GetTestsAssetsPath() + "/Audio/Train.wav",
                                       loop: true,
                                       loading: true,
                                       volume: 1.0f,
                                       waitForLoading: waitForLoading));

            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene);

            yield return(null);

            //NOTE(Brian): Play test
            yield return(CreateAudioSource(scene,
                                           entityId: entity.entityId,
                                           audioClipId: "audioClipTest",
                                           playing: true));

            DCLAudioSource dclAudioSource   = entity.gameObject.GetComponentInChildren <DCLAudioSource>();
            AudioSource    unityAudioSource = dclAudioSource.GetComponentInChildren <AudioSource>();

            Assert.IsTrue(scene.entities.ContainsKey(entity.entityId), "Entity was not created correctly!");
            Assert.IsTrue(dclAudioSource != null, "DCLAudioSource Creation Failure!");
            Assert.IsTrue(unityAudioSource != null, "Unity AudioSource Creation Failure!");

            yield return(dclAudioSource.routine);

            Assert.IsTrue(unityAudioSource.isPlaying, "Audio Source is not playing when it should!");

            //NOTE(Brian): Stop test
            yield return(CreateAudioSource(scene,
                                           entityId: entity.entityId,
                                           audioClipId: "audioClipTest",
                                           playing: false));

            yield return(null);

            Assert.IsTrue(!unityAudioSource.isPlaying, "Audio Source is playing when it should NOT play!");
        }
Exemplo n.º 4
0
        public IEnumerator VolumeWhenAudioCreatedWithNoUserInScene()
        {
            // We disable SceneController monobehaviour to avoid its current scene id update
            sceneController.enabled = false;

            // Set current scene as a different one
            CommonScriptableObjects.sceneID.Set("unexistent-scene");

            var entity = TestHelpers.CreateSceneEntity(scene);

            yield return(null);

            yield return(TestHelpers.CreateAudioSourceWithClipForEntity(entity));

            DCLAudioSource dclAudioSource = entity.gameObject.GetComponentInChildren <DCLAudioSource>();

            yield return(dclAudioSource.routine);

            AudioSource unityAudioSource = dclAudioSource.GetComponentInChildren <AudioSource>();

            // Check the volume
            Assert.AreEqual(0f, unityAudioSource.volume);
        }