25
25
26
26
#include < ignition/utilities/ExtraTestMacros.hh>
27
27
28
+ #include " sdf/Light.hh"
29
+ #include " sdf/Link.hh"
28
30
#include " sdf/Model.hh"
29
31
#include " sdf/Root.hh"
30
32
#include " sdf/World.hh"
@@ -121,6 +123,16 @@ TEST(check_cmd, IGN_UTILS_TEST_DISABLED_ON_WIN32(SDF))
121
123
EXPECT_EQ (
122
124
" ignition-gazebo-scene-broadcaster-system" , plugins[3 ].Filename ());
123
125
126
+ // the world should have lights attached to it
127
+ std::set<std::string> savedLightNames;
128
+ for (unsigned int i = 0 ; i < world->LightCount (); ++i)
129
+ savedLightNames.insert (world->LightByIndex (i)->Name ());
130
+ EXPECT_EQ (3u , savedLightNames.size ());
131
+
132
+ EXPECT_NE (savedLightNames.end (), savedLightNames.find (" defaultLight" ));
133
+ EXPECT_NE (savedLightNames.end (), savedLightNames.find (" diskLight" ));
134
+ EXPECT_NE (savedLightNames.end (), savedLightNames.find (" sun" ));
135
+
124
136
// make sure all models in the USD file were correctly parsed to SDF
125
137
std::set<std::string> savedModelNames;
126
138
for (unsigned int i = 0 ; i < world->ModelCount (); ++i)
@@ -140,20 +152,30 @@ TEST(check_cmd, IGN_UTILS_TEST_DISABLED_ON_WIN32(SDF))
140
152
ASSERT_NE (nullptr , world->ModelByName (" box" ));
141
153
EXPECT_FALSE (world->ModelByName (" box" )->Static ());
142
154
143
- // check that models have the right links
144
- std::function<void (const std::string &, const std::string &)> checkLink =
145
- [&world](const std::string &_modelName, const std::string &_linkName)
155
+ // Check that models have the right links.
156
+ // If a link should have a light attached to it, check that as well
157
+ std::function<void (const std::string &, const std::string &,
158
+ const std::string &)> checkLink =
159
+ [&world](const std::string &_modelName, const std::string &_linkName,
160
+ const std::string &_lightLinkName)
146
161
{
147
162
const auto modelPtr = world->ModelByName (_modelName);
148
163
ASSERT_NE (nullptr , modelPtr);
149
164
EXPECT_EQ (1u , modelPtr->LinkCount ());
150
165
EXPECT_NE (nullptr , modelPtr->LinkByName (_linkName));
166
+
167
+ if (!_lightLinkName.empty ())
168
+ {
169
+ auto modelLink = modelPtr->LinkByName (_linkName);
170
+ ASSERT_NE (nullptr , modelLink);
171
+ EXPECT_NE (nullptr , modelLink->LightByName (_lightLinkName));
172
+ }
151
173
};
152
- checkLink (" ground_plane" , " link" );
153
- checkLink (" box" , " box_link" );
154
- checkLink (" cylinder" , " cylinder_link" );
155
- checkLink (" sphere" , " sphere_link" );
156
- checkLink (" capsule" , " capsule_link" );
157
- checkLink (" ellipsoid" , " ellipsoid_link" );
174
+ checkLink (" ground_plane" , " link" , " " );
175
+ checkLink (" box" , " box_link" , " boxModelLight " );
176
+ checkLink (" cylinder" , " cylinder_link" , " " );
177
+ checkLink (" sphere" , " sphere_link" , " " );
178
+ checkLink (" capsule" , " capsule_link" , " " );
179
+ checkLink (" ellipsoid" , " ellipsoid_link" , " " );
158
180
}
159
181
}
0 commit comments