19 #include <gtest/gtest.h> 46 if (nextState == static_cast<int>(state))
50 else if (nextState != -1)
79 TEST(Packml_SM, set_execute)
83 sm->setExecute(std::bind(
success));
87 ASSERT_TRUE(sm->clear());
90 ASSERT_TRUE(sm->reset());
93 ASSERT_TRUE(sm->start());
96 ASSERT_TRUE(
waitForState(StatesEnum::COMPLETING, queue));
98 ASSERT_TRUE(sm->reset());
101 sm->setExecute(std::bind(
fail));
102 ASSERT_TRUE(sm->start());
115 EXPECT_FALSE(sm->isActive());
116 sm->setExecute(std::bind(
success));
119 EXPECT_TRUE(sm->isActive());
122 ASSERT_TRUE(sm->isActive());
124 ASSERT_TRUE(sm->clear());
128 ASSERT_TRUE(sm->reset());
129 ASSERT_TRUE(
waitForState(StatesEnum::RESETTING, queue));
132 ASSERT_TRUE(sm->start());
135 ASSERT_TRUE(
waitForState(StatesEnum::COMPLETING, queue));
138 ASSERT_TRUE(sm->reset());
139 ASSERT_TRUE(
waitForState(StatesEnum::RESETTING, queue));
142 ASSERT_TRUE(sm->start());
145 ASSERT_TRUE(sm->hold());
148 ASSERT_TRUE(sm->unhold());
149 ASSERT_TRUE(
waitForState(StatesEnum::UNHOLDING, queue));
152 ASSERT_TRUE(sm->suspend());
153 ASSERT_TRUE(
waitForState(StatesEnum::SUSPENDING, queue));
154 ASSERT_TRUE(
waitForState(StatesEnum::SUSPENDED, queue));
155 ASSERT_TRUE(sm->unsuspend());
156 ASSERT_TRUE(
waitForState(StatesEnum::UNSUSPENDING, queue));
159 ASSERT_TRUE(sm->stop());
163 ASSERT_TRUE(sm->abort());
169 EXPECT_FALSE(sm->isActive());
178 EXPECT_FALSE(sm->isActive());
179 sm->setExecute(std::bind(
success));
182 EXPECT_TRUE(sm->isActive());
185 ASSERT_TRUE(sm->isActive());
187 ASSERT_TRUE(sm->clear());
191 ASSERT_TRUE(sm->reset());
192 ASSERT_TRUE(
waitForState(StatesEnum::RESETTING, queue));
195 ASSERT_TRUE(sm->start());
198 ASSERT_FALSE(
waitForState(StatesEnum::COMPLETING, queue));
199 ASSERT_FALSE(
waitForState(StatesEnum::COMPLETE, queue));
201 ASSERT_TRUE(sm->hold());
205 ASSERT_TRUE(sm->unhold());
206 ASSERT_TRUE(
waitForState(StatesEnum::UNHOLDING, queue));
209 ASSERT_TRUE(sm->suspend());
210 ASSERT_TRUE(
waitForState(StatesEnum::SUSPENDING, queue));
211 ASSERT_TRUE(
waitForState(StatesEnum::SUSPENDED, queue));
213 ASSERT_TRUE(sm->unsuspend());
214 ASSERT_TRUE(
waitForState(StatesEnum::UNSUSPENDING, queue));
217 ASSERT_TRUE(sm->stop());
221 ASSERT_TRUE(sm->abort());
227 EXPECT_FALSE(sm->isActive());
static std::shared_ptr< PackmlStateMachineSingleCycle > spawn()
TEST(Packml_SM, set_execute)
#define ROS_WARN_STREAM(args)
bool waitForState(StatesEnum state, StateMachineVisitedStatesQueue &queue)
waitForState - returns true if the current state of the state machine (sm) matches the queried state ...
#define ROS_INFO_STREAM(args)
static std::shared_ptr< PackmlStateMachineContinuous > spawn()