Skip to content

Commit

Permalink
Avoid multiple type topics in tests. (#1150)
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
  • Loading branch information
hidmic authored Jun 1, 2020
1 parent ed68b4b commit 819612a
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace
constexpr const char kTestPubNodeName[]{"test_pub_stats_node"};
constexpr const char kTestSubNodeName[]{"test_sub_stats_node"};
constexpr const char kTestSubStatsTopic[]{"/test_sub_stats_topic"};
constexpr const char kTestSubStatsEmptyTopic[]{"/test_sub_stats_empty_topic"};
constexpr const char kTestTopicStatisticsTopic[]{"/test_topic_statistics_topic"};
constexpr const uint64_t kNoSamples{0};
constexpr const std::chrono::seconds kTestDuration{10};
Expand Down Expand Up @@ -210,21 +211,20 @@ class TestSubscriptionTopicStatisticsFixture : public ::testing::Test
void SetUp()
{
rclcpp::init(0 /* argc */, nullptr /* argv */);
empty_subscriber = std::make_shared<EmptySubscriber>(
kTestSubNodeName,
kTestSubStatsTopic);
}

void TearDown()
{
rclcpp::shutdown();
empty_subscriber.reset();
}
std::shared_ptr<EmptySubscriber> empty_subscriber;
};

TEST_F(TestSubscriptionTopicStatisticsFixture, test_manual_construction)
{
auto empty_subscriber = std::make_shared<EmptySubscriber>(
kTestSubNodeName,
kTestSubStatsEmptyTopic);

// Manually create publisher tied to the node
auto topic_stats_publisher =
empty_subscriber->create_publisher<MetricsMessage>(
Expand All @@ -251,7 +251,7 @@ TEST_F(TestSubscriptionTopicStatisticsFixture, test_receive_stats_for_message_no
// Create an empty publisher
auto empty_publisher = std::make_shared<EmptyPublisher>(
kTestPubNodeName,
kTestSubStatsTopic);
kTestSubStatsEmptyTopic);
// empty_subscriber has a topic statistics instance as part of its subscription
// this will listen to and generate statistics for the empty message

Expand All @@ -261,6 +261,10 @@ TEST_F(TestSubscriptionTopicStatisticsFixture, test_receive_stats_for_message_no
"/statistics",
2);

auto empty_subscriber = std::make_shared<EmptySubscriber>(
kTestSubNodeName,
kTestSubStatsEmptyTopic);

rclcpp::executors::SingleThreadedExecutor ex;
ex.add_node(empty_publisher);
ex.add_node(statistics_listener);
Expand Down

0 comments on commit 819612a

Please sign in to comment.