Audio: Add dummy device (in case OpenAL fails to load) and unifiate unit tests
This commit is contained in:
@@ -34,15 +34,24 @@ SCENARIO("Music", "[AUDIO][MUSIC]")
|
||||
Nz::Audio::Instance()->GetDefaultDevice()->SetGlobalVolume(0.f);
|
||||
|
||||
music.Play();
|
||||
CHECK(music.GetStatus() == Nz::SoundStatus::Playing);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
REQUIRE(music.GetPlayingOffset() >= 950);
|
||||
CHECK(music.GetPlayingOffset() >= 950);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
REQUIRE(music.GetPlayingOffset() <= 1300);
|
||||
CHECK(music.GetPlayingOffset() <= 1300);
|
||||
|
||||
music.SetPlayingOffset(4200);
|
||||
CHECK(music.GetStatus() == Nz::SoundStatus::Playing);
|
||||
CHECK(music.GetPlayingOffset() >= 4150);
|
||||
CHECK(music.GetPlayingOffset() < 4500);
|
||||
CHECK(music.GetStatus() == Nz::SoundStatus::Playing);
|
||||
|
||||
music.Pause();
|
||||
REQUIRE(music.GetStatus() == Nz::SoundStatus::Paused);
|
||||
CHECK(music.GetStatus() == Nz::SoundStatus::Paused);
|
||||
|
||||
music.SetPlayingOffset(3500);
|
||||
REQUIRE(music.GetPlayingOffset() >= 3500);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
CHECK(music.GetPlayingOffset() == 3500);
|
||||
|
||||
Nz::Audio::Instance()->GetDefaultDevice()->SetGlobalVolume(100.f);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#define CATCH_CONFIG_RUNNER
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include <Nazara/Audio/Audio.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Core/AbstractLogger.hpp>
|
||||
#include <Nazara/Core/Modules.hpp>
|
||||
@@ -12,7 +13,7 @@
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Nz::Modules<Nz::Network, Nz::Physics2D, Nz::Shader, Nz::Utility> nazaza;
|
||||
Nz::Modules<Nz::Audio, Nz::Network, Nz::Physics2D, Nz::Shader, Nz::Utility> nazaza;
|
||||
|
||||
if (!glslang::InitializeProcess())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#define CATCH_CONFIG_RUNNER
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include <Nazara/Audio/Audio.hpp>
|
||||
#include <Nazara/Core/AbstractLogger.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Core/Modules.hpp>
|
||||
#include <Nazara/Network/Network.hpp>
|
||||
#include <Nazara/Physics2D/Physics2D.hpp>
|
||||
#include <Nazara/Shader/Shader.hpp>
|
||||
#include <Nazara/Utility/Utility.hpp>
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Nz::Modules<Nz::Audio, Nz::Network, Nz::Physics2D, Nz::Shader, Nz::Utility> nazaza;
|
||||
|
||||
if (!glslang::InitializeProcess())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
int result = Catch::Session().run(argc, argv);
|
||||
|
||||
glslang::FinalizeProcess();
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -17,7 +17,7 @@ if has_config("tests") then
|
||||
set_group("Tests")
|
||||
set_kind("binary")
|
||||
|
||||
add_deps("NazaraCore", "NazaraNetwork", "NazaraPhysics2D", "NazaraShader")
|
||||
add_deps("NazaraAudio", "NazaraCore", "NazaraNetwork", "NazaraPhysics2D", "NazaraShader")
|
||||
add_packages("catch2", "entt", "glslang", "spirv-tools")
|
||||
add_headerfiles("Engine/**.hpp")
|
||||
add_files("resources.cpp")
|
||||
@@ -28,18 +28,8 @@ if has_config("tests") then
|
||||
add_rules("c++.unity_build")
|
||||
end
|
||||
|
||||
target("NazaraClientUnitTests")
|
||||
add_deps("NazaraAudio")
|
||||
add_files("main_client.cpp", {unity_ignored = true})
|
||||
|
||||
if has_config("usepch") then
|
||||
set_pcxxheader("Engine/ClientModules.hpp")
|
||||
end
|
||||
|
||||
target("NazaraUnitTests")
|
||||
add_files("main.cpp", {unity_ignored = true})
|
||||
remove_headerfiles("Engine/Audio/**")
|
||||
remove_files("Engine/Audio/**")
|
||||
|
||||
if has_config("usepch") then
|
||||
set_pcxxheader("Engine/Modules.hpp")
|
||||
|
||||
Reference in New Issue
Block a user