Skip to content

Commit

Permalink
[Testing] Deprecate BaseSimulationTest::importPlugin (#4467)
Browse files Browse the repository at this point in the history
* deprecate duplicated function importplugin

* use simpleapi::importPlugin instead
  • Loading branch information
fredroy committed Jan 31, 2024
1 parent 2587566 commit ea210dc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
6 changes: 4 additions & 2 deletions Sofa/framework/Simulation/Core/simutest/NodeContext_test.cpp
Expand Up @@ -32,15 +32,17 @@ using sofa::component::sceneutility::InfoComponent;
#include <sofa/helper/system/PluginManager.h>
using sofa::helper::system::PluginManager ;

#include <sofa/simulation/graph/SimpleApi.h>

class NodeContext_test: public BaseSimulationTest
{
public:


NodeContext_test()
{
importPlugin("Sofa.Component.StateContainer");
importPlugin("Sofa.Component.SceneUtility");
sofa::simpleapi::importPlugin("Sofa.Component.StateContainer");
sofa::simpleapi::importPlugin("Sofa.Component.SceneUtility");
}

void testGetNodeObjects()
Expand Down
Expand Up @@ -35,13 +35,14 @@ using sofa::simulation::SceneLoaderXML ;
#include <sofa/helper/system/PluginManager.h>
using sofa::helper::system::PluginManager ;

#include <sofa/simulation/graph/SimpleApi.h>

namespace sofa::testing
{

bool BaseSimulationTest::importPlugin(const std::string& name)
{
const auto status = PluginManager::getInstance().loadPlugin(name);
return status == PluginManager::PluginLoadStatus::SUCCESS || status == PluginManager::PluginLoadStatus::ALREADY_LOADED;
return sofa::simpleapi::importPlugin(name);
}

BaseSimulationTest::SceneInstance::SceneInstance(const std::string& type, const std::string& desc)
Expand Down Expand Up @@ -79,7 +80,7 @@ BaseSimulationTest::SceneInstance::SceneInstance(const std::string& rootname)
void BaseSimulationTest::SceneInstance::loadSceneFile(const std::string& filename)
{
root = sofa::simulation::node::load(filename);

if (root == nullptr)
msg_error("BaseSimulationTest") << "Unable to find a valid loader for: '" << filename << "'";
}
Expand Down
Expand Up @@ -37,6 +37,7 @@ class SOFA_TESTING_API BaseSimulationTest : public virtual BaseTest
public:
BaseSimulationTest() ;

SOFA_ATTRIBUTE_DEPRECATED__TESTING_IMPORT_PLUGIN()
bool importPlugin(const std::string& name) ;

class SOFA_TESTING_API SceneInstance
Expand Down
8 changes: 8 additions & 0 deletions Sofa/framework/Testing/src/sofa/testing/config.h.in
Expand Up @@ -35,3 +35,11 @@ constexpr char SOFA_TESTING_RESOURCES_DIR[] = "@SOFA_TESTING_RESOURCES_DIR@";
#else
# define SOFA_TESTING_API SOFA_IMPORT_DYNAMIC_LIBRARY
#endif

#ifdef SOFA_BUILD_SOFA_TESTING
#define SOFA_ATTRIBUTE_DEPRECATED__TESTING_IMPORT_PLUGIN()
#else
#define SOFA_ATTRIBUTE_DEPRECATED__TESTING_IMPORT_PLUGIN() \
SOFA_ATTRIBUTE_DEPRECATED( \
"v24.06", "v24.12", "Use sofa::simpleapi::importPlugin() instead.")
#endif // SOFA_BUILD_SOFA_TESTING
Expand Up @@ -53,13 +53,15 @@ using sofa::core::objectmodel::BaseContext;
#include <sofa/simulation/Simulation.h>
using sofa::simulation::Node;

#include <sofa/simulation/graph/SimpleApi.h>

class SceneCreator_test : public BaseSimulationTest
{
public:
void SetUp() override
{
importPlugin("Sofa.Component");
importPlugin("Sofa.GL.Component.Rendering3D");
sofa::simpleapi::importPlugin("Sofa.Component");
sofa::simpleapi::importPlugin("Sofa.GL.Component.Rendering3D");
}

bool createCubeFailed();
Expand Down

0 comments on commit ea210dc

Please sign in to comment.