@@ -497,6 +497,10 @@ TEST_F(TestTimerFixture, test_canceled_timer) {
497497 ret = rcl_timer_cancel (&timer);
498498 ASSERT_EQ (RCL_RET_OK, ret) << rcl_get_error_string ().str ;
499499
500+ int64_t next_call_time = 0 ;
501+ ret = rcl_timer_get_next_call_time (&timer, &next_call_time);
502+ EXPECT_EQ (RCL_RET_TIMER_CANCELED, ret) << rcl_get_error_string ().str ;
503+
500504 int64_t time_until_next_call = 0 ;
501505 ret = rcl_timer_get_time_until_next_call (&timer, &time_until_next_call);
502506 EXPECT_EQ (RCL_RET_TIMER_CANCELED, ret) << rcl_get_error_string ().str ;
@@ -904,3 +908,25 @@ TEST_F(TestPreInitTimer, test_time_since_last_call) {
904908 ASSERT_EQ (RCL_RET_OK, rcl_timer_get_time_since_last_call (&timer, &time_sice_next_call_end));
905909 EXPECT_GT (time_sice_next_call_end, time_sice_next_call_start);
906910}
911+
912+ TEST_F (TestPreInitTimer, test_next_call_time) {
913+ int64_t next_call_time_start = 0 ;
914+ int64_t next_call_time_end = 0 ;
915+ times_called = 0 ;
916+
917+ EXPECT_EQ (RCL_RET_INVALID_ARGUMENT, rcl_timer_get_next_call_time (nullptr , &next_call_time_start));
918+ rcl_reset_error ();
919+ EXPECT_EQ (RCL_RET_INVALID_ARGUMENT, rcl_timer_get_next_call_time (&timer, nullptr ));
920+ rcl_reset_error ();
921+
922+ ASSERT_EQ (RCL_RET_OK, rcl_timer_get_next_call_time (&timer, &next_call_time_start)) <<
923+ rcl_get_error_string ().str ;
924+
925+ // move the next call time one period forward
926+ ASSERT_EQ (RCL_RET_OK, rcl_timer_call (&timer)) << rcl_get_error_string ().str ;
927+ EXPECT_EQ (times_called, 1 );
928+
929+ ASSERT_EQ (RCL_RET_OK, rcl_timer_get_next_call_time (&timer, &next_call_time_end)) <<
930+ rcl_get_error_string ().str ;
931+ EXPECT_EQ (RCL_S_TO_NS (1 ), next_call_time_end - next_call_time_start);
932+ }
0 commit comments