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
00031
00032
00033
00034
00035
00036
00037 #include <string>
00038 #include <gtest/gtest.h>
00039 #include "gazebo/GetWorldProperties.h"
00040 #include "geometry_msgs/Pose.h"
00041 #include "std_srvs/Empty.h"
00042
00043 #include <sstream>
00044 #include <tinyxml.h>
00045 #include <boost/lexical_cast.hpp>
00046
00047
00048
00049 #include <ros/ros.h>
00050
00051 int g_argc;
00052 char** g_argv;
00053
00054 TEST(SpawnTest, spawnSingleBox)
00055 {
00056 ros::NodeHandle nh("");
00057
00058 ros::service::waitForService("gazebo/get_world_properties");
00059 ros::ServiceClient check_model_client = nh.serviceClient<gazebo::GetWorldProperties>("gazebo/get_world_properties");
00060 gazebo::GetWorldProperties world_properties;
00061
00062
00063 bool found = false;
00064
00065
00066 double test_duration = 10.0;
00067 try
00068 {
00069 test_duration = boost::lexical_cast<double>(g_argv[1]);
00070 }
00071 catch (boost::bad_lexical_cast &e)
00072 {
00073 ROS_ERROR("first argument of check_model should be timeout");
00074 return;
00075 }
00076 ros::Time timeout = ros::Time::now() + ros::Duration(test_duration);
00077
00078
00079 std::string model_name = std::string(g_argv[2]);
00080 ROS_INFO("looking for model: %s",model_name.c_str());
00081
00082 while (!found && ros::Time::now() < timeout)
00083 {
00084 check_model_client.call(world_properties);
00085 for (std::vector<std::string>::iterator mit = world_properties.response.model_names.begin();
00086 mit != world_properties.response.model_names.end();
00087 mit++)
00088 {
00089 if (*mit == model_name)
00090 {
00091 found = true;
00092 break;
00093 }
00094 }
00095 }
00096
00097 ASSERT_TRUE(found);
00098
00099 SUCCEED();
00100 }
00101
00102
00103
00104
00105 int main(int argc, char** argv)
00106 {
00107 ros::init(argc, argv, "test", ros::init_options::AnonymousName);
00108 testing::InitGoogleTest(&argc, argv);
00109 g_argc = argc;
00110 g_argv = argv;
00111 return RUN_ALL_TESTS();
00112 }