@@ -226,6 +226,45 @@ TEST_F(TestServer, construction_and_destruction_sub_node)
226
226
});
227
227
}
228
228
229
+ TEST_F (TestServer, action_name)
230
+ {
231
+ auto create_server_func = [](std::shared_ptr<rclcpp::Node> node, const std::string & action_name)
232
+ {
233
+ using GoalHandle = rclcpp_action::ServerGoalHandle<Fibonacci>;
234
+ auto as = rclcpp_action::create_server<Fibonacci>(
235
+ node, action_name,
236
+ [](const GoalUUID &, std::shared_ptr<const Fibonacci::Goal>) {
237
+ return rclcpp_action::GoalResponse::REJECT;
238
+ },
239
+ [](std::shared_ptr<GoalHandle>) {
240
+ return rclcpp_action::CancelResponse::REJECT;
241
+ },
242
+ [](std::shared_ptr<GoalHandle>) {});
243
+ return as;
244
+ };
245
+
246
+ {
247
+ // Default namespace
248
+ auto test_node = std::make_shared<rclcpp::Node>(" test_node" );
249
+ auto action_server = create_server_func (test_node, " my_action" );
250
+ EXPECT_EQ (action_server->expand_action_name (), " /my_action" );
251
+ }
252
+
253
+ {
254
+ // Custom namespace
255
+ auto test_node = std::make_shared<rclcpp::Node>(" test_node" , " test_namespace" );
256
+ auto action_server = create_server_func (test_node, " my_action" );
257
+ EXPECT_EQ (action_server->expand_action_name (), " /test_namespace/my_action" );
258
+ }
259
+
260
+ {
261
+ // Action with absolute (global) name
262
+ auto test_node = std::make_shared<rclcpp::Node>(" test_node" , " test_namespace" );
263
+ auto action_server = create_server_func (test_node, " /my_action" );
264
+ EXPECT_EQ (action_server->expand_action_name (), " /my_action" );
265
+ }
266
+ }
267
+
229
268
TEST_F (TestServer, handle_goal_called)
230
269
{
231
270
auto node = std::make_shared<rclcpp::Node>(" handle_goal_node" , " /rclcpp_action/handle_goal" );
0 commit comments