Skip to content

Commit b432c52

Browse files
committed
Test all commands with a timeout
1 parent f8b9763 commit b432c52

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/test_primary_client.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,23 @@ TEST_F(PrimaryClientTest, test_power_cycle_commands)
9191
EXPECT_NO_THROW(client_->commandBrakeRelease());
9292
EXPECT_NO_THROW(client_->commandPowerOff());
9393

94+
auto timeout = std::chrono::seconds(30);
9495
// provoke a timeout
9596
EXPECT_THROW(client_->commandBrakeRelease(true, std::chrono::milliseconds(1)), urcl::TimeoutException);
96-
97-
auto timeout = std::chrono::seconds(30);
9897
EXPECT_NO_THROW(waitFor([this]() { return client_->getRobotMode() == RobotMode::RUNNING; }, timeout));
98+
EXPECT_THROW(client_->commandPowerOff(true, std::chrono::milliseconds(1)), urcl::TimeoutException);
99+
EXPECT_NO_THROW(waitFor([this]() { return client_->getRobotMode() == RobotMode::POWER_OFF; }, timeout));
100+
EXPECT_THROW(client_->commandPowerOn(true, std::chrono::milliseconds(1)), urcl::TimeoutException);
101+
EXPECT_NO_THROW(waitFor([this]() { return client_->getRobotMode() == RobotMode::IDLE; }, timeout));
99102

103+
// Without a verification the calls should succeed, the robot ending up in the desired state
104+
// eventually.
100105
EXPECT_NO_THROW(client_->commandPowerOff(false));
101106
EXPECT_NO_THROW(waitFor([this]() { return client_->getRobotMode() == RobotMode::POWER_OFF; }, timeout));
107+
EXPECT_NO_THROW(client_->commandPowerOn(false));
108+
EXPECT_NO_THROW(waitFor([this]() { return client_->getRobotMode() == RobotMode::IDLE; }, timeout));
109+
EXPECT_NO_THROW(client_->commandBrakeRelease(false));
110+
EXPECT_NO_THROW(waitFor([this]() { return client_->getRobotMode() == RobotMode::RUNNING; }, timeout));
102111
}
103112

104113
TEST_F(PrimaryClientTest, test_uninitialized_primary_client)
@@ -120,4 +129,4 @@ int main(int argc, char* argv[])
120129
}
121130

122131
return RUN_ALL_TESTS();
123-
}
132+
}

0 commit comments

Comments
 (0)