2022-07-25 14:36:05 +08:00
|
|
|
#include <SFML/Audio/SoundStream.hpp>
|
|
|
|
|
2024-04-12 02:40:15 +08:00
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
|
|
|
2023-04-16 10:50:24 +08:00
|
|
|
#include <AudioUtil.hpp>
|
|
|
|
#include <SystemUtil.hpp>
|
2022-07-25 14:36:05 +08:00
|
|
|
#include <type_traits>
|
|
|
|
|
2023-04-16 10:50:24 +08:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
class SoundStream : public sf::SoundStream
|
|
|
|
{
|
|
|
|
[[nodiscard]] bool onGetData(Chunk& /* data */) override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void onSeek(sf::Time /* timeOffset */) override
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
TEST_CASE("[Audio] sf::SoundStream", runAudioDeviceTests())
|
2024-04-12 02:40:15 +08:00
|
|
|
{
|
|
|
|
SECTION("Type traits")
|
|
|
|
{
|
|
|
|
STATIC_CHECK(!std::is_constructible_v<sf::SoundStream>);
|
|
|
|
STATIC_CHECK(!std::is_copy_constructible_v<sf::SoundStream>);
|
|
|
|
STATIC_CHECK(!std::is_copy_assignable_v<sf::SoundStream>);
|
|
|
|
STATIC_CHECK(!std::is_nothrow_move_constructible_v<sf::SoundStream>);
|
2024-06-09 02:05:39 +08:00
|
|
|
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::SoundStream>);
|
2023-04-16 10:50:24 +08:00
|
|
|
STATIC_CHECK(std::has_virtual_destructor_v<sf::SoundStream>);
|
2024-04-12 02:40:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Chunk")
|
|
|
|
{
|
|
|
|
const sf::SoundStream::Chunk chunk;
|
|
|
|
CHECK(chunk.samples == nullptr);
|
|
|
|
CHECK(chunk.sampleCount == 0);
|
|
|
|
}
|
2023-04-16 10:50:24 +08:00
|
|
|
|
|
|
|
SECTION("Construction")
|
|
|
|
{
|
|
|
|
const SoundStream soundStream;
|
|
|
|
CHECK(soundStream.getChannelCount() == 0);
|
|
|
|
CHECK(soundStream.getSampleRate() == 0);
|
2024-05-17 02:57:40 +08:00
|
|
|
CHECK(soundStream.getStatus() == sf::SoundStream::Status::Stopped);
|
2023-04-16 10:50:24 +08:00
|
|
|
CHECK(soundStream.getPlayingOffset() == sf::Time::Zero);
|
|
|
|
CHECK(!soundStream.getLoop());
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Set/get playing offset")
|
|
|
|
{
|
|
|
|
SoundStream soundStream;
|
|
|
|
soundStream.setPlayingOffset(sf::milliseconds(100));
|
|
|
|
CHECK(soundStream.getPlayingOffset() == sf::milliseconds(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Set/get loop")
|
|
|
|
{
|
|
|
|
SoundStream soundStream;
|
|
|
|
soundStream.setLoop(true);
|
|
|
|
CHECK(soundStream.getLoop());
|
|
|
|
}
|
2024-04-12 02:40:15 +08:00
|
|
|
}
|