mirror of https://github.com/mosra/magnum.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
5.2 KiB
148 lines
5.2 KiB
|
12 years ago
|
/*
|
||
|
|
This file is part of Magnum.
|
||
|
|
|
||
|
8 years ago
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
|
||
|
12 years ago
|
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 <sstream>
|
||
|
|
#include <Corrade/TestSuite/Tester.h>
|
||
|
|
|
||
|
|
#include "Magnum/Context.h"
|
||
|
8 years ago
|
#include "Magnum/Version.h"
|
||
|
12 years ago
|
|
||
|
|
namespace Magnum { namespace Test {
|
||
|
|
|
||
|
11 years ago
|
struct ContextTest: TestSuite::Tester {
|
||
|
|
explicit ContextTest();
|
||
|
12 years ago
|
|
||
|
8 years ago
|
void extensions();
|
||
|
|
|
||
|
11 years ago
|
void debugFlag();
|
||
|
9 years ago
|
void debugFlags();
|
||
|
9 years ago
|
|
||
|
|
void debugDetectedDriver();
|
||
|
|
void debugDetectedDrivers();
|
||
|
12 years ago
|
};
|
||
|
|
|
||
|
|
ContextTest::ContextTest() {
|
||
|
8 years ago
|
addTests({&ContextTest::extensions,
|
||
|
|
|
||
|
|
&ContextTest::debugFlag,
|
||
|
9 years ago
|
&ContextTest::debugFlags,
|
||
|
|
|
||
|
|
&ContextTest::debugDetectedDriver,
|
||
|
|
&ContextTest::debugDetectedDrivers});
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
8 years ago
|
void ContextTest::extensions() {
|
||
|
|
const char* used[Implementation::ExtensionCount]{};
|
||
|
|
|
||
|
|
/* Check that all extension indices are unique */
|
||
|
|
for(Version version: {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
Version::GL300,
|
||
|
|
Version::GL310,
|
||
|
|
Version::GL320,
|
||
|
|
Version::GL330,
|
||
|
|
Version::GL400,
|
||
|
|
Version::GL410,
|
||
|
|
Version::GL420,
|
||
|
|
Version::GL430,
|
||
|
|
Version::GL440,
|
||
|
|
Version::GL450,
|
||
|
|
Version::GL460,
|
||
|
|
#else
|
||
|
|
Version::GLES200,
|
||
|
|
Version::GLES300,
|
||
|
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
|
Version::GLES310,
|
||
|
|
Version::GLES320,
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
Version::None})
|
||
|
|
{
|
||
|
|
for(const Extension& e: Extension::extensions(version)) {
|
||
|
|
if(e.index() >= Implementation::ExtensionCount) {
|
||
|
|
Error{} << "Index" << e.index() << "used by" << e.string()
|
||
|
|
<< "larger than" << Implementation::ExtensionCount;
|
||
|
|
CORRADE_VERIFY(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
if(used[e.index()]) {
|
||
|
|
Error{} << "Index" << e.index() << "used by both"
|
||
|
|
<< used[e.index()] << "and" << e.string();
|
||
|
|
CORRADE_VERIFY(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
used[e.index()] = e.string();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
CORRADE_VERIFY(true);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void ContextTest::debugFlag() {
|
||
|
10 years ago
|
#ifdef MAGNUM_TARGET_WEBGL
|
||
|
|
CORRADE_SKIP("No context flags on Emscripten yet.");
|
||
|
|
#else
|
||
|
12 years ago
|
std::ostringstream out;
|
||
|
10 years ago
|
Debug(&out) << Context::Flag::Debug << Context::Flag(0xdead);
|
||
|
|
CORRADE_COMPARE(out.str(), "Context::Flag::Debug Context::Flag(0xdead)\n");
|
||
|
10 years ago
|
#endif
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
9 years ago
|
void ContextTest::debugFlags() {
|
||
|
|
#ifdef MAGNUM_TARGET_WEBGL
|
||
|
|
CORRADE_SKIP("No context flags on Emscripten yet.");
|
||
|
|
#else
|
||
|
|
std::ostringstream out;
|
||
|
|
Debug(&out) << Context::Flags{} << (Context::Flag::Debug|Context::Flag::NoError) << (Context::Flag::Debug|Context::Flag(0xded0));
|
||
|
|
CORRADE_COMPARE(out.str(), "Context::Flags{} Context::Flag::Debug|Context::Flag::NoError Context::Flag::Debug|Context::Flag(0xded0)\n");
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
9 years ago
|
void ContextTest::debugDetectedDriver() {
|
||
|
|
std::ostringstream out;
|
||
|
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
9 years ago
|
Debug{&out} << Context::DetectedDriver::Amd << Context::DetectedDriver(0xdead);
|
||
|
|
CORRADE_COMPARE(out.str(), "Context::DetectedDriver::Amd Context::DetectedDriver(0xdead)\n");
|
||
|
9 years ago
|
#else
|
||
|
9 years ago
|
Debug{&out} << Context::DetectedDriver::Angle << Context::DetectedDriver(0xdead);
|
||
|
|
CORRADE_COMPARE(out.str(), "Context::DetectedDriver::Angle Context::DetectedDriver(0xdead)\n");
|
||
|
9 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
|
void ContextTest::debugDetectedDrivers() {
|
||
|
|
std::ostringstream out;
|
||
|
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
9 years ago
|
Debug{&out} << Context::DetectedDrivers{} << (Context::DetectedDriver::Amd|Context::DetectedDriver::NVidia) << (Context::DetectedDriver::Mesa|Context::DetectedDriver(0xde00));
|
||
|
|
CORRADE_COMPARE(out.str(), "Context::DetectedDrivers{} Context::DetectedDriver::Amd|Context::DetectedDriver::NVidia Context::DetectedDriver::Mesa|Context::DetectedDriver(0xde00)\n");
|
||
|
9 years ago
|
#else
|
||
|
9 years ago
|
Debug{&out} << Context::DetectedDrivers{} << (Context::DetectedDriver::Angle) << (Context::DetectedDriver::Angle|Context::DetectedDriver(0xde00));
|
||
|
|
CORRADE_COMPARE(out.str(), "Context::DetectedDrivers{} Context::DetectedDriver::Angle Context::DetectedDriver::Angle|Context::DetectedDriver(0xde00)\n");
|
||
|
9 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
}}
|
||
|
|
|
||
|
|
CORRADE_TEST_MAIN(Magnum::Test::ContextTest)
|