Skip to content

Commit

Permalink
fix ROS2FrameComponent::UpdateNamespaceConfiguration()
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Żak <[email protected]>
  • Loading branch information
zakmat committed Oct 10, 2024
1 parent f71979b commit 6a47d0c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Gems/ROS2/Code/Source/Frame/NamespaceConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ namespace ROS2
{
m_namespace = ros2Namespace;
m_namespaceStrategy = strategy;

if (strategy == NamespaceStrategy::Custom) {
m_customNamespace = ros2Namespace;
}

UpdateNamespace();
}

Expand Down
18 changes: 18 additions & 0 deletions Gems/ROS2/Code/Tests/Frame/ROS2FrameComponentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,24 @@ namespace UnitTest
}
}

TEST_F(ROS2FrameComponentFixture, UpdateNamespace_Custom)
{
ROS2::ROS2FrameConfiguration config;

AZ::Entity entity;
const std::string entityName = entity.GetName().c_str();
entity.CreateComponent<AzFramework::TransformComponent>();
auto frame = entity.CreateComponent<ROS2::ROS2FrameComponent>(config);


entity.Init();
entity.Activate();

ASSERT_STREQ(frame->GetNamespace().c_str(), ("o3de_" + entityName).c_str());
frame->UpdateNamespaceConfiguration("MyCustomNamespace", ROS2::NamespaceConfiguration::NamespaceStrategy::Custom);
EXPECT_STREQ(frame->GetNamespace().c_str(), "MyCustomNamespace");
}

} // namespace UnitTest

// required to support running integration tests with Qt and PhysX
Expand Down

0 comments on commit 6a47d0c

Please sign in to comment.