Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <gtest/gtest.h>
00031 #include <ros/package.h>
00032 #include <ros/types.h>
00033 #include <ros/console.h>
00034
00035 #include <rve_pluginloader/loader.h>
00036 #include <rve_pluginloader/plugin.h>
00037
00038 #include "shared.h"
00039
00040 std::string g_package_path;
00041 std::string g_plugin_path;
00042
00043 using namespace rve_pluginloader;
00044
00045 TEST(PluginLoader, createClass)
00046 {
00047 Base* b = create<Base>("Base", "Foo");
00048 ASSERT_TRUE(b);
00049 ASSERT_EQ(b->getVal(), 1U);
00050 destroy(b);
00051 }
00052
00053 TEST(PluginLoader, createClassShared)
00054 {
00055 boost::shared_ptr<Base> b = createShared<Base>("Base", "Foo");
00056 ASSERT_TRUE(b);
00057 ASSERT_EQ(b->getVal(), 1U);
00058 }
00059
00060 TEST(PluginLoader, outstandingAllocationOnUnload)
00061 {
00062 boost::shared_ptr<Base> b = createShared<Base>("Base", "Foo");
00063 ASSERT_TRUE(b);
00064 PluginPtr plugin = getPlugin(g_plugin_path);
00065 try
00066 {
00067 plugin->unload();
00068 }
00069 catch (OutstandingAllocationException& e)
00070 {
00071 ROS_INFO("%s", e.what());
00072 }
00073 }
00074
00075 int main(int argc, char** argv)
00076 {
00077 testing::InitGoogleTest(&argc, argv);
00078
00079 rve_pluginloader::init();
00080
00081 g_package_path = ros::package::getPath(ROS_PACKAGE_NAME);
00082 g_plugin_path = g_package_path + "/test/test_plugin_desc.yaml";
00083 rve_pluginloader::loadPlugin(g_plugin_path);
00084
00085 int ret = RUN_ALL_TESTS();
00086
00087 rve_pluginloader::shutdown();
00088
00089 return ret;
00090 }
00091
00092
00093