Skip to content

Commit aeea56d

Browse files
authored
Fix some renaming for V4 (#480)
1 parent 0d924c0 commit aeea56d

File tree

4 files changed

+30
-26
lines changed

4 files changed

+30
-26
lines changed

include/behaviortree_cpp/action_node.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ class SimpleActionNode : public SyncActionNode
102102
* the result of the method isHaltRequested() and stop your execution accordingly.
103103
*
104104
* - in the overriden halt() method, you can do some cleanup, but do not forget to
105-
* invoke the base class method AsyncActionNode::halt();
105+
* invoke the base class method ThreadedAction::halt();
106106
*
107-
* - remember, with few exceptions, a halted AsyncAction must return NodeStatus::IDLE.
107+
* - remember, with few exceptions, a halted ThreadedAction must return NodeStatus::IDLE.
108108
*
109109
* For a complete example, look at __AsyncActionTest__ in action_test_node.h in the folder test.
110110
*
@@ -137,12 +137,12 @@ class ThreadedAction : public ActionNodeBase
137137
};
138138

139139
#ifdef USE_BTCPP3_OLD_NAMES
140-
using AsyncActionNode = ThreadedActionNode;
140+
using AsyncActionNode = ThreadedAction;
141141
#endif
142142

143143
/**
144-
* @brief The StatefulAsyncAction is the preferred way to implement asynchronous Actions.
145-
* It is actually easier to use correctly, when compared with AsyncAction
144+
* @brief The StatefulActionNode is the preferred way to implement asynchronous Actions.
145+
* It is actually easier to use correctly, when compared with ThreadedAction
146146
*
147147
* It is particularly useful when your code contains a request-reply pattern,
148148
* i.e. when the actions sends an asynchronous request, then checks periodically

include/behaviortree_cpp/basic_types.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ using enable_if_not = typename std::enable_if<!Predicate::value>::type*;
201201
*
202202
* */
203203
template <typename T>
204+
using Expected = nonstd::expected<T, std::string>;
204205
#ifdef USE_BTCPP3_OLD_NAMES
205-
using Optional = nonstd::expected<T, std::string>;
206-
// note: we use the name Optional instead of expected because it is more intuitive
206+
// note: we also use the name Optional instead of expected because it is more intuitive
207207
// for users that are not up to date with "modern" C++
208-
#else
209-
using Expected = nonstd::expected<T, std::string>;
208+
template <typename T>
209+
using Optional = nonstd::expected<T, std::string>;
210210
#endif
211211

212212
/** Usage: given a function/method like:

tests/CMakeLists.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ if( BTCPP_ENABLE_COROUTINES AND BT_COROUTINES_FOUND )
2828
LIST( APPEND BT_TESTS gtest_coroutines.cpp)
2929
endif()
3030

31-
#if(ament_cmake_FOUND OR catkin_FOUND)
32-
# # This test requires gmock. Since we don't have a uniform way to include
33-
# # gmock for non-users, it is turned of when build without ros.
34-
# list(APPEND BT_TESTS gtest_async_action_node.cpp)
35-
#endif()
36-
3731

3832
if(ament_cmake_FOUND AND BUILD_TESTING)
3933

@@ -81,4 +75,14 @@ elseif(BTCPP_UNIT_TESTS)
8175

8276
endif()
8377

78+
# if(BUILD_TESTING AND (ament_cmake_FOUND OR catkin_FOUND))
79+
# # This test requires gmock. Since we don't have a uniform way to include
80+
# # gmock for non-users, it is turned of when build without ros.
81+
# list(APPEND BT_TESTS gtest_async_action_node.cpp)
82+
# target_link_libraries(${BEHAVIOR_TREE_LIBRARY}_test
83+
# ${BEHAVIOR_TREE_LIBRARY}
84+
# gmock
85+
# )
86+
# endif()
87+
8488
target_compile_definitions(${BEHAVIOR_TREE_LIBRARY}_test PRIVATE BT_TEST_FOLDER="${CMAKE_CURRENT_SOURCE_DIR}")

tests/gtest_async_action_node.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#include <gmock/gmock.h>
1414

1515
// The mocked version of the base.
16-
struct MockedAsyncActionNode : public BT::AsyncActionNode
16+
struct MockedThreadedAction : public BT::ThreadedAction
1717
{
18-
using BT::AsyncActionNode::AsyncActionNode;
18+
using BT::ThreadedAction::ThreadedAction;
1919
MOCK_METHOD0(tick, BT::NodeStatus());
2020

2121
// Tick while the node is running.
@@ -29,25 +29,25 @@ struct MockedAsyncActionNode : public BT::AsyncActionNode
2929
}
3030

3131
// Expose the setStatus method.
32-
using BT::AsyncActionNode::setStatus;
32+
using BT::ThreadedAction::setStatus;
3333
};
3434

3535
// The fixture taking care of the node-setup.
36-
struct MockedAsyncActionFixture : public testing::Test
36+
struct MockedThreadedActionFixture : public testing::Test
3737
{
3838
BT::NodeConfig config;
39-
MockedAsyncActionNode sn;
40-
MockedAsyncActionFixture() : sn("node", config)
39+
MockedThreadedAction sn;
40+
MockedThreadedActionFixture() : sn("node", config)
4141
{}
4242
};
4343

4444
// Parameters for the terminal node states.
4545
struct NodeStatusFixture : public testing::WithParamInterface<BT::NodeStatus>,
46-
public MockedAsyncActionFixture
46+
public MockedThreadedActionFixture
4747
{
4848
};
4949

50-
INSTANTIATE_TEST_CASE_P(/**/, NodeStatusFixture,
50+
INSTANTIATE_TEST_SUITE_P(/**/, NodeStatusFixture,
5151
testing::Values(BT::NodeStatus::SUCCESS,
5252
BT::NodeStatus::FAILURE));
5353

@@ -67,7 +67,7 @@ TEST_P(NodeStatusFixture, normal_routine)
6767
ASSERT_EQ(sn.spinUntilDone(), state);
6868
}
6969

70-
TEST_F(MockedAsyncActionFixture, no_halt)
70+
TEST_F(MockedThreadedActionFixture, no_halt)
7171
{
7272
// Test verifies that halt returns immediately, if the node is idle. It
7373
// further checks if the halt-flag is resetted correctly.
@@ -83,7 +83,7 @@ TEST_F(MockedAsyncActionFixture, no_halt)
8383
ASSERT_FALSE(sn.isHaltRequested());
8484
}
8585

86-
TEST_F(MockedAsyncActionFixture, halt)
86+
TEST_F(MockedThreadedActionFixture, halt)
8787
{
8888
// Test verifies that calling halt() is blocking.
8989
bool release = false;
@@ -120,7 +120,7 @@ TEST_F(MockedAsyncActionFixture, halt)
120120
ASSERT_EQ(sn.status(), state);
121121
}
122122

123-
TEST_F(MockedAsyncActionFixture, exception)
123+
TEST_F(MockedThreadedActionFixture, exception)
124124
{
125125
// Verifies that we can recover from the exceptions in the tick method:
126126
// 1) catch the exception, 2) re-raise it in the caller thread.

0 commit comments

Comments
 (0)