@@ -145,6 +145,85 @@ TEST_F(SimpleParallelTest, Threshold_3)
145
145
ASSERT_EQ (NodeStatus::SUCCESS, state);
146
146
}
147
147
148
+ TEST_F (SimpleParallelTest, Threshold_neg2)
149
+ {
150
+ root.setThresholdM (-2 );
151
+ action_1.setTime ( milliseconds (100 ) );
152
+ action_2.setTime ( milliseconds (500 ) ); // this takes a lot of time
153
+
154
+ BT::NodeStatus state = root.executeTick ();
155
+ // first tick, zero wait
156
+ ASSERT_EQ (NodeStatus::SUCCESS, condition_1.status ());
157
+ ASSERT_EQ (NodeStatus::SUCCESS, condition_2.status ());
158
+ ASSERT_EQ (NodeStatus::RUNNING, action_1.status ());
159
+ ASSERT_EQ (NodeStatus::RUNNING, action_2.status ());
160
+ ASSERT_EQ (NodeStatus::RUNNING, state);
161
+
162
+ std::this_thread::sleep_for ( milliseconds (150 ) );
163
+ state = root.executeTick ();
164
+ // second tick: action1 should be completed, but not action2
165
+ // nevertheless it is sufficient because threshold is 3
166
+ ASSERT_EQ (NodeStatus::IDLE, condition_1.status ());
167
+ ASSERT_EQ (NodeStatus::IDLE, condition_2.status ());
168
+ ASSERT_EQ (NodeStatus::IDLE, action_1.status ());
169
+ ASSERT_EQ (NodeStatus::IDLE, action_2.status ());
170
+ ASSERT_EQ (NodeStatus::SUCCESS, state);
171
+ }
172
+
173
+
174
+ TEST_F (SimpleParallelTest, Threshold_neg1)
175
+ {
176
+ root.setThresholdM (-1 );
177
+ action_1.setTime ( milliseconds (100 ) );
178
+ action_2.setTime ( milliseconds (500 ) ); // this takes a lot of time
179
+
180
+ BT::NodeStatus state = root.executeTick ();
181
+ // first tick, zero wait
182
+ ASSERT_EQ (NodeStatus::SUCCESS, condition_1.status ());
183
+ ASSERT_EQ (NodeStatus::SUCCESS, condition_2.status ());
184
+ ASSERT_EQ (NodeStatus::RUNNING, action_1.status ());
185
+ ASSERT_EQ (NodeStatus::RUNNING, action_2.status ());
186
+ ASSERT_EQ (NodeStatus::RUNNING, state);
187
+
188
+ std::this_thread::sleep_for ( milliseconds (150 ) );
189
+ state = root.executeTick ();
190
+ // second tick: action1 should be completed, but not action2
191
+ ASSERT_EQ (NodeStatus::SUCCESS, condition_1.status ());
192
+ ASSERT_EQ (NodeStatus::SUCCESS, condition_2.status ());
193
+ ASSERT_EQ (NodeStatus::SUCCESS, action_1.status ());
194
+ ASSERT_EQ (NodeStatus::RUNNING, action_2.status ());
195
+ ASSERT_EQ (NodeStatus::RUNNING, state);
196
+
197
+ std::this_thread::sleep_for ( milliseconds (650 ) );
198
+ state = root.executeTick ();
199
+ // third tick: all actions completed
200
+ ASSERT_EQ (NodeStatus::IDLE, condition_1.status ());
201
+ ASSERT_EQ (NodeStatus::IDLE, condition_2.status ());
202
+ ASSERT_EQ (NodeStatus::IDLE, action_1.status ());
203
+ ASSERT_EQ (NodeStatus::IDLE, action_2.status ());
204
+ ASSERT_EQ (NodeStatus::SUCCESS, state);
205
+ }
206
+
207
+
208
+ TEST_F (SimpleParallelTest, Threshold_thresholdFneg1)
209
+ {
210
+ root.setThresholdM (1 );
211
+ root.setThresholdFM (-1 );
212
+ action_1.setTime ( milliseconds (100 ) );
213
+ action_1.setExpectedResult (NodeStatus::FAILURE);
214
+ condition_1.setExpectedResult (NodeStatus::FAILURE);
215
+ action_2.setTime ( milliseconds (200 ) );
216
+ condition_2.setExpectedResult (NodeStatus::FAILURE);
217
+ action_2.setExpectedResult (NodeStatus::FAILURE);
218
+
219
+ BT::NodeStatus state = root.executeTick ();
220
+ ASSERT_EQ (NodeStatus::RUNNING, state);
221
+
222
+ std::this_thread::sleep_for (milliseconds (250 ));
223
+ state = root.executeTick ();
224
+ ASSERT_EQ (NodeStatus::FAILURE, state);
225
+ }
226
+
148
227
TEST_F (SimpleParallelTest, Threshold_2)
149
228
{
150
229
root.setThresholdM (2 );
@@ -271,6 +350,7 @@ TEST_F(ComplexParallelTest, ConditionRightFalse_thresholdF_2)
271
350
ASSERT_EQ (NodeStatus::SUCCESS, state);
272
351
}
273
352
353
+
274
354
TEST_F (ComplexParallelTest, ConditionRightFalseAction1Done)
275
355
{
276
356
condition_R.setExpectedResult (NodeStatus::FAILURE);
0 commit comments