Skip to content

Commit

Permalink
Fix bug and improved test
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <[email protected]>
  • Loading branch information
ahcorde committed Apr 20, 2022
1 parent 8881e09 commit 6e3f4b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Conversions_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ TEST(Conversions, Light)
light.SetSpotOuterAngle(3.3);
light.SetSpotFalloff(0.9);
light.SetIntensity(1.7);
light.SetLightOn(true);

msgs::Light lightMsg;
lightMsg = convert<msgs::Light>(light);
Expand All @@ -76,6 +77,7 @@ TEST(Conversions, Light)
/// \todo(anyone) add pose frame fields in ign-msgs?
// EXPECT_EQ("world", lightMsg.pose_frame());
EXPECT_TRUE(lightMsg.cast_shadows());
EXPECT_FALSE(lightMsg.is_light_off());
EXPECT_EQ(math::Color(0.4f, 0.5f, 0.6f, 1),
msgs::Convert(lightMsg.diffuse()));
EXPECT_EQ(math::Color(0.8f, 0.9f, 0.1f, 1),
Expand Down
2 changes: 1 addition & 1 deletion src/gui/plugins/component_inspector/ComponentInspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void ignition::gazebo::setData(QStandardItem *_item, const msgs::Light &_data)
QVariant(_data.spot_falloff()),
QVariant(_data.intensity()),
QVariant(lightType),
QVariant(_data.is_light_off()),
QVariant(!_data.is_light_off()),
QVariant(visualizeVisual)
}), ComponentsModel::RoleNames().key("data"));
}
Expand Down
9 changes: 8 additions & 1 deletion test/integration/user_commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ TEST_F(UserCommandsTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Light))
EXPECT_NEAR(0.2, pointLightComp->Data().ConstantAttenuationFactor(), 0.1);
EXPECT_NEAR(0.01, pointLightComp->Data().QuadraticAttenuationFactor(), 0.1);
EXPECT_FALSE(pointLightComp->Data().CastShadows());
EXPECT_TRUE(pointLightComp->Data().LightOn());

req.Clear();
ignition::msgs::Set(req.mutable_diffuse(),
Expand All @@ -835,7 +836,7 @@ TEST_F(UserCommandsTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Light))
req.set_attenuation_constant(0.6f);
req.set_attenuation_quadratic(0.001f);
req.set_cast_shadows(true);
req.set_is_light_off(true);
req.set_is_light_off(false);

EXPECT_TRUE(node.Request(service, req, timeout, res, result));
EXPECT_TRUE(result);
Expand All @@ -858,6 +859,7 @@ TEST_F(UserCommandsTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Light))
EXPECT_NEAR(0.6, pointLightComp->Data().ConstantAttenuationFactor(), 0.1);
EXPECT_NEAR(0.001, pointLightComp->Data().QuadraticAttenuationFactor(), 0.1);
EXPECT_TRUE(pointLightComp->Data().CastShadows());
EXPECT_TRUE(pointLightComp->Data().LightOn());
EXPECT_EQ(sdf::LightType::POINT, pointLightComp->Data().Type());

// Check directional light entity has not been edited yet - Initial values
Expand Down Expand Up @@ -885,6 +887,7 @@ TEST_F(UserCommandsTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Light))
EXPECT_EQ(
math::Vector3d(0.5, 0.2, -0.9), directionalLightComp->Data().Direction());
EXPECT_TRUE(directionalLightComp->Data().CastShadows());
EXPECT_TRUE(directionalLightComp->Data().LightOn());
EXPECT_EQ(sdf::LightType::POINT, pointLightComp->Data().Type());

req.Clear();
Expand All @@ -899,6 +902,7 @@ TEST_F(UserCommandsTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Light))
req.set_attenuation_constant(0.6f);
req.set_attenuation_quadratic(1.0f);
req.set_cast_shadows(false);
req.set_is_light_off(false);
ignition::msgs::Set(req.mutable_direction(),
ignition::math::Vector3d(1, 2, 3));
EXPECT_TRUE(node.Request(service, req, timeout, res, result));
Expand Down Expand Up @@ -927,6 +931,7 @@ TEST_F(UserCommandsTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Light))
1, directionalLightComp->Data().QuadraticAttenuationFactor(), 0.1);
EXPECT_EQ(math::Vector3d(1, 2, 3), directionalLightComp->Data().Direction());
EXPECT_FALSE(directionalLightComp->Data().CastShadows());
EXPECT_TRUE(directionalLightComp->Data().LightOn());
EXPECT_EQ(sdf::LightType::DIRECTIONAL,
directionalLightComp->Data().Type());

Expand Down Expand Up @@ -969,6 +974,7 @@ TEST_F(UserCommandsTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Light))
req.set_attenuation_constant(0.6f);
req.set_attenuation_quadratic(1.0f);
req.set_cast_shadows(true);
req.set_is_light_off(true);
ignition::msgs::Set(req.mutable_direction(),
ignition::math::Vector3d(1, 2, 3));
req.set_spot_inner_angle(1.5f);
Expand Down Expand Up @@ -997,6 +1003,7 @@ TEST_F(UserCommandsTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Light))
EXPECT_NEAR(1, spotLightComp->Data().QuadraticAttenuationFactor(), 0.1);
EXPECT_EQ(math::Vector3d(1, 2, 3), spotLightComp->Data().Direction());
EXPECT_TRUE(spotLightComp->Data().CastShadows());
EXPECT_FALSE(spotLightComp->Data().LightOn());
EXPECT_EQ(sdf::LightType::SPOT, spotLightComp->Data().Type());
EXPECT_NEAR(1.5, spotLightComp->Data().SpotInnerAngle().Radian(), 0.1);
EXPECT_NEAR(0.3, spotLightComp->Data().SpotOuterAngle().Radian(), 0.1);
Expand Down

0 comments on commit 6e3f4b0

Please sign in to comment.