Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Apr 1, 2024
1 parent d2a93c2 commit ad3353c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ Server::Server(const ServerConfig &_config)

sdf::Root sdfRoot;
sdf::ParserConfig sdfParserConfig = sdf::ParserConfig::GlobalConfig();
sdfParserConfig.SetStoreResolvedURIs(true);
sdfParserConfig.SetCalculateInertialConfiguration(
sdf::ConfigureResolveAutoInertials::SKIP_CALCULATION_IN_LOAD);

Expand Down
23 changes: 19 additions & 4 deletions test/integration/physics_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1834,12 +1834,13 @@ TEST_F(PhysicsSystemFixture, PhysicsOptions)
serverConfig.SetSdfFile(common::joinPaths(std::string(PROJECT_SOURCE_PATH),
"test", "worlds", "physics_options.sdf"));

bool checked{false};
bool checkedDart{false};
bool checkedBullet{false};

// Create a system to check components
test::Relay testSystem;
testSystem.OnPostUpdate(
[&checked](const sim::UpdateInfo &,
[&checkedDart, &checkedBullet](const sim::UpdateInfo &,
const sim::EntityComponentManager &_ecm)
{
_ecm.Each<components::World, components::PhysicsCollisionDetector,
Expand All @@ -1858,16 +1859,30 @@ TEST_F(PhysicsSystemFixture, PhysicsOptions)
{
EXPECT_EQ("pgs", _solver->Data());
}
checked = true;
checkedDart = true;
return true;
});
_ecm.Each<components::World, components::PhysicsSolverIterations>(
[&](const gz::sim::Entity &, const components::World *,
const components::PhysicsSolverIterations *_solverIters)->bool
{
EXPECT_NE(nullptr, _solverIters);
if (_solverIters)
{
EXPECT_EQ(100, _solverIters->Data());
}
checkedBullet = true;
return true;
});

});

sim::Server server(serverConfig);
server.AddSystem(testSystem.systemPtr);
server.Run(true, 1, false);

EXPECT_TRUE(checked);
EXPECT_TRUE(checkedDart);
EXPECT_TRUE(checkedBullet);
}

/////////////////////////////////////////////////
Expand Down
5 changes: 5 additions & 0 deletions test/worlds/physics_options.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<solver_type>pgs</solver_type>
</solver>
</dart>
<bullet>
<solver>
<iters>100</iters>
</solver>
</bullet>
<real_time_factor>0</real_time_factor>
</physics>
<plugin
Expand Down

0 comments on commit ad3353c

Please sign in to comment.