Skip to content

Commit

Permalink
Added integration test for light_config topic
Browse files Browse the repository at this point in the history
Signed-off-by: William Lew <WilliamMilesLew@gmail.com>
  • Loading branch information
WilliamLewww committed Dec 28, 2021
1 parent 7d704f4 commit f45e17c
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/integration/user_commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,8 @@ TEST_F(UserCommandsTest, Light)
{
// Start server
ServerConfig serverConfig;
const auto sdfFile = ignition::common::joinPaths(
std::string(PROJECT_SOURCE_PATH), "test", "worlds", "lights_render.sdf");
const auto sdfFile = std::string(PROJECT_SOURCE_PATH) +
"/test/worlds/lights_render.sdf";
serverConfig.SetSdfFile(sdfFile);

Server server(serverConfig);
Expand Down Expand Up @@ -919,6 +919,25 @@ TEST_F(UserCommandsTest, Light)
EXPECT_NEAR(1.5, spotLightComp->Data().SpotInnerAngle().Radian(), 0.1);
EXPECT_NEAR(0.3, spotLightComp->Data().SpotOuterAngle().Radian(), 0.1);
EXPECT_NEAR(0.9, spotLightComp->Data().SpotFalloff(), 0.1);

// Test light_config topic
const std::string lightTopic = "/world/lights_command/light_config";

msgs::Light lightMsg;
lightMsg.set_name("spot");
ignition::msgs::Set(lightMsg.mutable_diffuse(),
ignition::math::Color(1.0f, 1.0f, 1.0f, 1.0f));

// Publish joint trajectory
auto pub = node.Advertise<msgs::Light>(lightTopic);
pub.Publish(lightMsg);

server.Run(true, 100, false);
// Sleep for a small duration to allow Run thread to start
IGN_SLEEP_MS(10);

EXPECT_EQ(math::Color(1.0f, 1.0f, 1.0f, 1.0f),
spotLightComp->Data().Diffuse());
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit f45e17c

Please sign in to comment.