Pārlūkot izejas kodu

Adds configuration files test. (#33)

Damon Kohler 9 gadi atpakaļ
vecāks
revīzija
68482306df

+ 4 - 0
cartographer_turtlebot/CMakeLists.txt

@@ -17,15 +17,19 @@ cmake_minimum_required(VERSION 2.8.3)
 project(cartographer_turtlebot)
 
 set(PACKAGE_DEPENDENCIES
+  cartographer_ros
   roscpp
+  roslib
   sensor_msgs
 )
 
 find_package(cartographer REQUIRED)
 include("${CARTOGRAPHER_CMAKE_DIR}/functions.cmake")
 google_initialize_cartographer_project()
+google_enable_testing()
 
 find_package(catkin REQUIRED COMPONENTS ${PACKAGE_DEPENDENCIES})
+include_directories(${catkin_INCLUDE_DIRS})
 
 catkin_package(CATKIN_DEPENDS message_runtime ${PACKAGE_DEPENDENCIES})
 

+ 6 - 0
cartographer_turtlebot/cartographer_turtlebot/CMakeLists.txt

@@ -1,3 +1,9 @@
+google_test(configuration_files_test
+  USES_CARTOGRAPHER
+  SRCS
+    configuration_files_test.cc
+)
+
 google_binary(cartographer_flat_world_imu_node
   SRCS
     flat_world_imu_node_main.cc

+ 50 - 0
cartographer_turtlebot/cartographer_turtlebot/configuration_files_test.cc

@@ -0,0 +1,50 @@
+/*
+ * Copyright 2016 The Cartographer Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string>
+#include <vector>
+
+#include "cartographer/common/configuration_file_resolver.h"
+#include "cartographer/common/lua_parameter_dictionary.h"
+#include "cartographer_ros/node_options.h"
+#include "gtest/gtest.h"
+#include "ros/package.h"
+
+namespace cartographer_ros {
+namespace {
+
+class ConfigurationFilesTest : public ::testing::TestWithParam<const char*> {};
+
+TEST_P(ConfigurationFilesTest, ValidateNodeOptions) {
+  EXPECT_NO_FATAL_FAILURE({
+    auto file_resolver = ::cartographer::common::make_unique<
+        ::cartographer::common::ConfigurationFileResolver>(
+        std::vector<string>{::ros::package::getPath("cartographer_turtlebot") +
+                            "/configuration_files"});
+    const string code = file_resolver->GetFileContentOrDie(GetParam());
+    ::cartographer::common::LuaParameterDictionary lua_parameter_dictionary(
+        code, std::move(file_resolver));
+    ::cartographer_ros::CreateNodeOptions(&lua_parameter_dictionary);
+  });
+}
+
+INSTANTIATE_TEST_CASE_P(ValidateAllNodeOptions, ConfigurationFilesTest,
+                        ::testing::Values("turtlebot_depth_camera_2d.lua",
+                                          "turtlebot_depth_camera_3d.lua",
+                                          "turtlebot_urg_lidar_2d.lua"));
+
+}  // namespace
+}  // namespace cartographer_ros

+ 1 - 0
cartographer_turtlebot/package.xml

@@ -39,6 +39,7 @@
   <depend>message_runtime</depend>
   <depend>openni2_launch</depend>
   <depend>roscpp</depend>
+  <depend>roslib</depend>
   <depend>sensor_msgs</depend>
   <depend>turtlebot_bringup</depend>
   <depend>urg_node</depend>