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 #include <chrono>
38 #include <thread>
39 
40 TEST(InteractiveMarkerServer, addRemove)
41 {
42  // create an interactive marker server on the topic namespace simple_marker
44 
45  // create an interactive marker for our server
46  visualization_msgs::InteractiveMarker int_marker;
47  int_marker.name = "marker1";
48 
49  // create a valid pose
50  geometry_msgs::Pose pose;
51  pose.orientation.w = 1.0;
52 
53  //insert, apply, erase, apply
54  server.insert(int_marker);
55  ASSERT_TRUE( server.get("marker1", int_marker) );
56 
57  server.applyChanges();
58  ASSERT_TRUE( server.get("marker1", int_marker) );
59 
60  ASSERT_TRUE( server.erase( "marker1" ) );
61  ASSERT_FALSE( server.get("marker1", int_marker) );
62 
63  server.applyChanges();
64  ASSERT_FALSE( server.get("marker1", int_marker) );
65 
66 
67  //insert, erase, apply
68  server.insert(int_marker);
69  ASSERT_TRUE( server.get("marker1", int_marker) );
70 
71  ASSERT_TRUE( server.erase( "marker1" ) );
72  ASSERT_FALSE( server.get("marker1", int_marker) );
73 
74  server.applyChanges();
75  ASSERT_FALSE( server.get("marker1", int_marker) );
76 
77  //insert, apply, clear, apply
78  server.insert(int_marker);
79  ASSERT_TRUE( server.get("marker1", int_marker) );
80 
81  server.applyChanges();
82  ASSERT_TRUE( server.get("marker1", int_marker) );
83 
84  server.clear();
85  ASSERT_FALSE( server.get("marker1", int_marker) );
86 
87  server.applyChanges();
88  ASSERT_FALSE( server.get("marker1", int_marker) );
89 
90  //insert, setPose, apply, clear, apply
91  server.insert(int_marker);
92  ASSERT_TRUE( server.setPose("marker1", pose) );
93 
94  server.applyChanges();
95  server.clear();
96  ASSERT_FALSE( server.get("marker1", int_marker) );
97 
98  server.applyChanges();
99 
100  // erase unknown marker
101  ASSERT_FALSE( server.erase("marker1") );
102 
103  //avoid subscriber destruction warning
104  std::this_thread::sleep_for(std::chrono::microseconds(1000));
105 }
106 
107 
108 // Run all the tests that were declared with TEST()
109 int main(int argc, char **argv)
110 {
111  ros::init(argc, argv, "im_server_test");
112  testing::InitGoogleTest(&argc, argv);
113  return RUN_ALL_TESTS();
114 }
interactive_marker_server.h
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
ros.h
main
int main(int argc, char **argv)
Definition: server_test.cpp:109
interactive_markers::InteractiveMarkerServer
Definition: interactive_marker_server.h:56
server
boost::shared_ptr< interactive_markers::InteractiveMarkerServer > server
Definition: bursty_tf.cpp:43
TEST
TEST(InteractiveMarkerServer, addRemove)
Definition: server_test.cpp:40


interactive_markers
Author(s): David Gossow, William Woodall
autogenerated on Fri Oct 27 2023 02:31:54