@@ -103,22 +103,23 @@ class TCPSocketTest : public ::testing::Test
103103 class Client : public comm ::TCPSocket
104104 {
105105 public:
106- Client (int port, const std::string& ip = " 127.0.0.1" , const size_t max_num_tries = 0 )
106+ Client (int port, const std::string& ip = " 127.0.0.1" )
107107 {
108108 port_ = port;
109109 ip_ = ip;
110- max_num_tries_ = max_num_tries;
111110 }
112111
113- bool setup ()
112+ bool setup (const size_t max_num_tries = 0 ,
113+ const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10 ))
114114 {
115- return TCPSocket::setup (ip_, port_, max_num_tries_ );
115+ return TCPSocket::setup (ip_, port_, max_num_tries, reconnection_time );
116116 }
117117
118- void setupClientBeforeServer ()
118+ void setupClientBeforeServer (const size_t max_num_tries = 0 ,
119+ const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10 ))
119120 {
120121 done_setting_up_client_ = false ;
121- client_setup_thread_ = std::thread (&Client::setupClient, this , port_);
122+ client_setup_thread_ = std::thread (&Client::setupClient, this , port_, max_num_tries, reconnection_time );
122123 }
123124
124125 bool waitForClientSetupThread ()
@@ -149,10 +150,10 @@ class TCPSocketTest : public ::testing::Test
149150 std::thread client_setup_thread_;
150151 int port_;
151152 std::string ip_;
152- size_t max_num_tries_;
153153 bool done_setting_up_client_;
154154
155- void setupClient (int port)
155+ void setupClient (int port, const size_t max_num_tries = 0 ,
156+ std::chrono::milliseconds reconnection_time = std::chrono::seconds(10 ))
156157 {
157158 std::string ip = " 127.0.0.1" ;
158159 TCPSocket::setup (ip, port);
@@ -205,8 +206,7 @@ TEST_F(TCPSocketTest, setup_client_before_server)
205206 // Make server unavailable
206207 server_.reset ();
207208
208- client_->setReconnectionTime (std::chrono::seconds (1 ));
209- client_->setupClientBeforeServer ();
209+ client_->setupClientBeforeServer (0 , std::chrono::seconds (1 ));
210210
211211 // Make sure that the client has tried to connect to the server, before creating the server
212212 std::this_thread::sleep_for (std::chrono::seconds (1 ));
@@ -348,9 +348,8 @@ TEST_F(TCPSocketTest, setup_while_client_is_connected)
348348
349349TEST_F (TCPSocketTest, connect_non_running_robot)
350350{
351- Client client (12321 , " 127.0.0.1" , 2 );
352- client.setReconnectionTime (std::chrono::milliseconds (500 ));
353- EXPECT_FALSE (client.setup ());
351+ Client client (12321 , " 127.0.0.1" );
352+ EXPECT_FALSE (client.setup (2 , std::chrono::milliseconds (500 )));
354353}
355354
356355int main (int argc, char * argv[])
0 commit comments