Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid multiple type topics in tests. #1150

Merged
merged 3 commits into from
Jun 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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