File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1
1
#include < gtest/gtest.h>
2
2
#include " behaviortree_cpp/bt_factory.h"
3
3
#include " test_helper.hpp"
4
+ #include " behaviortree_cpp/loggers/bt_observer.h"
4
5
5
6
using BT::NodeStatus;
6
7
using std::chrono::milliseconds;
@@ -124,3 +125,41 @@ TEST(Reactive, PreTickHooks)
124
125
}
125
126
126
127
128
+ TEST (Reactive, TestLogging)
129
+ {
130
+ using namespace BT ;
131
+
132
+ static const char * reactive_xml_text = R"(
133
+ <root BTCPP_format="4" >
134
+ <BehaviorTree ID="Main">
135
+ <ReactiveSequence>
136
+ <TestA name="testA"/>
137
+ <AlwaysSuccess name="success"/>
138
+ <Sleep msec="100"/>
139
+ </ReactiveSequence>
140
+ </BehaviorTree>
141
+ </root>
142
+ )" ;
143
+
144
+ BehaviorTreeFactory factory;
145
+
146
+ std::array<int , 1 > counters;
147
+ RegisterTestTick (factory, " Test" , counters);
148
+
149
+ auto tree = factory.createTreeFromText (reactive_xml_text);
150
+ TreeObserver observer (tree);
151
+
152
+ auto ret = tree.tickWhileRunning ();
153
+ ASSERT_EQ (ret, NodeStatus::SUCCESS);
154
+
155
+ int num_ticks = counters[0 ];
156
+ ASSERT_GE (num_ticks, 5 );
157
+
158
+ ASSERT_EQ (observer.getStatistics (" testA" ).success_count , num_ticks);
159
+ ASSERT_EQ (observer.getStatistics (" success" ).success_count , num_ticks);
160
+ }
161
+
162
+
163
+
164
+
165
+
You can’t perform that action at this time.
0 commit comments