server_test.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 
31 #include <ros/ros.h>
32 
33 #include <gtest/gtest.h>
34 
36 
37 TEST(InteractiveMarkerServer, addRemove)
38 {
39  // create an interactive marker server on the topic namespace simple_marker
41 
42  // create an interactive marker for our server
43  visualization_msgs::InteractiveMarker int_marker;
44  int_marker.name = "marker1";
45 
46  // create a valid pose
47  geometry_msgs::Pose pose;
48  pose.orientation.w = 1.0;
49 
50  //insert, apply, erase, apply
51  server.insert(int_marker);
52  ASSERT_TRUE( server.get("marker1", int_marker) );
53 
54  server.applyChanges();
55  ASSERT_TRUE( server.get("marker1", int_marker) );
56 
57  server.erase( "marker1" );
58  ASSERT_FALSE( server.get("marker1", int_marker) );
59 
60  server.applyChanges();
61  ASSERT_FALSE( server.get("marker1", int_marker) );
62 
63 
64  //insert, erase, apply
65  server.insert(int_marker);
66  ASSERT_TRUE( server.get("marker1", int_marker) );
67 
68  server.erase( "marker1" );
69  ASSERT_FALSE( server.get("marker1", int_marker) );
70 
71  server.applyChanges();
72  ASSERT_FALSE( server.get("marker1", int_marker) );
73 
74  //insert, apply, clear, apply
75  server.insert(int_marker);
76  ASSERT_TRUE( server.get("marker1", int_marker) );
77 
78  server.applyChanges();
79  ASSERT_TRUE( server.get("marker1", int_marker) );
80 
81  server.clear();
82  ASSERT_FALSE( server.get("marker1", int_marker) );
83 
84  server.applyChanges();
85  ASSERT_FALSE( server.get("marker1", int_marker) );
86 
87  //insert, setPose, apply, clear, apply
88  server.insert(int_marker);
89  ASSERT_TRUE( server.setPose("marker1", pose) );
90 
91  server.applyChanges();
92  server.clear();
93  ASSERT_FALSE( server.get("marker1", int_marker) );
94 
95  server.applyChanges();
96 
97  //avoid subscriber destruction warning
98  usleep(1000);
99 }
100 
101 
102 // Run all the tests that were declared with TEST()
103 int main(int argc, char **argv)
104 {
105  ros::init(argc, argv, "im_server_test");
106  testing::InitGoogleTest(&argc, argv);
107  return RUN_ALL_TESTS();
108 }
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
boost::shared_ptr< interactive_markers::InteractiveMarkerServer > server
Definition: bursty_tf.cpp:40
TEST(InteractiveMarkerServer, addRemove)
Definition: server_test.cpp:37
bool get(std::string name, visualization_msgs::InteractiveMarker &int_marker) const
void insert(const visualization_msgs::InteractiveMarker &int_marker)
bool setPose(const std::string &name, const geometry_msgs::Pose &pose, const std_msgs::Header &header=std_msgs::Header())
int main(int argc, char **argv)


interactive_markers
Author(s): David Gossow
autogenerated on Sun Feb 3 2019 03:24:09