Testablility: Make Constructor of BehaviorNode protected
Right now, the ctor of BehaviorNode is private and only a few friend classes are allowed to use it. This prevents create Mocker-Objects for testing from the class.
By changing the access level from private to protected, it's possible to use BehaviorNodes in combination with gmock:
struct FakeBehavior : public BehaviorNode {
using Ptr = std::shared_ptr<FakeBehavior>;
FakeBehavior() : BehaviorNode("FakeBehavior"){};
~FakeBehavior() override = default;
MOCK_METHOD(void, onInit, ());
MOCK_METHOD(void, onTerminate, ());
MOCK_METHOD(void, initTree, ());
MOCK_METHOD(NodeStatus, tick, ());
};
TEST(Some, Test)
{
auto fake_child = std::make_shared<FakeBehavior>();
..
EXPECT_CALL(*fake_child, tick()).WillOnce(Return(NodeStatus::kSuccess));
..
}