forked from gazebosim/gz-sim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Util_TEST.cc
1026 lines (862 loc) · 39.2 KB
/
Util_TEST.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
863
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2019 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <gtest/gtest.h>
#include <gz/common/Console.hh>
#include <sdf/Actor.hh>
#include <sdf/Light.hh>
#include <sdf/Types.hh>
#include <gz/fuel_tools/ClientConfig.hh>
#include "gz/sim/components/Actor.hh"
#include "gz/sim/components/Collision.hh"
#include "gz/sim/components/Joint.hh"
#include "gz/sim/components/Light.hh"
#include "gz/sim/components/Link.hh"
#include "gz/sim/components/Model.hh"
#include "gz/sim/components/Name.hh"
#include "gz/sim/components/ParentEntity.hh"
#include "gz/sim/components/ParticleEmitter.hh"
#include "gz/sim/components/Projector.hh"
#include "gz/sim/components/Sensor.hh"
#include "gz/sim/components/Visual.hh"
#include "gz/sim/components/World.hh"
#include "gz/sim/EntityComponentManager.hh"
#include "gz/sim/Util.hh"
#include "helpers/EnvTestFixture.hh"
#include "test_config.hh"
using namespace gz;
using namespace sim;
/// \brief Tests for Util.hh
class UtilTest : public InternalFixture<::testing::Test>
{
};
/////////////////////////////////////////////////
TEST_F(UtilTest, ScopedName)
{
EntityComponentManager ecm;
// world
// - lightA
// - modelB
// - linkB
// - lightB
// - sensorB
// - modelC
// - linkC
// - collisionC
// - visualC
// - jointC
// - modelCC
// - linkCC
// - actorD
// World
auto worldEntity = ecm.CreateEntity();
EXPECT_EQ(kNullEntity, sim::worldEntity(ecm));
EXPECT_EQ(kNullEntity, sim::worldEntity(worldEntity, ecm));
ecm.CreateComponent(worldEntity, components::World());
ecm.CreateComponent(worldEntity, components::Name("world_name"));
// Light A
auto lightAEntity = ecm.CreateEntity();
ecm.CreateComponent(lightAEntity, components::Light(sdf::Light()));
ecm.CreateComponent(lightAEntity, components::Name("lightA_name"));
ecm.CreateComponent(lightAEntity, components::ParentEntity(worldEntity));
// Model B
auto modelBEntity = ecm.CreateEntity();
ecm.CreateComponent(modelBEntity, components::Model());
ecm.CreateComponent(modelBEntity, components::Name("modelB_name"));
ecm.CreateComponent(modelBEntity, components::ParentEntity(worldEntity));
// Link B
auto linkBEntity = ecm.CreateEntity();
ecm.CreateComponent(linkBEntity, components::Link());
ecm.CreateComponent(linkBEntity, components::Name("linkB_name"));
ecm.CreateComponent(linkBEntity, components::ParentEntity(modelBEntity));
// Light B
auto lightBEntity = ecm.CreateEntity();
ecm.CreateComponent(lightBEntity, components::Light(sdf::Light()));
ecm.CreateComponent(lightBEntity, components::Name("lightB_name"));
ecm.CreateComponent(lightBEntity, components::ParentEntity(linkBEntity));
// Sensor B
auto sensorBEntity = ecm.CreateEntity();
ecm.CreateComponent(sensorBEntity, components::Sensor());
ecm.CreateComponent(sensorBEntity, components::Name("sensorB_name"));
ecm.CreateComponent(sensorBEntity, components::ParentEntity(linkBEntity));
// Model C
auto modelCEntity = ecm.CreateEntity();
ecm.CreateComponent(modelCEntity, components::Model());
ecm.CreateComponent(modelCEntity, components::Name("modelC_name"));
ecm.CreateComponent(modelCEntity, components::ParentEntity(worldEntity));
// Link C
auto linkCEntity = ecm.CreateEntity();
ecm.CreateComponent(linkCEntity, components::Link());
ecm.CreateComponent(linkCEntity, components::Name("linkC_name"));
ecm.CreateComponent(linkCEntity, components::ParentEntity(modelCEntity));
// Collision C
auto collisionCEntity = ecm.CreateEntity();
ecm.CreateComponent(collisionCEntity, components::Collision());
ecm.CreateComponent(collisionCEntity, components::Name("collisionC_name"));
ecm.CreateComponent(collisionCEntity, components::ParentEntity(linkCEntity));
// Visual C
auto visualCEntity = ecm.CreateEntity();
ecm.CreateComponent(visualCEntity, components::Visual());
ecm.CreateComponent(visualCEntity, components::Name("visualC_name"));
ecm.CreateComponent(visualCEntity, components::ParentEntity(linkCEntity));
// Link C
auto jointCEntity = ecm.CreateEntity();
ecm.CreateComponent(jointCEntity, components::Joint());
ecm.CreateComponent(jointCEntity, components::Name("jointC_name"));
ecm.CreateComponent(jointCEntity, components::ParentEntity(modelCEntity));
// Model CC
auto modelCCEntity = ecm.CreateEntity();
ecm.CreateComponent(modelCCEntity, components::Model());
ecm.CreateComponent(modelCCEntity, components::Name("modelCC_name"));
ecm.CreateComponent(modelCCEntity, components::ParentEntity(modelCEntity));
// Link CC
auto linkCCEntity = ecm.CreateEntity();
ecm.CreateComponent(linkCCEntity, components::Link());
ecm.CreateComponent(linkCCEntity, components::Name("linkCC_name"));
ecm.CreateComponent(linkCCEntity, components::ParentEntity(modelCCEntity));
// Actor D
auto actorDEntity = ecm.CreateEntity();
ecm.CreateComponent(actorDEntity, components::Actor(sdf::Actor()));
ecm.CreateComponent(actorDEntity, components::Name("actorD_name"));
ecm.CreateComponent(actorDEntity, components::ParentEntity(worldEntity));
// Check names
EXPECT_EQ(scopedName(worldEntity, ecm), "world/world_name");
EXPECT_EQ(scopedName(lightAEntity, ecm, "::"),
"world::world_name::light::lightA_name");
EXPECT_EQ(scopedName(modelBEntity, ecm, "/"),
"world/world_name/model/modelB_name");
EXPECT_EQ(scopedName(linkBEntity, ecm, " "),
"world world_name model modelB_name link linkB_name");
EXPECT_EQ(scopedName(lightBEntity, ecm),
"world/world_name/model/modelB_name/link/linkB_name/light/lightB_name");
EXPECT_EQ(scopedName(sensorBEntity, ecm),
"world/world_name/model/modelB_name/link/linkB_name/sensor/sensorB_name");
EXPECT_EQ(scopedName(modelCEntity, ecm),
"world/world_name/model/modelC_name");
EXPECT_EQ(scopedName(linkCEntity, ecm),
"world/world_name/model/modelC_name/link/linkC_name");
EXPECT_EQ(scopedName(collisionCEntity, ecm),
"world/world_name/model/modelC_name/link/linkC_name/collision/"
std::string("collisionC_name"));
EXPECT_EQ(scopedName(visualCEntity, ecm),
"world/world_name/model/modelC_name/link/linkC_name/visual/"
std::string("visualC_name"));
EXPECT_EQ(scopedName(jointCEntity, ecm),
"world/world_name/model/modelC_name/joint/jointC_name");
EXPECT_EQ(scopedName(modelCCEntity, ecm),
"world/world_name/model/modelC_name/model/modelCC_name");
EXPECT_EQ(scopedName(linkCCEntity, ecm),
"world/world_name/model/modelC_name/model/modelCC_name/link/linkCC_name");
EXPECT_EQ(scopedName(actorDEntity, ecm, "::"),
"world::world_name::actor::actorD_name");
// check name without prefix
EXPECT_EQ(scopedName(worldEntity, ecm, "/", false), "world_name");
EXPECT_EQ(scopedName(lightAEntity, ecm, "::", false),
"world_name::lightA_name");
EXPECT_EQ(scopedName(modelBEntity, ecm, "/", false),
"world_name/modelB_name");
EXPECT_EQ(scopedName(linkBEntity, ecm, " ", false),
"world_name modelB_name linkB_name");
EXPECT_EQ(scopedName(lightBEntity, ecm, "/", false),
"world_name/modelB_name/linkB_name/lightB_name");
EXPECT_EQ(scopedName(sensorBEntity, ecm, "/", false),
"world_name/modelB_name/linkB_name/sensorB_name");
EXPECT_EQ(scopedName(modelCEntity, ecm, "/", false),
"world_name/modelC_name");
EXPECT_EQ(scopedName(linkCEntity, ecm, "/", false),
"world_name/modelC_name/linkC_name");
EXPECT_EQ(scopedName(collisionCEntity, ecm, "/", false),
"world_name/modelC_name/linkC_name/" std::string("collisionC_name"));
EXPECT_EQ(scopedName(visualCEntity, ecm, "/", false),
"world_name/modelC_name/linkC_name/" std::string("visualC_name"));
EXPECT_EQ(scopedName(jointCEntity, ecm, "/", false),
"world_name/modelC_name/jointC_name");
EXPECT_EQ(scopedName(modelCCEntity, ecm, "/", false),
"world_name/modelC_name/modelCC_name");
EXPECT_EQ(scopedName(linkCCEntity, ecm, "/", false),
"world_name/modelC_name/modelCC_name/linkCC_name");
EXPECT_EQ(scopedName(actorDEntity, ecm, "::", false),
"world_name::actorD_name");
// World entity
EXPECT_EQ(worldEntity, sim::worldEntity(ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(worldEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(lightAEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(modelBEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(linkBEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(lightBEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(sensorBEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(modelCEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(linkCEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(collisionCEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(visualCEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(jointCEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(modelCCEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(linkCCEntity, ecm));
EXPECT_EQ(worldEntity, sim::worldEntity(actorDEntity, ecm));
EXPECT_EQ(kNullEntity, sim::worldEntity(kNullEntity, ecm));
}
/////////////////////////////////////////////////
TEST_F(UtilTest, EntitiesFromScopedName)
{
EntityComponentManager ecm;
// banana 1
// - orange 2
// - plum 3
// - grape 4
// - pear 5
// - plum 6
// - grape 7
// - pear 8
// - plum 9
// - pear 10
// - grape 11
// - pear 12
// - orange 13
// - orange 14
// - pear 15
auto createEntity = [&ecm](const std::string &_name, Entity _parent) -> Entity
{
auto res = ecm.CreateEntity();
ecm.CreateComponent(res, components::Name(_name));
ecm.CreateComponent(res, components::ParentEntity(_parent));
return res;
};
auto banana1 = ecm.CreateEntity();
ecm.CreateComponent(banana1, components::Name("banana"));
auto orange2 = createEntity("orange", banana1);
auto plum3 = createEntity("plum", orange2);
auto grape4 = createEntity("grape", plum3);
auto pear5 = createEntity("pear", grape4);
auto plum6 = createEntity("plum", pear5);
auto grape7 = createEntity("grape", banana1);
auto pear8 = createEntity("pear", grape7);
auto plum9 = createEntity("plum", pear8);
auto pear10 = createEntity("pear", plum9);
auto grape11 = createEntity("grape", banana1);
auto pear12 = createEntity("pear", grape11);
auto orange13 = createEntity("orange", pear12);
auto orange14 = createEntity("orange", orange13);
auto pear15 = createEntity("pear", grape11);
auto checkEntities = [&ecm](const std::string &_scopedName,
Entity _relativeTo, const std::unordered_set<Entity> &_result,
const std::string &_delim)
{
auto res = entitiesFromScopedName(_scopedName, ecm, _relativeTo, _delim);
EXPECT_EQ(_result.size(), res.size()) << _scopedName;
for (auto it : _result)
{
EXPECT_NE(res.find(it), res.end()) << it << " " << _scopedName;
}
};
checkEntities("watermelon", kNullEntity, {}, "::");
checkEntities("banana", kNullEntity, {banana1}, "::");
checkEntities("orange", kNullEntity, {orange2, orange13, orange14}, ":");
checkEntities("banana::orange", kNullEntity, {orange2}, "::");
checkEntities("banana::grape", kNullEntity, {grape7, grape11}, "::");
checkEntities("grape/pear", kNullEntity, {pear5, pear8, pear12, pear15}, "/");
checkEntities("grape...pear...plum", kNullEntity, {plum6, plum9}, "...");
checkEntities(
"banana::orange::plum::grape::pear::plum", kNullEntity, {plum6}, "::");
checkEntities(
"banana::orange::kiwi::grape::pear::plum", kNullEntity, {}, "::");
checkEntities("orange orange", kNullEntity, {orange14}, " ");
checkEntities("orange", banana1, {orange2}, "::");
checkEntities("grape", banana1, {grape7, grape11}, "::");
checkEntities("orange", orange2, {}, "::");
checkEntities("orange", orange13, {orange14}, "::");
checkEntities("grape::pear::plum", plum3, {plum6}, "::");
checkEntities("pear", grape11, {pear12, pear15}, "==");
checkEntities("plum=pear", pear8, {pear10}, "=");
}
/////////////////////////////////////////////////
TEST_F(UtilTest, EntityTypeId)
{
EntityComponentManager ecm;
auto entity = ecm.CreateEntity();
EXPECT_EQ(kComponentTypeIdInvalid, entityTypeId(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::World());
EXPECT_EQ(components::World::typeId, entityTypeId(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Model());
EXPECT_EQ(components::Model::typeId, entityTypeId(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Light());
EXPECT_EQ(components::Light::typeId, entityTypeId(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Link());
EXPECT_EQ(components::Link::typeId, entityTypeId(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Visual());
EXPECT_EQ(components::Visual::typeId, entityTypeId(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Collision());
EXPECT_EQ(components::Collision::typeId, entityTypeId(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Joint());
EXPECT_EQ(components::Joint::typeId, entityTypeId(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Sensor());
EXPECT_EQ(components::Sensor::typeId, entityTypeId(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Actor());
EXPECT_EQ(components::Actor::typeId, entityTypeId(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::ParticleEmitter());
EXPECT_EQ(components::ParticleEmitter::typeId, entityTypeId(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Projector());
EXPECT_EQ(components::Projector::typeId, entityTypeId(entity, ecm));
}
/////////////////////////////////////////////////
TEST_F(UtilTest, EntityTypeStr)
{
EntityComponentManager ecm;
auto entity = ecm.CreateEntity();
EXPECT_TRUE(entityTypeStr(entity, ecm).empty());
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::World());
EXPECT_EQ("world", entityTypeStr(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Model());
EXPECT_EQ("model", entityTypeStr(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Light());
EXPECT_EQ("light", entityTypeStr(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Link());
EXPECT_EQ("link", entityTypeStr(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Visual());
EXPECT_EQ("visual", entityTypeStr(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Collision());
EXPECT_EQ("collision", entityTypeStr(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Joint());
EXPECT_EQ("joint", entityTypeStr(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Sensor());
EXPECT_EQ("sensor", entityTypeStr(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Actor());
EXPECT_EQ("actor", entityTypeStr(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::ParticleEmitter());
EXPECT_EQ("particle_emitter", entityTypeStr(entity, ecm));
entity = ecm.CreateEntity();
ecm.CreateComponent(entity, components::Projector());
EXPECT_EQ("projector", entityTypeStr(entity, ecm));
}
/////////////////////////////////////////////////
TEST_F(UtilTest, RemoveParentScopedName)
{
EXPECT_EQ(removeParentScope("world/world_name", "/"), "world_name");
EXPECT_EQ(removeParentScope("world::world_name::light::lightA_name", "::"),
"world_name::light::lightA_name");
EXPECT_EQ(removeParentScope("world_name/model/modelB_name", "/"),
"model/modelB_name");
EXPECT_EQ(removeParentScope(
"world world_name model modelB_name link linkB_name", " "),
"world_name model modelB_name link linkB_name");
EXPECT_EQ(removeParentScope("world::world_name::light::lightA_name", ""),
"world::world_name::light::lightA_name");
}
/////////////////////////////////////////////////
TEST_F(UtilTest, AsFullPath)
{
const std::string relativeUriUnix{"meshes/collision.dae"};
const std::string relativeUriWindows{"meshes\\collision.dae"};
const std::string absoluteUriUnix{"/path/to/collision.dae"};
const std::string absoluteUriWindows{R"(C:\path\to\collision.dae)"};
const std::string schemeUri{"https://website.com/collision.dae"};
// Empty path
{
const std::string path{""};
EXPECT_EQ(relativeUriUnix, asFullPath(relativeUriUnix, path));
EXPECT_EQ(relativeUriWindows, asFullPath(relativeUriWindows, path));
EXPECT_EQ(absoluteUriUnix, asFullPath(absoluteUriUnix, path));
EXPECT_EQ(absoluteUriWindows, asFullPath(absoluteUriWindows, path));
EXPECT_EQ(schemeUri, asFullPath(schemeUri, path));
}
// Data string
{
const std::string path{sdf::kSdfStringSource};
EXPECT_EQ(relativeUriUnix, asFullPath(relativeUriUnix, path));
EXPECT_EQ(relativeUriWindows, asFullPath(relativeUriWindows, path));
EXPECT_EQ(absoluteUriUnix, asFullPath(absoluteUriUnix, path));
EXPECT_EQ(absoluteUriWindows, asFullPath(absoluteUriWindows, path));
EXPECT_EQ(schemeUri, asFullPath(schemeUri, path));
}
#ifdef _WIN32
{
// Absolute Windows path
const std::string path{R"(C:\abs\path\file)"};
// Directory
EXPECT_EQ("C:\\abs\\path\\meshes\\collision.dae",
asFullPath(relativeUriUnix, path));
EXPECT_EQ("C:\\abs\\path\\meshes\\collision.dae",
asFullPath(relativeUriWindows, path));
// TODO(anyone) Support absolute Unix-style URIs on Windows
EXPECT_EQ(absoluteUriWindows, asFullPath(absoluteUriWindows, path));
EXPECT_EQ(schemeUri, asFullPath(schemeUri, path));
// File
auto filePath = common::joinPaths(path, "file.sdf");
EXPECT_EQ("C:\\abs\\path\\file\\meshes\\collision.dae",
asFullPath(relativeUriUnix, filePath));
EXPECT_EQ("C:\\abs\\path\\file\\meshes\\collision.dae",
asFullPath(relativeUriWindows, filePath));
// TODO(anyone) Support absolute Unix-style URIs on Windows
EXPECT_EQ(absoluteUriWindows, asFullPath(absoluteUriWindows, filePath));
EXPECT_EQ(schemeUri, asFullPath(schemeUri, filePath));
}
#else
{
// Absolute Unix path
const std::string path{"/abs/path/file"};
// Directory
EXPECT_EQ("/abs/path/meshes/collision.dae",
asFullPath(relativeUriUnix, path));
EXPECT_EQ("/abs/path/meshes/collision.dae",
asFullPath(relativeUriWindows, path));
EXPECT_EQ(absoluteUriUnix, asFullPath(absoluteUriUnix, path));
// TODO(anyone) Support absolute Windows paths on Unix
EXPECT_EQ(schemeUri, asFullPath(schemeUri, path));
// File
auto filePath = common::joinPaths(path, "file.sdf");
EXPECT_EQ("/abs/path/file/meshes/collision.dae",
asFullPath(relativeUriUnix, filePath));
EXPECT_EQ("/abs/path/file/meshes/collision.dae",
asFullPath(relativeUriWindows, filePath));
EXPECT_EQ(absoluteUriUnix, asFullPath(absoluteUriUnix, filePath));
// TODO(anyone) Support absolute Windows paths on Unix
EXPECT_EQ(schemeUri, asFullPath(schemeUri, filePath));
}
#endif
}
/////////////////////////////////////////////////
TEST_F(UtilTest, TopLevelModel)
{
EntityComponentManager ecm;
// world
// - modelA
// - linkA
// - modelB
// - linkB
// - visualB
// - modelC
// World
auto worldEntity = ecm.CreateEntity();
ecm.CreateComponent(worldEntity, components::World());
ecm.CreateComponent(worldEntity, components::Name("world_name"));
// Model A
auto modelAEntity = ecm.CreateEntity();
ecm.CreateComponent(modelAEntity, components::Model());
ecm.CreateComponent(modelAEntity, components::Name("modelA_name"));
ecm.CreateComponent(modelAEntity, components::ParentEntity(worldEntity));
// Link A - Child of Model A
auto linkAEntity = ecm.CreateEntity();
ecm.CreateComponent(linkAEntity, components::Link());
ecm.CreateComponent(linkAEntity, components::Name("linkA_name"));
ecm.CreateComponent(linkAEntity, components::ParentEntity(modelAEntity));
// Model B - nested inside Model A
auto modelBEntity = ecm.CreateEntity();
ecm.CreateComponent(modelBEntity, components::Model());
ecm.CreateComponent(modelBEntity, components::Name("modelB_name"));
ecm.CreateComponent(modelBEntity, components::ParentEntity(modelAEntity));
// Link B - child of Model B
auto linkBEntity = ecm.CreateEntity();
ecm.CreateComponent(linkBEntity, components::Link());
ecm.CreateComponent(linkBEntity, components::Name("linkB_name"));
ecm.CreateComponent(linkBEntity, components::ParentEntity(modelBEntity));
// Visual B - child of Link B
auto visualBEntity = ecm.CreateEntity();
ecm.CreateComponent(visualBEntity, components::Visual());
ecm.CreateComponent(visualBEntity, components::Name("visualB_name"));
ecm.CreateComponent(visualBEntity, components::ParentEntity(linkBEntity));
// Model C
auto modelCEntity = ecm.CreateEntity();
ecm.CreateComponent(modelCEntity, components::Model());
ecm.CreateComponent(modelCEntity, components::Name("modelC_name"));
ecm.CreateComponent(modelCEntity, components::ParentEntity(worldEntity));
// model A, link A, model B, link B and visual B should have
// model A as the top level model
EXPECT_EQ(modelAEntity, topLevelModel(modelAEntity, ecm));
EXPECT_EQ(modelAEntity, topLevelModel(linkAEntity, ecm));
EXPECT_EQ(modelAEntity, topLevelModel(modelBEntity, ecm));
EXPECT_EQ(modelAEntity, topLevelModel(linkBEntity, ecm));
EXPECT_EQ(modelAEntity, topLevelModel(visualBEntity, ecm));
// model C should have itself as the top level model
EXPECT_EQ(modelCEntity, topLevelModel(modelCEntity, ecm));
// the world should have no top level model
EXPECT_EQ(kNullEntity, topLevelModel(worldEntity, ecm));
}
/////////////////////////////////////////////////
TEST_F(UtilTest, ValidTopic)
{
std::string good{"good"};
std::string fixable{"not bad~"};
std::string invalid{"@~@~@~"};
EXPECT_EQ("good", validTopic({good}));
EXPECT_EQ("not_bad", validTopic({fixable}));
EXPECT_EQ("", validTopic({invalid}));
EXPECT_EQ("good", validTopic({good, fixable}));
EXPECT_EQ("not_bad", validTopic({fixable, good}));
EXPECT_EQ("good", validTopic({good, invalid}));
EXPECT_EQ("good", validTopic({invalid, good}));
EXPECT_EQ("not_bad", validTopic({fixable, invalid}));
EXPECT_EQ("not_bad", validTopic({invalid, fixable}));
EXPECT_EQ("not_bad", validTopic({fixable, invalid, good}));
EXPECT_EQ("good", validTopic({invalid, good, fixable}));
}
/////////////////////////////////////////////////
TEST_F(UtilTest, TopicFromScopedName)
{
EntityComponentManager ecm;
// world
// - modelA
// - linkA
// - modelB
// - linkB
// - emitterB
// - modelC
// World
auto worldEntity = ecm.CreateEntity();
ecm.CreateComponent(worldEntity, components::World());
ecm.CreateComponent(worldEntity, components::Name("world_name"));
// Model A
auto modelAEntity = ecm.CreateEntity();
ecm.CreateComponent(modelAEntity, components::Model());
ecm.CreateComponent(modelAEntity, components::Name("modelA_name"));
ecm.CreateComponent(modelAEntity, components::ParentEntity(worldEntity));
// Link A - Child of Model A
auto linkAEntity = ecm.CreateEntity();
ecm.CreateComponent(linkAEntity, components::Link());
ecm.CreateComponent(linkAEntity, components::Name("linkA_name"));
ecm.CreateComponent(linkAEntity, components::ParentEntity(modelAEntity));
// Model B - nested inside Model A
auto modelBEntity = ecm.CreateEntity();
ecm.CreateComponent(modelBEntity, components::Model());
ecm.CreateComponent(modelBEntity, components::Name("modelB_name"));
ecm.CreateComponent(modelBEntity, components::ParentEntity(modelAEntity));
// Link B - child of Model B
auto linkBEntity = ecm.CreateEntity();
ecm.CreateComponent(linkBEntity, components::Link());
ecm.CreateComponent(linkBEntity, components::Name("linkB_name"));
ecm.CreateComponent(linkBEntity, components::ParentEntity(modelBEntity));
// Emitter B - child of Link B
auto emitterBEntity = ecm.CreateEntity();
ecm.CreateComponent(emitterBEntity, components::ParticleEmitter());
ecm.CreateComponent(emitterBEntity, components::Name("emitterB_name"));
ecm.CreateComponent(emitterBEntity, components::ParentEntity(linkBEntity));
// Model C
auto modelCEntity = ecm.CreateEntity();
ecm.CreateComponent(modelCEntity, components::Model());
ecm.CreateComponent(modelCEntity, components::Name("modelC_name"));
ecm.CreateComponent(modelCEntity, components::ParentEntity(worldEntity));
std::string testName = "/model/modelA_name";
std::string worldName = "/world/world_name";
// model A, link A, model B, link B and visual B should have
// model A as the top level model
EXPECT_EQ(testName, topicFromScopedName(modelAEntity, ecm));
EXPECT_EQ(worldName testName,
topicFromScopedName(modelAEntity, ecm, false));
testName = "/link/linkA_name";
EXPECT_EQ(testName, topicFromScopedName(linkAEntity, ecm));
EXPECT_EQ(worldName testName, topicFromScopedName(linkAEntity, ecm, false));
testName = "/model/modelA_name/model/modelB_name";
EXPECT_EQ(testName, topicFromScopedName(modelBEntity, ecm));
EXPECT_EQ(worldName testName,
topicFromScopedName(modelBEntity, ecm, false));
testName ="/link/linkB_name";
EXPECT_EQ(testName, topicFromScopedName(linkBEntity, ecm));
EXPECT_EQ(worldName testName, topicFromScopedName(linkBEntity, ecm, false));
testName = "/particle_emitter/emitterB_name";
EXPECT_EQ(testName,
topicFromScopedName(emitterBEntity, ecm));
EXPECT_EQ(worldName testName,
topicFromScopedName(emitterBEntity, ecm, false));
testName = "/model/modelC_name";
EXPECT_EQ(testName, topicFromScopedName(modelCEntity, ecm));
EXPECT_EQ(worldName testName,
topicFromScopedName(modelCEntity, ecm, false));
EXPECT_TRUE(topicFromScopedName(worldEntity, ecm).empty());
EXPECT_EQ(worldName, topicFromScopedName(worldEntity, ecm, false));
}
/////////////////////////////////////////////////
TEST_F(UtilTest, EnableComponent)
{
EntityComponentManager ecm;
auto entity1 = ecm.CreateEntity();
EXPECT_EQ(nullptr, ecm.Component<components::Name>(entity1));
// Enable
EXPECT_TRUE(enableComponent<components::Name>(ecm, entity1));
EXPECT_NE(nullptr, ecm.Component<components::Name>(entity1));
// Enabling again makes no changes
EXPECT_FALSE(enableComponent<components::Name>(ecm, entity1, true));
EXPECT_NE(nullptr, ecm.Component<components::Name>(entity1));
// Disable
EXPECT_TRUE(enableComponent<components::Name>(ecm, entity1, false));
EXPECT_EQ(nullptr, ecm.Component<components::Name>(entity1));
// Disabling again makes no changes
EXPECT_FALSE(enableComponent<components::Name>(ecm, entity1, false));
EXPECT_EQ(nullptr, ecm.Component<components::Name>(entity1));
}
/////////////////////////////////////////////////
TEST_F(UtilTest, EntityFromMsg)
{
EntityComponentManager ecm;
// world
// - lightA (light)
// - modelB
// - linkB (link)
// - lightB (light)
// - sensorB (banana)
// - modelC
// - linkC (link)
// - collisionC
// - visualC (banana)
// - jointC
// - modelCC
// - linkCC (link)
// - actorD
// World
auto worldEntity = ecm.CreateEntity();
EXPECT_EQ(kNullEntity, sim::worldEntity(ecm));
EXPECT_EQ(kNullEntity, sim::worldEntity(worldEntity, ecm));
ecm.CreateComponent(worldEntity, components::World());
ecm.CreateComponent(worldEntity, components::Name("world"));
// Light A
auto lightAEntity = ecm.CreateEntity();
ecm.CreateComponent(lightAEntity, components::Light(sdf::Light()));
ecm.CreateComponent(lightAEntity, components::Name("light"));
ecm.CreateComponent(lightAEntity, components::ParentEntity(worldEntity));
// Model B
auto modelBEntity = ecm.CreateEntity();
ecm.CreateComponent(modelBEntity, components::Model());
ecm.CreateComponent(modelBEntity, components::Name("modelB"));
ecm.CreateComponent(modelBEntity, components::ParentEntity(worldEntity));
// Link B
auto linkBEntity = ecm.CreateEntity();
ecm.CreateComponent(linkBEntity, components::Link());
ecm.CreateComponent(linkBEntity, components::Name("link"));
ecm.CreateComponent(linkBEntity, components::ParentEntity(modelBEntity));
// Light B
auto lightBEntity = ecm.CreateEntity();
ecm.CreateComponent(lightBEntity, components::Light(sdf::Light()));
ecm.CreateComponent(lightBEntity, components::Name("light"));
ecm.CreateComponent(lightBEntity, components::ParentEntity(linkBEntity));
// Sensor B
auto sensorBEntity = ecm.CreateEntity();
ecm.CreateComponent(sensorBEntity, components::Sensor());
ecm.CreateComponent(sensorBEntity, components::Name("banana"));
ecm.CreateComponent(sensorBEntity, components::ParentEntity(linkBEntity));
// Model C
auto modelCEntity = ecm.CreateEntity();
ecm.CreateComponent(modelCEntity, components::Model());
ecm.CreateComponent(modelCEntity, components::Name("modelC"));
ecm.CreateComponent(modelCEntity, components::ParentEntity(worldEntity));
// Link C
auto linkCEntity = ecm.CreateEntity();
ecm.CreateComponent(linkCEntity, components::Link());
ecm.CreateComponent(linkCEntity, components::Name("link"));
ecm.CreateComponent(linkCEntity, components::ParentEntity(modelCEntity));
// Collision C
auto collisionCEntity = ecm.CreateEntity();
ecm.CreateComponent(collisionCEntity, components::Collision());
ecm.CreateComponent(collisionCEntity, components::Name("collisionC"));
ecm.CreateComponent(collisionCEntity, components::ParentEntity(linkCEntity));
// Visual C
auto visualCEntity = ecm.CreateEntity();
ecm.CreateComponent(visualCEntity, components::Visual());
ecm.CreateComponent(visualCEntity, components::Name("banana"));
ecm.CreateComponent(visualCEntity, components::ParentEntity(linkCEntity));
// Link C
auto jointCEntity = ecm.CreateEntity();
ecm.CreateComponent(jointCEntity, components::Joint());
ecm.CreateComponent(jointCEntity, components::Name("jointC"));
ecm.CreateComponent(jointCEntity, components::ParentEntity(modelCEntity));
// Model CC
auto modelCCEntity = ecm.CreateEntity();
ecm.CreateComponent(modelCCEntity, components::Model());
ecm.CreateComponent(modelCCEntity, components::Name("modelCC"));
ecm.CreateComponent(modelCCEntity, components::ParentEntity(modelCEntity));
// Link CC
auto linkCCEntity = ecm.CreateEntity();
ecm.CreateComponent(linkCCEntity, components::Link());
ecm.CreateComponent(linkCCEntity, components::Name("link"));
ecm.CreateComponent(linkCCEntity, components::ParentEntity(modelCCEntity));
// Actor D
auto actorDEntity = ecm.CreateEntity();
ecm.CreateComponent(actorDEntity, components::Actor(sdf::Actor()));
ecm.CreateComponent(actorDEntity, components::Name("actorD"));
ecm.CreateComponent(actorDEntity, components::ParentEntity(worldEntity));
// Check entities
auto createMsg = [&](Entity _id, const std::string &_name = "",
msgs::Entity::Type _type = msgs::Entity::NONE) -> msgs::Entity
{
msgs::Entity msg;
if (_id != kNullEntity)
msg.set_id(_id);
if (!_name.empty())
msg.set_name(_name);
if (_type != msgs::Entity::NONE)
msg.set_type(_type);
return msg;
};
// Only ID
EXPECT_EQ(worldEntity, entityFromMsg(ecm, createMsg(worldEntity)));
EXPECT_EQ(lightAEntity, entityFromMsg(ecm, createMsg(lightAEntity)));
EXPECT_EQ(modelBEntity, entityFromMsg(ecm, createMsg(modelBEntity)));
EXPECT_EQ(linkBEntity, entityFromMsg(ecm, createMsg(linkBEntity)));
EXPECT_EQ(lightBEntity, entityFromMsg(ecm, createMsg(lightBEntity)));
EXPECT_EQ(sensorBEntity, entityFromMsg(ecm, createMsg(sensorBEntity)));
EXPECT_EQ(modelCEntity, entityFromMsg(ecm, createMsg(modelCEntity)));
EXPECT_EQ(linkCEntity, entityFromMsg(ecm, createMsg(linkCEntity)));
EXPECT_EQ(collisionCEntity, entityFromMsg(ecm, createMsg(collisionCEntity)));
EXPECT_EQ(visualCEntity, entityFromMsg(ecm, createMsg(visualCEntity)));
EXPECT_EQ(jointCEntity, entityFromMsg(ecm, createMsg(jointCEntity)));
EXPECT_EQ(modelCCEntity, entityFromMsg(ecm, createMsg(modelCCEntity)));
EXPECT_EQ(linkCCEntity, entityFromMsg(ecm, createMsg(linkCCEntity)));
EXPECT_EQ(actorDEntity, entityFromMsg(ecm, createMsg(actorDEntity)));
// Name and type, with different scopes
EXPECT_EQ(worldEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world", msgs::Entity::WORLD)));
// There's more than one "light", so we need to scope it
EXPECT_EQ(lightAEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::light", msgs::Entity::LIGHT)));
EXPECT_EQ(modelBEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelB", msgs::Entity::MODEL)));
EXPECT_EQ(modelBEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::modelB", msgs::Entity::MODEL)));
// There's more than one "link", so we need to scope it
EXPECT_EQ(linkBEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelB::link", msgs::Entity::LINK)));
EXPECT_EQ(linkBEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::modelB::link", msgs::Entity::LINK)));
// There's more than one "light", so we need to scope it
EXPECT_EQ(lightBEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"link::light", msgs::Entity::LIGHT)));
EXPECT_EQ(lightBEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelB::link::light", msgs::Entity::LIGHT)));
EXPECT_EQ(lightBEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::modelB::link::light", msgs::Entity::LIGHT)));
// There's more than one "link::banana", so we need to scope it
EXPECT_EQ(sensorBEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelB::link::banana", msgs::Entity::SENSOR)));
EXPECT_EQ(sensorBEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::modelB::link::banana", msgs::Entity::SENSOR)));
EXPECT_EQ(modelCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelC", msgs::Entity::MODEL)));
EXPECT_EQ(modelCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::modelC", msgs::Entity::MODEL)));
// There's more than one "link", so we need to scope it
EXPECT_EQ(linkCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelC::link", msgs::Entity::LINK)));
EXPECT_EQ(linkCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::modelC::link", msgs::Entity::LINK)));
EXPECT_EQ(collisionCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"collisionC", msgs::Entity::COLLISION)));
EXPECT_EQ(collisionCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"link::collisionC", msgs::Entity::COLLISION)));
EXPECT_EQ(collisionCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelC::link::collisionC", msgs::Entity::COLLISION)));
EXPECT_EQ(collisionCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::modelC::link::collisionC", msgs::Entity::COLLISION)));
// There's more than one "banana", so we need to scope it
EXPECT_EQ(visualCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"link::banana", msgs::Entity::VISUAL)));
EXPECT_EQ(visualCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelC::link::banana", msgs::Entity::VISUAL)));
EXPECT_EQ(visualCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::modelC::link::banana", msgs::Entity::VISUAL)));
EXPECT_EQ(jointCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"jointC", msgs::Entity::JOINT)));
EXPECT_EQ(jointCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelC::jointC", msgs::Entity::JOINT)));
EXPECT_EQ(jointCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::modelC::jointC", msgs::Entity::JOINT)));
EXPECT_EQ(modelCCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelCC", msgs::Entity::MODEL)));
EXPECT_EQ(modelCCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelC::modelCC", msgs::Entity::MODEL)));
EXPECT_EQ(modelCCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::modelC::modelCC", msgs::Entity::MODEL)));
// There's more than one "link", so we need to scope it
EXPECT_EQ(linkCCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"modelC::modelCC::link", msgs::Entity::LINK)));
EXPECT_EQ(linkCCEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::modelC::modelCC::link", msgs::Entity::LINK)));
EXPECT_EQ(actorDEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"actorD", msgs::Entity::ACTOR)));
EXPECT_EQ(actorDEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"world::actorD", msgs::Entity::ACTOR)));
// Inexistent entity
EXPECT_EQ(1000u, entityFromMsg(ecm, createMsg(1000)));
// Not found
EXPECT_EQ(kNullEntity, entityFromMsg(ecm, createMsg(kNullEntity)));
EXPECT_EQ(kNullEntity, entityFromMsg(ecm, createMsg(kNullEntity,
"blueberry")));
EXPECT_EQ(kNullEntity, entityFromMsg(ecm, createMsg(kNullEntity, "banana",
msgs::Entity::COLLISION)));
EXPECT_EQ(kNullEntity, entityFromMsg(ecm, createMsg(kNullEntity, "peach",
msgs::Entity::WORLD)));
}
/////////////////////////////////////////////////
TEST_F(UtilTest, ResolveSdfWorldFile)
{
// Test resolving a Fuel URI
fuel_tools::ClientConfig config;
// URI to a Fuel world.
std::string fuelUri =
"https://fuel.ignitionrobotics.org/1.0/openrobotics/worlds/test world";
// The expect path for the local Fuel world.
std::string expectedPath = common::joinPaths(
config.CacheLocation(), "fuel.ignitionrobotics.org",
"openrobotics", "worlds", "test world");
// Get the Fuel world.
std::string resolvedPath = resolveSdfWorldFile(fuelUri,
config.CacheLocation());
// The Fuel model has not been downloaded, so it should not exist.
EXPECT_FALSE(resolvedPath.empty());
// The expected path should be the first part of the resolved path. The
// resolved path will have extra world version information at the end.
EXPECT_EQ(0u, resolvedPath.find(expectedPath));
// Now try to resolve the downloaded world file using an aboslute path
EXPECT_EQ(resolvedPath, resolveSdfWorldFile(resolvedPath));
// The "shapes.sdf" world file should resolve.
EXPECT_FALSE(resolveSdfWorldFile("shapes.sdf").empty());