Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic architecture for common tests #357

Merged
merged 10 commits into from
Jun 20, 2022
200 changes: 200 additions & 0 deletions bullet/src/EntityManagementFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,207 @@ bool EntityManagementFeatures::RemoveModelByName(

return false;
}
const std::string &EntityManagementFeatures::GetEngineName(
const Identity &) const
{
static const std::string engineName = "bullet";
return engineName;
}

std::size_t EntityManagementFeatures::GetEngineIndex(const Identity &) const
{
return 0;
}

std::size_t EntityManagementFeatures::GetWorldCount(const Identity &) const
{
return worlds.size();
}

Identity EntityManagementFeatures::GetWorld(
const Identity &, std::size_t) const
{
return this->GenerateIdentity(0);
}

Identity EntityManagementFeatures::GetWorld(
const Identity &, const std::string &) const
{
return this->GenerateIdentity(0);
}

const std::string &EntityManagementFeatures::GetWorldName(
const Identity &) const
{
static const std::string worldName = "bullet";
return worldName;
}

std::size_t EntityManagementFeatures::GetWorldIndex(const Identity &) const
{
return 0;
}

Identity EntityManagementFeatures::GetEngineOfWorld(const Identity &) const
{
return this->GenerateIdentity(0);
}

std::size_t EntityManagementFeatures::GetModelCount(
const Identity &) const
{
return 0;
}

Identity EntityManagementFeatures::GetModel(
const Identity &, std::size_t) const
{
return this->GenerateIdentity(0);
}

Identity EntityManagementFeatures::GetModel(
const Identity &, const std::string &) const
{
return this->GenerateIdentity(0);
}

const std::string &EntityManagementFeatures::GetModelName(
const Identity &) const
{
static const std::string modelName = "bulletModel";
return modelName;
}

std::size_t EntityManagementFeatures::GetModelIndex(const Identity &) const
{
return 0;
}

Identity EntityManagementFeatures::GetWorldOfModel(const Identity &) const
{
return this->GenerateIdentity(0);
}

std::size_t EntityManagementFeatures::GetNestedModelCount(
const Identity &) const
{
return 0;
}

Identity EntityManagementFeatures::GetNestedModel(
const Identity &, std::size_t ) const
{
return this->GenerateIdentity(0);
}

Identity EntityManagementFeatures::GetNestedModel(
const Identity &, const std::string &) const
{
return this->GenerateIdentity(0);
}

std::size_t EntityManagementFeatures::GetLinkCount(const Identity &) const
{
return 0;
}

Identity EntityManagementFeatures::GetLink(
const Identity &, std::size_t) const
{
return this->GenerateIdentity(0);
}

Identity EntityManagementFeatures::GetLink(
const Identity &, const std::string &) const

{
return this->GenerateIdentity(0);
}

std::size_t EntityManagementFeatures::GetJointCount(const Identity &) const
{
return 0;
}

Identity EntityManagementFeatures::GetJoint(
const Identity &, std::size_t ) const
{
return this->GenerateIdentity(0);
}

Identity EntityManagementFeatures::GetJoint(
const Identity &, const std::string &) const
{
return this->GenerateIdentity(0);
}

const std::string &EntityManagementFeatures::GetLinkName(
const Identity &) const
{
static const std::string linkName = "bulletLink";
return linkName;
}

std::size_t EntityManagementFeatures::GetLinkIndex(const Identity &) const
{
return 0;
}

Identity EntityManagementFeatures::GetModelOfLink(const Identity &) const
{
return this->GenerateIdentity(0);
}

std::size_t EntityManagementFeatures::GetShapeCount(const Identity &) const
{
return 0;
}

Identity EntityManagementFeatures::GetShape(
const Identity &, std::size_t) const
{
return this->GenerateIdentity(0);
}

Identity EntityManagementFeatures::GetShape(
const Identity &, const std::string &) const
{
return this->GenerateIdentity(0);
}

const std::string &EntityManagementFeatures::GetJointName(
const Identity &) const
{
static const std::string jointName = "bulletJoint";
return jointName;
}

std::size_t EntityManagementFeatures::GetJointIndex(const Identity &) const
{
return 0;
}

Identity EntityManagementFeatures::GetModelOfJoint(const Identity &) const
{
return this->GenerateIdentity(0);
}

const std::string &EntityManagementFeatures::GetShapeName(
const Identity &) const
{
static const std::string shapeName = "bulletShape";
return shapeName;
}

std::size_t EntityManagementFeatures::GetShapeIndex(const Identity &) const
{
return 0;
}

Identity EntityManagementFeatures::GetLinkOfShape(const Identity &) const
{
return this->GenerateIdentity(0);
}
} // namespace bullet
} // namespace physics
} // namespace gz
90 changes: 90 additions & 0 deletions bullet/src/EntityManagementFeatures.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace physics {
namespace bullet {

struct EntityManagementFeatureList : gz::physics::FeatureList<
GetEntities,
RemoveModelFromWorld,
ConstructEmptyWorldFeature
> { };
Expand All @@ -56,6 +57,95 @@ class EntityManagementFeatures :
// ----- Construct empty entities -----
public: Identity ConstructEmptyWorld(
const Identity &_engineID, const std::string & _name) override;

// ----- Get entities -----
public: const std::string &GetEngineName(const Identity &) const override;
public: std::size_t GetEngineIndex(const Identity &) const override;

public: std::size_t GetWorldCount(const Identity &) const override;

public: Identity GetWorld(
const Identity &, std::size_t _worldIndex) const override;

public: Identity GetWorld(
const Identity &, const std::string &_worldName) const override;

public: const std::string &GetWorldName(
const Identity &_worldID) const override;

public: std::size_t GetWorldIndex(const Identity &_worldID) const override;

public: Identity GetEngineOfWorld(const Identity &_worldID) const override;

public: std::size_t GetModelCount(
const Identity &_worldID) const override;

public: Identity GetModel(
const Identity &_worldID, std::size_t _modelIndex) const override;

public: Identity GetModel(
const Identity &_worldID, const std::string &_modelName) const override;

public: const std::string &GetModelName(
const Identity &_modelID) const override;

public: std::size_t GetModelIndex(const Identity &_modelID) const override;

public: Identity GetWorldOfModel(const Identity &_modelID) const override;

public: std::size_t GetNestedModelCount(
const Identity &_modelID) const override;

public: Identity GetNestedModel(
const Identity &_modelID, std::size_t _modelIndex) const override;

public: Identity GetNestedModel(
const Identity &_modelID, const std::string &_modelName) const override;

public: std::size_t GetLinkCount(const Identity &_modelID) const override;

public: Identity GetLink(
const Identity &_modelID, std::size_t _linkIndex) const override;

public: Identity GetLink(
const Identity &_modelID, const std::string &_linkName) const override;

public: std::size_t GetJointCount(const Identity &_modelID) const override;

public: Identity GetJoint(
const Identity &_modelID, std::size_t _jointIndex) const override;

public: Identity GetJoint(
const Identity &_modelID, const std::string &_jointName) const override;

public: const std::string &GetLinkName(
const Identity &_linkID) const override;

public: std::size_t GetLinkIndex(const Identity &_linkID) const override;

public: Identity GetModelOfLink(const Identity &_linkID) const override;

public: std::size_t GetShapeCount(const Identity &_linkID) const override;

public: Identity GetShape(
const Identity &_linkID, std::size_t _shapeIndex) const override;

public: Identity GetShape(
const Identity &_linkID, const std::string &_shapeName) const override;

public: const std::string &GetJointName(
const Identity &_jointID) const override;

public: std::size_t GetJointIndex(const Identity &_jointID) const override;

public: Identity GetModelOfJoint(const Identity &_jointID) const override;

public: const std::string &GetShapeName(
const Identity &_shapeID) const override;

public: std::size_t GetShapeIndex(const Identity &_shapeID) const override;

public: Identity GetLinkOfShape(const Identity &_shapeID) const override;
};

} // namespace bullet
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ExternalProject_Add(
)

add_subdirectory(benchmark)
add_subdirectory(common_test)
add_subdirectory(plugins)
add_subdirectory(integration)
add_subdirectory(performance)
Expand Down
37 changes: 37 additions & 0 deletions test/common_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
set(TEST_TYPE "COMMON_TEST")

set(tests
basic_test
)

link_directories(${PROJECT_BINARY_DIR}/test)

function(configure_common_test PHYSICS_ENGINE_NAME test_name)
set(_env_vars)
add_test(NAME ${test_name}_${PHYSICS_ENGINE_NAME} COMMAND ${test_name})
list(APPEND _env_vars "LIB_TO_TEST=${CMAKE_BINARY_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_LIBRARY_TARGET_NAME}-${PHYSICS_ENGINE_NAME}-plugin${CMAKE_SHARED_LIBRARY_SUFFIX}")
set_tests_properties(${test_name}_${PHYSICS_ENGINE_NAME}
PROPERTIES
ENVIRONMENT "${_env_vars}")
endfunction()

foreach(test ${tests})
add_executable(${TEST_TYPE}_${test} ${test}.cc)

target_link_libraries(${TEST_TYPE}_${test}
PUBLIC
ignition-plugin${IGN_PLUGIN_VER}::loader
ignition-common5::ignition-common5
${PROJECT_LIBRARY_TARGET_NAME}
gtest
gtest_main
)

if (${BULLET_FOUND})
configure_common_test("bullet" ${TEST_TYPE}_${test})
endif()
if (${DART_FOUND})
configure_common_test("dartsim" ${TEST_TYPE}_${test})
endif()
configure_common_test("tpe" ${TEST_TYPE}_${test})
endforeach()
Loading