Skip to content

Commit

Permalink
timeout as arg
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <[email protected]>
  • Loading branch information
ahcorde committed May 25, 2021
1 parent f884ab1 commit f111938
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/MoveToHelper_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,19 @@ class MoveToHelperTest : public testing::Test,

public: void OnMoveToComplete();

public: void checkIsCompleted();
public: void checkIsCompleted(double timeout);

public: MoveToHelper moveToHelper;

public: bool isMoveCompleted = false;

public: const double kTimeout = 0.5;
};

void MoveToHelperTest::OnMoveToComplete()
{
this->isMoveCompleted = true;
}

void MoveToHelperTest::checkIsCompleted()
void MoveToHelperTest::checkIsCompleted(double timeout)
{
isMoveCompleted = false;

Expand All @@ -68,7 +66,7 @@ void MoveToHelperTest::checkIsCompleted()
auto seconds =
std::chrono::duration_cast<std::chrono::milliseconds>(
endTime - startTime).count() / 1000.0;
if (seconds > kTimeout)
if (seconds > timeout)
break;
}
}
Expand Down Expand Up @@ -116,14 +114,14 @@ void MoveToHelperTest::MoveTo(const std::string &_renderEngine)
moveToHelper.MoveTo(camera, target, 0.5,
std::bind(&MoveToHelperTest::OnMoveToComplete, this));
EXPECT_FALSE(moveToHelper.Idle());
checkIsCompleted();
checkIsCompleted(0.5);
EXPECT_TRUE(moveToHelper.Idle());
EXPECT_EQ(math::Vector3d(28.5, 0.0, 0.0), camera->LocalPosition());

moveToHelper.MoveTo(camera, math::Pose3d(0.0, 0.0, 0.0, 0, 0, 0), 0.5,
std::bind(&MoveToHelperTest::OnMoveToComplete, this));
EXPECT_FALSE(moveToHelper.Idle());
checkIsCompleted();
checkIsCompleted(0.5);
EXPECT_EQ(math::Vector3d(0.0, 0.0, 0.0), camera->LocalPosition());
EXPECT_TRUE(moveToHelper.Idle());

Expand All @@ -133,7 +131,7 @@ void MoveToHelperTest::MoveTo(const std::string &_renderEngine)
viewAngleDirection, lookAt,
0.5, std::bind(&MoveToHelperTest::OnMoveToComplete, this));
EXPECT_FALSE(moveToHelper.Idle());
checkIsCompleted();
checkIsCompleted(0.5);
EXPECT_TRUE(moveToHelper.Idle());
EXPECT_EQ(math::Vector3d(0.0, -1, 0.0), camera->LocalPosition());
EXPECT_EQ(math::Quaterniond(0.0, -0.785398, 1.5708), camera->LocalRotation());
Expand Down

0 comments on commit f111938

Please sign in to comment.