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

Refactor Test Fixture to support different worlds #160

Merged
merged 3 commits into from
Mar 2, 2022
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
26 changes: 19 additions & 7 deletions lrauv_ignition_plugins/test/helper/LrauvTestFixture.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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,
Expand Down Expand Up @@ -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
protected: void SetUp() override
{
LrauvTestFixtureBase::SetUp("buoyant_tethys.sdf");
}
};
#endif