Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rviz_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ if(BUILD_TESTING)
test/interaction/mock_selection_renderer.hpp
test/interaction/selection_test_fixture.hpp
test/display_context_fixture.cpp
test/ogre_testing_environment.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET selection_manager_test)
target_link_libraries(selection_manager_test
Expand All @@ -423,6 +424,7 @@ if(BUILD_TESTING)
test/interaction/selection_handler_test.cpp
test/interaction/selection_test_fixture.hpp
test/display_context_fixture.cpp
test/ogre_testing_environment.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET selection_handler_test)
target_link_libraries(selection_handler_test
Expand Down
4 changes: 2 additions & 2 deletions rviz_common/test/display_context_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

void DisplayContextFixture::SetUpTestCase()
{
testing_environment_ = std::make_shared<rviz_rendering::OgreTestingEnvironment>();
testing_environment_ = std::make_shared<rviz_common::OgreTestingEnvironment>();
testing_environment_->setUpOgreTestEnvironment();

scene_manager_ = Ogre::Root::getSingletonPtr()->createSceneManager();
Expand Down Expand Up @@ -66,5 +66,5 @@ void DisplayContextFixture::TearDownTestCase()
}

Ogre::SceneManager * DisplayContextFixture::scene_manager_ = nullptr;
std::shared_ptr<rviz_rendering::OgreTestingEnvironment>
std::shared_ptr<rviz_common::OgreTestingEnvironment>
DisplayContextFixture::testing_environment_ = nullptr;
4 changes: 2 additions & 2 deletions rviz_common/test/display_context_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#include "rclcpp/clock.hpp"

#include "test/rviz_rendering/ogre_testing_environment.hpp"
#include "ogre_testing_environment.hpp"

#include "mock_display_context.hpp"
#include "mock_window_manager_interface.hpp"
Expand All @@ -59,7 +59,7 @@ class DisplayContextFixture : public testing::Test

static void TearDownTestCase();

static std::shared_ptr<rviz_rendering::OgreTestingEnvironment> testing_environment_;
static std::shared_ptr<rviz_common::OgreTestingEnvironment> testing_environment_;
static Ogre::SceneManager * scene_manager_;

std::shared_ptr<MockDisplayContext> context_;
Expand Down
56 changes: 56 additions & 0 deletions rviz_common/test/ogre_testing_environment.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2017, Bosch Software Innovations GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "ogre_testing_environment.hpp"

#include <string>

#include <OgreLogManager.h>

#include "rviz_rendering/render_system.hpp"

namespace rviz_common
{

void OgreTestingEnvironment::setUpOgreTestEnvironment(bool debug)
{
if (!debug) {
const std::string & name = "";
auto lm = new Ogre::LogManager();
lm->createLog(name, false, debug, true);
}
setUpRenderSystem();
}

void OgreTestingEnvironment::setUpRenderSystem()
{
rviz_rendering::RenderSystem::get();
}

} // end namespace rviz_common
51 changes: 51 additions & 0 deletions rviz_common/test/ogre_testing_environment.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2017, Bosch Software Innovations GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef OGRE_TESTING_ENVIRONMENT_HPP_
#define OGRE_TESTING_ENVIRONMENT_HPP_

namespace rviz_common
{
class OgreTestingEnvironment
{
public:
/**
* Set up a testing environment to run tests needing Ogre.
*
* @param: bool debug, if true, all logging of Ogre is send to std::out, if false no logging
* occurs. Since the logging pollutes the test output, it defaults to false
*/
void setUpOgreTestEnvironment(bool debug = false);

void setUpRenderSystem();
};

} // namespace rviz_common

#endif // OGRE_TESTING_ENVIRONMENT_HPP_
18 changes: 2 additions & 16 deletions rviz_default_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ if(BUILD_TESTING)
ament_find_gmock()
add_library(display_test_fixture
test/rviz_default_plugins/displays/display_test_fixture.cpp
test/rviz_default_plugins/ogre_testing_environment.cpp
test/rviz_default_plugins/scene_graph_introspection.cpp
)
target_include_directories(display_test_fixture PRIVATE ${GMOCK_INCLUDE_DIRS} ${TEST_INCLUDE_DIRS})
target_link_libraries(display_test_fixture ${GMOCK_LIBRARIES})
Expand All @@ -351,7 +353,6 @@ if(BUILD_TESTING)
ament_add_gmock(fps_view_controller_test
test/rviz_default_plugins/view_controllers/fps/fps_view_controller_test.cpp
test/rviz_default_plugins/view_controllers/view_controller_test_fixture.hpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET fps_view_controller_test)
target_include_directories(fps_view_controller_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -361,7 +362,6 @@ if(BUILD_TESTING)

ament_add_gmock(frame_info_test
test/rviz_default_plugins/displays/tf/frame_info_test.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET frame_info_test)
target_include_directories(frame_info_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand Down Expand Up @@ -397,7 +397,6 @@ if(BUILD_TESTING)
test/rviz_default_plugins/displays/marker/markers/triangle_list_marker_test.cpp
test/rviz_default_plugins/displays/marker/markers/markers_test_fixture.cpp
test/rviz_default_plugins/displays/marker/marker_messages.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET marker_test)
target_include_directories(marker_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -408,7 +407,6 @@ if(BUILD_TESTING)
ament_add_gmock(marker_common_test
test/rviz_default_plugins/displays/marker/marker_common_test.cpp
test/rviz_default_plugins/displays/marker/marker_messages.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET marker_common_test)
target_include_directories(marker_common_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -418,7 +416,6 @@ if(BUILD_TESTING)

ament_add_gmock(map_display_test
test/rviz_default_plugins/displays/map/map_display_test.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET map_display_test)
target_include_directories(map_display_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -428,7 +425,6 @@ if(BUILD_TESTING)

ament_add_gmock(measure_tool_test
test/rviz_default_plugins/tools/measure/measure_tool_test.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET measure_tool_test)
target_include_directories(measure_tool_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -438,7 +434,6 @@ if(BUILD_TESTING)

ament_add_gmock(odometry_display_test
test/rviz_default_plugins/displays/odometry/odometry_display_test.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET odometry_display_test)
target_include_directories(odometry_display_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -458,7 +453,6 @@ if(BUILD_TESTING)
ament_add_gmock(orbit_view_controller_test
test/rviz_default_plugins/view_controllers/orbit/orbit_view_controller_test.cpp
test/rviz_default_plugins/view_controllers/view_controller_test_fixture.hpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET orbit_view_controller_test)
target_include_directories(orbit_view_controller_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -469,7 +463,6 @@ if(BUILD_TESTING)
ament_add_gmock(ortho_view_controller_test
test/rviz_default_plugins/view_controllers/ortho/ortho_view_controller_test.cpp
test/rviz_default_plugins/view_controllers/view_controller_test_fixture.hpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET ortho_view_controller_test)
target_include_directories(ortho_view_controller_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -488,7 +481,6 @@ if(BUILD_TESTING)

ament_add_gmock(path_display_test
test/rviz_default_plugins/displays/path/path_display_test.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET path_display_test)
target_include_directories(path_display_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -511,7 +503,6 @@ if(BUILD_TESTING)
test/rviz_default_plugins/pointcloud_messages.hpp
test/rviz_default_plugins/pointcloud_messages.cpp
test/rviz_default_plugins/displays/pointcloud/point_cloud_common_test.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET point_cloud_common_test)
target_include_directories(point_cloud_common_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand Down Expand Up @@ -546,7 +537,6 @@ if(BUILD_TESTING)

ament_add_gmock(point_display_test
test/rviz_default_plugins/displays/point/point_stamped_display_test.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET point_display_test)
target_include_directories(point_display_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -556,7 +546,6 @@ if(BUILD_TESTING)

ament_add_gmock(pose_array_display_test
test/rviz_default_plugins/displays/pose_array/pose_array_display_test.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET pose_array_display_test)
target_include_directories(pose_array_display_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -566,7 +555,6 @@ if(BUILD_TESTING)

ament_add_gmock(pose_tool_test
test/rviz_default_plugins/tools/pose/pose_tool_test.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET pose_tool_test)
target_include_directories(pose_tool_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand All @@ -576,7 +564,6 @@ if(BUILD_TESTING)

ament_add_gmock(range_display_test
test/rviz_default_plugins/displays/range/range_display_test.cpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET range_display_test)
target_include_directories(range_display_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand Down Expand Up @@ -616,7 +603,6 @@ if(BUILD_TESTING)
ament_add_gmock(xy_orbit_view_controller_test
test/rviz_default_plugins/view_controllers/xy_orbit/xy_orbit_view_controller_test.cpp
test/rviz_default_plugins/view_controllers/view_controller_test_fixture.hpp
test/rviz_default_plugins/scene_graph_introspection_helper.cpp
${SKIP_DISPLAY_TESTS})
if(TARGET xy_orbit_view_controller_test)
target_include_directories(xy_orbit_view_controller_test PUBLIC ${TEST_INCLUDE_DIRS})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

void DisplayTestFixture::SetUpTestCase()
{
testing_environment_ = std::make_shared<rviz_rendering::OgreTestingEnvironment>();
testing_environment_ = std::make_shared<rviz_default_plugins::OgreTestingEnvironment>();
testing_environment_->setUpOgreTestEnvironment();

scene_manager_ = Ogre::Root::getSingletonPtr()->createSceneManager();
Expand Down Expand Up @@ -106,5 +106,5 @@ void DisplayTestFixture::mockValidTransform(Ogre::Vector3 position, Ogre::Quater
}

Ogre::SceneManager * DisplayTestFixture::scene_manager_ = nullptr;
std::shared_ptr<rviz_rendering::OgreTestingEnvironment>
std::shared_ptr<rviz_default_plugins::OgreTestingEnvironment>
DisplayTestFixture::testing_environment_ = nullptr;
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#include "rclcpp/clock.hpp"

#include "test/rviz_rendering/ogre_testing_environment.hpp"
#include "../ogre_testing_environment.hpp"

#include "../mock_display_context.hpp"
#include "../mock_frame_manager.hpp"
Expand All @@ -65,7 +65,7 @@ class DisplayTestFixture : public testing::Test

void mockValidTransform(Ogre::Vector3 position, Ogre::Quaternion orientation);

static std::shared_ptr<rviz_rendering::OgreTestingEnvironment> testing_environment_;
static std::shared_ptr<rviz_default_plugins::OgreTestingEnvironment> testing_environment_;
static Ogre::SceneManager * scene_manager_;

std::shared_ptr<MockDisplayContext> context_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@

#include "rviz_default_plugins/displays/grid_cells/grid_cells_display.hpp"

#include "test/rviz_rendering/scene_graph_introspection.hpp"
#include "../../scene_graph_introspection.hpp"
#include "../display_test_fixture.hpp"
#include "../../scene_graph_introspection_helper.hpp"

using namespace ::testing; // NOLINT

Expand Down Expand Up @@ -97,7 +96,7 @@ TEST_F(GridCellsDisplayFixture, processMessage_with_invalid_transform_returns_ea
auto msg = createGridCellsMessageWithTwoCells();
display_->processMessage(msg);

auto point_clouds = rviz_rendering::findAllPointClouds(scene_manager_->getRootSceneNode());
auto point_clouds = rviz_default_plugins::findAllPointClouds(scene_manager_->getRootSceneNode());
EXPECT_THAT(point_clouds.size(), Eq(1u));
EXPECT_THAT(point_clouds[0]->getPoints().size(), Eq(0u));
}
Expand All @@ -108,7 +107,7 @@ TEST_F(GridCellsDisplayFixture, processMessage_with_zero_size_does_not_add_messa
auto msg = createGridCellsMessageWithTwoCells(0, 1);
display_->processMessage(msg);

auto point_clouds = rviz_rendering::findAllPointClouds(scene_manager_->getRootSceneNode());
auto point_clouds = rviz_default_plugins::findAllPointClouds(scene_manager_->getRootSceneNode());
EXPECT_THAT(point_clouds.size(), Eq(1u));
EXPECT_THAT(point_clouds[0]->getPoints().size(), Eq(0u));
}
Expand All @@ -118,7 +117,7 @@ TEST_F(GridCellsDisplayFixture, processMessage_fills_pointcloud_with_correct_gri
auto msg = createGridCellsMessageWithTwoCells();
display_->processMessage(msg);

auto point_clouds = rviz_rendering::findAllPointClouds(scene_manager_->getRootSceneNode());
auto point_clouds = rviz_default_plugins::findAllPointClouds(scene_manager_->getRootSceneNode());
EXPECT_THAT(point_clouds.size(), Eq(1u));
EXPECT_THAT(point_clouds[0]->getPoints().size(), Eq(2u));
EXPECT_THAT(
Expand All @@ -137,7 +136,7 @@ TEST_F(GridCellsDisplayFixture, processMessage_clears_cloud_on_new_message) {
auto broken_msg = createGridCellsMessageWithTwoCells(0, 1);
display_->processMessage(broken_msg);

auto point_clouds = rviz_rendering::findAllPointClouds(scene_manager_->getRootSceneNode());
auto point_clouds = rviz_default_plugins::findAllPointClouds(scene_manager_->getRootSceneNode());
EXPECT_THAT(point_clouds.size(), Eq(1u));
EXPECT_THAT(point_clouds[0]->getPoints().size(), Eq(0u));
}
Loading