Increase test coverage of rclcpp_lifecycle to 96% (#1298)
* Increase test coverage of rclcpp_lifecycle to 96% Signed-off-by: Stephen Brawner <brawner@gmail.com> * PR Fixup Signed-off-by: Stephen Brawner <brawner@gmail.com> * test_depend Signed-off-by: Stephen Brawner <brawner@gmail.com> * rcutils test_depend Signed-off-by: Stephen Brawner <brawner@gmail.com> * More windows warnings Signed-off-by: Stephen Brawner <brawner@gmail.com>
This commit is contained in:
parent
ed7a23731a
commit
e920175dae
7 changed files with 921 additions and 14 deletions
|
@ -36,6 +36,8 @@
|
|||
#include "rclcpp/rclcpp.hpp"
|
||||
#include "rclcpp_lifecycle/lifecycle_node.hpp"
|
||||
|
||||
#include "./mocking_utils/patch.hpp"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
constexpr char const * lifecycle_node_name = "lc_talker";
|
||||
|
@ -393,3 +395,56 @@ TEST_F(TestLifecycleServiceClient, wait_for_graph_change)
|
|||
node_graph->wait_for_graph_change(event, std::chrono::milliseconds(0)),
|
||||
rclcpp::exceptions::EventNotRegisteredError);
|
||||
}
|
||||
|
||||
class TestLifecycleServiceClientRCLErrors : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
rclcpp::init(0, nullptr);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
rclcpp::shutdown();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(TestLifecycleServiceClientRCLErrors, call_services_rcl_errors) {
|
||||
auto lifecycle_node = std::make_shared<EmptyLifecycleNode>();
|
||||
auto lifecycle_client = std::make_shared<LifecycleServiceClient>("client_with_errors");
|
||||
|
||||
auto mock = mocking_utils::patch_and_return(
|
||||
"lib:rclcpp_lifecycle", rcl_lifecycle_state_machine_is_initialized, RCL_RET_ERROR);
|
||||
|
||||
// on_change_state
|
||||
lifecycle_client->change_state(
|
||||
lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE);
|
||||
rclcpp::spin_some(lifecycle_client);
|
||||
EXPECT_THROW(
|
||||
rclcpp::spin_some(lifecycle_node->get_node_base_interface()), std::runtime_error);
|
||||
|
||||
// on_get_state
|
||||
lifecycle_client->get_state();
|
||||
rclcpp::spin_some(lifecycle_client);
|
||||
EXPECT_THROW(
|
||||
rclcpp::spin_some(lifecycle_node->get_node_base_interface()), std::runtime_error);
|
||||
|
||||
// on_get_avilable_states
|
||||
lifecycle_client->get_available_states();
|
||||
rclcpp::spin_some(lifecycle_client);
|
||||
EXPECT_THROW(
|
||||
rclcpp::spin_some(lifecycle_node->get_node_base_interface()), std::runtime_error);
|
||||
|
||||
// on_get_available_transitions
|
||||
lifecycle_client->get_available_transitions();
|
||||
rclcpp::spin_some(lifecycle_client);
|
||||
EXPECT_THROW(
|
||||
rclcpp::spin_some(lifecycle_node->get_node_base_interface()), std::runtime_error);
|
||||
|
||||
// on_get_transition_graph
|
||||
lifecycle_client->get_transition_graph();
|
||||
rclcpp::spin_some(lifecycle_client);
|
||||
EXPECT_THROW(
|
||||
rclcpp::spin_some(lifecycle_node->get_node_base_interface()), std::runtime_error);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue