Exemple #1
0
        public void TestPause()
        {
            //////////////////////////////////////////////////////////////////////////////////
            // 1. Check that pausing an Disposed instance throw the 'ObjectDisposedException'
            var dispInst = SoundMusic.Load(defaultEngine, OpenDataBaseStream("EffectToneA"));

            dispInst.Dispose();
            Assert.Throws <ObjectDisposedException>(dispInst.Pause, "SoundMusic.Pause did not throw the 'ObjectDisposedException' when called from a disposed object.");

            //////////////////////////////////////////////////////////////////////////
            // 2. Check that Pause does not crash when the sound is not started/stopped
            Assert.DoesNotThrow(monoInstance.Pause, "Call to SoundMusic.Pause crashed throwing an exception with a stopped sound.");

            //////////////////////////////////////////////////////////////////////////////////////////
            // 3. Check that Pause does not crash and has the correct effect when called after playing
            mp3Instance.Play();
            ActiveAudioEngineUpdate(2000);
            Assert.DoesNotThrow(mp3Instance.Pause, "Call to SoundMusic.Pause crashed throwing an exception.");
            ActiveAudioEngineUpdate(500);
            mp3Instance.Play();
            ActiveAudioEngineUpdate(2000);

            ////////////////////////////////////////////////////////////////////
            // 4. Check that a second call to Pause while playing does not crash
            mp3Instance.Play();
            mp3Instance.Pause();
            Assert.DoesNotThrow(mp3Instance.Pause, "Second call to SoundMusic.Pause while paused crashed throwing an exception.");

            ///////////////////////////////////////////////////////////////
            // 5. Check that Pause from another instance has no influence
            mp3Instance.Play();
            monoInstance.Pause();
            ActiveAudioEngineUpdate(1000);
            Assert.AreEqual(SoundPlayState.Playing, mp3Instance.PlayState, "Pause from another music instance stopped current music.");
            mp3Instance.Stop();
            ActiveAudioEngineUpdate(1000);
        }
        public void TestInvalidationDuringSoundMusicPlay()
        {
            sayuriPart.Play();

            // user should unplug and plug back the the headphone here
            // and check that sound restart without throwing any exceptions.
            var count = 0;

            while (count < 1500)
            {
                ++count;

                Assert.DoesNotThrow(() => sayuriPart.Pause());
                engine.Update();

                Assert.DoesNotThrow(() => sayuriPart.Play());
                engine.Update();

                Utilities.Sleep(10);
            }

            sayuriPart.Stop();
        }
Exemple #3
0
        public void TestPlay()
        {
            /////////////////////////////////////
            // 1. Check that Play does not crash
            Assert.DoesNotThrow(monoInstance.Play, "Call to SoundMusic.Play crashed throwing an exception.");

            ////////////////////////////////////////////////////////////////////
            // 2. Check that a second call to Play while playing does not crash
            Assert.DoesNotThrow(monoInstance.Play, "Second call to SoundMusic.Play while playing crashed throwing an exception.");

            ////////////////////////////////////////////
            // 3. Listen that the played sound is valid
            ActiveAudioEngineUpdate(1500);

            //////////////////////////////////////////////////////////////////
            // 4. Check that there is no crash when restarting the sound
            Assert.DoesNotThrow(monoInstance.Play, "Restarting the audio sound after it finishes crashed throwing an exception.");
            ActiveAudioEngineUpdate(200);

            //////////////////////////////////////////////////////////////////////////////////////////////////////
            // 5. Check  that there is no crash when playing after pausing the sound and that play flow is correct
            monoInstance.Pause();
            ActiveAudioEngineUpdate(200);
            Assert.DoesNotThrow(monoInstance.Play, "Restarting the audio sound after pausing it crashed throwing an exception.");
            ActiveAudioEngineUpdate(1500);

            //////////////////////////////////////////////////////////////////////////////////////////////////////
            // 6. Check that there is no crash when playing after stopping a sound and that the play flow restart
            monoInstance.Play();
            ActiveAudioEngineUpdate(200);

            monoInstance.Stop();
            ActiveAudioEngineUpdate(200);
            Assert.DoesNotThrow(monoInstance.Play, "Restarting the audio sound after stopping it crashed throwing an exception.");
            int timeCount = 0;

            while (monoInstance.PlayState == SoundPlayState.Playing)
            {
                ActiveAudioEngineUpdate(1000);
                timeCount += 1000;

                if (timeCount > 3000)
                {
                    Assert.Fail("SoundMusic.Play has not finished after 3 seconds.");
                }
            }

            ////////////////////////////////////////////////////////////////
            // 7. Play a stereo file a listen that the played sound is valid
            stereoInstance.Play();
            ActiveAudioEngineUpdate(3000);

            //////////////////////////////////////////////////////////////////////////////////
            // 8. Check that Playing an Disposed instance throw the 'ObjectDisposedException'
            var dispInstance = SoundMusic.Load(defaultEngine, OpenDataBaseStream("EffectToneA"));

            dispInstance.Dispose();
            Assert.Throws <ObjectDisposedException>(dispInstance.Play, "SoundEffectInstance.Play did not throw the 'ObjectDisposedException' when called from a disposed object.");

            ////////////////////////////////////////////////////////////////
            // 9. Play a mp3 file and listen that the played sound is valid
            mp3Instance.Play();
            ActiveAudioEngineUpdate(4000);

            //////////////////////////////////////////////////////////////////////////////
            // 10. Play another music and check that the previous one is correctly stopped
            monoInstance.Play();
            Assert.AreEqual(SoundPlayState.Playing, monoInstance.PlayState, "Mono intstance play status is not what it is supposed to be.");
            Assert.AreEqual(SoundPlayState.Stopped, mp3Instance.PlayState, "MP3 intstance play status is not what it is supposed to be.");
            ActiveAudioEngineUpdate(1500);
        }
Exemple #4
0
        public Office(Level level)
        {
            Level = level;

            CameraOffset = new Vector2(MAX_CAMERA_OFFSET / 2.0f, 0);

            lightswitchInput = new InputRegion(LIGHTSWITCH_INPUTBOX, false, (i) => {
                IsLightOn = !IsLightOn;

                if (IsLightOn)
                {
                    soundLightOn.Play();

                    if (!Level.IsHardBoiled)
                    {
                        musicClassicalish.Play();
                    }
                }
                else
                {
                    soundLightOff.Play();
                    Level.Monsters.GoldenFlumpty.Shoo();

                    if (!Level.IsHardBoiled)                     // Don't pause music in hard boiled mode
                    {
                        musicClassicalish.Pause();
                    }
                }
            });

            buttonLeftInput = new InputRegion(BUTTON_LEFT_OFFSET + CameraOffset, BUTTON_SIZE, true, (i) => {
                if (Vent != VentState.Left)
                {
                    Vent        = VentState.Left;
                    _ventMoving = true;
                    soundVent.Stop();
                    soundVent.Play();
                }
            });

            buttonRightInput = new InputRegion(BUTTON_RIGHT_OFFSET + CameraOffset, BUTTON_SIZE, false, (i) => {
                if (Vent != VentState.Right)
                {
                    Vent        = VentState.Right;
                    _ventMoving = true;
                    soundVent.Stop();
                    soundVent.Play();
                }
            });

            rawrInput = new InputRegion(RAWR_HITBOX_OFFSET + CameraOffset, RAWR_HITBOX_SIZE, true, (i) => {
                soundRawr.Stop();
                soundRawr.Play();                 // spammable
            });

            muteIntroInput = new InputRegion(MUTE_INTRO_INPUTBOX, false, (i) => {
                musicIntro.Stop();
                showMuteButton = false;
                muteButtonTimer.Stop();

                if (Level.IsHardBoiled)
                {
                    musicToreador.Play();
                }
                else
                {
                    musicClassicalish.Play();
                }
            });

            Vent = VentState.Left;
        }