-
Notifications
You must be signed in to change notification settings - Fork 15
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
Refactor Test Fixture to support different worlds #160
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -50,12 +50,13 @@ double angleDiff(double _a, double _b) | |||||
return diff.Radian(); | ||||||
} | ||||||
|
||||||
/// \brief Convenient fixture that provides boilerplate code common to most | ||||||
/// LRAUV tests. | ||||||
class LrauvTestFixture : public ::testing::Test | ||||||
/// \brief Abstract base class for fixture that provides boilerplate code common | ||||||
/// to most LRAUV tests. | ||||||
class LrauvTestFixtureBase : public ::testing::Test | ||||||
{ | ||||||
// Documentation inherited | ||||||
protected: void SetUp() override | ||||||
// Setup the specified world. | ||||||
// \param[in] _worldName Name of the world to load. | ||||||
public: void SetUp(const std::string &_worldName) | ||||||
{ | ||||||
ignition::common::Console::SetVerbosity(4); | ||||||
|
||||||
|
@@ -66,12 +67,12 @@ class LrauvTestFixture : public ::testing::Test | |||||
commandTopic); | ||||||
|
||||||
auto stateTopic = "/tethys/state_topic"; | ||||||
this->node.Subscribe(stateTopic, &LrauvTestFixture::OnState, this); | ||||||
this->node.Subscribe(stateTopic, &LrauvTestFixtureBase::OnState, this); | ||||||
|
||||||
// Setup fixture | ||||||
this->fixture = std::make_unique<ignition::gazebo::TestFixture>( | ||||||
ignition::common::joinPaths( | ||||||
std::string(PROJECT_SOURCE_PATH), "worlds", "buoyant_tethys.sdf")); | ||||||
std::string(PROJECT_SOURCE_PATH), "worlds", _worldName)); | ||||||
|
||||||
fixture->OnPostUpdate( | ||||||
[&](const ignition::gazebo::UpdateInfo &_info, | ||||||
|
@@ -302,4 +303,15 @@ class LrauvTestFixture : public ::testing::Test | |||||
/// \brief Publishes commands | ||||||
public: ignition::transport::Node::Publisher commandPub; | ||||||
}; | ||||||
|
||||||
|
||||||
/// \brief Loads the default "buyant_tethys.sdf" world. | ||||||
class LrauvTestFixture : public LrauvTestFixtureBase | ||||||
{ | ||||||
/// Documentation inherited | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
So, within the Ignition codebase, we leave "Documentation inherited" comments to explain that we're not adding documentation on purpose. When it's not added, the documentation is taken from the base class. But if the comment is added with three Not important here since we're not generating docs for these classes, but I thought I should mention |
||||||
protected: void SetUp() override | ||||||
{ | ||||||
LrauvTestFixtureBase::SetUp("buoyant_tethys.sdf"); | ||||||
} | ||||||
}; | ||||||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.