@@ -168,6 +168,53 @@ TEST(PreconditionsDecorator, ChecksConditionOnce)
168168 EXPECT_EQ (tree.tickOnce (), NodeStatus::SUCCESS );
169169}
170170
171+ TEST (PreconditionsDecorator, ChecksConditionAfterHalt)
172+ {
173+ BehaviorTreeFactory factory;
174+ factory.registerNodeType <KeepRunning>(" KeepRunning" );
175+
176+ const std::string xml_text = R"(
177+ <root BTCPP_format="4">
178+ <BehaviorTree ID="MainTree">
179+ <Precondition if="A==0" else="FAILURE">
180+ <KeepRunning/>
181+ </Precondition>
182+ </BehaviorTree>
183+ </root>)" ;
184+
185+ auto tree = factory.createTreeFromText (xml_text);
186+ tree.rootBlackboard ()->set (" A" , 0 );
187+ EXPECT_EQ (tree.tickOnce (), NodeStatus::RUNNING );
188+
189+ tree.haltTree ();
190+ tree.rootBlackboard ()->set (" A" , 1 );
191+ EXPECT_EQ (tree.tickOnce (), NodeStatus::FAILURE );
192+ }
193+
194+ TEST (PreconditionsDecorator, ChecksConditionAfterSkippedChild)
195+ {
196+ BehaviorTreeFactory factory;
197+ factory.registerNodeType <KeepRunning>(" KeepRunning" );
198+
199+ const std::string xml_text = R"(
200+ <root BTCPP_format="4">
201+ <BehaviorTree ID="MainTree">
202+ <Precondition if="A==0" else="FAILURE">
203+ <KeepRunning _skipIf="skip"/>
204+ </Precondition>
205+ </BehaviorTree>
206+ </root>)" ;
207+
208+ auto tree = factory.createTreeFromText (xml_text);
209+ tree.rootBlackboard ()->set (" A" , 0 );
210+ tree.rootBlackboard ()->set (" skip" , true );
211+ EXPECT_EQ (tree.tickOnce (), NodeStatus::SKIPPED );
212+
213+ tree.rootBlackboard ()->set (" A" , 1 );
214+ tree.rootBlackboard ()->set (" skip" , false );
215+ EXPECT_EQ (tree.tickOnce (), NodeStatus::FAILURE );
216+ }
217+
171218TEST (PreconditionsDecorator, CanRunChildrenMultipleTimes)
172219{
173220 BehaviorTreeFactory factory;
0 commit comments