Skip to content

Commit 726f485

Browse files
committed
Re-use existing dashboard client
1 parent 7f611cc commit 726f485

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

tests/test_dashboard_client.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,29 +221,25 @@ TEST_F(DashboardClientTest, connect_non_running_robot)
221221

222222
TEST_F(DashboardClientTest, non_expected_result_returns_correctly)
223223
{
224-
std::unique_ptr<DashboardClient> dashboard_client;
225-
dashboard_client.reset(new DashboardClient("192.168.56.101"));
226-
ASSERT_TRUE(dashboard_client->connect());
227-
EXPECT_TRUE(dashboard_client->commandPowerOff());
224+
ASSERT_TRUE(dashboard_client_->connect());
225+
EXPECT_TRUE(dashboard_client_->commandPowerOff());
228226

229227
// We will not get this answer
230-
EXPECT_FALSE(dashboard_client->sendRequest("brake release", "non-existing-response"));
228+
EXPECT_FALSE(dashboard_client_->sendRequest("brake release", "non-existing-response"));
231229

232230
// A non-matching answer should throw an exception for this call
233-
EXPECT_THROW(dashboard_client->sendRequestString("brake release", "non-existing-response"), UrException);
231+
EXPECT_THROW(dashboard_client_->sendRequestString("brake release", "non-existing-response"), UrException);
234232

235233
// Waiting for a non-matching answer should return false
236234
// Internally we wait 100ms between each attempt, hence the 300ms wait time
237235
EXPECT_FALSE(
238-
dashboard_client->waitForReply("brake_release", "non-existing-response", std::chrono::milliseconds(300)));
236+
dashboard_client_->waitForReply("brake_release", "non-existing-response", std::chrono::milliseconds(300)));
239237
}
240238

241-
TEST_F(DashboardClientTest, connecting_twoice_returns_false)
239+
TEST_F(DashboardClientTest, connecting_twice_returns_false)
242240
{
243-
std::unique_ptr<DashboardClient> dashboard_client;
244-
dashboard_client.reset(new DashboardClient("192.168.56.101"));
245-
ASSERT_TRUE(dashboard_client->connect());
246-
EXPECT_FALSE(dashboard_client->connect());
241+
ASSERT_TRUE(dashboard_client_->connect());
242+
EXPECT_FALSE(dashboard_client_->connect());
247243
}
248244

249245
int main(int argc, char* argv[])

0 commit comments

Comments
 (0)