From 4fa3de519c90fe4fed547fd6417df217abfd9ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 20 Mar 2022 19:41:46 +0100 Subject: [PATCH] Adjust sound unit tests --- tests/Engine/Audio/MusicTest.cpp | 18 ++++++++++++------ tests/Engine/Audio/SoundTest.cpp | 23 +++++++++++++++-------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/tests/Engine/Audio/MusicTest.cpp b/tests/Engine/Audio/MusicTest.cpp index 05569ee18..b52beb039 100644 --- a/tests/Engine/Audio/MusicTest.cpp +++ b/tests/Engine/Audio/MusicTest.cpp @@ -18,15 +18,21 @@ SCENARIO("Music", "[AUDIO][MUSIC]") THEN("We can ask the informations of the file") { - CHECK(music.GetDuration() <= 64000); // 1 min 03 = 63s = 63000ms - CHECK(music.GetDuration() >= 63000); + CHECK(music.GetDuration() == 63059); // 1 min 03 = 63s = 63000ms CHECK(music.GetFormat() == Nz::AudioFormat::I16_Stereo); CHECK(music.GetPlayingOffset() == 0); - CHECK(music.GetSampleCount() <= 5644800); // 64s * 44100 Hz * 2 (stereo) - CHECK(music.GetSampleCount() >= 5556600); // 63s * 44100 Hz * 2 (stereo) + CHECK(music.GetSampleCount() <= 64 * 44100 * 2); // * 2 (stereo) + CHECK(music.GetSampleCount() >= 63 * 44100 * 2); // * 2 (stereo) CHECK(music.GetSampleRate() == 44100 /* Hz */); CHECK(music.GetStatus() == Nz::SoundStatus::Stopped); - CHECK(music.IsLooping() == false); + CHECK_FALSE(music.IsLooping()); + CHECK(music.IsSpatializationEnabled()); + CHECK(music.GetMinDistance() == 1.f); + CHECK(music.GetPitch() == 1.f); + CHECK(music.GetPlayingOffset() == 0); + CHECK(music.GetPosition() == Nz::Vector3f::Zero()); + CHECK(music.GetVelocity() == Nz::Vector3f::Zero()); + CHECK(music.GetVolume() == 1.f); } THEN("We can play it and get the time offset") @@ -38,7 +44,7 @@ SCENARIO("Music", "[AUDIO][MUSIC]") std::this_thread::sleep_for(std::chrono::seconds(1)); CHECK(music.GetPlayingOffset() >= 950); std::this_thread::sleep_for(std::chrono::milliseconds(200)); - CHECK(music.GetPlayingOffset() <= 1300); + CHECK(music.GetPlayingOffset() <= 1500); music.SetPlayingOffset(4200); CHECK(music.GetStatus() == Nz::SoundStatus::Playing); diff --git a/tests/Engine/Audio/SoundTest.cpp b/tests/Engine/Audio/SoundTest.cpp index 08ffc624d..ff71f57c0 100644 --- a/tests/Engine/Audio/SoundTest.cpp +++ b/tests/Engine/Audio/SoundTest.cpp @@ -18,10 +18,17 @@ SCENARIO("Sound", "[AUDIO][SOUND]") THEN("We can ask the informations of the file") { - REQUIRE(sound.GetDuration() <= 8500); // 8s = 8000ms - REQUIRE(sound.GetDuration() >= 8000); - REQUIRE(sound.GetStatus() == Nz::SoundStatus::Stopped); - REQUIRE(sound.IsLooping() == false); + CHECK(sound.GetDuration() == 8192); + CHECK(sound.GetStatus() == Nz::SoundStatus::Stopped); + CHECK_FALSE(sound.IsLooping()); + CHECK(sound.IsPlayable()); + CHECK(sound.IsSpatializationEnabled()); + CHECK(sound.GetMinDistance() == 1.f); + CHECK(sound.GetPitch() == 1.f); + CHECK(sound.GetPlayingOffset() == 0); + CHECK(sound.GetPosition() == Nz::Vector3f::Zero()); + CHECK(sound.GetVelocity() == Nz::Vector3f::Zero()); + CHECK(sound.GetVolume() == 1.f); } THEN("We can play it and get the time offset") @@ -30,14 +37,14 @@ SCENARIO("Sound", "[AUDIO][SOUND]") sound.Play(); std::this_thread::sleep_for(std::chrono::seconds(1)); - REQUIRE(sound.GetPlayingOffset() >= 950); + CHECK(sound.GetPlayingOffset() >= 950); std::this_thread::sleep_for(std::chrono::milliseconds(200)); - REQUIRE(sound.GetPlayingOffset() <= 1300); + CHECK(sound.GetPlayingOffset() <= 1500); sound.Pause(); - REQUIRE(sound.GetStatus() == Nz::SoundStatus::Paused); + CHECK(sound.GetStatus() == Nz::SoundStatus::Paused); sound.SetPlayingOffset(3500); - REQUIRE(sound.GetPlayingOffset() >= 3500); + CHECK(sound.GetPlayingOffset() == 3500); Nz::Audio::Instance()->GetDefaultDevice()->SetGlobalVolume(100.f); }