Skip to content

Commit

Permalink
Test solved
Browse files Browse the repository at this point in the history
Signed-off-by: Juancams <[email protected]>
  • Loading branch information
Juancams committed Oct 4, 2024
1 parent 00d40ec commit 7990dd1
Showing 1 changed file with 45 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ TEST_F(IntegrationTest, CreateStringPublisher)
auto response =
std::make_shared<coresense_instrumentation_interfaces::srv::CreatePublisher::Response>();
request->topic_name = "/new_test_topic";
request->qos_history = "KEEP_LAST";
request->qos_queue = 10;
request->qos_reliability = "RELIABLE";
request->qos_durability = "VOLATILE";

client->async_send_request(
request,
Expand All @@ -236,7 +240,7 @@ TEST_F(IntegrationTest, CreateStringPublisher)
executor.spin_once(std::chrono::milliseconds(100));
}

ASSERT_EQ(response->success, false);
ASSERT_EQ(response->success, true);
}

TEST_F(IntegrationTest, DeleteStringPublisher)
Expand Down Expand Up @@ -282,7 +286,7 @@ TEST_F(IntegrationTest, DeleteStringPublisher)
executor.spin_once(std::chrono::milliseconds(100));
}

ASSERT_EQ(response_create->success, false);
ASSERT_EQ(response_create->success, true);

auto request_delete =
std::make_shared<coresense_instrumentation_interfaces::srv::DeletePublisher::Request>();
Expand All @@ -309,7 +313,7 @@ TEST_F(IntegrationTest, DeleteStringPublisher)
executor.spin_once(std::chrono::milliseconds(100));
}

ASSERT_EQ(response_delete->success, false);
ASSERT_EQ(response_delete->success, true);
}

TEST_F(IntegrationTest, CreateTwistSubscription)
Expand Down Expand Up @@ -355,7 +359,7 @@ TEST_F(IntegrationTest, CreateTwistSubscription)
executor.spin_once(std::chrono::milliseconds(100));
}

ASSERT_EQ(response->success, false);
ASSERT_EQ(response->success, true);
}

TEST_F(IntegrationTest, DeleteTwistSubscription)
Expand Down Expand Up @@ -401,7 +405,7 @@ TEST_F(IntegrationTest, DeleteTwistSubscription)
executor.spin_once(std::chrono::milliseconds(100));
}

ASSERT_EQ(response_create->success, false);
ASSERT_EQ(response_create->success, true);

auto request_delete =
std::make_shared<coresense_instrumentation_interfaces::srv::DeleteSubscriber::Request>();
Expand All @@ -428,7 +432,42 @@ TEST_F(IntegrationTest, DeleteTwistSubscription)
executor.spin_once(std::chrono::milliseconds(100));
}

ASSERT_EQ(response_delete->success, false);
ASSERT_EQ(response_delete->success, true);
}

TEST_F(IntegrationTest, GetStatus)
{
rclcpp::executors::SingleThreadedExecutor executor;

auto node =
std::make_shared<coresense_instrumentation_driver::InstrumentationProducer<std_msgs::msg::String>>(
rclcpp::NodeOptions().append_parameter_override(
"topic",
"/test_topic").append_parameter_override(
"topic_type", "std_msgs::msg::String").
append_parameter_override("type", "Producer"));

auto node_sub = rclcpp::Node::make_shared("node_sub");

executor.add_node(node->get_node_base_interface());
executor.add_node(node_sub->get_node_base_interface());

auto node_info = std::make_shared<coresense_instrumentation_interfaces::msg::NodeInfo>();

auto sub = node_sub->create_subscription<coresense_instrumentation_interfaces::msg::NodeInfo>(
"/status", 10,
[&node_info](const coresense_instrumentation_interfaces::msg::NodeInfo::SharedPtr msg) {
node_info = std::move(msg);
});

for (int i = 0; i < 30; i++) {
executor.spin_once(std::chrono::milliseconds(100));
}

ASSERT_EQ(node_info->node_name, "lifecycle_node");
ASSERT_EQ(node_info->type, "Producer");
ASSERT_EQ(node_info->state, 1);
ASSERT_EQ(node_info->type_msg, "std_msgs::msg::String");
}

TEST_F(IntegrationTest, GetTopic)
Expand Down

0 comments on commit 7990dd1

Please sign in to comment.