Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Oct 21, 2024
1 parent 2fe2078 commit d6e3c39
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions panther_manager/test/plugins/condition/test_check_joy_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ class TestCheckJoyMsg : public panther_manager::plugin_test_utils::PluginTestUti
JoyMsg CreateMsg(
const std::vector<float> & axes = {}, const std::vector<int> & buttons = {},
const HeaderMsg & header = HeaderMsg());
void SetCurrentHeaderTime(HeaderMsg & header)
{
header.stamp.sec = bt_node_->now().seconds();
header.stamp.nanosec = bt_node_->now().nanoseconds();
}
void SetCurrentMsgTime(JoyMsg & header);

protected:
rclcpp::Publisher<JoyMsg>::SharedPtr joy_publisher_;
Expand All @@ -76,6 +72,12 @@ JoyMsg TestCheckJoyMsg::CreateMsg(
return msg;
}

void TestCheckJoyMsg::SetCurrentMsgTime(JoyMsg & msg)
{
msg.header.stamp.sec = bt_node_->now().seconds();
msg.header.stamp.nanosec = bt_node_->now().nanoseconds();
}

TEST_F(TestCheckJoyMsg, NoTopicSet)
{
bt_ports input = {{"topic_name", ""}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}};
Expand Down Expand Up @@ -109,10 +111,8 @@ TEST_F(TestCheckJoyMsg, TimeoutTests)
CreateMsg()}};

for (auto & test_case : test_cases) {
SCOPED_TRACE("Test case name: " + test_case.name);

CreateTree(PLUGIN, test_case.input);
SetCurrentHeaderTime(test_case.msg.header);
SetCurrentMsgTime(test_case.msg);
std::this_thread::sleep_for(std::chrono::milliseconds(2));
PublishMsg(test_case.msg);

Expand Down Expand Up @@ -177,7 +177,7 @@ TEST_F(TestCheckJoyMsg, OnTickBehavior)

for (auto & test_case : test_cases) {
CreateTree(PLUGIN, test_case.input);
SetCurrentHeaderTime(test_case.msg.header);
SetCurrentMsgTime(test_case.msg);
PublishMsg(test_case.msg);

auto & tree = GetTree();
Expand Down

0 comments on commit d6e3c39

Please sign in to comment.