Skip to content

Commit

Permalink
Update user_commands test check all spheres.
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
  • Loading branch information
bperseghetti committed Jan 23, 2024
1 parent ed1b31c commit 89a6367
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
27 changes: 24 additions & 3 deletions test/integration/user_commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1116,16 +1116,37 @@ TEST_F(UserCommandsTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(MaterialColor))
gz::msgs::Set(materialColorMsg.mutable_diffuse(),
gz::math::Color(1.0f, 1.0f, 1.0f, 1.0f));

Entity sphereEntity0 =
ecm->EntityByComponents(components::Name("sphere_0"));
Entity sphereEntity1 =
ecm->EntityByComponents(components::Name("sphere_1"));
auto sphereLinkEntity0 =
ecm->ChildrenByComponents(sphereEntity0, components::Name("sphere_link_0"))[0];
auto sphereLinkEntity1 =
ecm->ChildrenByComponents(sphereEntity1, components::Name("sphere_link_1"))[0];
auto sphereVisualEntity0 =
ecm->ChildrenByComponents(sphereLinkEntity0, components::Name("sphere_visual"))[0];
auto sphereVisualEntity1 =
ecm->ChildrenByComponents(sphereLinkEntity1, components::Name("sphere_visual"))[0];
auto updatedVisual0 =
ecm->Component<components::Material>(sphereVisualEntity0);
auto updatedVisual1 =
ecm->Component<components::Material>(sphereVisualEntity1);
EXPECT_TRUE((math::Color(0.0f, 0.0f, 0.0f, 1.0f) ==
updatedVisual0->Data().Diffuse()) ||
(math::Color(0.0f, 0.0f, 0.0f, 1.0f) ==
updatedVisual1->Data().Diffuse()));

// Publish material color
pub.Publish(materialColorMsg);
server.Run(true, 100, false);
// Sleep for a small duration to allow Run thread to start
GZ_SLEEP_MS(100);

auto updatedVisual =
ecm->Component<components::Material>(sphereVisualEntity);
EXPECT_EQ(math::Color(1.0f, 1.0f, 1.0f, 1.0f),
updatedVisual->Data().Diffuse());
updatedVisual0->Data().Diffuse());
EXPECT_EQ(math::Color(1.0f, 1.0f, 1.0f, 1.0f),
updatedVisual1->Data().Diffuse());
}

/////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions test/worlds/material_color.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<render_engine>ogre2</render_engine>
</plugin>

<model name="sphere">
<model name="sphere_0">
<pose>0 0.0 0.0 0 0 0</pose>
<link name="sphere_link">
<link name="sphere_link_0">
<!-- Added a render sensor to trigger RenderUtil:Update -->
<sensor name="camera" type="camera">
<pose>1 0 1.3 0 0 0</pose>
Expand Down Expand Up @@ -57,7 +57,7 @@
</model>
<model name="sphere_1">
<pose>0.5 1.0 0.0 0 0 0</pose>
<link name="sphere_link">
<link name="sphere_link_1">
<visual name="sphere_visual">
<geometry>
<sphere>
Expand Down

0 comments on commit 89a6367

Please sign in to comment.