Skip to content
Snippets Groups Projects
Commit e90fab99 authored by Gael Rial Costas's avatar Gael Rial Costas Committed by Felix de las Pozas
Browse files

Tests

parent bd77ff59
No related branches found
No related tags found
No related merge requests found
Showing
with 936 additions and 21 deletions
......@@ -27,20 +27,20 @@ bld/
# Dependencies
.settings
Brion
Keyv
Lexis
Lunchbox
MVDTool
Pression
ReTo
Servus
SimIL
ZeroBuf
ZeroEQ
gmrvlex
prefr
scoop
vmmlib
HighFive
acuterecorder
/Brion
/Keyv
/Lexis
/Lunchbox
/MVDTool
/Pression
/ReTo
/Servus
/SimIL
/ZeroBuf
/ZeroEQ
/gmrvlex
/prefr
/scoop
/vmmlib
/HighFive
/acuterecorder
......@@ -9,7 +9,7 @@
cmake_minimum_required( VERSION 3.1 FATAL_ERROR )
# visimpl project and version
project( visimpl VERSION 1.8.8 )
project( visimpl VERSION 1.8.9 )
set( visimpl_VERSION_ABI 6 )
SET( VISIMPL_LICENSE "GPL")
......@@ -57,6 +57,7 @@ option(VISIMPL_WITH_ZEQ "VISIMPL_WITH_ZEQ" ON)
option(VISIMPL_WITH_GMRVLEX "VISIMPL_WITH_GMRVLEX" ON)
set(VISIMPL_WITH_OPENMP ON)
set (VISIMPL_BUILD_TESTS OFF CACHE BOOL "Build ViSimpl Tests")
common_find_package( GLM REQUIRED SYSTEM )
common_find_package( Qt5Core 5.4 REQUIRED )
......@@ -128,6 +129,19 @@ add_subdirectory( sumrice )
add_subdirectory( visimpl )
add_subdirectory( stackviz )
if(VISIMPL_BUILD_TESTS)
include (CTest)
# Generate coverage information
set(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
set(GCC_COVERAGE_LINK_FLAGS "-lgcov")
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}" )
add_subdirectory(tests)
endif()
# importers subdirectory contains code for processing data and convert it
# to ViSimpl formats, not needed for release.
#add_subdirectory( importers )
......
......@@ -12,10 +12,10 @@ glm::vec4 ColorInterpolator::getValue( float percentage )
auto first = data[ 0 ];
if ( first.first >= percentage ) return first.second;
auto last = data[ data.size( ) ];
auto& last = data.back();
if ( percentage >= last.first ) return last.second;
auto value = visimpl::lower_bound(
auto next = visimpl::lower_bound(
data.cbegin( ) , data.cend( ) , percentage ,
[ ](
const std::pair< float , glm::vec4 >& e ,
......@@ -24,7 +24,7 @@ glm::vec4 ColorInterpolator::getValue( float percentage )
return e.first < v;
} );
auto next = value + 1;
auto value = next - 1;
float n = ( percentage - value->first ) / ( next->first - value->first );
return glm::mix( value->second , next->second , n );
}
......
find_package(Qt5 REQUIRED COMPONENTS Core Gui Network Widgets Test)
enable_testing()
set(VISIMPL_DIR ${CMAKE_SOURCE_DIR}/visimpl)
set(STACKVIZ_DIR ${CMAKE_SOURCE_DIR}/stackviz)
set(SUMRICE_DIR ${CMAKE_SOURCE_DIR}/sumrice)
set(RETO_DIR ${CMAKE_SOURCE_DIR}/ReTo)
set(SIMIL_DIR ${CMAKE_SOURCE_DIR}/SimIL)
set(PLAB_DIR ${CMAKE_SOURCE_DIR}/plab)
set(SCOOP_DIR ${CMAKE_SOURCE_DIR}/scoop)
include_directories(
.
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/include
${CMAKE_BINARY_DIR}/visimpl/include
${CMAKE_BINARY_DIR}/stackviz/include
${CMAKE_BINARY_DIR}/sumrice/include
${CMAKE_BINARY_DIR}/ReTo/include
${CMAKE_BINARY_DIR}/SimIL/include
${CMAKE_BINARY_DIR}/plab/include
${CMAKE_BINARY_DIR}/scoop/include
${CMAKE_BINARY_DIR}/acuterecorder/include
${CMAKE_BINARY_DIR}/Brion/include
${CMAKE_BINARY_DIR}/gmrvlex/include
${CMAKE_BINARY_DIR}/Lexis/include
${CMAKE_BINARY_DIR}/Servus/include
${CMAKE_BINARY_DIR}/ZeroEQ/include
${CMAKE_BINARY_DIR}/ZeroBuf/include
${CMAKE_BINARY_DIR}/vmmlib/include
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/visimpl/
${CMAKE_SOURCE_DIR}/stackviz/
${CMAKE_SOURCE_DIR}/sumrice/
${CMAKE_SOURCE_DIR}/ReTo/
${CMAKE_SOURCE_DIR}/SimIL/
${CMAKE_SOURCE_DIR}/plab/
${CMAKE_SOURCE_DIR}/scoop/
${CMAKE_SOURCE_DIR}/acuterecorder/
${CMAKE_SOURCE_DIR}/Brion/
${CMAKE_SOURCE_DIR}/gmrvlex/
${CMAKE_SOURCE_DIR}/Lexis/
${CMAKE_SOURCE_DIR}/Servus/
${CMAKE_SOURCE_DIR}/ZeroEQ/
${CMAKE_SOURCE_DIR}/ZeroBuf/
${CMAKE_SOURCE_DIR}/vmmlib
)
# Core
qt5_add_resources(TEST_RESOURCES
# Qt resources if needed
)
qt5_wrap_cpp(TEST_MOCS
# Qt classes MOCs if needed for testing.
)
common_find_package(Boost COMPONENTS system filesystem unit_test_framework REQUIRED)
if (NOT Boost_FOUND)
return()
endif ()
set(EXTERNAL_LIBS_DEPENDENCIES
${QT_LIBRARIES}
Qt5::Test
ReTo
SimIL
plab
sumrice
scoop
visimpl_test_lib
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
set(DEPENDENCIES_SOURCES
visimpl_test_utils.h
visimpl_test_utils.cpp)
add_library(VisimplTesting SHARED ${DEPENDENCIES_SOURCES})
target_link_libraries(VisimplTesting ${EXTERNAL_LIBS_DEPENDENCIES})
common_find_package_post()
add_definitions(-DBOOST_TEST_DYN_LINK)
if (VISIMPL_BUILD_TESTS)
add_subdirectory(visimpl)
add_subdirectory(sumrice)
# add_subdirectory(stackviz)
add_subdirectory(ReTo)
# add_subdirectory(SimIL)
add_subdirectory(plab)
add_subdirectory(scoop)
endif (VISIMPL_BUILD_TESTS)
# ReTo tests
configure_file(reto_test_data.in ${CMAKE_CURRENT_BINARY_DIR}/reto_test_data.h)
if (NOT Boost_FOUND)
return()
endif ()
set(TEST_LIBRARIES
VisimplTesting
${EXTERNAL_LIBS_DEPENDENCIES})
add_executable(test_reto_camera camera.cpp)
include_directories(test_reto_camera PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(test_reto_camera ${TEST_LIBRARIES})
add_test(NAME test_reto_camera COMMAND test_reto_camera)
add_executable(test_reto_model model.cpp)
include_directories(test_reto_model PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(test_reto_model ${TEST_LIBRARIES})
add_test(NAME test_reto_model COMMAND test_reto_model)
add_executable(test_reto_spline spline.cpp)
include_directories(test_reto_spline PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(test_reto_spline ${TEST_LIBRARIES})
add_test(NAME test_reto_spline COMMAND test_reto_spline)
add_executable(test_reto_shader_program shader_program.cpp)
include_directories(test_reto_shader_program PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(test_reto_shader_program ${TEST_LIBRARIES})
add_test(NAME test_reto_shader_program COMMAND test_reto_shader_program)
/*
* Copyright (c) 2015-2022 VG-Lab/URJC.
*
* Authors: Gael Rial Costas <gael.rial.costas@urjc.es>
*
* This file is part of ViSimpl <https://github.com/vg-lab/visimpl>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define BOOST_TEST_MODULE reto_camera
#include <vector>
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <reto/reto.h>
BOOST_AUTO_TEST_CASE( reto_camera_move )
{
reto::Camera camera;
reto::FreeCameraController controller( &camera );
// Check identity
auto* data = camera.viewMatrix( );
Eigen::Matrix4f identity = Eigen::Matrix4f::Identity( );
auto* iData = identity.data( );
BOOST_CHECK_EQUAL_COLLECTIONS( data , data + 16 , iData , iData + 16 );
// Check movement
auto move = Eigen::Vector3f( 10.0f , 0.0f , 0.0f );
controller.position( move );
BOOST_CHECK_EQUAL( controller.position( ) , move );
controller.translate( move );
BOOST_CHECK_EQUAL( controller.position( ) , move + move );
controller.localTranslate( move );
BOOST_CHECK_EQUAL( controller.position( ) , move + move + move );
// Check movement with rotation
controller.position( Eigen::Vector3f( 0.0f , 0.0f , 0.0f ));
controller.rotate( Eigen::Vector3f( 1.570796325f , 0.0f , 0.0f ));
controller.translate( move );
BOOST_CHECK_EQUAL( controller.position( ) , move );
controller.position( Eigen::Vector3f( 0.0f , 0.0f , 0.0f ));
controller.localTranslate( move );
auto rotatedMove = Eigen::Vector3f( 0.0f , 0.0f , 10.0f );
auto distance = std::abs(( controller.position( ) - rotatedMove ).norm( ));
BOOST_CHECK( distance < 0.0001 );
}
\ No newline at end of file
/*
* Copyright (c) 2015-2022 VG-Lab/URJC.
*
* Authors: Gael Rial Costas <gael.rial.costas@urjc.es>
*
* This file is part of ViSimpl <https://github.com/vg-lab/visimpl>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//
// Created by gaeqs on 9/11/22.
//
#define BOOST_TEST_MODULE reto_model
#include <reto/reto.h>
#include <boost/test/unit_test.hpp>
#include <reto_test_data.h>
using namespace reto;
BOOST_AUTO_TEST_CASE( reto_model_parse )
{
ObjParser obj;
Model m = obj.loadObj( OBJ_MODEL_TEST_DATA , true );
BOOST_CHECK_EQUAL( m.vertices.size( ) , 8 * 3 * 3 );
BOOST_CHECK_EQUAL( m.normals.size( ) , 8 * 3 * 3 );
BOOST_CHECK_EQUAL( m.texCoords.size( ) , 4 * 6 * 2 );
BOOST_CHECK_EQUAL( m.indices.size( ) , 36 );
BOOST_CHECK_EQUAL( m.tangents.size( ) , 8 * 3 * 3 );
BOOST_CHECK_EQUAL( m.bitangents.size( ) , 8 * 3 * 3 );
}
\ No newline at end of file
/*
* Copyright (c) 2014-2017 GMRV/URJC.
*
* Authors: Cristian Rodríguez Bernal <cristian.rodriguez@urjc.es>
*
* This file is part of ReTo <https://gitlab.gmrv.es/nsviz/ReTo>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#define OBJ_MODEL_TEST_DATA "@PROJECT_SOURCE_DIR@/ReTo/testData/cube.obj_"
/*
* Copyright (c) 2015-2022 VG-Lab/URJC.
*
* Authors: Gael Rial Costas <gael.rial.costas@urjc.es>
*
* This file is part of ViSimpl <https://github.com/vg-lab/visimpl>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define BOOST_TEST_MODULE reto_shader_program
#include <reto/reto.h>
#include <boost/test/unit_test.hpp>
#include <visimpl_test_utils.h>
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <iostream>
using namespace reto;
BOOST_AUTO_TEST_CASE(test_reto_program_shader)
{
test_utils::initOpenGLContext();
const std::string vsShader = (
"#version 430 core\n"
"layout(location = 0) in vec3 position;\n"
"uniform mat4 MVP;\n"
"void main() {\n"
" gl_Position = MVP * vec4(position, 1.0);\n"
"}"
);
const std::string fsShader = (
"#version 430 core\n"
"out vec4 fragColor;\n"
"void main() {\n"
" fragColor = vec4(1.0);\n"
"}"
);
const std::string gsShader = (
"#version 430 core\n"
"layout (points) in;\n"
"layout (line_strip) out;\n"
"layout (max_vertices = 8) out;\n"
"void main() {\n"
" gl_Position = gl_in[0].gl_Position + vec4(-0.1, 0.0, 0.0, 0.0);\n"
" EmitVertex();\n"
" gl_Position = gl_in[0].gl_Position + vec4(0.1, 0.0, 0.0, 0.0);\n"
" EmitVertex();\n"
" EndPrimitive();\n"
"}"
);
//reto::Camera c;
reto::ShaderProgram prog;
bool vsCreate = prog.loadVertexShaderFromText(vsShader);
BOOST_CHECK(vsCreate == true);
bool fsCreate = prog.loadFragmentShaderFromText(fsShader);
BOOST_CHECK(fsCreate == true);
bool compile = prog.compileAndLink();
BOOST_CHECK(compile == true);
prog.addUniform("MVP");
BOOST_CHECK(prog["MVP"] == 0);
BOOST_CHECK(prog.uniform("MVP") == 0);
reto::ShaderProgram prog2;
vsCreate = prog2.loadVertexShaderFromText(vsShader);
BOOST_CHECK(vsCreate == true);
fsCreate = prog2.loadFragmentShaderFromText(fsShader);
BOOST_CHECK(fsCreate == true);
bool gsCreate = prog2.loadGeometryShaderFromText(gsShader);
BOOST_CHECK(gsCreate == true);
prog2.create();
compile = prog2.link();
BOOST_CHECK(compile == true);
prog2.use();
BOOST_CHECK(prog2.getGeometryInputType() == GL_POINTS);
BOOST_CHECK(prog2.getGeometryOutputType() == GL_LINE_STRIP);
BOOST_CHECK(prog2.getGeometryMaxOutput() == 8);
test_utils::terminateOpenGLContext();
}
/*
* Copyright (c) 2015-2022 VG-Lab/URJC.
*
* Authors: Gael Rial Costas <gael.rial.costas@urjc.es>
*
* This file is part of ViSimpl <https://github.com/vg-lab/visimpl>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define BOOST_TEST_MODULE reto_spline
#include <reto/reto.h>
#include <boost/test/unit_test.hpp>
using namespace reto;
BOOST_AUTO_TEST_CASE( reto_spline_example )
{
std::vector<Eigen::Vector3f> v;
v.push_back(Eigen::Vector3f{0.0f, 0.0f, 0.0f});
v.push_back(Eigen::Vector3f{0.0f, 200.0f, 0.0f});
v.push_back(Eigen::Vector3f{150.0f, 150.0f, 0.0f});
v.push_back(Eigen::Vector3f{150.0f, 50.0f, 0.0f});
v.push_back(Eigen::Vector3f{250.0f, 100.0f, 0.0f});
v.push_back(Eigen::Vector3f{250.0f, 300.0f, 0.0f});
v.push_back(Eigen::Vector3f{150.0f, 50.0f, 0.0f});
Spline sp(v);
BOOST_CHECK_EQUAL( sp.evaluate( 0.0f ),
Eigen::Vector3f(0.0f, 0.0f, 0.0f) );
BOOST_CHECK_EQUAL( sp.evaluate( 0.5f ),
Eigen::Vector3f(150.0f, 50.0f, 0.0f) );
BOOST_CHECK_EQUAL( sp.evaluate( 1.1f ),
Eigen::Vector3f(150.0f, 50.0f, 0.0f) );
sp.evaluate( 0.8f );
BOOST_CHECK_EQUAL( sp.angleBetweenPoints( ), 0.0f );
BOOST_CHECK_EQUAL( sp.angleBetweenPoints( 0.0f, 0.1f ), 0.054831136f );
auto tg0 = sp.getTangent( );
BOOST_CHECK_EQUAL( tg0( 0 ), -0.862098992f );
auto tg1 = sp.getTangent( 0.0f, 0.1f );
BOOST_CHECK_EQUAL( tg1( 0 ), -0.0838161781f );
}
# ParticleLab tests
set(TEST_LIBRARIES
VisimplTesting
${EXTERNAL_LIBS_DEPENDENCIES})
add_executable(test_plab_cluster cluster.cpp)
target_link_libraries(test_plab_cluster ${TEST_LIBRARIES})
add_test(NAME test_plab_cluster COMMAND test_plab_cluster)
\ No newline at end of file
/*
* Copyright (c) 2015-2022 VG-Lab/URJC.
*
* Authors: Gael Rial Costas <gael.rial.costas@urjc.es>
*
* This file is part of ViSimpl <https://github.com/vg-lab/visimpl>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define BOOST_TEST_MODULE plab_cluster
#include <vector>
#include <boost/test/unit_test.hpp>
#include <visimpl_test_utils.h>
#include <plab/plab.h>
BOOST_AUTO_TEST_CASE( plab_cluster_fill )
{
std::vector< BasicParticle > particles;
for ( uint32_t i = 0; i < 100; ++i )
{
particles.push_back( {{ i , i , i }} );
}
test_utils::initOpenGLContext( );
plab::Cluster< BasicParticle > cluster;
// Test normal allocation
cluster.setParticles( particles );
BOOST_CHECK_EQUAL( 100 , cluster.size( ));
auto* map = cluster.mapData( );
for ( uint32_t i = 0; i < cluster.size( ); ++i )
{
BOOST_CHECK_EQUAL( i , ( map + i )->position.x );
BOOST_CHECK_EQUAL( i , ( map + i )->position.y );
BOOST_CHECK_EQUAL( i , ( map + i )->position.z );
}
cluster.unmapData( );
cluster.setParticles( { } );
BOOST_CHECK_EQUAL( 0 , cluster.size( ));
// Test raw allocation
cluster.allocateBuffer( 100 );
BOOST_CHECK_EQUAL( 100 , cluster.size( ));
// The buffer should be filled with invalid data.
cluster.allocateBuffer( 0 );
BOOST_CHECK_EQUAL( 0 , cluster.size( ));
test_utils::terminateOpenGLContext();
}
\ No newline at end of file
# ParticleLab tests
set(TEST_LIBRARIES
VisimplTesting
${EXTERNAL_LIBS_DEPENDENCIES})
add_executable(test_scoop_color color.cpp)
target_link_libraries(test_scoop_color ${TEST_LIBRARIES})
add_test(NAME test_scoop_color COMMAND test_scoop_color)
add_executable(test_scoop_color_palette color_palette.cpp)
target_link_libraries(test_scoop_color_palette ${TEST_LIBRARIES})
add_test(NAME test_scoop_color_palette COMMAND test_scoop_color_palette)
\ No newline at end of file
/*
* Copyright (c) 2015-2022 VG-Lab/URJC.
*
* Authors: Gael Rial Costas <gael.rial.costas@urjc.es>
*
* This file is part of ViSimpl <https://github.com/vg-lab/visimpl>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define BOOST_TEST_MODULE scoop_color
#include <boost/test/unit_test.hpp>
#include <visimpl_test_utils.h>
#include <scoop/scoop.h>
BOOST_AUTO_TEST_CASE( scoop_color_rgb )
{
scoop::Color color1(100, 0, 0);
scoop::Color color2(0, 100, 0);
// RGBA returns ARGB because Qt hates us.
BOOST_CHECK_EQUAL(color1.rgba(), 0xFF640000);
BOOST_CHECK_EQUAL(color2.rgba(), 0xFF006400);
}
\ No newline at end of file
/*
* Copyright (c) 2015-2022 VG-Lab/URJC.
*
* Authors: Gael Rial Costas <gael.rial.costas@urjc.es>
*
* This file is part of ViSimpl <https://github.com/vg-lab/visimpl>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//
// Created by grial on 18/11/22.
//
#define BOOST_TEST_MODULE scoop_color_palette
#include <boost/test/unit_test.hpp>
#include <scoop/scoop.h>
#include <iostream>
BOOST_AUTO_TEST_CASE( scoop_color_palette_interpolate )
{
scoop::ColorPalette palette = scoop::ColorPalette::colorBrewerDiverging(
scoop::ColorPalette::ColorBrewerDiverging::BrBG ,
3 ,
true
);
BOOST_CHECK_EQUAL( palette.size( ) , 3 );
BOOST_CHECK_EQUAL( palette.colors( )[ 0 ] ,
scoop::Color( 216 , 179 , 101 , 255 ));
}
\ No newline at end of file
# ParticleLab tests
set(TEST_LIBRARIES
VisimplTesting
${EXTERNAL_LIBS_DEPENDENCIES})
add_executable(test_sumrice_color_interpolator color_interpolator.cpp)
target_link_libraries(test_sumrice_color_interpolator ${TEST_LIBRARIES})
add_test(NAME test_sumrice_color_interpolator COMMAND test_sumrice_color_interpolator)
\ No newline at end of file
/*
* Copyright (c) 2015-2022 VG-Lab/URJC.
*
* Authors: Gael Rial Costas <gael.rial.costas@urjc.es>
*
* This file is part of ViSimpl <https://github.com/vg-lab/visimpl>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define BOOST_TEST_MODULE sumrice_color_interpolator
#include <vector>
#include <boost/test/unit_test.hpp>
#include <sumrice/ColorInterpolator.h>
namespace boost
{
namespace test_tools
{
namespace tt_detail
{
template< >
struct print_log_value< glm::vec4 >
{
void operator()( std::ostream& os , const glm::vec4& tc )
{
os << "(" << tc.x << ", " << tc.y << ", "
<< tc.z << ", " << tc.w << ")";
}
};
}
}
}
BOOST_AUTO_TEST_CASE( sumrice_color_interpolator )
{
ColorInterpolator interpolator;
glm::vec4 r = glm::vec4( 1.0f , 0.0f , 0.0f , 1.0f );
glm::vec4 g = glm::vec4( 0.0f , 1.0f , 0.0f , 1.0f );
glm::vec4 b = glm::vec4( 0.0f , 0.0f , 1.0f , 1.0f );
interpolator.insert( 0 , r );
interpolator.insert( 1 , g );
interpolator.insert( 2 , b );
BOOST_CHECK_EQUAL( interpolator.getValue( -1.0f ) , r );
BOOST_CHECK_EQUAL( interpolator.getValue( 0.0f ) , r );
BOOST_CHECK_EQUAL( interpolator.getValue( 1.0f ) , g );
BOOST_CHECK_EQUAL( interpolator.getValue( 2.0f ) , b );
BOOST_CHECK_EQUAL( interpolator.getValue( 3.0f ) , b );
glm::vec4 interpolated = glm::vec4( 0.5f , 0.5f , 0.0f , 1.0f );
glm::vec4 interpolated2 = glm::vec4( 0.0f , 0.5f , 0.5f , 1.0f );
BOOST_CHECK_EQUAL( interpolator.getValue( 0.5f ) , interpolated );
BOOST_CHECK_EQUAL( interpolator.getValue( 1.5f ) , interpolated2 );
}
\ No newline at end of file
# ViSimpl tests
set(TEST_LIBRARIES
VisimplTesting
${EXTERNAL_LIBS_DEPENDENCIES})
add_executable(test_visimpl_domain_manager domain_manager.cpp)
target_link_libraries(test_visimpl_domain_manager ${TEST_LIBRARIES})
add_test(NAME test_visimpl_domain_manager COMMAND test_visimpl_domain_manager)
\ No newline at end of file
/*
* Copyright (c) 2015-2022 VG-Lab/URJC.
*
* Authors: Gael Rial Costas <gael.rial.costas@urjc.es>
*
* This file is part of ViSimpl <https://github.com/vg-lab/visimpl>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define BOOST_TEST_MODULE visimpl_domain_manager
#include <boost/test/unit_test.hpp>
#include <visimpl_test_utils.h>
#include <visimpl/DomainManager.h>
#include <visimpl/types.h>
BOOST_AUTO_TEST_CASE( visimpl_domain_manager_groups_init )
{
float minLimit = std::numeric_limits< float >::min( );
float maxLimit = std::numeric_limits< float >::max( );
visimpl::GIDUSet testSet{ 0 };
visimpl::tGidPosMap testSetPositions{{ 0 , { 1.0f , 0.0f , 0.0f }}};
auto camera = std::make_shared< visimpl::Camera >( );
test_utils::initOpenGLContext( );
visimpl::DomainManager dManager;
// Check initial conditions
BOOST_CHECK_EQUAL( dManager.getGroupAmount( ) , 0 );
BOOST_CHECK_EQUAL( dManager.getAttributeClusters( ).size( ) , 0 );
BOOST_CHECK_EQUAL(
static_cast<int>(dManager.getMode( )) ,
static_cast<int>(visimpl::VisualMode::Selection)
);
dManager.initRenderers( nullptr , nullptr , camera );
// Check if bounding box is empty
BOOST_CHECK_EQUAL( dManager.getBoundingBox( ).first.x , maxLimit );
BOOST_CHECK_EQUAL( dManager.getBoundingBox( ).second.x , minLimit );
// Check selection
dManager.setSelection( testSet , testSetPositions );
BOOST_CHECK_EQUAL( dManager.getBoundingBox( ).first.x , 1.0f );
BOOST_CHECK_EQUAL( dManager.getBoundingBox( ).second.x , 1.0f );
// DomainManager has two setSelection methods!
dManager.setSelection( visimpl::TGIDSet{ 0 } , testSetPositions );
BOOST_CHECK_EQUAL( dManager.getBoundingBox( ).first.x , 1.0f );
BOOST_CHECK_EQUAL( dManager.getBoundingBox( ).second.x , 1.0f );
// Add group from selection
dManager.createGroupFromSelection( testSetPositions , "selection" );
BOOST_CHECK_EQUAL( dManager.getGroupAmount( ) , 1 );
BOOST_CHECK_NE( dManager.getGroup( "selection" ) , nullptr );
BOOST_CHECK_EQUAL( dManager.getGroup( "selection" )->getGids( ).size( ) , 1 );
dManager.removeGroup( "selection" );
BOOST_CHECK_EQUAL( dManager.getGroupAmount( ) , 0 );
dManager.setSelection( visimpl::TGIDSet{ } , visimpl::tGidPosMap{ } );
BOOST_CHECK_EQUAL( dManager.getBoundingBox( ).first.x , maxLimit );
BOOST_CHECK_EQUAL( dManager.getBoundingBox( ).second.x , minLimit );
// Check group addition
dManager.createGroup( { } , { } , "test_group" );
BOOST_CHECK_EQUAL( dManager.getGroupAmount( ) , 1 );
dManager.removeGroup( "invalid_group" );
BOOST_CHECK_EQUAL( dManager.getGroupAmount( ) , 1 );
dManager.removeGroup( "test_group" );
BOOST_CHECK_EQUAL( dManager.getGroupAmount( ) , 0 );
dManager.setMode( visimpl::VisualMode::Groups );
BOOST_CHECK_EQUAL(
static_cast<int>(dManager.getMode( )) ,
static_cast<int>(visimpl::VisualMode::Groups)
);
// Check time
// We have to add a group to test the time.
dManager.createGroup( { } , { } , "test_group" );
{
auto group = dManager.getGroup( "test_group" );
BOOST_CHECK_EQUAL( group->getModel( )->getTime( ) , 0.0f );
dManager.addTime( 20.0f , 40.0f );
BOOST_CHECK_EQUAL( group->getModel( )->getTime( ) , 20.0f );
dManager.addTime( 20.0f , 40.0f ); // Time is cyclic!
BOOST_CHECK_EQUAL( group->getModel( )->getTime( ) , 0.0f );
dManager.addTime( 20.0f , 40.0f );
BOOST_CHECK_EQUAL( group->getModel( )->getTime( ) , 20.0f );
dManager.setTime( 25.0f );
BOOST_CHECK_EQUAL( group->getModel( )->getTime( ) , 25.0f );
}
dManager.removeGroup( "test_group" );
// Test drawing
dManager.setMode( visimpl::VisualMode::Groups );
dManager.createGroup( testSet , testSetPositions , "test_group" );
dManager.applySolidShader( );
dManager.draw( );
dManager.applyDefaultShader( );
dManager.draw( );
test_utils::terminateOpenGLContext();
}
BOOST_AUTO_TEST_CASE( visimpl_domain_manager_spikes )
{
test_utils::initOpenGLContext( );
visimpl::DomainManager dManager;
auto camera = std::make_shared< visimpl::Camera >( );
visimpl::GIDUSet testSet{ 0 };
visimpl::tGidPosMap testSetPositions{{ 0 , { 1.0f , 0.0f , 0.0f }}};
dManager.initRenderers( nullptr , nullptr , camera );
dManager.setSelection( testSet , testSetPositions );
BOOST_CHECK_EQUAL( dManager.getSelectionCluster( )->size( ) , 1 );
simil::Spikes spikes;
spikes.emplace_back( 1.0f , 0 );
simil::SpikesCRange range( spikes.cbegin( ) , spikes.cend( ));
dManager.processInput( range , false );
auto map = dManager.getSelectionCluster( )->mapData( );
BOOST_CHECK_EQUAL( map->timestamp , 1.0f );
dManager.getSelectionCluster( )->unmapData( );
dManager.setMode( visimpl::VisualMode::Groups );
dManager.createGroup( testSet , testSetPositions , "test_group" );
dManager.processInput( range , false );
{
auto groupCluster = dManager.getGroup( "test_group" )->getCluster( );
map = groupCluster->mapData( );
BOOST_CHECK_EQUAL( map->timestamp , 1.0f );
groupCluster->unmapData( );
}
test_utils::terminateOpenGLContext();
}
\ No newline at end of file
/*
* Copyright (c) 2015-2022 VG-Lab/URJC.
*
* Authors: Gael Rial Costas <gael.rial.costas@urjc.es>
*
* This file is part of ViSimpl <https://github.com/vg-lab/visimpl>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//
// Created by gaeqs on 2/11/22.
//
#include <iostream>
#include <GL/glew.h>
#include <GL/freeglut.h>
namespace test_utils
{
void initOpenGLContext( )
{
int argc = 0;
glutInit( &argc , nullptr );
glutInitContextVersion( 3 , 3 );
glutInitContextFlags( GLUT_FORWARD_COMPATIBLE );
glutInitContextProfile( GLUT_CORE_PROFILE );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH );
glutInitWindowSize( 1 , 1 );
glutInitWindowPosition( 0 , 0 );
glutCreateWindow( "GLUT example" );
glewExperimental = GL_TRUE;
GLenum err = glewInit( );
if ( GLEW_OK != err )
{
std::cout << "Error: " << glewGetErrorString( err ) << std::endl;
exit( -1 );
}
const GLubyte* oglVersion = glGetString( GL_VERSION );
std::cout << "This system supports OpenGL Version: "
<< oglVersion << std::endl;
}
void terminateOpenGLContext( )
{
glutExit( );
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment