mirror of https://github.com/mosra/magnum.git
Browse Source
Added a new enabled-by-default BUILD_AL_TESTS CMake option. The test cases that actually require OpenAL context were split to new tests with `*ALTest` suffix so they can be executed selectively.pull/175/merge
13 changed files with 450 additions and 261 deletions
@ -0,0 +1,52 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <Corrade/TestSuite/Tester.h> |
||||
|
||||
#include "Magnum/Audio/Buffer.h" |
||||
#include "Magnum/Audio/Context.h" |
||||
|
||||
namespace Magnum { namespace Audio { namespace Test { |
||||
|
||||
struct BufferALTest: TestSuite::Tester { |
||||
explicit BufferALTest(); |
||||
|
||||
void construct(); |
||||
|
||||
Context _context; |
||||
}; |
||||
|
||||
BufferALTest::BufferALTest() { |
||||
addTests({&BufferALTest::construct}); |
||||
} |
||||
|
||||
void BufferALTest::construct() { |
||||
Buffer buf; |
||||
CORRADE_VERIFY(buf.id() != 0); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Audio::Test::BufferALTest) |
||||
@ -0,0 +1,60 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
Copyright © 2015 Jonathan Hale <squareys@googlemail.com> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <Corrade/TestSuite/Tester.h> |
||||
|
||||
#include "Magnum/Audio/Extensions.h" |
||||
#include "Magnum/Audio/Context.h" |
||||
|
||||
namespace Magnum { namespace Audio { namespace Test { |
||||
|
||||
struct ContextALTest: TestSuite::Tester { |
||||
explicit ContextALTest(); |
||||
|
||||
void extensionsString(); |
||||
void isExtensionEnabled(); |
||||
|
||||
Context _context; |
||||
}; |
||||
|
||||
ContextALTest::ContextALTest() { |
||||
addTests({&ContextALTest::extensionsString, |
||||
&ContextALTest::isExtensionEnabled}); |
||||
} |
||||
|
||||
void ContextALTest::extensionsString() { |
||||
std::vector<std::string> extensions = _context.extensionStrings(); |
||||
|
||||
CORRADE_VERIFY(extensions.size() > 0); |
||||
} |
||||
|
||||
void ContextALTest::isExtensionEnabled() { |
||||
CORRADE_VERIFY(Context::current().isExtensionSupported<Extensions::ALC::EXT::ENUMERATION>()); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Audio::Test::ContextALTest) |
||||
@ -0,0 +1,110 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <Corrade/TestSuite/Tester.h> |
||||
|
||||
#include "Magnum/Audio/Context.h" |
||||
#include "Magnum/Audio/Renderer.h" |
||||
|
||||
namespace Magnum { namespace Audio { namespace Test { |
||||
|
||||
struct RendererALTest: TestSuite::Tester { |
||||
explicit RendererALTest(); |
||||
|
||||
void listenerOrientation(); |
||||
void listenerPosition(); |
||||
void listenerVelocity(); |
||||
void listenerGain(); |
||||
void speedOfSound(); |
||||
void dopplerFactor(); |
||||
void distanceModel(); |
||||
|
||||
Context _context; |
||||
}; |
||||
|
||||
RendererALTest::RendererALTest() { |
||||
addTests({&RendererALTest::listenerOrientation, |
||||
&RendererALTest::listenerPosition, |
||||
&RendererALTest::listenerVelocity, |
||||
&RendererALTest::listenerGain, |
||||
&RendererALTest::speedOfSound, |
||||
&RendererALTest::dopplerFactor, |
||||
&RendererALTest::distanceModel}); |
||||
} |
||||
|
||||
void RendererALTest::listenerOrientation() { |
||||
constexpr Vector3 up{1.0f, 2.0f, 3.0f}, fwd{3.0f, 2.0f, 1.0f}; |
||||
Renderer::setListenerOrientation(fwd, up); |
||||
std::array<Vector3, 2> orientation = Renderer::listenerOrientation(); |
||||
|
||||
CORRADE_COMPARE(orientation[0], fwd); |
||||
CORRADE_COMPARE(orientation[1], up); |
||||
} |
||||
|
||||
void RendererALTest::listenerPosition() { |
||||
constexpr Vector3 pos{1.0f, 3.0f, 2.0f}; |
||||
Renderer::setListenerPosition(pos); |
||||
|
||||
CORRADE_COMPARE(Renderer::listenerPosition(), pos); |
||||
} |
||||
|
||||
void RendererALTest::listenerVelocity() { |
||||
constexpr Vector3 vel{1.0f, 3.0f, 2.0f}; |
||||
Renderer::setListenerVelocity(vel); |
||||
|
||||
CORRADE_COMPARE(Renderer::listenerVelocity(), vel); |
||||
} |
||||
|
||||
void RendererALTest::listenerGain() { |
||||
constexpr Float gain = 0.512f; |
||||
Renderer::setListenerGain(gain); |
||||
|
||||
CORRADE_COMPARE(Renderer::listenerGain(), gain); |
||||
} |
||||
|
||||
void RendererALTest::speedOfSound() { |
||||
constexpr Float speed = 1.25f; |
||||
Renderer::setSpeedOfSound(speed); |
||||
|
||||
CORRADE_COMPARE(Renderer::speedOfSound(), speed); |
||||
} |
||||
|
||||
void RendererALTest::dopplerFactor() { |
||||
constexpr Float factor = 0.3335f; |
||||
Renderer::setDopplerFactor(factor); |
||||
|
||||
CORRADE_COMPARE(Renderer::dopplerFactor(), factor); |
||||
} |
||||
|
||||
void RendererALTest::distanceModel() { |
||||
constexpr Renderer::DistanceModel model = Renderer::DistanceModel::InverseClamped; |
||||
Renderer::setDistanceModel(model); |
||||
|
||||
CORRADE_COMPARE(Renderer::distanceModel(), model); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Audio::Test::RendererALTest) |
||||
@ -0,0 +1,173 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <Corrade/TestSuite/Tester.h> |
||||
|
||||
#include "Magnum/Audio/Context.h" |
||||
#include "Magnum/Audio/Source.h" |
||||
|
||||
namespace Magnum { namespace Audio { namespace Test { |
||||
|
||||
struct SourceALTest: TestSuite::Tester { |
||||
explicit SourceALTest(); |
||||
|
||||
void construct(); |
||||
|
||||
void position(); |
||||
void direction(); |
||||
void velocity(); |
||||
void gain(); |
||||
void looping(); |
||||
void relative(); |
||||
void maxDistance(); |
||||
void maxGain(); |
||||
void minGain(); |
||||
void coneAnglesAndGain(); |
||||
void rolloffFactor(); |
||||
|
||||
Context _context; |
||||
}; |
||||
|
||||
SourceALTest::SourceALTest() { |
||||
addTests({&SourceALTest::construct, |
||||
|
||||
&SourceALTest::position, |
||||
&SourceALTest::direction, |
||||
&SourceALTest::velocity, |
||||
&SourceALTest::gain, |
||||
&SourceALTest::looping, |
||||
&SourceALTest::relative, |
||||
&SourceALTest::maxDistance, |
||||
&SourceALTest::maxGain, |
||||
&SourceALTest::minGain, |
||||
&SourceALTest::coneAnglesAndGain, |
||||
&SourceALTest::rolloffFactor}); |
||||
} |
||||
|
||||
void SourceALTest::construct() { |
||||
Source source; |
||||
CORRADE_VERIFY(source.id() != 0); |
||||
} |
||||
|
||||
void SourceALTest::position() { |
||||
Source source; |
||||
constexpr Vector3 pos{3.0f, 5.0f, 6.0f}; |
||||
source.setPosition(pos); |
||||
|
||||
CORRADE_COMPARE(source.position(), pos); |
||||
} |
||||
|
||||
void SourceALTest::direction() { |
||||
Source source; |
||||
constexpr Vector3 dir{3.0f, 1.0f, 2.0f}; |
||||
source.setDirection(dir); |
||||
|
||||
CORRADE_COMPARE(source.direction(), dir); |
||||
} |
||||
|
||||
void SourceALTest::velocity() { |
||||
Source source; |
||||
constexpr Vector3 vel{-3.0f, 5.0f, -6.0f}; |
||||
source.setVelocity(vel); |
||||
|
||||
CORRADE_COMPARE(source.velocity(), vel); |
||||
} |
||||
|
||||
void SourceALTest::gain() { |
||||
Source source; |
||||
constexpr Float gain = 0.1234f; |
||||
source.setGain(gain); |
||||
|
||||
CORRADE_COMPARE(source.gain(), gain); |
||||
} |
||||
|
||||
void SourceALTest::looping() { |
||||
Source source; |
||||
source.setLooping(true); |
||||
CORRADE_VERIFY(source.isLooping()); |
||||
source.setLooping(false); |
||||
CORRADE_VERIFY(!source.isLooping()); |
||||
} |
||||
|
||||
void SourceALTest::relative() { |
||||
Source source; |
||||
source.setRelative(true); |
||||
CORRADE_VERIFY(source.isRelative()); |
||||
source.setRelative(false); |
||||
CORRADE_VERIFY(!source.isRelative()); |
||||
} |
||||
|
||||
void SourceALTest::maxDistance() { |
||||
Source source; |
||||
constexpr Float dist = 0.222f; |
||||
source.setMaxDistance(dist); |
||||
|
||||
CORRADE_COMPARE(source.maxDistance(), dist); |
||||
} |
||||
|
||||
void SourceALTest::maxGain() { |
||||
Source source; |
||||
constexpr Float gain = 0.3131f; |
||||
source.setMaxGain(gain); |
||||
|
||||
CORRADE_COMPARE(source.maxGain(), gain); |
||||
} |
||||
|
||||
void SourceALTest::minGain() { |
||||
Source source; |
||||
constexpr Float gain = 0.4144f; |
||||
source.setMinGain(gain); |
||||
|
||||
CORRADE_COMPARE(source.minGain(), gain); |
||||
} |
||||
|
||||
void SourceALTest::coneAnglesAndGain() { |
||||
using namespace Math::Literals; |
||||
|
||||
Source source; |
||||
constexpr auto outerAngle = 12.0_degf; |
||||
constexpr auto innerAngle = 21.0_degf; |
||||
constexpr Float outerGain = 0.05f; |
||||
|
||||
source.setInnerConeAngle(innerAngle); |
||||
source.setOuterConeAngle(outerAngle); |
||||
source.setOuterConeGain(outerGain); |
||||
|
||||
CORRADE_COMPARE(source.outerConeAngle(), outerAngle); |
||||
CORRADE_COMPARE(source.innerConeAngle(), innerAngle); |
||||
CORRADE_COMPARE(source.outerConeGain(), outerGain); |
||||
} |
||||
|
||||
void SourceALTest::rolloffFactor() { |
||||
Source source; |
||||
constexpr Float fact = 42.0f; |
||||
source.setRolloffFactor(fact); |
||||
|
||||
CORRADE_COMPARE(source.rolloffFactor(), fact); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Audio::Test::SourceALTest) |
||||
Loading…
Reference in new issue