Skip to content

Commit

Permalink
also test getState() in the callback
Browse files Browse the repository at this point in the history
as suggested by rhaschke in #156 (comment)
  • Loading branch information
jschleicher committed Feb 25, 2020
1 parent 0db4fe3 commit 61d95ae
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions actionlib/test/simple_client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,15 @@ TEST(SimpleClient, easy_tests) {
}


void easyDoneCallback(bool * called, const SimpleClientGoalState & state,
void easyDoneCallback(bool * called, SimpleActionClient<TestAction> * ac, const SimpleClientGoalState & state,
const TestResultConstPtr &)
{
ros::Duration(0.1).sleep();
*called = true;
EXPECT_TRUE(ac->getState() == SimpleClientGoalState::SUCCEEDED)
<< "Expected [SUCCEEDED], but getState() returned [" << ac->getState().toString() << "]";
EXPECT_TRUE(state == SimpleClientGoalState::SUCCEEDED)
<< "Expected [SUCCEEDED], but goal state is [" << state.toString() << "]";
}

void easyOldDoneCallback(bool * called, const TerminalState & terminal_state,
const TestResultConstPtr &)
{
ros::Duration(0.1).sleep();
*called = true;
EXPECT_TRUE(terminal_state == TerminalState::SUCCEEDED)
<< "Expected [SUCCEEDED], but terminal state is [" << terminal_state.toString() << "]";
}

TEST(SimpleClient, easy_callback)
Expand All @@ -109,7 +103,7 @@ TEST(SimpleClient, easy_callback)

bool called = false;
goal.goal = 1;
SimpleActionClient<TestAction>::SimpleDoneCallback func = boost::bind(&easyDoneCallback, &called, _1, _2);
SimpleActionClient<TestAction>::SimpleDoneCallback func = boost::bind(&easyDoneCallback, &called, &client, _1, _2);
client.sendGoal(goal, func);
finished = client.waitForResult(ros::Duration(10.0));
ASSERT_TRUE(finished);
Expand Down

0 comments on commit 61d95ae

Please sign in to comment.